Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. ############################################################################
  2. # configs/Makefile
  3. #
  4. # Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
  5. # Author: Gregory Nutt <gnutt@nuttx.org>
  6. #
  7. # Redistribution and use in source and binary forms, with or without
  8. # modification, are permitted provided that the following conditions
  9. # are met:
  10. #
  11. # 1. Redistributions of source code must retain the above copyright
  12. # notice, this list of conditions and the following disclaimer.
  13. # 2. Redistributions in binary form must reproduce the above copyright
  14. # notice, this list of conditions and the following disclaimer in
  15. # the documentation and/or other materials provided with the
  16. # distribution.
  17. # 3. Neither the name NuttX nor the names of its contributors may be
  18. # used to endorse or promote products derived from this software
  19. # without specific prior written permission.
  20. #
  21. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. # POSSIBILITY OF SUCH DAMAGE.
  33. #
  34. ############################################################################
  35. -include $(TOPDIR)/Make.defs
  36. # Determine if there is a Kconfig file for any custom board configuration
  37. ifeq ($(CONFIG_ARCH_BOARD_CUSTOM),y)
  38. CUSTOM_DIR = $(patsubst "%",%,$(CONFIG_ARCH_BOARD_CUSTOM_DIR))
  39. ifeq ($(CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH),y)
  40. CUSTOM_KPATH = $(TOPDIR)$(DELIM)$(CUSTOM_DIR)$(DELIM)Kconfig
  41. else
  42. CUSTOM_KPATH = $(CUSTOM_DIR)$(DELIM)Kconfig
  43. endif
  44. CUSTOM_KCONFIG = $(if $(wildcard $(CUSTOM_KPATH)),y,)
  45. else
  46. CUSTOM_KCONFIG =
  47. endif
  48. ifeq ($(CUSTOM_KCONFIG),y)
  49. BOARD_KCONFIG = $(CUSTOM_KPATH)
  50. else
  51. BOARD_KCONFIG = $(TOPDIR)$(DELIM)configs$(DELIM)dummy$(DELIM)dummy_kconfig
  52. endif
  53. DUMMY_KCONFIG = $(TOPDIR)$(DELIM)configs$(DELIM)dummy$(DELIM)Kconfig
  54. # The board configuration should be installed in the arch/ directory
  55. BOARD_DIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board
  56. BOARD_INSTALLED = $(if $(wildcard $(BOARD_DIR)$(DELIM)Makefile),y,)
  57. # Basic
  58. CONFIG_ASRCS =
  59. CONFIG_CSRCS =
  60. CONFIG_CXXSRCS =
  61. # boardctl support
  62. ifeq ($(CONFIG_LIB_BOARDCTL),y)
  63. CONFIG_CSRCS += boardctl.c
  64. endif
  65. ASRCS = $(CONFIG_ASRCS)
  66. AOBJS = $(ASRCS:.S=$(OBJEXT))
  67. CSRCS = $(CONFIG_CSRCS)
  68. COBJS = $(CSRCS:.c=$(OBJEXT))
  69. CXXSRCS = $(CONFIG_CXXSRCS)
  70. CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
  71. SRCS = $(ASRCS) $(CSRCS)
  72. OBJS = $(AOBJS) $(COBJS)
  73. BIN = libconfigs$(LIBEXT)
  74. all: $(BIN)
  75. .PHONY: depend context clean_context clean distclean
  76. $(AOBJS): %$(OBJEXT): %.S
  77. $(call ASSEMBLE, $<, $@)
  78. $(COBJS): %$(OBJEXT): %.c
  79. $(call COMPILE, $<, $@)
  80. $(CXXOBJS): %$(OBJEXT): %.cxx
  81. $(call COMPILEXX, $<, $@)
  82. $(BIN): $(OBJS) $(CXXOBJS)
  83. $(call ARCHIVE, $@, $(OBJS) $(CXXOBJS))
  84. .depend: Makefile $(SRCS) $(CXXSRCS)
  85. ifneq ($(SRCS),)
  86. $(Q) $(MKDEP) --dep-path . "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
  87. endif
  88. ifneq ($(CXXSRCS),)
  89. $(Q) $(MKDEP) --dep-path . "$(CXX)" -- $(CXXFLAGS) -- $(CXXSRCS) >>Make.dep
  90. endif
  91. $(Q) touch $@
  92. depend: .depend
  93. $(DUMMY_KCONFIG): $(BOARD_KCONFIG)
  94. $(call DELFILE, $(DUMMY_KCONFIG))
  95. $(call COPYFILE, $(BOARD_KCONFIG), $(DUMMY_KCONFIG))
  96. dirlinks: $(DUMMY_KCONFIG)
  97. context: $(DUMMY_KCONFIG)
  98. ifeq ($(BOARD_INSTALLED),y)
  99. $(Q) $(MAKE) -C $(BOARD_DIR) TOPDIR="$(TOPDIR)" context
  100. endif
  101. clean_context:
  102. $(call DELFILE, $(DUMMY_KCONFIG))
  103. clean: clean_context
  104. $(call DELFILE, $(BIN))
  105. $(call CLEAN)
  106. distclean: clean
  107. $(call DELFILE, Make.dep)
  108. $(call DELFILE, .depend)
  109. -include Make.dep