Makefile 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. HOSTCFLAGS = -Wall
  37. HOST_LDFLAGS =
  38. ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
  39. HOSTCFLAGS += -traditional-cpp
  40. HOST_LDFLAGS += -multiply_defined suppress
  41. else
  42. HOSTCFLAGS += -pedantic
  43. endif
  44. ifeq ($(HOSTOS),cygwin)
  45. HOSTCFLAGS += -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_LCD_LOGO) += bmp_logo$(SFX)
  62. BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(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_CMD_NET) += gen_eth_addr$(SFX)
  72. BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
  73. BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX)
  74. BIN_FILES-y += mkimage$(SFX)
  75. BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
  76. BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
  77. # Source files which exist outside the tools directory
  78. EXT_OBJ_FILES-y += common/env_embedded.o
  79. EXT_OBJ_FILES-y += common/image.o
  80. EXT_OBJ_FILES-y += lib_generic/crc32.o
  81. EXT_OBJ_FILES-y += lib_generic/md5.o
  82. EXT_OBJ_FILES-y += lib_generic/sha1.o
  83. # Source files located in the tools directory
  84. OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
  85. OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
  86. OBJ_FILES-y += default_image.o
  87. OBJ_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc.o
  88. OBJ_FILES-y += fit_image.o
  89. OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
  90. OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
  91. OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
  92. OBJ_FILES-y += mkimage.o
  93. OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
  94. OBJ_FILES-y += os_support.o
  95. OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
  96. # Don't build by default
  97. #ifeq ($(ARCH),ppc)
  98. #BIN_FILES-y += mpc86x_clk$(SFX)
  99. #OBJ_FILES-y += mpc86x_clk.o
  100. #endif
  101. # Flattened device tree objects
  102. LIBFDT_OBJ_FILES-y += fdt.o
  103. LIBFDT_OBJ_FILES-y += fdt_ro.o
  104. LIBFDT_OBJ_FILES-y += fdt_rw.o
  105. LIBFDT_OBJ_FILES-y += fdt_strerror.o
  106. LIBFDT_OBJ_FILES-y += fdt_wip.o
  107. # Generated LCD/video logo
  108. LOGO_H = $(OBJTREE)/include/bmp_logo.h
  109. LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
  110. LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
  111. ifeq ($(LOGO_BMP),)
  112. LOGO_BMP= logos/denx.bmp
  113. endif
  114. ifeq ($(VENDOR),atmel)
  115. LOGO_BMP= logos/atmel.bmp
  116. endif
  117. ifeq ($(VENDOR),ronetix)
  118. LOGO_BMP= logos/ronetix.bmp
  119. endif
  120. # now $(obj) is defined
  121. SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
  122. SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
  123. SRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
  124. BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y)))
  125. LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
  126. #
  127. # Use native tools and options
  128. # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
  129. #
  130. CPPFLAGS = -idirafter $(SRCTREE)/include \
  131. -idirafter $(OBJTREE)/include2 \
  132. -idirafter $(OBJTREE)/include \
  133. -I $(SRCTREE)/libfdt \
  134. -I $(SRCTREE)/tools \
  135. -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC \
  136. -D__KERNEL_STRICT_NAMES
  137. CFLAGS = $(HOSTCFLAGS) $(CPPFLAGS) -O
  138. # No -pedantic switch to avoid libfdt compilation warnings
  139. FIT_CFLAGS = -Wall $(CPPFLAGS) -O
  140. AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
  141. CC = $(HOSTCC)
  142. STRIP = $(HOSTSTRIP)
  143. MAKEDEPEND = makedepend
  144. all: $(obj).depend $(BINS) $(LOGO-y) subdirs
  145. $(obj)bin2header$(SFX): $(obj)bin2header.o
  146. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  147. $(STRIP) $@
  148. $(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
  149. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  150. $(STRIP) $@
  151. $(obj)envcrc$(SFX): $(obj)crc32.o $(obj)env_embedded.o $(obj)envcrc.o $(obj)sha1.o
  152. $(CC) $(CFLAGS) -o $@ $^
  153. $(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
  154. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  155. $(STRIP) $@
  156. $(obj)img2srec$(SFX): $(obj)img2srec.o
  157. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  158. $(STRIP) $@
  159. $(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
  160. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  161. $(STRIP) $@
  162. $(obj)mkimage$(SFX): $(obj)crc32.o \
  163. $(obj)default_image.o \
  164. $(obj)fit_image.o \
  165. $(obj)image.o \
  166. $(obj)md5.o \
  167. $(obj)mkimage.o \
  168. $(obj)os_support.o \
  169. $(obj)sha1.o \
  170. $(LIBFDT_OBJS)
  171. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  172. $(STRIP) $@
  173. $(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
  174. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  175. $(STRIP) $@
  176. $(obj)ncb$(SFX): $(obj)ncb.o
  177. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  178. $(STRIP) $@
  179. $(obj)ubsha1$(SFX): $(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o
  180. $(CC) $(CFLAGS) -o $@ $^
  181. # Some files complain if compiled with -pedantic, use FIT_CFLAGS
  182. $(obj)default_image.o: $(SRCTREE)/tools/default_image.c
  183. $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
  184. $(obj)fit_image.o: $(SRCTREE)/tools/fit_image.c
  185. $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
  186. $(obj)image.o: $(SRCTREE)/common/image.c
  187. $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
  188. $(obj)mkimage.o: $(SRCTREE)/tools/mkimage.c
  189. $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
  190. $(obj)os_support.o: $(SRCTREE)/tools/os_support.c
  191. $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
  192. # Some of the tool objects need to be accessed from outside the tools directory
  193. $(obj)%.o: $(SRCTREE)/common/%.c
  194. $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
  195. $(obj)%.o: $(SRCTREE)/lib_generic/%.c
  196. $(CC) -g $(CFLAGS) -c -o $@ $<
  197. $(LIBFDT_OBJS):
  198. $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
  199. subdirs:
  200. ifeq ($(TOOLSUBDIRS),)
  201. @:
  202. else
  203. @for dir in $(TOOLSUBDIRS) ; do \
  204. $(MAKE) \
  205. HOSTOS=$(HOSTOS) \
  206. HOSTARCH=$(HOSTARCH) \
  207. HOSTCFLAGS="$(HOSTCFLAGS)" \
  208. HOST_LDFLAGS="$(HOST_LDFLAGS)" \
  209. -C $$dir || exit 1 ; \
  210. done
  211. endif
  212. $(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
  213. $(obj)./bmp_logo $(LOGO_BMP) >$@
  214. #########################################################################
  215. # defines $(obj).depend target
  216. include $(SRCTREE)/rules.mk
  217. sinclude $(obj).depend
  218. #########################################################################