Makefile 4.4 KB

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