Makefile 6.9 KB

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