2003-03-02 19:59:24 -05:00
|
|
|
# MAKEFILE for linux GCC
|
|
|
|
#
|
|
|
|
# Tom St Denis
|
|
|
|
# Modified by Clay Culver
|
2017-05-10 05:56:52 -04:00
|
|
|
#
|
|
|
|
# (GNU make only)
|
2015-01-13 16:41:27 -05:00
|
|
|
|
2015-12-05 08:30:15 -05:00
|
|
|
ifeq ($V,1)
|
|
|
|
silent=
|
2017-02-28 07:26:12 -05:00
|
|
|
silent_stdout=
|
2015-12-05 08:30:15 -05:00
|
|
|
else
|
|
|
|
silent=@
|
2017-02-28 07:26:12 -05:00
|
|
|
silent_stdout= > /dev/null
|
2015-12-05 08:30:15 -05:00
|
|
|
endif
|
|
|
|
|
2017-06-13 06:25:25 -04:00
|
|
|
PLATFORM := $(shell uname | sed -e 's/_.*//')
|
|
|
|
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
|
|
ifeq ($(PLATFORM), Darwin)
|
2017-07-14 06:45:09 -04:00
|
|
|
$(error Known to not work on Mac, please use makefile.unix for static libraries or makefile.shared for shared libraries)
|
2017-06-13 06:25:25 -04:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2005-11-18 00:15:37 -05:00
|
|
|
# ranlib tools
|
|
|
|
ifndef RANLIB
|
2017-06-19 05:51:40 -04:00
|
|
|
RANLIB:=$(CROSS_COMPILE)ranlib
|
2007-07-20 13:48:02 -04:00
|
|
|
endif
|
2017-05-08 18:07:22 -04:00
|
|
|
INSTALL_CMD = install
|
2017-07-10 04:16:35 -04:00
|
|
|
UNINSTALL_CMD = rm
|
2017-05-08 18:07:22 -04:00
|
|
|
|
2003-03-02 19:59:24 -05:00
|
|
|
#Output filenames for various targets.
|
2005-08-01 12:36:47 -04:00
|
|
|
ifndef LIBNAME
|
|
|
|
LIBNAME=libtomcrypt.a
|
|
|
|
endif
|
|
|
|
|
2017-05-10 05:56:52 -04:00
|
|
|
|
|
|
|
include makefile_include.mk
|
|
|
|
|
2017-05-11 09:53:22 -04:00
|
|
|
ifeq ($(COVERAGE),1)
|
|
|
|
all_test: LIB_PRE = -Wl,--whole-archive
|
|
|
|
all_test: LIB_POST = -Wl,--no-whole-archive
|
2017-07-10 05:48:05 -04:00
|
|
|
LTC_CFLAGS += -fprofile-arcs -ftest-coverage
|
2017-05-11 09:53:22 -04:00
|
|
|
EXTRALIBS += -lgcov
|
|
|
|
endif
|
2017-05-10 05:56:52 -04:00
|
|
|
|
2015-12-05 08:30:15 -05:00
|
|
|
#AES comes in two flavours... enc+dec and enc
|
2004-12-30 18:55:53 -05:00
|
|
|
src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
|
2017-07-10 05:48:05 -04:00
|
|
|
${silent} ${CC} ${LTC_CFLAGS} -DENCRYPT_ONLY -c $< -o $@
|
2004-06-19 22:41:49 -04:00
|
|
|
|
2017-05-05 13:11:16 -04:00
|
|
|
.c.o:
|
|
|
|
ifneq ($V,1)
|
|
|
|
@echo " * ${CC} $@"
|
|
|
|
endif
|
2017-07-10 05:48:05 -04:00
|
|
|
${silent} ${CC} ${LTC_CFLAGS} -c $< -o $@
|
2017-05-05 13:11:16 -04:00
|
|
|
|
2003-09-07 21:06:11 -04:00
|
|
|
$(LIBNAME): $(OBJECTS)
|
2016-01-18 18:38:05 -05:00
|
|
|
ifneq ($V,1)
|
|
|
|
@echo " * ${AR} $@"
|
|
|
|
endif
|
|
|
|
${silent} $(AR) $(ARFLAGS) $@ $(OBJECTS)
|
|
|
|
ifneq ($V,1)
|
|
|
|
@echo " * ${RANLIB} $@"
|
|
|
|
endif
|
|
|
|
${silent} $(RANLIB) $@
|
2003-03-02 19:59:24 -05:00
|
|
|
|
2017-07-14 06:18:51 -04:00
|
|
|
test: $(call print-help,test,Builds the library and the 'test' application to run all self-tests) $(LIBNAME) $(TOBJECTS)
|
2016-01-23 13:00:23 -05:00
|
|
|
ifneq ($V,1)
|
|
|
|
@echo " * ${CC} $@"
|
|
|
|
endif
|
2017-07-10 05:48:05 -04:00
|
|
|
${silent} $(CC) $(LTC_LDFLAGS) $(TOBJECTS) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TEST)
|
2016-01-23 13:00:23 -05:00
|
|
|
|
2016-01-23 12:59:30 -05:00
|
|
|
# build the demos from a template
|
|
|
|
define DEMO_template
|
2017-07-14 06:18:51 -04:00
|
|
|
$(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) demos/$(1).o $$(LIBNAME)
|
2016-01-23 12:59:30 -05:00
|
|
|
ifneq ($V,1)
|
|
|
|
@echo " * $${CC} $$@"
|
|
|
|
endif
|
2017-07-10 05:48:05 -04:00
|
|
|
$${silent} $$(CC) $$(LTC_CFLAGS) $$< $$(LIB_PRE) $$(LIBNAME) $$(LIB_POST) $$(EXTRALIBS) -o $(1)
|
2016-01-23 12:59:30 -05:00
|
|
|
endef
|
2003-03-02 19:59:24 -05:00
|
|
|
|
2016-01-23 12:59:30 -05:00
|
|
|
$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
|
2005-04-17 07:37:13 -04:00
|
|
|
|
2014-03-06 18:46:01 -05:00
|
|
|
|
2003-03-02 19:59:24 -05:00
|
|
|
#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
|
|
|
|
#directories and to set the owner and group to root.
|
2017-07-20 06:58:28 -04:00
|
|
|
install: $(call print-help,install,Installs the library and headers) .common_install
|
2003-03-02 19:59:24 -05:00
|
|
|
|
2017-07-14 06:18:51 -04:00
|
|
|
install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) .common_install_bins
|
2017-05-07 16:30:59 -04:00
|
|
|
|
2017-07-20 06:58:28 -04:00
|
|
|
uninstall: $(call print-help,uninstall,Uninstalls the library and headers) .common_uninstall
|
2017-07-10 04:16:35 -04:00
|
|
|
|
2005-06-08 20:08:13 -04:00
|
|
|
profile:
|
2017-07-10 05:48:05 -04:00
|
|
|
LTC_CFLAGS="$(LTC_CFLAGS) -fprofile-generate" $(MAKE) timing EXTRALIBS="$(EXTRALIBS) -lgcov"
|
2005-06-08 20:08:13 -04:00
|
|
|
./timing
|
|
|
|
rm -f timing `find . -type f | grep [.][ao] | xargs`
|
2017-07-10 05:48:05 -04:00
|
|
|
LTC_CFLAGS="$(LTC_CFLAGS) -fprofile-use" $(MAKE) timing EXTRALIBS="$(EXTRALIBS) -lgcov"
|
2005-06-08 20:08:13 -04:00
|
|
|
|
2015-09-07 20:11:43 -04:00
|
|
|
# target that pre-processes all coverage data
|
|
|
|
lcov-single-create:
|
|
|
|
lcov --capture --no-external --directory src -q --output-file coverage_std.info
|
|
|
|
|
|
|
|
# target that removes all coverage output
|
|
|
|
cleancov-clean:
|
|
|
|
rm -f `find . -type f -name "*.info" | xargs`
|
|
|
|
rm -rf coverage/
|
|
|
|
|
2017-05-11 09:53:22 -04:00
|
|
|
# merges all coverage_*.info files into coverage.info
|
|
|
|
coverage.info:
|
|
|
|
lcov `find -name 'coverage_*.info' -exec echo -n " -a {}" \;` -o coverage.info
|
|
|
|
|
2015-09-07 20:11:43 -04:00
|
|
|
# generates html output from all coverage_*.info files
|
2017-05-11 09:53:22 -04:00
|
|
|
lcov-html: coverage.info
|
2015-08-30 11:17:05 -04:00
|
|
|
genhtml coverage.info --output-directory coverage -q
|
2004-10-29 23:00:26 -04:00
|
|
|
|
2015-09-07 20:11:43 -04:00
|
|
|
# combines all necessary steps to create the coverage from a single testrun with e.g.
|
|
|
|
# CFLAGS="-DUSE_LTM -DLTM_DESC -I../libtommath" EXTRALIBS="../libtommath/libtommath.a" make coverage -j9
|
2017-05-11 09:53:22 -04:00
|
|
|
lcov-single:
|
|
|
|
$(MAKE) cleancov-clean
|
|
|
|
$(MAKE) lcov-single-create
|
|
|
|
$(MAKE) coverage.info
|
2015-09-07 20:11:43 -04:00
|
|
|
|
|
|
|
|
2016-04-03 11:45:16 -04:00
|
|
|
#make the code coverage of the library
|
2017-07-10 05:48:05 -04:00
|
|
|
coverage: LTC_CFLAGS += -fprofile-arcs -ftest-coverage
|
2015-09-07 20:11:43 -04:00
|
|
|
coverage: EXTRALIBS += -lgcov
|
2016-04-03 11:45:16 -04:00
|
|
|
coverage: LIB_PRE = -Wl,--whole-archive
|
|
|
|
coverage: LIB_POST = -Wl,--no-whole-archive
|
2015-09-07 20:11:43 -04:00
|
|
|
|
2017-07-14 06:18:51 -04:00
|
|
|
coverage: $(call print-help,coverage,Create code-coverage of the library - but better use coverage.sh) test
|
2015-09-07 20:11:43 -04:00
|
|
|
./test
|
|
|
|
|
|
|
|
# cleans everything - coverage output and standard 'clean'
|
|
|
|
cleancov: cleancov-clean clean
|
|
|
|
|
2017-05-10 07:54:05 -04:00
|
|
|
# ref: $Format:%D$
|
|
|
|
# git commit: $Format:%H$
|
|
|
|
# commit time: $Format:%ai$
|