makefile 3.7 KB

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