Adding debian version 3.70~pre8+dfsg-1.
[syslinux-debian/hramrach.git] / gpxe / contrib / baremetal / Makefile
blobdf4de762e2f80f4b124b40f9f86d941e00d9cc6d
2 # Makefile for Etherboot
4 # Most of the time you should edit Config
6 # Common options:
7 # VERSION=v - Set the version string
9 # NS8390 options:
10 # -DINCLUDE_NE - Include NE1000/NE2000 support
11 # -DNE_SCAN=list - Probe for NE base address using list of
12 # comma separated hex addresses
13 # -DINCLUDE_3C503 - Include 3c503 support
14 # -DT503_SHMEM - Use 3c503 shared memory mode (off by default)
15 # -DINCLUDE_WD - Include Western Digital/SMC support
16 # -DWD_DEFAULT_MEM- Default memory location for WD/SMC cards
17 # -DCOMPEX_RL2000_FIX
19 # If you have a Compex RL2000 PCI 32-bit (11F6:1401),
20 # and the bootrom hangs in "Probing...[NE*000/PCI]",
21 # try enabling this fix... it worked for me :).
22 # In the first packet write somehow it somehow doesn't
23 # get back the expected data so it is stuck in a loop.
24 # I didn't bother to investigate what or why because it works
25 # when I interrupt the loop if it takes more then COMPEX_RL2000_TRIES.
26 # The code will notify if it does a abort.
27 # SomniOne - somnione@gmx.net
29 # 3C509 option:
30 # -DINCLUDE_3C509 - Include 3c509 support
32 # 3C90X options:
33 # -DINCLUDE_3C90X - Include 3c90x support
34 # -DCFG_3C90X_PRESERVE_XCVR - Reset the transceiver type to the value it
35 # had initially just before the loaded code is started.
36 # -DCFG_3C90X_XCVR - Hardcode the tranceiver type Etherboot uses.
37 # -DCFG_3C90X_BOOTROM_FIX - If you have a 3c905B with buggy ROM
38 # interface, setting this option might "fix" it. Use
39 # with caution and read the docs in 3c90x.txt!
41 # See the documentation file 3c90x.txt for more details.
43 # CS89X0 (optional) options:
44 # -DINCLUDE_CS89X0- Include CS89x0 support
45 # -DCS_SCAN=list - Probe for CS89x0 base address using list of
46 # comma separated hex addresses; increasing the
47 # address by one (0x300 -> 0x301) will force a
48 # more aggressive probing algorithm. This might
49 # be neccessary after a soft-reset of the NIC.
51 # LANCE options:
52 # -DINCLUDE_NE2100- Include NE2100 support
53 # -DINCLUDE_NI6510- Include NI6510 support
55 # SK_G16 options:
56 # -DINCLUDE_SK_G16- Include SK_G16 support
58 # I82586 options:
59 # -DINCLUDE_3C507 - Include 3c507 support
60 # -DINCLUDE_NI5210- Include NI5210 support
61 # -DINCLUDE_EXOS205-Include EXOS205 support
63 # SMC9000 options:
64 # -DINCLUDE_SMC9000 - Include SMC9000 driver
65 # -DSMC9000_SCAN=list - List of I/O addresses to probe
67 # TIARA (Fujitsu Etherstar) options:
68 # -DINCLUDE_TIARA - Include Tiara support
70 # NI5010 options:
71 # -DINCLUDE_NI5010 - Include NI5010 support
73 # TULIP options:
74 # -DINCLUDE_TULIP - Include Tulip support
75 # -DUSE_INTERNAL_BUFFER - receuve and transmit buffers within program
76 # space, not below 0x10000, in case that region is used
78 # RTL8139 options:
79 # -DINCLUDE_RTL8139 - Include RTL8139 support
80 # -DUSE_INTERNAL_BUFFER - 8 kB receive buffer within program space,
81 # not at 0x10000 - 8kB, in case that region is used
84 include Config
86 GCC= gcc
87 CPP= gcc -E
88 VERSION= 4.6.12
89 CFLAGS16+= -DVERSION=\"$(VERSION)\" -DRELOC=$(RELOCADDR)
90 CFLAGS32+= -DVERSION=\"$(VERSION)\" -DRELOC=$(RELOCADDR) $(OLDGAS)
91 LCONFIG+= -DRELOC=$(RELOCADDR)
93 IDENT16= 'Etherboot/16 $(VERSION) (GPL) $(@F)'
94 IDENT32= 'Etherboot/32 $(VERSION) (GPL) $(@F)'
96 # Find out if we're using binutils 2.9.1 which uses a different syntax in some
97 # places (most prominently in the opcode prefix area).
98 OLDGAS:= $(shell $(AS) --version | grep -q '2\.9\.1' && echo -DGAS291)
100 # Check the requested type of build (32, 16 or both families)
101 ifeq ($(ETHERBOOT),16)
102 BUILD_LIBS= $(BLIB16)
103 BUILD_BINS= $(BINS16)
104 endif
105 ifeq ($(ETHERBOOT),32)
106 BUILD_LIBS= $(BLIB32)
107 BUILD_BINS= $(BINS32)
108 endif
109 ifeq ($(ETHERBOOT),both)
110 BUILD_LIBS= $(BLIB16) $(BLIB32)
111 BUILD_BINS= $(BINS16) $(BINS32)
112 endif
114 3C503FLAGS= -DINCLUDE_3C503 # -DT503_SHMEM
115 # Note that the suffix to MAKEROM_ is the (mixed case) basename of the ROM file
116 MAKEROM_3c503= -3
117 3C507FLAGS= -DINCLUDE_3C507
118 3C509FLAGS= -DINCLUDE_3C509
119 3C529FLAGS= -DINCLUDE_3C529
120 3C595FLAGS= -DINCLUDE_3C595
121 3C90XFLAGS= -DINCLUDE_3C90X
122 CS89X0FLAGS= -DINCLUDE_CS89X0
123 EEPROFLAGS= -DINCLUDE_EEPRO
124 EEPRO100FLAGS= -DINCLUDE_EEPRO100
125 EPIC100FLAGS= -DINCLUDE_EPIC100
126 EXOS205FLAGS= -DINCLUDE_EXOS205
127 LANCEFLAGS= -DINCLUDE_LANCE # Lance/PCI!
128 NE2100FLAGS= -DINCLUDE_NE2100
129 NEFLAGS= -DINCLUDE_NE -DNE_SCAN=0x300,0x280,0x320,0x340,0x380
130 NS8390FLAGS= -DINCLUDE_NS8390 # NE2000/PCI!
131 NI5010FLAGS= -DINCLUDE_NI5010
132 NI5210FLAGS= -DINCLUDE_NI5210
133 NI6510FLAGS= -DINCLUDE_NI6510
134 RTL8139FLAGS= -DINCLUDE_RTL8139
135 SK_G16FLAGS= -DINCLUDE_SK_G16
136 SMC9000FLAGS= -DINCLUDE_SMC9000
137 TIARAFLAGS= -DINCLUDE_TIARA
138 DEPCAFLAGS= -DINCLUDE_DEPCA # -DDEPCA_MODEL=DEPCA -DDEPCA_RAM_BASE=0xd0000
139 TULIPFLAGS= -DINCLUDE_TULIP
140 OTULIPFLAGS= -DINCLUDE_OTULIP
141 VIA_RHINEFLAGS= -DINCLUDE_VIA_RHINE
142 WDFLAGS= -DINCLUDE_WD -DWD_DEFAULT_MEM=0xCC000
143 W89C840FLAGS= -DINCLUDE_W89C840
145 # If you have not made any changes to the *.S files, AS86 need not be set.
146 # (most people)
147 # If you have made changes to the *.S files and you want to rebuild *loader.bin
148 # and {floppy,com}load.bin and you have as86 from the ELKS Dev86 package (not
149 # the one that normally comes with Linux) (not most people)
150 #AS86= as86
151 # If you have made changes to the *.S files and you want to rebuild *loader.bin
152 # and {floppy,com}load.bin and you have nasm (not most people)
153 #AS86= nasm
155 # if your as has trouble with the data32 directive, uncomment this
156 # but note that the premade start*.o will be larger than necessary because it
157 # contains some routines which may not be used
158 #AS_PSEUDOS= n
160 SRCS= floppyload.S comload.S liloprefix.S loader.S start16.S start32.S serial.S startmpcc.S
161 SRCS+= main.c pci.c osloader.c nfs.c misc.c ansiesc.c bootmenu.c config.c
162 SRCS+= md5.c floppy.c
164 # ROM loaders: LZ version (prefix Z), PCI header version (prefix P)
165 ifndef AS86
166 RLOADER= rloader.bin.pre
167 PRLOADER= prloader.bin.pre
168 RZLOADER= rzloader.bin.pre
169 PRZLOADER= przloader.bin.pre
170 FLOPPYLOAD= floppyload.bin.pre
171 COMLOAD= comload.bin.pre
172 LILOPREFIX= liloprefix.bin.pre
173 else
174 RLOADER= bin/rloader.bin
175 PRLOADER= bin/prloader.bin
176 RZLOADER= bin/rzloader.bin
177 PRZLOADER= bin/przloader.bin
178 FLOPPYLOAD= bin/floppyload.bin
179 COMLOAD= bin/comload.bin
180 LILOPREFIX= bin/liloprefix.bin
181 endif
183 ifeq ($(AS86),as86)
184 LCPPFLAGS+= -DUSE_AS86
185 LASFLAGS+= $(AS86FLAGS) -0
186 LASBINARY:= -b
187 endif
188 ifeq ($(AS86),nasm)
189 LCPPFLAGS+= -DUSE_NASM
190 LASFLAGS+= $(NASMFLAGS) -fbin
191 LASBINARY:= -o
192 endif
194 ifeq ($(AS_PSEUDOS),n)
195 START16= start16.o.pre
196 START32= start32.o.pre
197 else
198 START16= bin16/start16.o
199 START32= bin32/startmpcc.o
200 endif
202 BOBJS16= bin16/main.o bin16/osloader.o bin16/misc.o bin16/bootmenu.o
203 BOBJS16+= bin16/floppy.o bin16/timer.o
204 BOBJS32= bin32/main.o bin32/osloader.o bin32/nfs.o bin32/misc.o
205 BOBJS32+= bin32/ansiesc.o bin32/bootmenu.o bin32/md5.o bin32/floppy.o
206 BOBJS32+= bin32/serial.o bin32/timer.o
207 BLIB16= bin16/bootlib.a
208 BLIB32= bin32/bootlib.a
209 LIBS16= $(BLIB16) $(LIBC16)
210 LIBS32= $(BLIB32) $(LIBC32) /usr/lib/gcc-lib/i386-redhat-linux/2.96/libgcc.a
211 UTIL_LZHUF:= $(shell if [ -d ../contrib/compressor ]; then echo bin/lzhuf; fi)
212 UTILS+= bin/makerom $(UTIL_LZHUF) bin/organon
213 STDDEPS16= $(START16) $(BLIB16) $(UTILS)
214 STDDEPS32= $(START32) $(BLIB32) $(UTILS)
215 MAKEDEPS= Makefile Config Roms
217 CHECKSIZE= { read d1; read d1 d2 d3 size d4; [ $$size -gt $(ROMLIMIT) ] &&\
218 { $(RM) $@; echo "ERROR: code size exceeds limit!"; exit 1; }; exit 0; }
220 # Make sure that the relocation address is acceptable for all ROM sizes.
221 # Setting it to 0x98000 leaves about 29kB of space for the Etherboot program.
222 # The check is done based running 'size' on the binary, not ROM size, but
223 # roughly this means a ROM of 16kB or a partially used ROM of 32kB,
224 # remembering to compressed ROM images into account.
225 # You may also set RELOCADDR to 0x88000 to avoid using 0x98000
226 # because of other drivers (e.g. Disk On Chip). In that case, you may
227 # only load 512kB of OS, or load in memory above 1MB.
228 # Don't forget to choose an assembler because the loaders have to be rebuilt.
229 ifndef RELOCADDR
230 RELOCADDR=0x98000
231 #RELOCADDR=0xe0000
232 endif
234 # Evaluate ROMLIMIT only once - it is constant during the make run.
235 # Note that the 3K safety margin below is for the 1K extended BIOS data area
236 # and for the Etherboot runtime stack. Under normal situations, 2K of stack
237 # are rarely needed. If you experience strange behaviour in functions that use
238 # many local variables or that call functions that do, check for stack overrun!
239 # Make sure that the normal case needs no perl interpreter - if someone uses a
240 # different RELOCADDR, then he has perl installed anyways (the shell cannot
241 # deal with hex numbers, as test/eval don't support non-decimal integers).
242 ifeq ($(RELOCADDR),0x98000)
243 ROMLIMIT=29696
244 else
245 ROMLIMIT:=$(shell perl -e 'print 0x10000 - 3072 - ($(RELOCADDR) & 0xFFFF), "\n";')
246 endif
248 # Start of targets
250 all: $(UTILS) $(BUILD_LIBS) allbins
252 include Roms
254 # We need allbins because $(BINS16) and $(BINS32) are not defined until
255 # the Makefile fragment "Roms" is read.
257 allbins: $(BUILD_BINS)
259 # Common files
261 $(BLIB16): $(BOBJS16)
262 $(AR16) rv $@ $(BOBJS16)
263 $(RANLIB16) $@
265 $(BLIB32): $(BOBJS32)
266 $(AR32) rv $@ $(BOBJS32)
267 $(RANLIB32) $@
269 bin16/main.o: main.c etherboot.h osdep.h nic.h
270 bin32/main.o: main.c etherboot.h osdep.h nic.h
272 bin16/osloader.o: osloader.c etherboot.h osdep.h
273 bin32/osloader.o: osloader.c etherboot.h osdep.h
275 # NFS currently makes no sense for Etherboot/16
276 bin32/nfs.o: nfs.c etherboot.h osdep.h nic.h
278 bin16/misc.o: misc.c etherboot.h osdep.h
279 bin32/misc.o: misc.c etherboot.h osdep.h
281 # ANSIESC is not supported for Etherboot/16
282 bin32/ansiesc.o: ansiesc.c etherboot.h osdep.h
284 bin16/bootmenu.o: bootmenu.c etherboot.h osdep.h
285 bin32/bootmenu.o: bootmenu.c etherboot.h osdep.h
287 # Password support is not available for Etherboot/16
288 bin32/md5.o: md5.c etherboot.h osdep.h
290 bin16/floppy.o: floppy.c etherboot.h osdep.h
291 bin32/floppy.o: floppy.c etherboot.h osdep.h
293 bin16/timer.o: timer.c timer.h etherboot.h osdep.h
294 bin32/timer.o: timer.c timer.h etherboot.h osdep.h
296 bin32/inthw.o: inthw.c
298 # PCI support code (common to all PCI drivers)
300 bin32/pci.o: pci.c pci.h
302 # Do not add driver specific dependencies here unless it's something the
303 # genrules.pl script *can't* deal with, i.e. if it is not C code.
305 # Prepended loaders
307 #ifndef AS86
308 #$(RLOADER) $(RZLOADER) $(PRLOADER) $(PRZLOADER): $(MAKEDEPS)
309 # @if [ $(RELOCADDR) != 0x98000 ]; then echo Non-standard RELOCADDR, must assemble $@; exit 1; fi
310 # $(TOUCH) $@
311 #else
312 #bin/rloader.s: loader.S $(MAKEDEPS)
313 # $(CPP) $(LCPPFLAGS) $(LCONFIG) -o $@ $<
315 #bin/rzloader.s: loader.S $(MAKEDEPS)
316 # $(CPP) $(LCPPFLAGS) $(LCONFIG) -DZLOADER -o $@ $<
318 #bin/prloader.s: loader.S $(MAKEDEPS)
319 # $(CPP) $(LCPPFLAGS) $(LCONFIG) -DPCI_PNP_HEADER -o $@ $<
321 #bin/przloader.s: loader.S $(MAKEDEPS)
322 # $(CPP) $(LCPPFLAGS) $(LCONFIG) -DPCI_PNP_HEADER -DZLOADER -o $@ $<
323 #endif
325 # Floppy loader
327 ifdef AS86
328 bin/floppyload.s: floppyload.S $(MAKEDEPS)
329 $(CPP) $(LCPPFLAGS) -o $@ $<
330 endif
332 # COM loader
334 ifdef AS86
335 bin/comload.s: comload.S $(MAKEDEPS)
336 $(CPP) $(LCPPFLAGS) -o $@ $<
337 endif
339 # LILO prefix:
341 ifdef AS86
342 bin/liloprefix.s: liloprefix.S $(MAKEDEPS)
343 $(CPP) $(LCPPFLAGS) -o $@ $<
344 endif
346 # Utilities
348 bin/makerom: makerom.c
349 $(GCC) -O2 -o $@ makerom.c
351 bin/organon: organon.c
352 $(GCC) -o $@ organon.c
354 bin/lzhuf: ../contrib/compressor/lzhuf.c
355 $(GCC) -O2 -DENCODE -DDECODE -DMAIN -DVERBOSE -o $@ $<
357 # Roms file
359 Roms: NIC genrules.pl
360 @chmod +x genrules.pl
361 ./genrules.pl NIC > $@
363 # Pattern Rules
365 # general rules for compiling/assembling source files
366 bin16/%.o: %.c $(MAKEDEPS)
367 $(CC16) $(CFLAGS16) -o $@ -c $<
369 bin32/%.o: %.c $(MAKEDEPS)
370 $(CC32) $(CFLAGS32) -o $@ -c $<
372 bin16/%.o: %.S $(MAKEDEPS)
373 $(CC16) $(CFLAGS16) $(ASFLAGS16) -c -o $@ $<
375 bin32/%.o: %.S $(MAKEDEPS)
376 $(CPP) $(CFLAGS32) $< | $(AS) $(ASFLAGS32) -o $@
378 # general rule for .bin (plain binary loader code), may be overridden
379 ifdef AS86
380 bin/%.bin: bin/%.s
381 $(AS86) $(LASFLAGS) $(LASBINARY) $@ $<
382 endif
384 # general rule for .huf (compressed binary code), may be overridden
385 %.huf: %.img
386 bin/lzhuf e $< $@
388 # general rules for normal/compressed ROM images, may be overridden
389 bin16/%.rom: bin16/%.img $(RLOADER)
390 cat $(RLOADER) $< > $@
391 bin/makerom $(MAKEROM_$*) -i$(IDENT16) $@
393 bin32/%.rom: bin32/%.img $(RLOADER)
394 cat $(RLOADER) $< > $@
395 bin/makerom $(MAKEROM_$*) -i$(IDENT32) $@
397 bin16/%.lzrom: bin16/%.huf $(RZLOADER)
398 cat $(RZLOADER) $< > $@
399 bin/makerom $(MAKEROM_$*) -i$(IDENT16) $@
401 bin32/%.lzrom: bin32/%.huf $(RZLOADER)
402 cat $(RZLOADER) $< > $@
403 bin/makerom $(MAKEROM_$*) -i$(IDENT32) $@
405 # rules to write the .rom/.lzrom image onto a blank floppy
406 # You must give the directory name, e.g. use bin32/rtl8139.lzfd0 as the target.
407 %.fd0: %.rom $(FLOPPYLOAD)
408 cat $(FLOPPYLOAD) $< > /dev/fd0
410 %.lzfd0: %.lzrom $(FLOPPYLOAD)
411 cat $(FLOPPYLOAD) $< > /dev/fd0
413 # rules to generate a .com executable
414 # You must give the directory name, e.g. use bin32/rtl8139.com as the target.
415 %.com: %.lzrom $(COMLOAD)
416 cat $(COMLOAD) $< > $@
418 # rules to make a floppy image (padding to fill an even number of cylinders).
419 # VMware reports floppy image read errors if it cannot read ahead 36 sectors,
420 # probably because the floppyload.S code reads up to that number of sectors in
421 # a single request. Not that 18k matters much these days...
422 # You must give the directory name, e.g. use bin32/rtl8139.fdimg as the target.
423 %.fdimg: %.rom $(FLOPPYLOAD)
424 cat $(FLOPPYLOAD) $< > $@.x
425 dd if=$@.x of=$@ bs=36k conv=sync 2> /dev/null
426 $(RM) $@.x
428 %.lzfdimg: %.lzrom $(FLOPPYLOAD)
429 cat $(FLOPPYLOAD) $< > $@.x
430 dd if=$@.x of=$@ bs=36k conv=sync 2> /dev/null
431 $(RM) $@.x
433 # rules to make a LILO-bootable image
434 %.lilo: %.rom $(LILOPREFIX)
435 cat $(LILOPREFIX) $< /dev/zero | head -c 64k > $@
437 %.lzlilo: %.lzrom $(LILOPREFIX)
438 cat $(LILOPREFIX) $< /dev/zero | head -c 64k > $@
440 # Housekeeping
442 # To make sure that this actually builds a start32.o.pre with all options set,
443 # you have to make sure that -DFLOPPY -DANSIESC -DCONSOLE_DUAL are in CFLAGS32.
444 precompiled: bin/rloader.bin bin/rzloader.bin bin/prloader.bin bin/przloader.bin bin/floppyload.bin bin/comload.bin bin16/start16.o bin32/start32.o bin/liloprefix.bin
445 cp -p bin/rloader.bin rloader.bin.pre
446 cp -p bin/rzloader.bin rzloader.bin.pre
447 cp -p bin/prloader.bin prloader.bin.pre
448 cp -p bin/przloader.bin przloader.bin.pre
449 cp -p bin/floppyload.bin floppyload.bin.pre
450 cp -p bin/comload.bin comload.bin.pre
451 cp -p bin16/start16.o start16.o.pre
452 cp -p bin32/start32.o start32.o.pre
453 cp -p bin/liloprefix.bin liloprefix.bin.pre
455 clean:
456 $(RM) $(UTILS) bin/*.s bin/*.bin
457 $(RM) $(BLIB16) $(BLIB32)
458 $(RM) bin16/*.o bin32/*.o bin16/*.tmp bin32/*.tmp
459 $(RM) bin16/*.img bin32/*.img bin16/*.huf bin32/*.huf
460 $(RM) bin16/*.rom bin32/*.rom bin16/*.lzrom bin32/*.lzrom
461 $(RM) bin16/*.com bin32/*.com
462 $(RM) bin16/*.fdimg bin32/*.fdimg bin16/*.lzfdimg bin32/*.lzfdimg
463 $(RM) bin16/*.lilo bin32/*.lilo bin16/*.lzlilo bin32/*.lzlilo
464 $(RM) bin32/*.hex
465 $(RM) bin32/*.asm
466 $(RM) bin32/*.map
468 tarball:
469 (echo -n $(VERSION) ''; date -u +'%Y-%m-%d') > ../VERSION
470 (cd ..; tar cf /tmp/mpccboot-$(VERSION).tar --exclude CVS mpccboot)
471 bzip2 -9 < /tmp/mpccboot-$(VERSION).tar > /tmp/mpccboot-$(VERSION).tar.bz2
472 gzip -9 < /tmp/mpccboot-$(VERSION).tar > /tmp/mpccboot-$(VERSION).tar.gz
474 version:
475 @echo $(VERSION)