From 7379c94f0aafab5eb388c7977950036e3579118c Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Wed, 10 May 2017 11:56:52 +0200 Subject: [PATCH] merge .include and .common makefiles --- helper.pl | 2 +- makefile | 11 +-- makefile.common | 85 ----------------------- makefile.shared | 12 ++-- makefile.include => makefile_include.mk | 92 ++++++++++++++++++++++++- 5 files changed, 103 insertions(+), 99 deletions(-) delete mode 100644 makefile.common rename makefile.include => makefile_include.mk (86%) diff --git a/helper.pl b/helper.pl index 2db9ad8..8126954 100755 --- a/helper.pl +++ b/helper.pl @@ -260,7 +260,7 @@ sub process_makefiles { } # update OBJECTS + HEADERS in makefile* - for my $m (qw/ makefile makefile.shared makefile.unix makefile.mingw makefile.msvc makefile.include /) { + for my $m (qw/ makefile makefile.shared makefile.unix makefile.mingw makefile.msvc makefile_include.mk /) { my $old = read_file($m); my $new = $m eq 'makefile.msvc' ? patch_makefile($old, $var_obj, $var_h, $var_tobj, @ver_version) : patch_makefile($old, $var_o, $var_h, $var_to, @ver_version); diff --git a/makefile b/makefile index bfc5a4b..d4b086e 100644 --- a/makefile +++ b/makefile @@ -2,8 +2,8 @@ # # Tom St Denis # Modified by Clay Culver - -include makefile.include +# +# (GNU make only) ifeq ($V,1) silent= @@ -23,7 +23,6 @@ endif endif INSTALL_CMD = install - #Output filenames for various targets. ifndef LIBNAME LIBNAME=libtomcrypt.a @@ -32,6 +31,10 @@ ifndef LIBTEST LIBTEST=libtomcrypt_prof.a endif + +include makefile_include.mk + + #AES comes in two flavours... enc+dec and enc src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c ${silent} ${CC} ${CFLAGS} -DENCRYPT_ONLY -c $< -o $@ @@ -136,6 +139,4 @@ coverage: test # cleans everything - coverage output and standard 'clean' cleancov: cleancov-clean clean -include makefile.common - # git commit: $Format:%h$ $Format:%ai$ diff --git a/makefile.common b/makefile.common deleted file mode 100644 index 4da06bc..0000000 --- a/makefile.common +++ /dev/null @@ -1,85 +0,0 @@ -#common make targets shared over multiple makefiles - -ifndef INSTALL_CMD -$(error your makefile must define INSTALL_CMD) -endif - -bins: $(USEFUL_DEMOS) - -all_test: test tv_gen $(DEMOS) - -#build the doxy files (requires Doxygen, tetex and patience) -doxygen doxy docs: - $(MAKE) -C doc/ $@ V=$(V) - -doc/crypt.pdf: - $(MAKE) -C doc/ crypt.pdf V=$(V) - - -install_all: install install_bins install_docs install_test - - -.common_install: $(LIBNAME) - install -d $(INCPATH) - install -d $(LIBPATH) - $(INSTALL_CMD) -m 644 $(LIBNAME) $(LIBPATH)/$(LIBNAME) - install -m 644 $(HEADERS) $(INCPATH) - -.common_install_bins: $(USEFUL_DEMOS) - install -d $(BINPATH) - $(INSTALL_CMD) -m 775 $(USEFUL_DEMOS) $(BINPATH) - -.common_install_test: $(LIBTEST) - install -d $(LIBPATH) - install -d $(INCPATH) - install -m 644 testprof/tomcrypt_test.h $(INCPATH) - $(INSTALL_CMD) -m 644 $(LIBTEST) $(LIBPATH) - -install_docs: doc/crypt.pdf - install -d $(DATAPATH) - install -m 644 doc/crypt.pdf $(DATAPATH) - -install_hooks: - for s in `ls hooks/`; do ln -s ../../hooks/$$s .git/hooks/$$s; done - -#This rule cleans the source tree of all compiled code, not including the pdf -#documentation. -clean: - find . -type f -name "*.o" \ - -o -name "*.lo" \ - -o -name "*.a" \ - -o -name "*.la" \ - -o -name "*.obj" \ - -o -name "*.lib" \ - -o -name "*.exe" \ - -o -name "*.dll" \ - -o -name "*.so" \ - -o -name "*.gcov"\ - -o -name "*.gcda"\ - -o -name "*.gcno"\ - -o -name "*.il" \ - -o -name "*.dyn" \ - -o -name "*.dpi" | xargs rm -f - rm -f $(TIMING) $(TEST) $(DEMOS) - rm -f *_tv.txt - rm -f *.pc - rm -rf `find . -type d -name "*.libs" | xargs` - $(MAKE) -C doc/ clean - -zipup: docs - @git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommited changes or not a git" && exit 1 ) - @perl helper.pl --check-all || ( echo "FAILURE: helper.pl --check-all errors" && exit 1 ) - rm -rf libtomcrypt-$(VERSION) libtomcrypt-$(VERSION).* - # files/dirs excluded from "git archive" are defined in .gitattributes - git archive --format=tar --prefix=libtomcrypt-$(VERSION)/ HEAD | tar x - mkdir -p libtomcrypt-$(VERSION)/doc - cp doc/crypt.pdf libtomcrypt-$(VERSION)/doc/crypt.pdf - tar -cJf libtomcrypt-$(VERSION).tar.xz libtomcrypt-$(VERSION) - zip -9rq libtomcrypt-$(VERSION).zip libtomcrypt-$(VERSION) - rm -rf libtomcrypt-$(VERSION) - gpg -b -a libtomcrypt-$(VERSION).tar.xz - gpg -b -a libtomcrypt-$(VERSION).zip - -codecheck: - perl helper.pl -a - perlcritic *.pl diff --git a/makefile.shared b/makefile.shared index 7e2f998..04e08e7 100644 --- a/makefile.shared +++ b/makefile.shared @@ -4,9 +4,8 @@ # # Thanks to Zed Shaw for helping debug this on BSD/OSX. # Tom St Denis - -include makefile.include - +# +# (GNU make only) ifndef LT ifeq ($(PLATFORM), Darwin) @@ -18,7 +17,6 @@ endif LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC) INSTALL_CMD = $(LT) --mode=install install - #Output filenames for various targets. ifndef LIBTEST LIBTEST=libtomcrypt_prof.la @@ -27,6 +25,10 @@ ifndef LIBNAME LIBNAME=libtomcrypt.la endif + +include makefile_include.mk + + #ciphers come in two flavours... enc+dec and enc src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c $(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o @@ -66,8 +68,6 @@ endef $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo)))) -include makefile.common - # $Source$ # $Revision$ # $Date$ diff --git a/makefile.include b/makefile_include.mk similarity index 86% rename from makefile.include rename to makefile_include.mk index ad15672..e4f1787 100644 --- a/makefile.include +++ b/makefile_include.mk @@ -1,6 +1,6 @@ # -# Include makefile for libtomcrypt -# +# Include makefile used by makefile + makefile.shared +# (GNU make only) # The version - BEWARE: VERSION and VERSION_LT are updated via ./updatemakes.sh VERSION=1.17 @@ -313,3 +313,91 @@ library: $(LIBNAME) $(OBJECTS): $(HEADERS) $(DOBJECTS): $(HEADERS) $(THEADERS) $(TOBJECTS): $(HEADERS) $(THEADERS) + +ifndef INSTALL_CMD +$(error your makefile must define INSTALL_CMD) +endif + +ifndef EXTRALIBS +EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config libtommath --libs) +endif + +bins: $(USEFUL_DEMOS) + +all_test: test tv_gen $(DEMOS) + +#build the doxy files (requires Doxygen, tetex and patience) +doxygen doxy docs: + $(MAKE) -C doc/ $@ V=$(V) + +doc/crypt.pdf: + $(MAKE) -C doc/ crypt.pdf V=$(V) + + +install_all: install install_bins install_docs install_test + + +.common_install: $(LIBNAME) + install -d $(INCPATH) + install -d $(LIBPATH) + $(INSTALL_CMD) -m 644 $(LIBNAME) $(LIBPATH)/$(LIBNAME) + install -m 644 $(HEADERS) $(INCPATH) + +.common_install_bins: $(USEFUL_DEMOS) + install -d $(BINPATH) + $(INSTALL_CMD) -m 775 $(USEFUL_DEMOS) $(BINPATH) + +.common_install_test: $(LIBTEST) + install -d $(LIBPATH) + install -d $(INCPATH) + install -m 644 testprof/tomcrypt_test.h $(INCPATH) + $(INSTALL_CMD) -m 644 $(LIBTEST) $(LIBPATH) + +install_docs: doc/crypt.pdf + install -d $(DATAPATH) + install -m 644 doc/crypt.pdf $(DATAPATH) + +install_hooks: + for s in `ls hooks/`; do ln -s ../../hooks/$$s .git/hooks/$$s; done + +#This rule cleans the source tree of all compiled code, not including the pdf +#documentation. +clean: + find . -type f -name "*.o" \ + -o -name "*.lo" \ + -o -name "*.a" \ + -o -name "*.la" \ + -o -name "*.obj" \ + -o -name "*.lib" \ + -o -name "*.exe" \ + -o -name "*.dll" \ + -o -name "*.so" \ + -o -name "*.gcov"\ + -o -name "*.gcda"\ + -o -name "*.gcno"\ + -o -name "*.il" \ + -o -name "*.dyn" \ + -o -name "*.dpi" | xargs rm -f + rm -f $(TIMING) $(TEST) $(DEMOS) + rm -f *_tv.txt + rm -f *.pc + rm -rf `find . -type d -name "*.libs" | xargs` + $(MAKE) -C doc/ clean + +zipup: docs + @git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommited changes or not a git" && exit 1 ) + @perl helper.pl --check-all || ( echo "FAILURE: helper.pl --check-all errors" && exit 1 ) + rm -rf libtomcrypt-$(VERSION) libtomcrypt-$(VERSION).* + # files/dirs excluded from "git archive" are defined in .gitattributes + git archive --format=tar --prefix=libtomcrypt-$(VERSION)/ HEAD | tar x + mkdir -p libtomcrypt-$(VERSION)/doc + cp doc/crypt.pdf libtomcrypt-$(VERSION)/doc/crypt.pdf + tar -cJf libtomcrypt-$(VERSION).tar.xz libtomcrypt-$(VERSION) + zip -9rq libtomcrypt-$(VERSION).zip libtomcrypt-$(VERSION) + rm -rf libtomcrypt-$(VERSION) + gpg -b -a libtomcrypt-$(VERSION).tar.xz + gpg -b -a libtomcrypt-$(VERSION).zip + +codecheck: + perl helper.pl -a + perlcritic *.pl