config.mk 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. # When cross-compiling on NetBSD, we have to define __PPC__ or else we
  43. # will pick up a va_list declaration that is incompatible with the
  44. # actual argument lists emitted by the compiler.
  45. #
  46. # [Tested on NetBSD/i386 1.5 + cross-powerpc-netbsd-1.3]
  47. ifeq ($(ARCH),ppc)
  48. ifeq ($(CROSS_COMPILE),powerpc-netbsd-)
  49. PLATFORM_CPPFLAGS+= -D__PPC__
  50. endif
  51. ifeq ($(CROSS_COMPILE),powerpc-openbsd-)
  52. PLATFORM_CPPFLAGS+= -D__PPC__
  53. endif
  54. endif
  55. ifeq ($(ARCH),arm)
  56. ifeq ($(CROSS_COMPILE),powerpc-netbsd-)
  57. PLATFORM_CPPFLAGS+= -D__ARM__
  58. endif
  59. ifeq ($(CROSS_COMPILE),powerpc-openbsd-)
  60. PLATFORM_CPPFLAGS+= -D__ARM__
  61. endif
  62. endif
  63. ifdef ARCH
  64. sinclude $(TOPDIR)/$(ARCH)_config.mk # include architecture dependend rules
  65. endif
  66. ifdef CPU
  67. sinclude $(TOPDIR)/cpu/$(CPU)/config.mk # include CPU specific rules
  68. endif
  69. ifdef SOC
  70. sinclude $(TOPDIR)/cpu/$(CPU)/$(SOC)/config.mk # include SoC specific rules
  71. endif
  72. ifdef VENDOR
  73. BOARDDIR = $(VENDOR)/$(BOARD)
  74. else
  75. BOARDDIR = $(BOARD)
  76. endif
  77. ifdef BOARD
  78. sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk # include board specific rules
  79. endif
  80. # Load generated board configuration
  81. sinclude $(OBJTREE)/include/autoconf.mk
  82. #########################################################################
  83. CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
  84. else if [ -x /bin/bash ]; then echo /bin/bash; \
  85. else echo sh; fi ; fi)
  86. ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
  87. HOSTCC = cc
  88. else
  89. HOSTCC = gcc
  90. endif
  91. HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
  92. HOSTSTRIP = strip
  93. #########################################################################
  94. #
  95. # Option checker (courtesy linux kernel) to ensure
  96. # only supported compiler options are used
  97. #
  98. cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
  99. > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
  100. #
  101. # Include the make variables (CC, etc...)
  102. #
  103. AS = $(CROSS_COMPILE)as
  104. LD = $(CROSS_COMPILE)ld
  105. CC = $(CROSS_COMPILE)gcc
  106. CPP = $(CC) -E
  107. AR = $(CROSS_COMPILE)ar
  108. NM = $(CROSS_COMPILE)nm
  109. STRIP = $(CROSS_COMPILE)strip
  110. OBJCOPY = $(CROSS_COMPILE)objcopy
  111. OBJDUMP = $(CROSS_COMPILE)objdump
  112. RANLIB = $(CROSS_COMPILE)RANLIB
  113. ifneq (,$(findstring s,$(MAKEFLAGS)))
  114. ARFLAGS = cr
  115. else
  116. ARFLAGS = crv
  117. endif
  118. RELFLAGS= $(PLATFORM_RELFLAGS)
  119. DBGFLAGS= -g # -DDEBUG
  120. OPTFLAGS= -Os #-fomit-frame-pointer
  121. ifndef LDSCRIPT
  122. #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
  123. ifeq ($(CONFIG_NAND_U_BOOT),y)
  124. LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
  125. else
  126. LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
  127. endif
  128. endif
  129. OBJCFLAGS += --gap-fill=0xff
  130. gccincdir := $(shell $(CC) -print-file-name=include)
  131. CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \
  132. -D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE) \
  133. ifneq ($(OBJTREE),$(SRCTREE))
  134. CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include
  135. endif
  136. CPPFLAGS += -I$(TOPDIR)/include
  137. CPPFLAGS += -fno-builtin -ffreestanding -nostdinc \
  138. -isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
  139. ifdef BUILD_TAG
  140. CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \
  141. -DBUILD_TAG='"$(BUILD_TAG)"'
  142. else
  143. CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes
  144. endif
  145. # avoid trigraph warnings while parsing pci.h (produced by NIOS gcc-2.9)
  146. # this option have to be placed behind -Wall -- that's why it is here
  147. ifeq ($(ARCH),nios)
  148. ifeq ($(findstring 2.9,$(shell $(CC) --version)),2.9)
  149. CFLAGS := $(CPPFLAGS) -Wall -Wno-trigraphs
  150. endif
  151. endif
  152. # $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
  153. # option to the assembler.
  154. AFLAGS_DEBUG :=
  155. # turn jbsr into jsr for m68k
  156. ifeq ($(ARCH),m68k)
  157. ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
  158. AFLAGS_DEBUG := -Wa,-gstabs,-S
  159. endif
  160. endif
  161. AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
  162. LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)
  163. # Location of a usable BFD library, where we define "usable" as
  164. # "built for ${HOST}, supports ${TARGET}". Sensible values are
  165. # - When cross-compiling: the root of the cross-environment
  166. # - Linux/ppc (native): /usr
  167. # - NetBSD/ppc (native): you lose ... (must extract these from the
  168. # binutils build directory, plus the native and U-Boot include
  169. # files don't like each other)
  170. #
  171. # So far, this is used only by tools/gdb/Makefile.
  172. ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
  173. BFD_ROOT_DIR = /usr/local/tools
  174. else
  175. ifeq ($(HOSTARCH),$(ARCH))
  176. # native
  177. BFD_ROOT_DIR = /usr
  178. else
  179. #BFD_ROOT_DIR = /LinuxPPC/CDK # Linux/i386
  180. #BFD_ROOT_DIR = /usr/pkg/cross # NetBSD/i386
  181. BFD_ROOT_DIR = /opt/powerpc
  182. endif
  183. endif
  184. ifeq ($(PCI_CLOCK),PCI_66M)
  185. CFLAGS := $(CFLAGS) -DPCI_66M
  186. endif
  187. #########################################################################
  188. export CONFIG_SHELL HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \
  189. AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP \
  190. MAKE
  191. export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
  192. #########################################################################
  193. ifndef REMOTE_BUILD
  194. %.s: %.S
  195. $(CPP) $(AFLAGS) -o $@ $<
  196. %.o: %.S
  197. $(CC) $(AFLAGS) -c -o $@ $<
  198. %.o: %.c
  199. $(CC) $(CFLAGS) -c -o $@ $<
  200. else
  201. $(obj)%.s: %.S
  202. $(CPP) $(AFLAGS) -o $@ $<
  203. $(obj)%.o: %.S
  204. $(CC) $(AFLAGS) -c -o $@ $<
  205. $(obj)%.o: %.c
  206. $(CC) $(CFLAGS) -c -o $@ $<
  207. endif
  208. #########################################################################