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