Fix c&p error [skip-ci]
[libtomcrypt.git] / makefile
blobddddb6cc91d68aca38c1838b7cd49b4ea6067882
1 # MAKEFILE for linux GCC
3 # Tom St Denis
4 # Modified by Clay Culver
6 # (GNU make only)
8 ifeq ($V,0)
9 silent_echo= > /dev/null
10 else
11 silent_echo=
12 endif
13 ifeq ($V,1)
14 silent=
15 silent_stdout=
16 silent_stderr=
17 else
18 silent=@
19 silent_stdout= > /dev/null
20 silent_stderr= 2> /dev/null
21 endif
23 PLATFORM := $(shell uname | sed -e 's/_.*//')
25 # ranlib tools
26 ifndef RANLIB
27 RANLIB:=$(CROSS_COMPILE)ranlib
28 endif
29 INSTALL_CMD = install
30 UNINSTALL_CMD = rm
32 #Output filenames for various targets.
33 ifndef LIBNAME
34 LIBNAME=libtomcrypt.a
35 endif
38 include makefile_include.mk
40 ifeq ($(COVERAGE),1)
41 all_test: LIB_PRE = -Wl,--whole-archive
42 all_test: LIB_POST = -Wl,--no-whole-archive
43 LTC_CFLAGS += -fprofile-arcs -ftest-coverage
44 LTC_EXTRALIBS += -lgcov
45 endif
47 LTC_EXTRALIBS += $(EXTRALIBS)
49 #AES comes in two flavours... enc+dec and enc
50 src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
51 ifneq ($V,1)
52 @echo " * ${CC} $@" ${silent_echo}
53 endif
54 ${silent} ${CC} ${LTC_CFLAGS} -DENCRYPT_ONLY -c $< -o $@
55 src/ciphers/aes/aes_enc_desc.o: src/ciphers/aes/aes_desc.c
56 ifneq ($V,1)
57 @echo " * ${CC} $@" ${silent_echo}
58 endif
59 ${silent} ${CC} ${LTC_CFLAGS} -DENCRYPT_ONLY -c $< -o $@
61 .c.o:
62 ifneq ($V,1)
63 @echo " * ${CC} $@" ${silent_echo}
64 endif
65 ${silent} ${CC} ${LTC_CFLAGS} -c $< -o $@
67 $(LIBNAME): $(OBJECTS)
68 ifneq ($V,1)
69 @echo " * ${AR} $@" ${silent_echo}
70 endif
71 ${silent} $(AR) $(ARFLAGS) $@ $(OBJECTS)
72 ifneq ($V,1)
73 @echo " * ${RANLIB} $@" ${silent_echo}
74 endif
75 ${silent} $(RANLIB) $@
77 test: $(call print-help,test,Builds the library and the 'test' application to run all self-tests) $(LIBNAME) $(TOBJECTS)
78 ifneq ($V,1)
79 @echo " * ${CC} $@" ${silent_echo}
80 endif
81 ${silent} $(CC) $(LTC_LDFLAGS) $(TOBJECTS) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(LTC_EXTRALIBS) -o $(TEST)
83 # build the demos from a template
84 define DEMO_template
85 $(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) demos/$(1).o $$(LIBNAME)
86 ifneq ($V,1)
87 @echo " * $${CC} $$@" ${silent_echo}
88 endif
89 $${silent} $$(CC) $$(LTC_LDFLAGS) $$< $$(LIB_PRE) $$(LIBNAME) $$(LIB_POST) $$(LTC_EXTRALIBS) -o $$@
90 endef
92 $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
95 #This rule installs the library and the header files. This must be run
96 #as root in order to have a high enough permission to write to the correct
97 #directories and to set the owner and group to root.
98 install: $(call print-help,install,Installs the library and headers) .common_install
100 install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) .common_install_bins
102 uninstall: $(call print-help,uninstall,Uninstalls the library and headers) .common_uninstall
104 profile:
105 LTC_CFLAGS="$(LTC_CFLAGS) -fprofile-generate" $(MAKE) timing EXTRALIBS="$(LTC_EXTRALIBS) -lgcov"
106 ./timing
107 rm -f timing `find . -type f | grep [.][ao] | xargs`
108 LTC_CFLAGS="$(LTC_CFLAGS) -fprofile-use" $(MAKE) timing EXTRALIBS="$(LTC_EXTRALIBS) -lgcov"
110 # target that pre-processes all coverage data
111 lcov-single-create:
112 lcov --capture --no-external --directory src -q --output-file coverage_std.info
114 # target that removes all coverage output
115 cleancov-clean:
116 rm -f `find . -type f -name "*.info" | xargs`
117 rm -rf coverage/
119 # merges all coverage_*.info files into coverage.info
120 coverage.info:
121 lcov `find -name 'coverage_*.info' -exec echo -n " -a {}" \;` -o coverage.info
123 # generates html output from all coverage_*.info files
124 lcov-html: coverage.info
125 genhtml coverage.info --output-directory coverage -q
127 # combines all necessary steps to create the coverage from a single testrun with e.g.
128 # CFLAGS="-DUSE_LTM -DLTM_DESC -I../libtommath" EXTRALIBS="../libtommath/libtommath.a" make coverage -j9
129 lcov-single:
130 $(MAKE) cleancov-clean
131 $(MAKE) lcov-single-create
132 $(MAKE) coverage.info
135 #make the code coverage of the library
136 coverage: LTC_CFLAGS += -fprofile-arcs -ftest-coverage
137 coverage: LTC_EXTRALIBS += -lgcov
138 coverage: LIB_PRE = -Wl,--whole-archive
139 coverage: LIB_POST = -Wl,--no-whole-archive
141 coverage: $(call print-help,coverage,Create code-coverage of the library - but better use coverage.sh) test
142 ./test
144 # cleans everything - coverage output and standard 'clean'
145 cleancov: cleancov-clean clean