libtomcrypt/makefile

138 lines
3.8 KiB
Makefile
Raw Normal View History

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