From 4572357e876f7bd5de03139e255ae4e8380629e1 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Sat, 23 Jan 2016 18:59:30 +0100 Subject: [PATCH] make easily built demos in a template --- demos/{demo_crypt_constants.c => constants.c} | 0 demos/{encrypt.c => crypt.c} | 0 demos/{demo_crypt_sizes.c => sizes.c} | 0 makefile | 39 ++++++------------- 4 files changed, 11 insertions(+), 28 deletions(-) rename demos/{demo_crypt_constants.c => constants.c} (100%) rename demos/{encrypt.c => crypt.c} (100%) rename demos/{demo_crypt_sizes.c => sizes.c} (100%) diff --git a/demos/demo_crypt_constants.c b/demos/constants.c similarity index 100% rename from demos/demo_crypt_constants.c rename to demos/constants.c diff --git a/demos/encrypt.c b/demos/crypt.c similarity index 100% rename from demos/encrypt.c rename to demos/crypt.c diff --git a/demos/demo_crypt_sizes.c b/demos/sizes.c similarity index 100% rename from demos/demo_crypt_sizes.c rename to demos/sizes.c diff --git a/makefile b/makefile index e225e57..285b37c 100644 --- a/makefile +++ b/makefile @@ -181,15 +181,10 @@ src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h #END_INS -HASHOBJECTS=demos/hashsum.o -CRYPTOBJECTS=demos/encrypt.o -SMALLOBJECTS=demos/small.o -TVS=demos/tv_gen.o -MULTIS=demos/multi.o +DEMOS=hashsum crypt small tv_gen multi sizes constants + TIMINGS=demos/timing.o TESTS=demos/test.o -CRYPTSIZES=demos/demo_crypt_sizes.o -CRYPTCONSTANTS=demos/demo_crypt_constants.o #Files left over from making the crypt.pdf. LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind *.out *.lof @@ -232,23 +227,16 @@ ifneq ($V,1) endif ${silent} $(RANLIB) $@ -#This rule makes the hash program included with libtomcrypt -hashsum: library $(HASHOBJECTS) - $(CC) $(HASHOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(HASH) +# build the demos from a template +define DEMO_template +$(1): demos/$(1).o library +ifneq ($V,1) + @echo " * $${CC} $$@" +endif + $${silent} $$(CC) $$< $$(LIBNAME) $$(EXTRALIBS) -o $(1) +endef -#makes the crypt program -crypt: library $(CRYPTOBJECTS) - $(CC) $(CRYPTOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(CRYPT) - -#makes the small program -small: library $(SMALLOBJECTS) - $(CC) $(SMALLOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(SMALL) - -tv_gen: library $(TVS) - $(CC) $(LDFLAGS) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV) - -multi: library $(MULTIS) - $(CC) $(MULTIS) $(LIBNAME) $(EXTRALIBS) -o $(MULTI) +$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo)))) timing: library testprof/$(LIBTEST) $(TIMINGS) $(CC) $(LDFLAGS) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING) @@ -257,11 +245,6 @@ timing: library testprof/$(LIBTEST) $(TIMINGS) test: library testprof/$(LIBTEST) $(TESTS) $(CC) $(LDFLAGS) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST) -sizes: library $(CRYPTSIZES) - $(CC) $(LDFLAGS) $(CRYPTSIZES) $(LIBNAME) $(EXTRALIBS) -o $(SIZES) - -constants: library $(CRYPTCONSTANTS) - $(CC) $(LDFLAGS) $(CRYPTCONSTANTS) $(LIBNAME) $(EXTRALIBS) -o $(CONSTANTS) #This rule installs the library and the header files. This must be run #as root in order to have a high enough permission to write to the correct