makefile 3.9 KB

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