Makefile 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. ##
  2. ## This file is part of the libopencm3 project.
  3. ##
  4. ## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
  5. ##
  6. ## This library is free software: you can redistribute it and/or modify
  7. ## it under the terms of the GNU Lesser General Public License as published by
  8. ## the Free Software Foundation, either version 3 of the License, or
  9. ## (at your option) any later version.
  10. ##
  11. ## This library is distributed in the hope that it will be useful,
  12. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ## GNU Lesser General Public License for more details.
  15. ##
  16. ## You should have received a copy of the GNU Lesser General Public License
  17. ## along with this library. If not, see <http://www.gnu.org/licenses/>.
  18. ##
  19. PREFIX ?= arm-none-eabi-
  20. STYLECHECK := scripts/checkpatch.pl
  21. STYLECHECKFLAGS := --no-tree -f --terse --mailback
  22. TARGETS ?= stm32/f0 stm32/f1 stm32/f2 stm32/f3 stm32/f4 stm32/f7 \
  23. stm32/l0 stm32/l1 stm32/l4 \
  24. stm32/g0 stm32/g4 \
  25. stm32/h7 \
  26. gd32/f1x0 \
  27. lpc13xx lpc17xx lpc43xx/m4 lpc43xx/m0 \
  28. lm3s lm4f msp432/e4 \
  29. efm32/tg efm32/g efm32/lg efm32/gg efm32/hg efm32/wg \
  30. efm32/ezr32wg \
  31. sam/3a sam/3n sam/3s sam/3u sam/3x sam/4l \
  32. sam/d \
  33. vf6xx \
  34. swm050 \
  35. pac55xx
  36. # Be silent per default, but 'make V=1' will show all compiler calls.
  37. ifneq ($(V),1)
  38. Q := @
  39. # Do not print "Entering directory ...".
  40. MAKEFLAGS += --no-print-directory
  41. endif
  42. # Avoid the use of shell find, for windows compatibility
  43. IRQ_DEFN_FILES := $(foreach TARGET,$(TARGETS),$(wildcard include/libopencm3/$(TARGET)/irq.json))
  44. STYLECHECKFILES := $(wildcard include/*/*.h include/*/*/*.h include/*/*/*/*.h)
  45. STYLECHECKFILES += $(wildcard lib/*/*.h lib/*/*/*.h lib/*/*/*/*.h)
  46. STYLECHECKFILES += $(wildcard lib/*/*.c lib/*/*/*.c lib/*/*/*/*.c)
  47. all: build
  48. build: lib
  49. %.genhdr:
  50. @printf " GENHDR $*\n";
  51. $(Q)./scripts/irq2nvic_h ./$*;
  52. %.cleanhdr:
  53. @printf " CLNHDR $*\n";
  54. $(Q)./scripts/irq2nvic_h --remove ./$*
  55. LIB_DIRS:=$(wildcard $(addprefix lib/,$(TARGETS)))
  56. $(LIB_DIRS): $(IRQ_DEFN_FILES:=.genhdr)
  57. $(Q)$(RM) .stamp_failure_$(subst /,_,$@)
  58. @printf " BUILD $@\n";
  59. $(Q)$(MAKE) --directory=$@ PREFIX="$(PREFIX)" || \
  60. echo "Failure building: $@: code: $$?" > .stamp_failure_$(subst /,_,$@)
  61. lib: $(LIB_DIRS)
  62. $(Q)$(RM) .stamp_failure_tld
  63. $(Q)for failure in .stamp_failure_*; do \
  64. [ -f $$failure ] && cat $$failure >> .stamp_failure_tld || true; \
  65. done;
  66. $(Q)[ -f .stamp_failure_tld ] && cat .stamp_failure_tld && exit 1 || true;
  67. html doc:
  68. $(Q)$(MAKE) -C doc html TARGETS="$(TARGETS)"
  69. clean: $(IRQ_DEFN_FILES:=.cleanhdr) $(LIB_DIRS:=.clean) $(EXAMPLE_DIRS:=.clean) doc.clean styleclean genlinktests.clean
  70. %.clean:
  71. $(Q)if [ -d $* ]; then \
  72. printf " CLEAN $*\n"; \
  73. $(MAKE) -C $* clean || exit $?; \
  74. fi;
  75. $(Q)$(RM) .stamp_failure_*;
  76. stylecheck: $(STYLECHECKFILES:=.stylecheck)
  77. styleclean: $(STYLECHECKFILES:=.styleclean)
  78. # the cat is due to multithreaded nature - we like to have consistent chunks of text on the output
  79. %.stylecheck: %
  80. $(Q)if ! grep -q "* It was generated by the irq2nvic_h script." $* ; then \
  81. $(STYLECHECK) $(STYLECHECKFLAGS) $* > $*.stylecheck; \
  82. if [ -s $*.stylecheck ]; then \
  83. cat $*.stylecheck; \
  84. else \
  85. rm -f $*.stylecheck; \
  86. fi; \
  87. fi;
  88. %.styleclean:
  89. $(Q)rm -f $*.stylecheck;
  90. LDTESTS :=$(wildcard ld/tests/*.data)
  91. genlinktests: $(LDTESTS:.data=.ldtest)
  92. genlinktests.clean:
  93. $(Q)rm -f $(LDTESTS:.data=.out)
  94. %.ldtest:
  95. @if ./scripts/genlinktest.sh $* >/dev/null; then\
  96. printf " TEST OK : $*\n"; \
  97. else \
  98. printf " TEST FAIL : $*\n"; \
  99. fi;
  100. .PHONY: build lib $(LIB_DIRS) doc clean generatedheaders cleanheaders stylecheck genlinktests genlinktests.clean