config.mk 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. ifdef ARCH
  51. sinclude $(TOPDIR)/$(ARCH)_config.mk # include architecture dependend rules
  52. endif
  53. ifdef CPU
  54. sinclude $(TOPDIR)/cpu/$(CPU)/config.mk # include CPU specific rules
  55. endif
  56. ifdef SOC
  57. sinclude $(TOPDIR)/cpu/$(CPU)/$(SOC)/config.mk # include SoC specific rules
  58. endif
  59. ifdef VENDOR
  60. BOARDDIR = $(VENDOR)/$(BOARD)
  61. else
  62. BOARDDIR = $(BOARD)
  63. endif
  64. ifdef BOARD
  65. sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk # include board specific rules
  66. endif
  67. #########################################################################
  68. CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
  69. else if [ -x /bin/bash ]; then echo /bin/bash; \
  70. else echo sh; fi ; fi)
  71. ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
  72. HOSTCC = cc
  73. else
  74. HOSTCC = gcc
  75. endif
  76. HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
  77. HOSTSTRIP = strip
  78. #########################################################################
  79. #
  80. # Include the make variables (CC, etc...)
  81. #
  82. AS = $(CROSS_COMPILE)as
  83. LD = $(CROSS_COMPILE)ld
  84. CC = $(CROSS_COMPILE)gcc
  85. CPP = $(CC) -E
  86. AR = $(CROSS_COMPILE)ar
  87. NM = $(CROSS_COMPILE)nm
  88. STRIP = $(CROSS_COMPILE)strip
  89. OBJCOPY = $(CROSS_COMPILE)objcopy
  90. OBJDUMP = $(CROSS_COMPILE)objdump
  91. RANLIB = $(CROSS_COMPILE)RANLIB
  92. RELFLAGS= $(PLATFORM_RELFLAGS)
  93. DBGFLAGS= -g #-DDEBUG
  94. OPTFLAGS= -Os #-fomit-frame-pointer
  95. ifndef LDSCRIPT
  96. #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
  97. LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
  98. endif
  99. OBJCFLAGS += --gap-fill=0xff
  100. gccincdir := $(shell $(CC) -print-file-name=include)
  101. CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \
  102. -D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE) \
  103. -I$(TOPDIR)/include \
  104. -fno-builtin -ffreestanding -nostdinc -isystem \
  105. $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
  106. ifdef BUILD_TAG
  107. CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \
  108. -DBUILD_TAG='"$(BUILD_TAG)"'
  109. else
  110. CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes
  111. endif
  112. # avoid trigraph warnings while parsing pci.h (produced by NIOS gcc-2.9)
  113. # this option have to be placed behind -Wall -- that's why it is here
  114. ifeq ($(ARCH),nios)
  115. ifeq ($(findstring 2.9,$(shell $(CC) --version)),2.9)
  116. CFLAGS := $(CPPFLAGS) -Wall -Wno-trigraphs
  117. endif
  118. endif
  119. AFLAGS_DEBUG := -Wa,-gstabs
  120. AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
  121. LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)
  122. # Location of a usable BFD library, where we define "usable" as
  123. # "built for ${HOST}, supports ${TARGET}". Sensible values are
  124. # - When cross-compiling: the root of the cross-environment
  125. # - Linux/ppc (native): /usr
  126. # - NetBSD/ppc (native): you lose ... (must extract these from the
  127. # binutils build directory, plus the native and U-Boot include
  128. # files don't like each other)
  129. #
  130. # So far, this is used only by tools/gdb/Makefile.
  131. ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
  132. BFD_ROOT_DIR = /usr/local/tools
  133. else
  134. ifeq ($(HOSTARCH),$(ARCH))
  135. # native
  136. BFD_ROOT_DIR = /usr
  137. else
  138. #BFD_ROOT_DIR = /LinuxPPC/CDK # Linux/i386
  139. #BFD_ROOT_DIR = /usr/pkg/cross # NetBSD/i386
  140. BFD_ROOT_DIR = /opt/powerpc
  141. endif
  142. endif
  143. #########################################################################
  144. export CONFIG_SHELL HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \
  145. AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP \
  146. MAKE
  147. export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
  148. #########################################################################
  149. %.s: %.S
  150. $(CPP) $(AFLAGS) -o $@ $(CURDIR)/$<
  151. %.o: %.S
  152. $(CC) $(AFLAGS) -c -o $@ $(CURDIR)/$<
  153. %.o: %.c
  154. $(CC) $(CFLAGS) -c -o $@ $<
  155. #########################################################################