wdenk | efee170 | 2002-07-20 20:14:13 +0000 | [diff] [blame^] | 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 | |
| 24 | BINS = img2srec$(SFX) mkimage$(SFX) envcrc$(SFX) gen_eth_addr$(SFX) bmp_logo$(SFX) |
| 25 | |
| 26 | OBJS = environment.o img2srec.o mkimage.o crc32.o envcrc.o gen_eth_addr.o bmp_logo.o |
| 27 | |
| 28 | LOGO_H = $(TOPDIR)/include/bmp_logo.h |
| 29 | |
| 30 | ifeq ($(LOGO_BMP),) |
| 31 | LOGO_BMP= logos/denx.bmp |
| 32 | endif |
| 33 | |
| 34 | #------------------------------------------------------------------------- |
| 35 | |
| 36 | HOSTARCH := $(shell uname -m | \ |
| 37 | sed -e s/i.86/i386/ \ |
| 38 | -e s/sun4u/sparc64/ \ |
| 39 | -e s/arm.*/arm/ \ |
| 40 | -e s/sa110/arm/ \ |
| 41 | -e s/powerpc/ppc/ \ |
| 42 | -e s/Power\ Macintosh/ppc/ \ |
| 43 | -e s/macppc/ppc/) |
| 44 | |
| 45 | HOSTOS := $(shell uname -s | tr A-Z a-z | \ |
| 46 | sed -e 's/\(cygwin\).*/cygwin/') |
| 47 | |
| 48 | TOOLSUBDIRS = |
| 49 | |
| 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 | TOOLSUBDIRS+= gdb |
| 64 | HOST_CFLAGS = -traditional-cpp -Wall |
| 65 | HOST_LDFLAGS =-multiply_defined suppress |
| 66 | HOST_ENVIRO_CFLAGS = -traditional-cpp |
| 67 | |
| 68 | else |
| 69 | # |
| 70 | # The gdb tools won't build natively on NetBSD since bfd.h (and ansidecl.h) |
| 71 | # are not installed -- just skip them, they are not really essential. |
| 72 | # |
| 73 | ifeq ($(HOSTOS)-$(HOSTARCH),netbsd-ppc) |
| 74 | HOST_CFLAGS = -Wall -pedantic |
| 75 | HOST_LDFLAGS = |
| 76 | HOST_ENVIRO_CFLAGS = |
| 77 | |
| 78 | # |
| 79 | # Everyone else |
| 80 | # |
| 81 | else |
| 82 | TOOLSUBDIRS+= gdb |
| 83 | HOST_CFLAGS = -Wall -pedantic |
| 84 | HOST_LDFLAGS = |
| 85 | HOST_ENVIRO_CFLAGS = |
| 86 | endif |
| 87 | endif |
| 88 | |
| 89 | # |
| 90 | # Cygwin needs .exe files :-( |
| 91 | # |
| 92 | ifeq ($(HOSTOS),cygwin) |
| 93 | SFX = .exe |
| 94 | else |
| 95 | SFX = |
| 96 | endif |
| 97 | |
| 98 | |
| 99 | # |
| 100 | # Include this after HOSTOS HOSTARCH check |
| 101 | # so that we can act intelligently. |
| 102 | # |
| 103 | include $(TOPDIR)/config.mk |
| 104 | |
| 105 | # |
| 106 | # Use native tools and options |
| 107 | # |
| 108 | CPPFLAGS = -I../include -I.. -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC |
| 109 | CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O |
| 110 | AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS) |
| 111 | CC = $(HOSTCC) |
| 112 | STRIP = $(HOSTSTRIP) |
| 113 | MAKEDEPEND = makedepend |
| 114 | |
| 115 | all: .depend $(BINS) $(LOGO_H) subdirs |
| 116 | |
| 117 | envcrc$(SFX): envcrc.o crc32.o environment.o |
| 118 | $(CC) $(CFLAGS) -o $@ $^ |
| 119 | |
| 120 | img2srec$(SFX): img2srec.o |
| 121 | $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ |
| 122 | $(STRIP) $@ |
| 123 | |
| 124 | mkimage$(SFX): mkimage.o crc32.o |
| 125 | $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ |
| 126 | $(STRIP) $@ |
| 127 | |
| 128 | gen_eth_addr$(SFX): gen_eth_addr.o |
| 129 | $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ |
| 130 | $(STRIP) $@ |
| 131 | |
| 132 | bmp_logo$(SFX): bmp_logo.o |
| 133 | $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ |
| 134 | $(STRIP) $@ |
| 135 | |
| 136 | envcrc.o: envcrc.c |
| 137 | $(CC) -g $(CFLAGS) -c $< |
| 138 | |
| 139 | crc32.o: crc32.c |
| 140 | $(CC) -g $(CFLAGS) -c $< |
| 141 | |
| 142 | mkimage.o: mkimage.c |
| 143 | $(CC) -g $(CFLAGS) -c $< |
| 144 | |
| 145 | gen_eth_addr.o: gen_eth_addr.c |
| 146 | $(CC) -g $(CFLAGS) -c $< |
| 147 | |
| 148 | subdirs: |
| 149 | @for dir in $(TOOLSUBDIRS) ; do \ |
| 150 | $(MAKE) \ |
| 151 | HOSTOS=$(HOSTOS) \ |
| 152 | HOSTARCH=$(HOSTARCH) \ |
| 153 | HOST_CFLAGS="$(HOST_CFLAGS)" \ |
| 154 | HOST_LDFLAGS="$(HOST_LDFLAGS)" \ |
| 155 | -C $$dir || exit 1 ; \ |
| 156 | done |
| 157 | environment.c: |
| 158 | ln -s ../common/environment.c environment.c |
| 159 | |
| 160 | environment.o: environment.c |
| 161 | $(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c $< |
| 162 | |
| 163 | crc32.c: |
| 164 | ln -s ../lib_generic/crc32.c crc32.c |
| 165 | |
| 166 | $(LOGO_H): bmp_logo $(LOGO_BMP) |
| 167 | ./bmp_logo $(LOGO_BMP) >$@ |
| 168 | |
| 169 | ######################################################################### |
| 170 | |
| 171 | .depend: Makefile $(OBJS:.o=.c) |
| 172 | $(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) $(OBJS:.o=.c) > $@ |
| 173 | |
| 174 | sinclude .depend |
| 175 | |
| 176 | ######################################################################### |
| 177 | |