config.mk 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. #
  2. # (C) Copyright 2000-2006
  3. # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. #
  5. # See file CREDITS for list of people who contributed to this
  6. # project.
  7. #
  8. # This program is free software; you can redistribute it and/or
  9. # modify it under the terms of the GNU General Public License as
  10. # published by the Free Software Foundation; either version 2 of
  11. # the License, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. # MA 02111-1307 USA
  22. #
  23. #########################################################################
  24. ifneq ($(OBJTREE),$(SRCTREE))
  25. ifeq ($(CURDIR),$(SRCTREE))
  26. dir :=
  27. else
  28. dir := $(subst $(SRCTREE)/,,$(CURDIR))
  29. endif
  30. obj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)
  31. src := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)
  32. $(shell mkdir -p $(obj))
  33. else
  34. obj :=
  35. src :=
  36. endif
  37. # clean the slate ...
  38. PLATFORM_RELFLAGS =
  39. PLATFORM_CPPFLAGS =
  40. PLATFORM_LDFLAGS =
  41. #########################################################################
  42. CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
  43. else if [ -x /bin/bash ]; then echo /bin/bash; \
  44. else echo sh; fi ; fi)
  45. ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
  46. HOSTCC = cc
  47. else
  48. HOSTCC = gcc
  49. endif
  50. HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
  51. HOSTSTRIP = strip
  52. #########################################################################
  53. #
  54. # Option checker (courtesy linux kernel) to ensure
  55. # only supported compiler options are used
  56. #
  57. cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
  58. > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
  59. #
  60. # Include the make variables (CC, etc...)
  61. #
  62. AS = $(CROSS_COMPILE)as
  63. LD = $(CROSS_COMPILE)ld
  64. CC = $(CROSS_COMPILE)gcc
  65. CPP = $(CC) -E
  66. AR = $(CROSS_COMPILE)ar
  67. NM = $(CROSS_COMPILE)nm
  68. LDR = $(CROSS_COMPILE)ldr
  69. STRIP = $(CROSS_COMPILE)strip
  70. OBJCOPY = $(CROSS_COMPILE)objcopy
  71. OBJDUMP = $(CROSS_COMPILE)objdump
  72. RANLIB = $(CROSS_COMPILE)RANLIB
  73. #########################################################################
  74. # Load generated board configuration
  75. sinclude $(OBJTREE)/include/autoconf.mk
  76. ifdef ARCH
  77. sinclude $(TOPDIR)/$(ARCH)_config.mk # include architecture dependend rules
  78. endif
  79. ifdef CPU
  80. sinclude $(TOPDIR)/cpu/$(CPU)/config.mk # include CPU specific rules
  81. endif
  82. ifdef SOC
  83. sinclude $(TOPDIR)/cpu/$(CPU)/$(SOC)/config.mk # include SoC specific rules
  84. endif
  85. ifdef VENDOR
  86. BOARDDIR = $(VENDOR)/$(BOARD)
  87. else
  88. BOARDDIR = $(BOARD)
  89. endif
  90. ifdef BOARD
  91. sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk # include board specific rules
  92. endif
  93. #########################################################################
  94. ifneq (,$(findstring s,$(MAKEFLAGS)))
  95. ARFLAGS = cr
  96. else
  97. ARFLAGS = crv
  98. endif
  99. RELFLAGS= $(PLATFORM_RELFLAGS)
  100. DBGFLAGS= -g # -DDEBUG
  101. OPTFLAGS= -Os #-fomit-frame-pointer
  102. ifndef LDSCRIPT
  103. #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
  104. ifeq ($(CONFIG_NAND_U_BOOT),y)
  105. LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
  106. else
  107. LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
  108. endif
  109. endif
  110. OBJCFLAGS += --gap-fill=0xff
  111. gccincdir := $(shell $(CC) -print-file-name=include)
  112. CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \
  113. -D__KERNEL__
  114. ifneq ($(TEXT_BASE),)
  115. CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)
  116. endif
  117. ifneq ($(OBJTREE),$(SRCTREE))
  118. CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include
  119. endif
  120. CPPFLAGS += -I$(TOPDIR)/include
  121. CPPFLAGS += -fno-builtin -ffreestanding -nostdinc \
  122. -isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
  123. ifdef BUILD_TAG
  124. CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \
  125. -DBUILD_TAG='"$(BUILD_TAG)"'
  126. else
  127. CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes
  128. endif
  129. CFLAGS += $(call cc-option,-fno-stack-protector)
  130. # avoid trigraph warnings while parsing pci.h (produced by NIOS gcc-2.9)
  131. # this option have to be placed behind -Wall -- that's why it is here
  132. ifeq ($(ARCH),nios)
  133. ifeq ($(findstring 2.9,$(shell $(CC) --version)),2.9)
  134. CFLAGS := $(CPPFLAGS) -Wall -Wno-trigraphs
  135. endif
  136. endif
  137. # $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
  138. # option to the assembler.
  139. AFLAGS_DEBUG :=
  140. # turn jbsr into jsr for m68k
  141. ifeq ($(ARCH),m68k)
  142. ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
  143. AFLAGS_DEBUG := -Wa,-gstabs,-S
  144. endif
  145. endif
  146. AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
  147. LDFLAGS += -Bstatic -T $(LDSCRIPT) $(PLATFORM_LDFLAGS)
  148. ifneq ($(TEXT_BASE),)
  149. LDFLAGS += -Ttext $(TEXT_BASE)
  150. endif
  151. # Location of a usable BFD library, where we define "usable" as
  152. # "built for ${HOST}, supports ${TARGET}". Sensible values are
  153. # - When cross-compiling: the root of the cross-environment
  154. # - Linux/ppc (native): /usr
  155. # - NetBSD/ppc (native): you lose ... (must extract these from the
  156. # binutils build directory, plus the native and U-Boot include
  157. # files don't like each other)
  158. #
  159. # So far, this is used only by tools/gdb/Makefile.
  160. ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
  161. BFD_ROOT_DIR = /usr/local/tools
  162. else
  163. ifeq ($(HOSTARCH),$(ARCH))
  164. # native
  165. BFD_ROOT_DIR = /usr
  166. else
  167. #BFD_ROOT_DIR = /LinuxPPC/CDK # Linux/i386
  168. #BFD_ROOT_DIR = /usr/pkg/cross # NetBSD/i386
  169. BFD_ROOT_DIR = /opt/powerpc
  170. endif
  171. endif
  172. ifeq ($(PCI_CLOCK),PCI_66M)
  173. CFLAGS := $(CFLAGS) -DPCI_66M
  174. endif
  175. #########################################################################
  176. export CONFIG_SHELL HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \
  177. AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP \
  178. MAKE
  179. export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
  180. #########################################################################
  181. ifndef REMOTE_BUILD
  182. %.s: %.S
  183. $(CPP) $(AFLAGS) -o $@ $<
  184. %.o: %.S
  185. $(CC) $(AFLAGS) -c -o $@ $<
  186. %.o: %.c
  187. $(CC) $(CFLAGS) -c -o $@ $<
  188. else
  189. $(obj)%.s: %.S
  190. $(CPP) $(AFLAGS) -o $@ $<
  191. $(obj)%.o: %.S
  192. $(CC) $(AFLAGS) -c -o $@ $<
  193. $(obj)%.o: %.c
  194. $(CC) $(CFLAGS) -c -o $@ $<
  195. endif
  196. #########################################################################