Makefile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. ############################################################################
  2. # configs/same70-xplainged/kernel/Makefile
  3. #
  4. # Copyright (C) 2015, 2017 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. # This is the directory for the board-specific header files
  37. BOARD_INCLUDE = $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)include
  38. # The entry point name (if none is provided in the .config file)
  39. CONFIG_USER_ENTRYPOINT ?= user_start
  40. ENTRYPT = $(patsubst "%",%,$(CONFIG_USER_ENTRYPOINT))
  41. # Get the paths to the libraries and the links script path in format that
  42. # is appropriate for the host OS
  43. ifeq ($(WINTOOL),y)
  44. # Windows-native toolchains
  45. USER_LIBPATHS = ${shell for path in $(USERLIBS); do dir=`dirname $(TOPDIR)$(DELIM)$$path`;echo "-L\"`cygpath -w $$dir`\"";done}
  46. USER_LDSCRIPT = -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)memory.ld}"
  47. USER_LDSCRIPT += -T "${shell cygpath -w $(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)user-space.ld}"
  48. USER_HEXFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.hex}"
  49. USER_SRECFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.srec}"
  50. USER_BINFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.bin}"
  51. else
  52. # Linux/Cygwin-native toolchain
  53. USER_LIBPATHS = $(addprefix -L$(TOPDIR)$(DELIM),$(dir $(USERLIBS)))
  54. USER_LDSCRIPT = -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)memory.ld
  55. USER_LDSCRIPT += -T$(TOPDIR)$(DELIM)configs$(DELIM)$(CONFIG_ARCH_BOARD)$(DELIM)scripts$(DELIM)user-space.ld
  56. USER_HEXFILE += "$(TOPDIR)$(DELIM)nuttx_user.hex"
  57. USER_SRECFILE += "$(TOPDIR)$(DELIM)nuttx_user.srec"
  58. USER_BINFILE += "$(TOPDIR)$(DELIM)nuttx_user.bin"
  59. endif
  60. USER_LDFLAGS = --undefined=$(ENTRYPT) --entry=$(ENTRYPT) $(USER_LDSCRIPT)
  61. USER_LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(USERLIBS))))
  62. USER_LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}"
  63. # Source files
  64. CSRCS = sam_userspace.c
  65. COBJS = $(CSRCS:.c=$(OBJEXT))
  66. OBJS = $(COBJS)
  67. # Targets:
  68. all: $(TOPDIR)$(DELIM)nuttx_user.elf $(TOPDIR)$(DELIM)User.map
  69. .PHONY: nuttx_user.elf depend clean distclean
  70. $(COBJS): %$(OBJEXT): %.c
  71. $(call COMPILE, $<, $@)
  72. # Create the nuttx_user.elf file containing all of the user-mode code
  73. nuttx_user.elf: $(OBJS)
  74. $(Q) $(LD) -o $@ $(USER_LDFLAGS) $(USER_LIBPATHS) $(OBJS) --start-group $(USER_LDLIBS) --end-group $(USER_LIBGCC)
  75. $(TOPDIR)$(DELIM)nuttx_user.elf: nuttx_user.elf
  76. @echo "LD: nuttx_user.elf"
  77. $(Q) cp -a nuttx_user.elf $(TOPDIR)$(DELIM)nuttx_user.elf
  78. ifeq ($(CONFIG_INTELHEX_BINARY),y)
  79. @echo "CP: nuttx_user.hex"
  80. $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O ihex nuttx_user.elf $(USER_HEXFILE)
  81. endif
  82. ifeq ($(CONFIG_MOTOROLA_SREC),y)
  83. @echo "CP: nuttx_user.srec"
  84. $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O srec nuttx_user.elf $(USER_SRECFILE)
  85. endif
  86. ifeq ($(CONFIG_RAW_BINARY),y)
  87. @echo "CP: nuttx_user.bin"
  88. $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary nuttx_user.elf $(USER_BINFILE)
  89. endif
  90. $(TOPDIR)$(DELIM)User.map: nuttx_user.elf
  91. @echo "MK: User.map"
  92. $(Q) $(NM) nuttx_user.elf >$(TOPDIR)$(DELIM)User.map
  93. $(Q) $(CROSSDEV)size nuttx_user.elf
  94. .depend:
  95. depend: .depend
  96. clean:
  97. $(call DELFILE, nuttx_user.elf)
  98. $(call DELFILE, "$(TOPDIR)$(DELIM)nuttx_user.*")
  99. $(call DELFILE, "$(TOPDIR)$(DELIM)User.map")
  100. $(call CLEAN)
  101. distclean: clean