2 # Makefile for Etherboot
4 # Most of the time you should edit Config
7 # VERSION=v - Set the version string
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
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
30 # -DINCLUDE_3C509 - Include 3c509 support
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.
52 # -DINCLUDE_NE2100- Include NE2100 support
53 # -DINCLUDE_NI6510- Include NI6510 support
56 # -DINCLUDE_SK_G16- Include SK_G16 support
59 # -DINCLUDE_3C507 - Include 3c507 support
60 # -DINCLUDE_NI5210- Include NI5210 support
61 # -DINCLUDE_EXOS205-Include EXOS205 support
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
71 # -DINCLUDE_NI5010 - Include NI5010 support
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
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
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
)
105 ifeq ($(ETHERBOOT
),32)
106 BUILD_LIBS
= $(BLIB32
)
107 BUILD_BINS
= $(BINS32
)
109 ifeq ($(ETHERBOOT
),both
)
110 BUILD_LIBS
= $(BLIB16
) $(BLIB32
)
111 BUILD_BINS
= $(BINS16
) $(BINS32
)
114 3C503FLAGS
= -DINCLUDE_3C503
# -DT503_SHMEM
115 # Note that the suffix to MAKEROM_ is the (mixed case) basename of the ROM file
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.
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)
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)
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
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)
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
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
184 LCPPFLAGS
+= -DUSE_AS86
185 LASFLAGS
+= $(AS86FLAGS
) -0
189 LCPPFLAGS
+= -DUSE_NASM
190 LASFLAGS
+= $(NASMFLAGS
) -fbin
194 ifeq ($(AS_PSEUDOS
),n
)
195 START16
= start16.o.pre
196 START32
= start32.o.pre
198 START16
= bin16
/start16.o
199 START32
= bin32
/startmpcc.o
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.
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)
245 ROMLIMIT
:=$(shell perl
-e
'print 0x10000 - 3072 - ($(RELOCADDR) & 0xFFFF), "\n";')
250 all: $(UTILS
) $(BUILD_LIBS
) allbins
254 # We need allbins because $(BINS16) and $(BINS32) are not defined until
255 # the Makefile fragment "Roms" is read.
257 allbins
: $(BUILD_BINS
)
261 $(BLIB16
): $(BOBJS16
)
262 $(AR16
) rv
$@
$(BOBJS16
)
265 $(BLIB32
): $(BOBJS32
)
266 $(AR32
) rv
$@
$(BOBJS32
)
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.
308 #$(RLOADER) $(RZLOADER) $(PRLOADER) $(PRZLOADER): $(MAKEDEPS)
309 # @if [ $(RELOCADDR) != 0x98000 ]; then echo Non-standard RELOCADDR, must assemble $@; exit 1; fi
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 $@ $<
328 bin
/floppyload.s
: floppyload.S
$(MAKEDEPS
)
329 $(CPP
) $(LCPPFLAGS
) -o
$@
$<
335 bin
/comload.s
: comload.S
$(MAKEDEPS
)
336 $(CPP
) $(LCPPFLAGS
) -o
$@
$<
342 bin
/liloprefix.s
: liloprefix.S
$(MAKEDEPS
)
343 $(CPP
) $(LCPPFLAGS
) -o
$@
$<
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
$@
$<
359 Roms
: NIC genrules.pl
360 @chmod
+x genrules.pl
361 .
/genrules.pl NIC
> $@
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
381 $(AS86
) $(LASFLAGS
) $(LASBINARY
) $@
$<
384 # general rule for .huf (compressed binary code), may be overridden
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
428 %.lzfdimg
: %.lzrom
$(FLOPPYLOAD
)
429 cat
$(FLOPPYLOAD
) $< > $@.x
430 dd if
=$@.x of
=$@ bs
=36k conv
=sync
2> /dev
/null
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
> $@
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
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
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