config.mk 5.0 KB

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