Makefile 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. TOOLSUBDIRS =
  24. #
  25. # Mac OS X / Darwin's C preprocessor is Apple specific. It
  26. # generates numerous errors and warnings. We want to bypass it
  27. # and use GNU C's cpp. To do this we pass the -traditional-cpp
  28. # option to the compiler. Note that the -traditional-cpp flag
  29. # DOES NOT have the same semantics as GNU C's flag, all it does
  30. # is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
  31. #
  32. # Apple's linker is similar, thanks to the new 2 stage linking
  33. # multiple symbol definitions are treated as errors, hence the
  34. # -multiply_defined suppress option to turn off this error.
  35. #
  36. HOST_CFLAGS = -Wall
  37. HOST_LDFLAGS =
  38. ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
  39. HOST_CFLAGS += -traditional-cpp
  40. HOST_LDFLAGS += -multiply_defined suppress
  41. else
  42. HOST_CFLAGS += -pedantic
  43. endif
  44. ifeq ($(HOSTOS),cygwin)
  45. HOST_CFLAGS += -ansi
  46. endif
  47. #
  48. # toolchains targeting win32 generate .exe files
  49. #
  50. ifneq (,$(findstring WIN32 ,$(shell $(HOSTCC) -E -dM -xc /dev/null)))
  51. SFX = .exe
  52. else
  53. SFX =
  54. endif
  55. #
  56. # Include this after HOSTOS HOSTARCH check
  57. # so that we can act intelligently.
  58. #
  59. include $(TOPDIR)/config.mk
  60. # Generated executable files
  61. BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
  62. BIN_FILES-y += mkimage$(SFX)
  63. BIN_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc$(SFX)
  64. BIN_FILES-$(CONFIG_ENV_IS_IN_DATAFLASH) += envcrc$(SFX)
  65. BIN_FILES-$(CONFIG_ENV_IS_IN_EEPROM) += envcrc$(SFX)
  66. BIN_FILES-$(CONFIG_ENV_IS_IN_FLASH) += envcrc$(SFX)
  67. BIN_FILES-$(CONFIG_ENV_IS_IN_ONENAND) += envcrc$(SFX)
  68. BIN_FILES-$(CONFIG_ENV_IS_IN_NAND) += envcrc$(SFX)
  69. BIN_FILES-$(CONFIG_ENV_IS_IN_NVRAM) += envcrc$(SFX)
  70. BIN_FILES-$(CONFIG_ENV_IS_IN_SPI_FLASH) += envcrc$(SFX)
  71. BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
  72. BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
  73. BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
  74. BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
  75. BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX)
  76. BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
  77. # Source files which exist outside the tools directory
  78. EXT_OBJ_FILES-y += common/env_embedded.o
  79. EXT_OBJ_FILES-y += lib_generic/crc32.o
  80. EXT_OBJ_FILES-y += lib_generic/md5.o
  81. EXT_OBJ_FILES-y += lib_generic/sha1.o
  82. EXT_OBJ_FILES-y += common/image.o
  83. # Source files located in the tools directory
  84. OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
  85. OBJ_FILES-y += mkimage.o
  86. OBJ_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc.o
  87. OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
  88. OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
  89. OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
  90. OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
  91. OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
  92. OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
  93. OBJ_FILES-y += os_support.o
  94. # Don't build by default
  95. #ifeq ($(ARCH),ppc)
  96. #BIN_FILES-y += mpc86x_clk$(SFX)
  97. #OBJ_FILES-y += mpc86x_clk.o
  98. #endif
  99. # Flattened device tree objects
  100. LIBFDT_OBJ_FILES-y += fdt.o
  101. LIBFDT_OBJ_FILES-y += fdt_ro.o
  102. LIBFDT_OBJ_FILES-y += fdt_rw.o
  103. LIBFDT_OBJ_FILES-y += fdt_strerror.o
  104. LIBFDT_OBJ_FILES-y += fdt_wip.o
  105. # Generated LCD/video logo
  106. LOGO_H = $(OBJTREE)/include/bmp_logo.h
  107. LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
  108. LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
  109. ifeq ($(LOGO_BMP),)
  110. LOGO_BMP= logos/denx.bmp
  111. endif
  112. ifeq ($(VENDOR),atmel)
  113. LOGO_BMP= logos/atmel.bmp
  114. endif
  115. ifeq ($(VENDOR),ronetix)
  116. LOGO_BMP= logos/ronetix.bmp
  117. endif
  118. # now $(obj) is defined
  119. SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
  120. SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
  121. SRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
  122. BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y)))
  123. LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
  124. #
  125. # Use native tools and options
  126. # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
  127. #
  128. CPPFLAGS = -idirafter $(SRCTREE)/include \
  129. -idirafter $(OBJTREE)/include2 \
  130. -idirafter $(OBJTREE)/include \
  131. -I $(SRCTREE)/libfdt \
  132. -I $(SRCTREE)/tools \
  133. -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC \
  134. -D__KERNEL_STRICT_NAMES
  135. CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
  136. # No -pedantic switch to avoid libfdt compilation warnings
  137. FIT_CFLAGS = -Wall $(CPPFLAGS) -O
  138. AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
  139. CC = $(HOSTCC)
  140. STRIP = $(HOSTSTRIP)
  141. MAKEDEPEND = makedepend
  142. all: $(obj).depend $(BINS) $(LOGO-y) subdirs
  143. $(obj)envcrc$(SFX): $(obj)envcrc.o $(obj)crc32.o $(obj)env_embedded.o $(obj)sha1.o
  144. $(CC) $(CFLAGS) -o $@ $^
  145. $(obj)ubsha1$(SFX): $(obj)ubsha1.o $(obj)sha1.o $(obj)os_support.o
  146. $(CC) $(CFLAGS) -o $@ $^
  147. $(obj)img2srec$(SFX): $(obj)img2srec.o
  148. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  149. $(STRIP) $@
  150. $(obj)mkimage$(SFX): $(obj)mkimage.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \
  151. $(obj)sha1.o $(LIBFDT_OBJS) $(obj)os_support.o
  152. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  153. $(STRIP) $@
  154. $(obj)ncb$(SFX): $(obj)ncb.o
  155. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  156. $(STRIP) $@
  157. $(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
  158. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  159. $(STRIP) $@
  160. $(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
  161. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  162. $(STRIP) $@
  163. $(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
  164. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  165. $(STRIP) $@
  166. $(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
  167. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  168. $(STRIP) $@
  169. $(obj)bin2header$(SFX): $(obj)bin2header.o
  170. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  171. $(STRIP) $@
  172. # Some files complain if compiled with -pedantic, use FIT_CFLAGS
  173. $(obj)image.o: $(SRCTREE)/common/image.c
  174. $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
  175. $(obj)mkimage.o: $(SRCTREE)/tools/mkimage.c
  176. $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
  177. $(obj)os_support.o: $(SRCTREE)/tools/os_support.c
  178. $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
  179. # Some of the tool objects need to be accessed from outside the tools directory
  180. $(obj)%.o: $(SRCTREE)/common/%.c
  181. $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
  182. $(obj)%.o: $(SRCTREE)/lib_generic/%.c
  183. $(CC) -g $(CFLAGS) -c -o $@ $<
  184. $(LIBFDT_OBJS):
  185. $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
  186. subdirs:
  187. ifeq ($(TOOLSUBDIRS),)
  188. @:
  189. else
  190. @for dir in $(TOOLSUBDIRS) ; do \
  191. $(MAKE) \
  192. HOSTOS=$(HOSTOS) \
  193. HOSTARCH=$(HOSTARCH) \
  194. HOST_CFLAGS="$(HOST_CFLAGS)" \
  195. HOST_LDFLAGS="$(HOST_LDFLAGS)" \
  196. -C $$dir || exit 1 ; \
  197. done
  198. endif
  199. $(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
  200. $(obj)./bmp_logo $(LOGO_BMP) >$@
  201. #########################################################################
  202. # defines $(obj).depend target
  203. include $(SRCTREE)/rules.mk
  204. sinclude $(obj).depend
  205. #########################################################################