Makefile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. #
  2. # (C) Copyright 2000-2003
  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. BINS = img2srec$(SFX) mkimage$(SFX) envcrc$(SFX) gen_eth_addr$(SFX) bmp_logo$(SFX)
  24. OBJS = environment.o img2srec.o mkimage.o crc32.o envcrc.o gen_eth_addr.o bmp_logo.o
  25. ifeq ($(ARCH),mips)
  26. BINS += inca-swap-bytes$(SFX)
  27. OBJS += inca-swap-bytes.o
  28. endif
  29. # Don't build by default
  30. #ifeq ($(ARCH),ppc)
  31. #BINS += mpc86x_clk$(SFX)
  32. #OBJS += mpc86x_clk.o
  33. #endif
  34. LOGO_H = $(TOPDIR)/include/bmp_logo.h
  35. ifeq ($(LOGO_BMP),)
  36. LOGO_BMP= logos/denx.bmp
  37. endif
  38. #-------------------------------------------------------------------------
  39. HOSTARCH := $(shell uname -m | \
  40. sed -e s/i.86/i386/ \
  41. -e s/sun4u/sparc64/ \
  42. -e s/arm.*/arm/ \
  43. -e s/sa110/arm/ \
  44. -e s/powerpc/ppc/ \
  45. -e s/Power\ Macintosh/ppc/ \
  46. -e s/macppc/ppc/)
  47. HOSTOS := $(shell uname -s | tr A-Z a-z | \
  48. sed -e 's/\(cygwin\).*/cygwin/')
  49. TOOLSUBDIRS =
  50. #
  51. # Mac OS X / Darwin's C preprocessor is Apple specific. It
  52. # generates numerous errors and warnings. We want to bypass it
  53. # and use GNU C's cpp. To do this we pass the -traditional-cpp
  54. # option to the compiler. Note that the -traditional-cpp flag
  55. # DOES NOT have the same semantics as GNU C's flag, all it does
  56. # is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
  57. #
  58. # Apple's linker is similar, thanks to the new 2 stage linking
  59. # multiple symbol definitions are treated as errors, hence the
  60. # -multiply_defined suppress option to turn off this error.
  61. #
  62. ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
  63. HOST_CFLAGS = -traditional-cpp -Wall
  64. HOST_LDFLAGS =-multiply_defined suppress
  65. HOST_ENVIRO_CFLAGS = -traditional-cpp
  66. else
  67. ifeq ($(HOSTOS)-$(HOSTARCH),netbsd-ppc)
  68. HOST_CFLAGS = -Wall -pedantic
  69. HOST_LDFLAGS =
  70. HOST_ENVIRO_CFLAGS =
  71. #
  72. # Everyone else
  73. #
  74. else
  75. HOST_CFLAGS = -Wall -pedantic
  76. HOST_LDFLAGS =
  77. HOST_ENVIRO_CFLAGS =
  78. endif
  79. endif
  80. #
  81. # Cygwin needs .exe files :-(
  82. #
  83. ifeq ($(HOSTOS),cygwin)
  84. SFX = .exe
  85. else
  86. SFX =
  87. endif
  88. #
  89. # Include this after HOSTOS HOSTARCH check
  90. # so that we can act intelligently.
  91. #
  92. include $(TOPDIR)/config.mk
  93. #
  94. # Use native tools and options
  95. #
  96. CPPFLAGS = -idirafter ../include -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
  97. CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
  98. AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
  99. CC = $(HOSTCC)
  100. STRIP = $(HOSTSTRIP)
  101. MAKEDEPEND = makedepend
  102. all: .depend $(BINS) $(LOGO_H) subdirs
  103. envcrc$(SFX): envcrc.o crc32.o environment.o
  104. $(CC) $(CFLAGS) -o $@ $^
  105. img2srec$(SFX): img2srec.o
  106. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  107. $(STRIP) $@
  108. mkimage$(SFX): mkimage.o crc32.o
  109. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  110. $(STRIP) $@
  111. ncb$(SFX): ncb.o
  112. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  113. $(STRIP) $@
  114. gen_eth_addr$(SFX): gen_eth_addr.o
  115. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  116. $(STRIP) $@
  117. bmp_logo$(SFX): bmp_logo.o
  118. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  119. $(STRIP) $@
  120. inca-swap-bytes$(SFX): inca-swap-bytes.o
  121. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  122. $(STRIP) $@
  123. mpc86x_clk$(SFX): mpc86x_clk.o
  124. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  125. $(STRIP) $@
  126. envcrc.o: envcrc.c
  127. $(CC) -g $(CFLAGS) -c $<
  128. crc32.o: crc32.c
  129. $(CC) -g $(CFLAGS) -c $<
  130. mkimage.o: mkimage.c
  131. $(CC) -g $(CFLAGS) -c $<
  132. ncb.o: ncb.c
  133. $(CC) -g $(CFLAGS) -c $<
  134. gen_eth_addr.o: gen_eth_addr.c
  135. $(CC) -g $(CFLAGS) -c $<
  136. inca-swap-bytes.o: inca-swap-bytes.c
  137. $(CC) -g $(CFLAGS) -c $<
  138. mpc86x_clk.o: mpc86x_clk.c
  139. $(CC) -g $(CFLAGS) -c $<
  140. subdirs:
  141. ifeq ($(TOOLSUBDIRS),)
  142. @:
  143. else
  144. @for dir in $(TOOLSUBDIRS) ; do \
  145. $(MAKE) \
  146. HOSTOS=$(HOSTOS) \
  147. HOSTARCH=$(HOSTARCH) \
  148. HOST_CFLAGS="$(HOST_CFLAGS)" \
  149. HOST_LDFLAGS="$(HOST_LDFLAGS)" \
  150. -C $$dir || exit 1 ; \
  151. done
  152. endif
  153. environment.c:
  154. @rm -f environment.c
  155. ln -s ../common/environment.c environment.c
  156. environment.o: environment.c
  157. $(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c $<
  158. crc32.c:
  159. @rm -f crc32.c
  160. ln -s ../lib_generic/crc32.c crc32.c
  161. $(LOGO_H): bmp_logo $(LOGO_BMP)
  162. ./bmp_logo $(LOGO_BMP) >$@
  163. #########################################################################
  164. .depend: Makefile $(OBJS:.o=.c)
  165. $(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) $(OBJS:.o=.c) > $@
  166. sinclude .depend
  167. #########################################################################