I2C toy code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

139 line
3.9 KiB

  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. ifneq ($(MAKECMDGOALS),clean)
  16. ifeq ($(PLATFORM), Darwin)
  17. $(error Known to not work on Mac, please use makefile.unix for static libraries or makefile.shared for shared libraries)
  18. endif
  19. endif
  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. EXTRALIBS += -lgcov
  36. endif
  37. #AES comes in two flavours... enc+dec and enc
  38. src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
  39. ${silent} ${CC} ${LTC_CFLAGS} -DENCRYPT_ONLY -c $< -o $@
  40. .c.o:
  41. ifneq ($V,1)
  42. @echo " * ${CC} $@"
  43. endif
  44. ${silent} ${CC} ${LTC_CFLAGS} -c $< -o $@
  45. $(LIBNAME): $(OBJECTS)
  46. ifneq ($V,1)
  47. @echo " * ${AR} $@"
  48. endif
  49. ${silent} $(AR) $(ARFLAGS) $@ $(OBJECTS)
  50. ifneq ($V,1)
  51. @echo " * ${RANLIB} $@"
  52. endif
  53. ${silent} $(RANLIB) $@
  54. test: $(call print-help,test,Builds the library and the 'test' application to run all self-tests) $(LIBNAME) $(TOBJECTS)
  55. ifneq ($V,1)
  56. @echo " * ${CC} $@"
  57. endif
  58. ${silent} $(CC) $(LTC_LDFLAGS) $(TOBJECTS) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TEST)
  59. # build the demos from a template
  60. define DEMO_template
  61. $(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) demos/$(1).o $$(LIBNAME)
  62. ifneq ($V,1)
  63. @echo " * $${CC} $$@"
  64. endif
  65. $${silent} $$(CC) $$(LTC_CFLAGS) $$< $$(LIB_PRE) $$(LIBNAME) $$(LIB_POST) $$(EXTRALIBS) -o $(1)
  66. endef
  67. $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
  68. #This rule installs the library and the header files. This must be run
  69. #as root in order to have a high enough permission to write to the correct
  70. #directories and to set the owner and group to root.
  71. install: $(call print-help,install,Installs the library and headers) .common_install
  72. install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) .common_install_bins
  73. uninstall: $(call print-help,uninstall,Uninstalls the library and headers) .common_uninstall
  74. profile:
  75. LTC_CFLAGS="$(LTC_CFLAGS) -fprofile-generate" $(MAKE) timing EXTRALIBS="$(EXTRALIBS) -lgcov"
  76. ./timing
  77. rm -f timing `find . -type f | grep [.][ao] | xargs`
  78. LTC_CFLAGS="$(LTC_CFLAGS) -fprofile-use" $(MAKE) timing EXTRALIBS="$(EXTRALIBS) -lgcov"
  79. # target that pre-processes all coverage data
  80. lcov-single-create:
  81. lcov --capture --no-external --directory src -q --output-file coverage_std.info
  82. # target that removes all coverage output
  83. cleancov-clean:
  84. rm -f `find . -type f -name "*.info" | xargs`
  85. rm -rf coverage/
  86. # merges all coverage_*.info files into coverage.info
  87. coverage.info:
  88. lcov `find -name 'coverage_*.info' -exec echo -n " -a {}" \;` -o coverage.info
  89. # generates html output from all coverage_*.info files
  90. lcov-html: coverage.info
  91. genhtml coverage.info --output-directory coverage -q
  92. # combines all necessary steps to create the coverage from a single testrun with e.g.
  93. # CFLAGS="-DUSE_LTM -DLTM_DESC -I../libtommath" EXTRALIBS="../libtommath/libtommath.a" make coverage -j9
  94. lcov-single:
  95. $(MAKE) cleancov-clean
  96. $(MAKE) lcov-single-create
  97. $(MAKE) coverage.info
  98. #make the code coverage of the library
  99. coverage: LTC_CFLAGS += -fprofile-arcs -ftest-coverage
  100. coverage: EXTRALIBS += -lgcov
  101. coverage: LIB_PRE = -Wl,--whole-archive
  102. coverage: LIB_POST = -Wl,--no-whole-archive
  103. coverage: $(call print-help,coverage,Create code-coverage of the library - but better use coverage.sh) test
  104. ./test
  105. # cleans everything - coverage output and standard 'clean'
  106. cleancov: cleancov-clean clean
  107. # ref: $Format:%D$
  108. # git commit: $Format:%H$
  109. # commit time: $Format:%ai$