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.
 
 
 
 
 
 

129 lines
4.1 KiB

  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. NVIC_H := $(IRQ_DEFN_FILES:%/irq.json=%/nvic.h)
  45. VECTOR_NVIC_C := $(IRQ_DEFN_FILES:./include/libopencm3/%/irq.json=./lib/%/vector_nvic.c)
  46. IRQHANDLERS_H := $(IRQ_DEFN_FILES:./include/libopencm3/%/irq.json=./include/libopencmsis/%/irqhandlers.h)
  47. IRQ_GENERATED_FILES = $(NVIC_H) $(VECTOR_NVIC_C) $(IRQHANDLERS_H)
  48. STYLECHECKFILES := $(wildcard include/*/*.h include/*/*/*.h include/*/*/*/*.h)
  49. STYLECHECKFILES += $(wildcard lib/*/*.h lib/*/*/*.h lib/*/*/*/*.h)
  50. STYLECHECKFILES += $(wildcard lib/*/*.c lib/*/*/*.c lib/*/*/*/*.c)
  51. all: build
  52. build: lib
  53. include/libopencm3/%/nvic.h lib/%/vector_nvic.c include/libopencmsis/%/irqhandlers.h: include/libopencm3/%/irq.json ./scripts/irq2nvic_h
  54. @printf " GENHDR $*\n";
  55. $(Q)./scripts/irq2nvic_h ./$<;
  56. %.cleanhdr:
  57. @printf " CLNHDR $*\n";
  58. $(Q)./scripts/irq2nvic_h --remove ./$*
  59. LIB_DIRS:=$(wildcard $(addprefix lib/,$(TARGETS)))
  60. $(LIB_DIRS): $(IRQ_GENERATED_FILES)
  61. $(Q)$(RM) .stamp_failure_$(subst /,_,$@)
  62. @printf " BUILD $@\n";
  63. $(Q)$(MAKE) --directory=$@ PREFIX="$(PREFIX)" || \
  64. echo "Failure building: $@: code: $$?" > .stamp_failure_$(subst /,_,$@)
  65. lib: $(LIB_DIRS)
  66. $(Q)$(RM) .stamp_failure_tld
  67. $(Q)for failure in .stamp_failure_*; do \
  68. [ -f $$failure ] && cat $$failure >> .stamp_failure_tld || true; \
  69. done;
  70. $(Q)[ -f .stamp_failure_tld ] && cat .stamp_failure_tld && exit 1 || true;
  71. html doc:
  72. $(Q)$(MAKE) -C doc html TARGETS="$(TARGETS)"
  73. clean: $(IRQ_DEFN_FILES:=.cleanhdr) $(LIB_DIRS:=.clean) $(EXAMPLE_DIRS:=.clean) doc.clean styleclean genlinktests.clean
  74. %.clean:
  75. $(Q)if [ -d $* ]; then \
  76. printf " CLEAN $*\n"; \
  77. $(MAKE) -C $* clean || exit $?; \
  78. fi;
  79. $(Q)$(RM) .stamp_failure_*;
  80. stylecheck: $(STYLECHECKFILES:=.stylecheck)
  81. styleclean: $(STYLECHECKFILES:=.styleclean)
  82. # the cat is due to multithreaded nature - we like to have consistent chunks of text on the output
  83. %.stylecheck: %
  84. $(Q)if ! grep -q "* It was generated by the irq2nvic_h script." $* ; then \
  85. $(STYLECHECK) $(STYLECHECKFLAGS) $* > $*.stylecheck; \
  86. if [ -s $*.stylecheck ]; then \
  87. cat $*.stylecheck; \
  88. else \
  89. rm -f $*.stylecheck; \
  90. fi; \
  91. fi;
  92. %.styleclean:
  93. $(Q)rm -f $*.stylecheck;
  94. LDTESTS :=$(wildcard ld/tests/*.data)
  95. genlinktests: $(LDTESTS:.data=.ldtest)
  96. genlinktests.clean:
  97. $(Q)rm -f $(LDTESTS:.data=.out)
  98. %.ldtest:
  99. @if ./scripts/genlinktest.sh $* >/dev/null; then\
  100. printf " TEST OK : $*\n"; \
  101. else \
  102. printf " TEST FAIL : $*\n"; \
  103. fi;
  104. .PHONY: build lib $(LIB_DIRS) doc clean generatedheaders cleanheaders stylecheck genlinktests genlinktests.clean