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