Makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. #
  2. # (C) Copyright 2000, 2001
  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. TOOLSUBDIRS+= gdb
  59. HOST_CFLAGS = -traditional-cpp -Wall
  60. HOST_LDFLAGS =-multiply_defined suppress
  61. HOST_ENVIRO_CFLAGS = -traditional-cpp
  62. else
  63. #
  64. # The gdb tools won't build natively on NetBSD since bfd.h (and ansidecl.h)
  65. # are not installed -- just skip them, they are not really essential.
  66. #
  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. TOOLSUBDIRS+= gdb
  76. HOST_CFLAGS = -Wall -pedantic
  77. HOST_LDFLAGS =
  78. HOST_ENVIRO_CFLAGS =
  79. endif
  80. endif
  81. #
  82. # Cygwin needs .exe files :-(
  83. #
  84. ifeq ($(HOSTOS),cygwin)
  85. SFX = .exe
  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. gen_eth_addr$(SFX): gen_eth_addr.o
  113. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  114. $(STRIP) $@
  115. bmp_logo$(SFX): bmp_logo.o
  116. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  117. $(STRIP) $@
  118. inca-swap-bytes$(SFX): inca-swap-bytes.o
  119. $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
  120. $(STRIP) $@
  121. envcrc.o: envcrc.c
  122. $(CC) -g $(CFLAGS) -c $<
  123. crc32.o: crc32.c
  124. $(CC) -g $(CFLAGS) -c $<
  125. mkimage.o: mkimage.c
  126. $(CC) -g $(CFLAGS) -c $<
  127. gen_eth_addr.o: gen_eth_addr.c
  128. $(CC) -g $(CFLAGS) -c $<
  129. inca-swap-bytes.o: inca-swap-bytes.c
  130. $(CC) -g $(CFLAGS) -c $<
  131. subdirs:
  132. @for dir in $(TOOLSUBDIRS) ; do \
  133. $(MAKE) \
  134. HOSTOS=$(HOSTOS) \
  135. HOSTARCH=$(HOSTARCH) \
  136. HOST_CFLAGS="$(HOST_CFLAGS)" \
  137. HOST_LDFLAGS="$(HOST_LDFLAGS)" \
  138. -C $$dir || exit 1 ; \
  139. done
  140. environment.c:
  141. ln -s ../common/environment.c environment.c
  142. environment.o: environment.c
  143. $(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c $<
  144. crc32.c:
  145. ln -s ../lib_generic/crc32.c crc32.c
  146. $(LOGO_H): bmp_logo $(LOGO_BMP)
  147. ./bmp_logo $(LOGO_BMP) >$@
  148. #########################################################################
  149. .depend: Makefile $(OBJS:.o=.c)
  150. $(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) $(OBJS:.o=.c) > $@
  151. sinclude .depend
  152. #########################################################################