Board.mk 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. ############################################################################
  2. # boards/Board.mk
  3. #
  4. # Copyright (C) 2015 Gregory Nutt. All rights reserved.
  5. # Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved.
  6. # Author: Gregory Nutt <gnutt@nuttx.org>
  7. # Paul Alexander Patience <paul-a.patience@polymtl.ca>
  8. #
  9. # Redistribution and use in source and binary forms, with or without
  10. # modification, are permitted provided that the following conditions
  11. # are met:
  12. #
  13. # 1. Redistributions of source code must retain the above copyright
  14. # notice, this list of conditions and the following disclaimer.
  15. # 2. Redistributions in binary form must reproduce the above copyright
  16. # notice, this list of conditions and the following disclaimer in
  17. # the documentation and/or other materials provided with the
  18. # distribution.
  19. # 3. Neither the name NuttX nor the names of its contributors may be
  20. # used to endorse or promote products derived from this software
  21. # without specific prior written permission.
  22. #
  23. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  26. # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  27. # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  28. # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  29. # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  30. # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  31. # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  33. # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  34. # POSSIBILITY OF SUCH DAMAGE.
  35. #
  36. ############################################################################
  37. ifneq ($(RCSRCS)$(RCRAWS),)
  38. ETCDIR := etctmp
  39. ETCSRC := $(ETCDIR:%=%.c)
  40. CSRCS += $(ETCSRC)
  41. RCOBJS = $(RCSRCS:%=$(ETCDIR)$(DELIM)%)
  42. $(RCOBJS): $(ETCDIR)$(DELIM)%: %
  43. $(Q) mkdir -p $(dir $@)
  44. $(call PREPROCESS, $<, $@)
  45. $(ETCSRC): $(RCRAWS) $(RCOBJS)
  46. $(foreach raw, $(RCRAWS), \
  47. $(shell rm -rf $(ETCDIR)$(DELIM)$(raw)) \
  48. $(shell mkdir -p $(dir $(ETCDIR)$(DELIM)$(raw))) \
  49. $(shell cp -rfp $(raw) $(ETCDIR)$(DELIM)$(raw)))
  50. $(Q) genromfs -f romfs.img -d $(ETCDIR)$(DELIM)$(CONFIG_NSH_ROMFSMOUNTPT) -V "$(basename $<)"
  51. $(Q) xxd -i romfs.img | sed -e "s/^unsigned/const unsigned/g" > $@
  52. $(Q) rm romfs.img
  53. endif
  54. ifneq ($(ZDSVERSION),)
  55. AOBJS = $(ASRCS:.S=$(OBJEXT))
  56. else
  57. AOBJS = $(ASRCS:$(ASMEXT)=$(OBJEXT))
  58. endif
  59. COBJS = $(CSRCS:.c=$(OBJEXT))
  60. CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
  61. SRCS = $(ASRCS) $(CSRCS)
  62. OBJS = $(AOBJS) $(COBJS)
  63. SCHEDSRCDIR = $(TOPDIR)$(DELIM)sched
  64. ARCHSRCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src
  65. ifneq ($(CONFIG_ARCH_FAMILY),)
  66. ARCH_FAMILY = $(patsubst "%",%,$(CONFIG_ARCH_FAMILY))
  67. endif
  68. CFLAGS += ${shell $(INCDIR) "$(CC)" "$(SCHEDSRCDIR)"}
  69. CFLAGS += ${shell $(INCDIR) "$(CC)" "$(ARCHSRCDIR)$(DELIM)chip"}
  70. ifneq ($(CONFIG_ARCH_SIM),y)
  71. CFLAGS += ${shell $(INCDIR) "$(CC)" "$(ARCHSRCDIR)$(DELIM)common"}
  72. endif
  73. ifneq ($(ARCH_FAMILY),)
  74. CFLAGS += ${shell $(INCDIR) "$(CC)" "$(ARCHSRCDIR)$(DELIM)$(ARCH_FAMILY)"}
  75. endif
  76. all: libboard$(LIBEXT)
  77. ifneq ($(ZDSVERSION),)
  78. $(ASRCS) $(HEAD_ASRC): %$(ASMEXT): %.S
  79. ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
  80. $(Q) $(CPP) $(CPPFLAGS) `cygpath -w $<` -o $@.tmp
  81. else
  82. $(Q) $(CPP) $(CPPFLAGS) $< -o $@.tmp
  83. endif
  84. $(Q) cat $@.tmp | sed -e "s/^#/;/g" > $@
  85. $(Q) rm $@.tmp
  86. endif
  87. $(AOBJS): %$(OBJEXT): %$(ASMEXT)
  88. $(call ASSEMBLE, $<, $@)
  89. $(COBJS) $(LINKOBJS): %$(OBJEXT): %.c
  90. $(call COMPILE, $<, $@)
  91. $(CXXOBJS) $(LINKOBJS): %$(OBJEXT): %.cxx
  92. $(call COMPILEXX, $<, $@)
  93. libboard$(LIBEXT): $(OBJS) $(CXXOBJS)
  94. $(call ARCHIVE, $@, $(OBJS) $(CXXOBJS))
  95. .depend: Makefile $(SRCS) $(CXXSRCS) $(RCSRCS) $(TOPDIR)$(DELIM).config
  96. ifneq ($(ZDSVERSION),)
  97. $(Q) $(MKDEP) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
  98. else
  99. $(Q) $(MKDEP) $(DEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
  100. endif
  101. ifneq ($(CXXSRCS),)
  102. $(Q) $(MKDEP) $(DEPPATH) "$(CXX)" -- $(CXXFLAGS) -- $(CXXSRCS) >>Make.dep
  103. endif
  104. ifneq ($(RCSRCS),)
  105. $(Q) $(MKDEP) $(DEPPATH) "$(CPP)" --obj-path . -- $(CPPFLAGS) -- $(RCSRCS) >>Make.dep
  106. endif
  107. $(Q) touch $@
  108. depend: .depend
  109. context::
  110. clean::
  111. $(call DELFILE, libboard$(LIBEXT))
  112. $(call DELFILE, $(ETCSRC))
  113. $(call DELDIR, $(ETCDIR))
  114. $(call CLEAN)
  115. distclean:: clean
  116. $(call DELFILE, Make.dep)
  117. $(call DELFILE, .depend)
  118. -include Make.dep