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