Makefile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. HOST_CFLAGS += -D__WIN32__
  86. else
  87. SFX =
  88. endif
  89. #
  90. # Include this after HOSTOS HOSTARCH check
  91. # so that we can act intelligently.
  92. #
  93. include $(TOPDIR)/config.mk
  94. #
  95. # Use native tools and options
  96. #
  97. CPPFLAGS = -I../include -I.. -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
  98. CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
  99. AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
  100. CC = $(HOSTCC)
  101. STRIP = $(HOSTSTRIP)
  102. MAKEDEPEND = makedepend
  103. all: .depend $(BINS) $(LOGO_H) subdirs
  104. envcrc$(SFX): envcrc.o crc32.o environment.o
  105. $(CC) $(CFLAGS) -o $@ $^
  106. img2srec$(SFX): img2srec.o
  107. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  108. $(STRIP) $@
  109. mkimage$(SFX): mkimage.o crc32.o
  110. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  111. $(STRIP) $@
  112. ncb$(SFX): ncb.o
  113. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  114. $(STRIP) $@
  115. gen_eth_addr$(SFX): gen_eth_addr.o
  116. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  117. $(STRIP) $@
  118. bmp_logo$(SFX): bmp_logo.o
  119. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  120. $(STRIP) $@
  121. inca-swap-bytes$(SFX): inca-swap-bytes.o
  122. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  123. $(STRIP) $@
  124. mpc86x_clk$(SFX): mpc86x_clk.o
  125. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  126. $(STRIP) $@
  127. envcrc.o: envcrc.c
  128. $(CC) -g $(CFLAGS) -c $<
  129. crc32.o: crc32.c
  130. $(CC) -g $(CFLAGS) -c $<
  131. mkimage.o: mkimage.c
  132. $(CC) -g $(CFLAGS) -c $<
  133. ncb.o: ncb.c
  134. $(CC) -g $(CFLAGS) -c $<
  135. gen_eth_addr.o: gen_eth_addr.c
  136. $(CC) -g $(CFLAGS) -c $<
  137. inca-swap-bytes.o: inca-swap-bytes.c
  138. $(CC) -g $(CFLAGS) -c $<
  139. mpc86x_clk.o: mpc86x_clk.c
  140. $(CC) -g $(CFLAGS) -c $<
  141. subdirs:
  142. ifeq ($(TOOLSUBDIRS),)
  143. @:
  144. else
  145. @for dir in $(TOOLSUBDIRS) ; do \
  146. $(MAKE) \
  147. HOSTOS=$(HOSTOS) \
  148. HOSTARCH=$(HOSTARCH) \
  149. HOST_CFLAGS="$(HOST_CFLAGS)" \
  150. HOST_LDFLAGS="$(HOST_LDFLAGS)" \
  151. -C $$dir || exit 1 ; \
  152. done
  153. endif
  154. environment.c:
  155. @rm -f environment.c
  156. ln -s ../common/environment.c environment.c
  157. environment.o: environment.c
  158. $(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c $<
  159. crc32.c:
  160. @rm -f crc32.c
  161. ln -s ../lib_generic/crc32.c crc32.c
  162. $(LOGO_H): bmp_logo $(LOGO_BMP)
  163. ./bmp_logo $(LOGO_BMP) >$@
  164. #########################################################################
  165. .depend: Makefile $(OBJS:.o=.c)
  166. $(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) $(OBJS:.o=.c) > $@
  167. sinclude .depend
  168. #########################################################################