config.mk 5.6 KB

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