@@ -64,6 +64,9 @@ Targets
6464 dist:
6565 Create tar-gzipped archives for arXiv submission.
6666
67+ bundle:
68+ Create an archive containing all files from the current Git repository.
69+
6770 watch:
6871 Watch the changes and automatically rebuild documents.
6972
@@ -139,6 +142,9 @@ EXTRADISTFILES =
139142# Files to be copied in "anc" directory in a distribution.
140143ANCILLARYFILES =
141144
145+ # Bundle filename (including extension).
146+ BUNDLEFILE = bundle.tar.gz
147+
142148# Additional files to mostly-clean.
143149MOSTLYCLEANFILES =
144150
@@ -893,6 +899,7 @@ cleanfiles_impl = $(wildcard $(strip \
893899 $(srcltxfiles:.ltx=.fmt ) \
894900 $(srcdtxfiles:.dtx=.cls ) \
895901 $(srcdtxfiles:.dtx=.sty ) \
902+ $(BUNDLEFILE ) \
896903 $(CLEANFILES ) \
897904 $(mostlycleanfiles ) \
898905) )
@@ -1377,6 +1384,52 @@ _check_rule = \
13771384 $(MAKE ) --no-print-directory $1 1="$(call TESTS_OPT,$1) " || exit 1; \
13781385 )
13791386
1387+ bundle :
1388+ @$(if $(strip $(BUNDLEFILE ) ) , \
1389+ $(if $(or $(filter % .tar.gz,$(BUNDLEFILE ) ) ,$(filter % .tgz,$(BUNDLEFILE ) ) ) , \
1390+ $(call _make_bundle,$(_make_bundle_tar_gz ) ) \
1391+ ,$(if $(filter % .zip,$(BUNDLEFILE ) ) , \
1392+ $(call _make_bundle,$(_make_bundle_zip ) ) \
1393+ , \
1394+ $(error unsupported BUNDLEFILE extension: $(BUNDLEFILE ) ) \
1395+ )) \
1396+ , \
1397+ $(error BUNDLEFILE is not set) \
1398+ )
1399+
1400+ _make_bundle = \
1401+ temp_dir=.tmp_$$$$_$$(awk 'BEGIN {srand( ) ; print srand()}') \
1402+ && mkdir "$$temp_dir" \
1403+ && cd "$$temp_dir" \
1404+ && git clone .. "$(_bundle_name ) " \
1405+ && cd "$(_bundle_name ) " \
1406+ && git remote remove origin \
1407+ && git reflog expire --expire=now --expire-unreachable=now --all \
1408+ && git prune --expire=now \
1409+ && git pack-refs --all --prune \
1410+ && git gc --aggressive --prune=now \
1411+ && cd .. \
1412+ && $1 \
1413+ && cd .. \
1414+ && mv "$$temp_dir/$(notdir $(BUNDLEFILE ) ) " "$(BUNDLEFILE ) " \
1415+ && rm -rf "$$temp_dir"
1416+
1417+ _make_bundle_tar_gz = \
1418+ $(call exec,tar cfv - --exclude $(notdir $(BUNDLEFILE ) ) * | gzip -9 -n >$(notdir $(BUNDLEFILE ) ) )
1419+
1420+ _make_bundle_zip = \
1421+ $(call exec,TZ=UTC zip -X -9 -r $(notdir $(BUNDLEFILE ) ) * )
1422+
1423+ _bundle_name = $(strip \
1424+ $(if $(filter % .tar.gz,$(BUNDLEFILE ) ) , \
1425+ $(basename $(basename $(notdir $(BUNDLEFILE ) ) ) ) \
1426+ ,$(if $(or $(filter % .tgz,$(BUNDLEFILE ) ) ,$(filter % .zip,$(BUNDLEFILE ) ) ) , \
1427+ $(basename $(notdir $(BUNDLEFILE ) ) ) \
1428+ , \
1429+ $(notdir $(BUNDLEFILE ) ) \
1430+ ) ) \
1431+ )
1432+
13801433# The "watch" mode. Try to update .log files instead of .pdf/.dvi files,
13811434# otherwise make would continuously try to typeset for sources previously
13821435# failed.
@@ -1516,7 +1569,7 @@ _FORCE:
15161569_run_testsuite :
15171570 @$(run_testsuite )
15181571
1519- .PHONY : all all-recursive check clean dist dvi eps fmt help jpg lint mostlyclean pdf png pretty ps prerequisite postprocess svg upgrade watch _FORCE _run_testsuite
1572+ .PHONY : all all-recursive bundle check clean dist dvi eps fmt help jpg lint mostlyclean pdf png pretty ps prerequisite postprocess svg upgrade watch _FORCE _run_testsuite
15201573
15211574# $(call typeset,LATEX-COMMAND) tries to typeset the document.
15221575# $(call typeset,LATEX-COMMAND,false) doesn't delete the output file on failure.
0 commit comments