config.mk 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. #
  25. # When cross-compiling on NetBSD, we have to define __PPC__ or else we
  26. # will pick up a va_list declaration that is incompatible with the
  27. # actual argument lists emitted by the compiler.
  28. #
  29. # [Tested on NetBSD/i386 1.5 + cross-powerpc-netbsd-1.3]
  30. ifeq ($(ARCH),ppc)
  31. ifeq ($(CROSS_COMPILE),powerpc-netbsd-)
  32. PLATFORM_CPPFLAGS+= -D__PPC__
  33. endif
  34. ifeq ($(CROSS_COMPILE),powerpc-openbsd-)
  35. PLATFORM_CPPFLAGS+= -D__PPC__
  36. endif
  37. endif
  38. ifeq ($(ARCH),arm)
  39. ifeq ($(CROSS_COMPILE),powerpc-netbsd-)
  40. PLATFORM_CPPFLAGS+= -D__ARM__
  41. endif
  42. ifeq ($(CROSS_COMPILE),powerpc-openbsd-)
  43. PLATFORM_CPPFLAGS+= -D__ARM__
  44. endif
  45. endif
  46. ifdef ARCH
  47. sinclude $(TOPDIR)/$(ARCH)_config.mk # include architecture dependend rules
  48. endif
  49. ifdef CPU
  50. sinclude $(TOPDIR)/cpu/$(CPU)/config.mk # include CPU specific rules
  51. endif
  52. ifdef VENDOR
  53. BOARDDIR = $(VENDOR)/$(BOARD)
  54. else
  55. BOARDDIR = $(BOARD)
  56. endif
  57. ifdef BOARD
  58. sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk # include board specific rules
  59. endif
  60. #########################################################################
  61. CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
  62. else if [ -x /bin/bash ]; then echo /bin/bash; \
  63. else echo sh; fi ; fi)
  64. ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
  65. HOSTCC = cc
  66. else
  67. HOSTCC = gcc
  68. endif
  69. HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
  70. HOSTSTRIP = strip
  71. #########################################################################
  72. #
  73. # Include the make variables (CC, etc...)
  74. #
  75. AS = $(CROSS_COMPILE)as
  76. LD = $(CROSS_COMPILE)ld
  77. CC = $(CROSS_COMPILE)gcc
  78. CPP = $(CC) -E
  79. AR = $(CROSS_COMPILE)ar
  80. NM = $(CROSS_COMPILE)nm
  81. STRIP = $(CROSS_COMPILE)strip
  82. OBJCOPY = $(CROSS_COMPILE)objcopy
  83. OBJDUMP = $(CROSS_COMPILE)objdump
  84. RANLIB = $(CROSS_COMPILE)RANLIB
  85. RELFLAGS= $(PLATFORM_RELFLAGS)
  86. DBGFLAGS= -g #-DDEBUG
  87. OPTFLAGS= -Os #-fomit-frame-pointer
  88. #LDSCRIPT := board/$(BOARDDIR)/u-boot.lds.debug
  89. LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
  90. OBJCFLAGS := --gap-fill=0xff
  91. CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \
  92. -D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE) \
  93. -I$(TOPDIR)/include \
  94. -fno-builtin \
  95. -pipe $(PLATFORM_CPPFLAGS)
  96. ifdef BUILD_TAG
  97. CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \
  98. -DBUILD_TAG='"$(BUILD_TAG)"'
  99. else
  100. CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes
  101. endif
  102. AFLAGS_DEBUG := -Wa,-gstabs
  103. AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
  104. LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)
  105. # Location of a usable BFD library, where we define "usable" as
  106. # "built for ${HOST}, supports ${TARGET}". Sensible values are
  107. # - When cross-compiling: the root of the cross-environment
  108. # - Linux/ppc (native): /usr
  109. # - NetBSD/ppc (native): you lose ... (must extract these from the
  110. # binutils build directory, plus the native and U-Boot include
  111. # files don't like each other)
  112. #
  113. # So far, this is used only by tools/gdb/Makefile.
  114. ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
  115. BFD_ROOT_DIR = /usr/local/tools
  116. else
  117. #BFD_ROOT_DIR = /LinuxPPC/CDK # Linux/i386
  118. #BFD_ROOT_DIR = /usr/pkg/cross # NetBSD/i386
  119. #BFD_ROOT_DIR = /usr # native
  120. BFD_ROOT_DIR = /opt/powerpc
  121. endif
  122. #########################################################################
  123. export CONFIG_SHELL HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \
  124. AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP \
  125. MAKE
  126. export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
  127. #########################################################################
  128. %.s: %.S
  129. $(CPP) $(AFLAGS) -o $@ $(CURDIR)/$<
  130. %.o: %.S
  131. $(CC) $(AFLAGS) -c -o $@ $(CURDIR)/$<
  132. %.o: %.c
  133. $(CC) $(CFLAGS) -c -o $@ $<
  134. #########################################################################