makefile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #######################################################################################
  2. # Software License Agreement (BSD License)
  3. # Copyright (c) 2012, hathach (tinyusb.net)
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms, with or without modification,
  7. # are permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of source code must retain the above copyright notice,
  10. # this list of conditions and the following disclaimer.
  11. # 2. Redistributions in binary form must reproduce the above copyright notice,
  12. # this list of conditions and the following disclaimer in the documentation
  13. # and/or other materials provided with the distribution.
  14. # 3. The name of the author may not be used to endorse or promote products
  15. # derived from this software without specific prior written permission.
  16. #
  17. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  18. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  19. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
  20. # SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  21. # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
  22. # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  23. # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  24. # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  25. # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  26. # OF SUCH DAMAGE.
  27. #######################################################################################
  28. ##################################################
  29. # Keyboard makefile
  30. ##################################################
  31. ############ Toolchain ############
  32. toolchain := lpcxpresso
  33. CC := arm-none-eabi-gcc
  34. RM := rm -rf
  35. #AR LD
  36. toolchain_def = __REDLIB__ __CODE_RED __USE_CMSIS=CMSISv2p00_LPC11Uxx
  37. mcu = lpc11uxx
  38. build_path = ../build/
  39. #helper function
  40. rel2abs = $(shell cd $(1); pwd)
  41. #path
  42. tinyusb_path = ../../../tinyusb
  43. bsp_path = ../../bsp
  44. cmsis_path = ../../../../CMSISv2p00_LPC11Uxx
  45. build_path_abs = $(CURDIR)/$(build_path_relative)
  46. tinyusb_path_abs = $(CURDIR)/$(tinyusb_path)
  47. bsp_path_abs = $(CURDIR)/$(bsp_path)
  48. cmsis_path_abs = $(CURDIR)/$(cmsis_path)
  49. ############ Sources ############
  50. src = $(shell find $(CURDIR) -type f -name "*.c") $(tinyusb_src) $(bsp_src)
  51. objects = $(subst .c,.o,$(src))
  52. dependencies = $(subst .c,.d,$(src))
  53. tinyusb_src = $(shell find $(tinyusb_path_abs) \( ! -name "*hal*" \) -type f -name "*.c") $(tinyusb_path_abs)/hal/hal_$(mcu).c
  54. bsp_src = $(shell find $(bsp_path_abs)/boards -type f -name "*.c") $(shell find $(bsp_path_abs)/$(mcu) -type f -name "*.c")
  55. cmsis_src = $(shell find $(cmsis_path_abs) -type f -name "*.c")
  56. ############ CFLAGS C Compiler Flag ##############
  57. #CFLAGS = $(addprefix -D,$(toolchain_def) $(macros_def)) $(addprefix -I,$(inc_path))
  58. ############ LDFLAGS Linker Flag ##############
  59. #LDFLAGS
  60. ############ CPPFLAGS C Preprocessor Flag ##############
  61. CPPFLAGS = $(addprefix -D,$(toolchain_def) $(macros_def)) $(addprefix -I,$(inc_path))
  62. macros_def += BOARD=BOARD_AT86RF2XX
  63. macros_def += MCU=MCU_LPC11UXX
  64. inc_path = $(CURDIR) $(tinyusb_path_abs) $(bsp_path_abs) $(cmsis_path_abs)/inc
  65. ############ Compile Rules ##############
  66. #%.o : %.c
  67. ############ Target ##############
  68. all: keyboard.axf
  69. keyboard.axf : $(objects)
  70. clean:
  71. -$(RM) $(objects) $(dependencies) keyboard.axf
  72. .PHONY: all clean
  73. ############ Dependencies Generate and Inlcude ############
  74. ifneq ($(MAKECMDGOALS),clean)
  75. include $(dependencies)
  76. endif
  77. %.d: %.c
  78. $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
  79. sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
  80. rm -f $@.$$$$