Makefile 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. ############################################################################
  2. # mm/Makefile
  3. #
  4. # Copyright (C) 2007, 2012, 2013-2014 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. # REVISIT: Backslash causes problems in $(COBJS) target
  37. DELIM := $(strip /)
  38. # CFLAGS
  39. ifeq ($(CONFIG_BUILD_PROTECTED),y)
  40. ifeq ($(CONFIG_WINDOWS_NATIVE),y)
  41. KDEFINE = ${shell $(TOPDIR)\tools\define.bat "$(CC)" __KERNEL__}
  42. else
  43. KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__}
  44. endif
  45. endif
  46. # Sources and paths
  47. ASRCS =
  48. CSRCS =
  49. DEPPATH = --dep-path .
  50. VPATH = .
  51. include mm_heap/Make.defs
  52. include umm_heap/Make.defs
  53. include kmm_heap/Make.defs
  54. include mm_gran/Make.defs
  55. include shm/Make.defs
  56. include iob/Make.defs
  57. BINDIR ?= bin
  58. AOBJS = $(patsubst %.S, $(BINDIR)$(DELIM)%$(OBJEXT), $(ASRCS))
  59. COBJS = $(patsubst %.c, $(BINDIR)$(DELIM)%$(OBJEXT), $(CSRCS))
  60. SRCS = $(ASRCS) $(CSRCS)
  61. OBJS = $(AOBJS) $(COBJS)
  62. UBIN = libumm$(LIBEXT)
  63. KBIN = libkmm$(LIBEXT)
  64. BIN ?= libmm$(LIBEXT)
  65. all: $(BIN)
  66. .PHONY: clean distclean
  67. $(AOBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.S
  68. $(call ASSEMBLE, $<, $@)
  69. $(call MOVEOBJ,$(patsubst $(BINDIR)$(DELIM)%$(OBJEXT),%,$@),$(BINDIR))
  70. $(COBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.c
  71. $(call COMPILE, $<, $@)
  72. $(call MOVEOBJ,$(patsubst $(BINDIR)$(DELIM)%$(OBJEXT),%,$@),$(BINDIR))
  73. # Memory manager for the flat build
  74. $(BIN): $(OBJS)
  75. $(call ARCHIVE, $@, $(OBJS))
  76. # Memory manager for the user phase of the two-pass kernel build
  77. ifneq ($(BIN),$(UBIN))
  78. $(UBIN):
  79. $(Q) $(MAKE) $(UBIN) BIN=$(UBIN) BINDIR=ubin TOPDIR=$(TOPDIR) EXTRADEFINES=$(EXTRADEFINES)
  80. endif
  81. # Memory manager for the kernel phase of the two-pass kernel build
  82. ifneq ($(BIN),$(KBIN))
  83. $(KBIN):
  84. $(Q) $(MAKE) $(KBIN) BIN=$(KBIN) BINDIR=kbin TOPDIR=$(TOPDIR) EXTRADEFINES=$(EXTRADEFINES)
  85. endif
  86. # Dependencies
  87. .depend: Makefile $(SRCS)
  88. ifeq ($(CONFIG_BUILD_PROTECTED),y)
  89. $(Q) $(MKDEP) --obj-path ubin --obj-suffix $(OBJEXT) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make_ubin.dep
  90. $(Q) $(MKDEP) --obj-path kbin --obj-suffix $(OBJEXT) $(DEPPATH) "$(CC)" -- $(CFLAGS) $(KDEFINE) -- $(SRCS) >Make_kbin.dep
  91. else
  92. $(Q) $(MKDEP) --obj-path bin --obj-suffix $(OBJEXT) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make_bin.dep
  93. endif
  94. $(Q) touch $@
  95. depend: .depend
  96. # Clean most derived files, retaining the configuration
  97. clean:
  98. $(Q) $(MAKE) -C bin clean TOPDIR=$(TOPDIR)
  99. $(Q) $(MAKE) -C ubin clean TOPDIR=$(TOPDIR)
  100. $(Q) $(MAKE) -C kbin clean TOPDIR=$(TOPDIR)
  101. $(call DELFILE, $(BIN))
  102. $(call DELFILE, $(UBIN))
  103. $(call DELFILE, $(KBIN))
  104. $(call CLEAN)
  105. # Deep clean -- removes all traces of the configuration
  106. distclean: clean
  107. $(Q) $(MAKE) -C bin distclean TOPDIR=$(TOPDIR)
  108. $(Q) $(MAKE) -C ubin distclean TOPDIR=$(TOPDIR)
  109. $(Q) $(MAKE) -C kbin distclean TOPDIR=$(TOPDIR)
  110. $(call DELFILE, Make_bin.dep)
  111. $(call DELFILE, Make_ubin.dep)
  112. $(call DELFILE, Make_kbin.dep)
  113. $(call DELFILE, .depend)
  114. -include Make_bin.dep
  115. -include Make_ubin.dep
  116. -include Make_kbin.dep