#	Makefile,v 1.4 1994/12/31 17:16:49 jkh Exp
#
# Makefile for ETHERBOOT
#
# Don't edit this file except to change the version, edit Config
#
# Common options:
#	VERSION=v	- Set the version string (but see comment in config.c)
#
# NS8390 options:
#	-DINCLUDE_NE	- Include NE1000/NE2000 support
#	-DNE_SCAN=list	- Probe for NE base address using list of
#			  comma separated hex addresses
#	-DINCLUDE_T503  - Include 3c503 support
#	  -DT503_SHMEM	- Use 3c503 shared memory mode (off by default)
#	-DINCLUDE_WD	- Include Western Digital/SMC support
#	-DWD_DEFAULT_MEM- Default memory location for WD/SMC cards
#
# 3C509 option:
#	-DINCLUDE_T509	- Include 3c509 support
#
# 3C905B option:
#	-DINCLUDE_T905B	- Include 3c905B support
#
# CS89x0 (optional) options:
#	-DINCLUDE_CS89x0- Include CS89x0 support
#	-DCS_SCAN=list	- Probe for CS89x0 base address using list of
#			  comma separated hex addresses; increasing the
#			  address by one (0x300 -> 0x301) will force a
#			  more aggressive probing algorithm. This might
#			  be neccessary after a soft-reset of the NIC.
#
# LANCE options;
#	-DINCLUDE_NE2100- Include NE2100 support
#	-DINCLUDE_NI6510- Include NI6510 support
#
# SK_G16 options;
#	-DINCLUDE_SK_G16- Include SK_G16 support
#
# I82586 options
#	-DINCLUDE_T507	- Include 3c507 support
#	-DINCLUDE_NI5210- Include NI5210 support
#	-DINCLUDE_EXOS205-Include EXOS205 support
#
# SMC9000 options
#       -DINCLUDE_SMC9000   - Include SMC9000 driver
#       -DSMC9000_SCAN=list - List of I/O addresses to probe
#
# TIARA (Fujitsu Etherstar) options
#	-DINCLUDE_TIARA	- Include Tiara support
#
# RTL8139 options
#	-DINCLUDE_RTL8139 - Include RTL8139 support
#
# XXX nothing depends on this Makefile so you must run `make clean' after
# changing an option.
#

include Config

GCC=		gcc
CPP=		gcc -E
VERSION=	4.2.0
CFLAGS+=	-DVERSION=\"$(VERSION)\"
CFLAGS+=	-DRELOC=$(RELOCADDR)
# Stack must be below 640kb so we have real memory there
# In 32 bit version, stack is automatically set using BIOS call 
# to avoid trampling on extended BIOS area at top of 640kB
# We assume XT and AT BIOSes are not that sophisticated
LCONFIG+=	-DSTACKADDR=0xA0000-$(RELOCADDR)
EEPRO100FLAGS=	-DINCLUDE_EEPRO100
EPIC100FLAGS=	-DINCLUDE_EPIC100
EXOS205FLAGS=	-DINCLUDE_EXOS205
LANCEPCIFLAGS=	-DINCLUDE_LANCEPCI
NE2100FLAGS=	-DINCLUDE_NE2100
NEFLAGS=	-DINCLUDE_NE -DNE_SCAN=0x280,0x300,0x320,0x340
NEPCIFLAGS=	-DINCLUDE_NEPCI
NI5210FLAGS=	-DINCLUDE_NI5210
NI6510FLAGS=	-DINCLUDE_NI6510
RTL8139FLAGS=	-DINCLUDE_RTL8139
SK_G16FLAGS=	-DINCLUDE_SK_G16
SMC9000FLAGS=   -DINCLUDE_SMC9000
T503FLAGS=	-DINCLUDE_T503 # -DT503_SHMEM
T507FLAGS=	-DINCLUDE_T507
T905BFLAGS=	-DINCLUDE_T905B
TIARAFLAGS=	-DINCLUDE_TIARA
TULIPFLAGS=	-DINCLUDE_TULIP
WDFLAGS=	-DINCLUDE_WD -DWD_DEFAULT_MEM=0xCC000
AR=		ar
RANLIB=		ranlib
# if you want to rebuild *loader.bin and floppyload.bin and
# you know your as86 is sufficiently recent, set this to an absolute path
AS86=		as86
# if you wan to rebuild start.o, and your as has .code16, .code32,
# and data32, comment this out
AS_PSEUDOS=	n

SRCS=	floppyload.asm loader.asm start.S main.c linuxloader.c misc.c ansiesc.c bootmenu.c
SRCS+=  config.c md5.c floppy.c
RLOADER=	rloader.bin
PRLOADER=	prloader.bin	# PCI header version
RZLOADER=	rzloader.bin
PRZLOADER=	przloader.bin	# PCI header version
FLOPPYLOAD=	floppyload.bin
START=	start.o
BOBJS=	main.o linuxloader.o misc.o ansiesc.o bootmenu.o md5.o floppy.o
TOBJS=	test.o misc.o
BLIB=	bootlib.a
DOBJS=	wd.o 3c503.o 3c509.o ne.o ne2100.o 3c507.o ni5210.o exos205.o ni6510.o sk_g16.o smc9000.o tiara.o
DOBJS+=	$(shell if [ -f 3c905b.c ] ; then echo 3c905b.o ; fi)
DOBJS+= $(shell if [ -f cs89x0.c ] ; then echo cs89x0.o ; fi)
DOBJS+= $(shell if [ -f eepro100.c ] ; then echo eepro100.o ; fi)
DOBJS+= $(shell if [ -f epic100.c ] ; then echo epic100.o ; fi)
DOBJS+=	$(shell if [ -f pci.c ] ; then echo pci.o ; fi)
DOBJS+=	$(shell if [ -f rtl8139.c ] ; then echo rtl8139.o ; fi)
DOBJS+=	$(shell if [ -f tulip.c ] ; then echo tulip.o ; fi)
DLIB=	driver.a
UTILS+=	makerom $(shell if [ -d ../contrib/compressor ]; then echo lzhuf; fi)
STDDEPS=$(START) $(BLIB) $(DLIB) $(UTILS)
BINS=	wd.rom 3c503.rom ne.rom 3c509.rom ne2100.rom 3c507.rom ni5210.rom exos205.rom ni6510.rom sk_g16.rom smc9000.rom tiara.rom
BINS+=	$(shell if [ -d ../contrib/compressor ]; then \
          echo wd.lzrom 3c503.lzrom ne.lzrom 3c509.lzrom ne2100.lzrom 3c507.lzrom ni5210.lzrom exos205.lzrom ni6510.lzrom sk_g16.lzrom smc9000.lzrom tiara.lzrom; fi)
BINS+=  $(shell if [ -f 3c905b.c ] ; then echo 3c905b.lzrom 3c905b.rom ; fi)  
BINS+=  $(shell if [ -f cs89x0.c ] ; then echo cs89x0.lzrom cs89x0.rom ; fi)  
BINS+=  $(shell if [ -f eepro100.c ] ; then echo eepro100.lzrom eepro100.rom ; fi)
BINS+=  $(shell if [ -f epic100.c ] ; then echo epic100.lzrom epic100.rom ; fi)
BINS+=  $(shell if [ -f rtl8139.c ] ; then echo rtl8139.lzrom rtl8139.rom ; fi)  
BINS+=  $(shell if [ -f pci.c ] ; then echo nepci.lzrom nepci.rom lancepci.lzrom lancepci.rom; fi)
BINS+=  $(shell if [ -f tulip.c ] ; then echo tulip.lzrom tulip.rom ; fi)  
CLEANFILES=	$(START) $(BOBJS) $(DOBJS) $(TOBJS)
CLEANFILES+=	$(BLIB) $(DLIB) config-*.o $(UTILS)
CLEANFILES+=	*.rom *.lzrom *.tmp *.tst *.bin *.huf lzhuf
CLEANFILES+=	$(shell if [ -f pci.c ] ; then echo nepci.o lancepci.o; fi)
# nepci.o and lancpci.o are not included in DOBJS because they are the same
# as the non-PCI versions but they have to be cleaned up also

# Make sure that the relocation address is acceptable for all ROM sizes
RELOCADDR=0x98000

.SUFFIXES:	.S .asm .s .bin .rom .tst .lzrom .fd0

all:	$(UTILS) $(BINS)

clean:
	$(RM) -f $(CLEANFILES)

.S.s:
	$(CC) $(LCONFIG) $(CFLAGS) $(ASFLAGS) -E $< > $@

.S.o:
	$(CC) $(LCONFIG) $(CFLAGS) $(ASFLAGS) -c -o $@ $<

# general rule for .roms, may be overriden
.o.rom:	config-$*.o $(RLOADER) $(START)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	cat $(RLOADER) $*.bin > $@ 
	./makerom -i'Etherboot/$(BITS) $(VERSION) $@' $@

# general rule for .lzroms, may be overriden
.o.lzrom:	config-$*.o $(RZLOADER) $(START)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	./lzhuf e $*.bin $*.huf
	cat $(RZLOADER) $*.huf > $@
	./makerom -i'Etherboot/$(BITS) $(VERSION) $@' $@

# hmm, anybody still use this?
.o.tst:	config-$*.o $(RLOADER) $(START)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) test.o config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	cat $(RLOADER) $*.bin > $@ 
	./makerom -i'Etherboot/$(BITS) $(VERSION) $@' $@

# rule to write the .rom image onto a blank floppy
.rom.fd0:	$*.rom $(FLOPPYLOAD)
	cat $(FLOPPYLOAD) $*.rom > /dev/fd0

wd.rom:		config-wd.o $(RLOADER) $(STDDEPS)

# special case because we need to use the -3 flag to makerom
3c503.rom:	config-3c503.o $(RLOADER) $(STDDEPS)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	cat $(RLOADER) $*.bin > $@ 
	./makerom -3 -i'Etherboot/$(BITS) $(VERSION) $@' $@

ne.rom:		config-ne.o $(RLOADER) $(STDDEPS)

3c509.rom:	config-3c509.o $(RLOADER) $(STDDEPS)

# special case because we need to set the VENDOR and DEVICE IDs
3c905b.rom:	config-3c905b.o $(PRLOADER) $(STDDEPS)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	cat $(PRLOADER) $*.bin > $@ 
	./makerom -p 0x10b7,0x9055 -i'Etherboot/$(BITS) $(VERSION) $@' $@

# special case because we need to set the VENDOR and DEVICE IDs
epic100.rom:	config-epic100.o $(PRLOADER) $(STDDEPS)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	cat $(PRLOADER) $*.bin > $@ 
	./makerom -p 0x10b8,0x0005 -i'Etherboot/$(BITS) $(VERSION) $@' $@

# special case because we need to set the VENDOR and DEVICE IDs
eepro100.rom:	config-eepro100.o $(PRLOADER) $(STDDEPS)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	cat $(PRLOADER) $*.bin > $@ 
	./makerom -p 0x8086,0x1229 -i'Etherboot/$(BITS) $(VERSION) $@' $@

# special case because we need to set the VENDOR and DEVICE IDs
rtl8139.rom:	config-rtl8139.o $(PRLOADER) $(STDDEPS)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	cat $(PRLOADER) $*.bin > $@ 
	./makerom -p 0x10ec,0x8139 -i'Etherboot/$(BITS) $(VERSION) $@' $@

# special case because we need to set the VENDOR and DEVICE IDs
# vendor id and device id are correct for original Tulip only
tulip.rom:	config-tulip.o $(PRLOADER) $(STDDEPS)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	cat $(PRLOADER) $*.bin > $@ 
	./makerom -p 0x1011,0x0002 -i'Etherboot/$(BITS) $(VERSION) $@' $@
	# cat $(PRLOADER) tulip.bin > tulipclone.rom
	# ./makerom -p 0x1011,0x0002 -i'Etherboot/$(BITS) $(VERSION) tulipclone.rom' tulipclone.rom
# to also make a ROM for a Tulip clone with a different id pair, uncomment the
# previous two lines and edit the vendor and device ids

cs89x0.rom:	config-cs89x0.o $(RLOADER) $(STDDEPS)

ne2100.rom:	config-ne2100.o $(RLOADER) $(STDDEPS)

ni6510.rom:	config-ni6510.o $(RLOADER) $(STDDEPS)

sk_g16.rom:	config-sk_g16.o $(RLOADER) $(STDDEPS)

# special case because we need to set the VENDOR and DEVICE IDs
# vendor id and device id are correct for Realtek 8029 only
nepci.rom:	config-nepci.o $(PRLOADER) $(STDDEPS)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	cat $(PRLOADER) $*.bin > $@ 
	./makerom -p 0x10ec,0x8029 -i'Etherboot/$(BITS) $(VERSION) $@' $@
	# cat $(PRLOADER) nepci.bin > nepciclone.rom
	# ./makerom -p 0x10ec,0x8029 -i'Etherboot/$(BITS) $(VERSION) nepciclone.rom' nepciclone.rom
# to also make a ROM for a NEPCI clone with a different id pair, uncomment the
# previous two lines and edit the vendor and device ids

# special case because we need to set the VENDOR and DEVICE IDs
lancepci.rom:	config-lancepci.o $(PRLOADER) $(STDDEPS)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	cat $(PRLOADER) $*.bin > $@ 
	./makerom -p 0x1022,0x2000 -i'Etherboot/$(BITS) $(VERSION) $@' $@

3c507.rom:	config-3c507.o $(RLOADER) $(STDDEPS)

ni5210.rom:	config-ni5210.o $(RLOADER) $(STDDEPS)

exos205.rom:	config-exos205.o $(RLOADER) $(STDDEPS)

# should we make a PCI ROM?
smc9000.rom:	config-smc9000.o $(RLOADER) $(STDDEPS)

tiara.rom:	config-tiara.o $(RLOADER) $(STDDEPS)

wd.lzrom:	config-wd.o $(RZLOADER) $(STDDEPS)

# special case because we need to use the -3 flag to makerom
3c503.lzrom:	config-3c503.o $(RZLOADER) $(STDDEPS)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	./lzhuf e $*.bin $*.huf
	cat $(RZLOADER) $*.huf > $@
	./makerom -3 -i'Etherboot/$(BITS) $(VERSION) $@' $@

ne.lzrom:	config-ne.o $(RZLOADER) $(STDDEPS)

3c509.lzrom:	config-3c509.o $(RZLOADER) $(STDDEPS)

# special case because we need to set the VENDOR and DEVICE IDs
3c905b.lzrom:	config-3c905b.o $(PRZLOADER) $(STDDEPS)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	./lzhuf e $*.bin $*.huf
	cat $(PRZLOADER) $*.huf > $@
	./makerom -p 0x10b7,0x9055 -i'Etherboot/$(BITS) $(VERSION) $@' $@

# special case because we need to set the VENDOR and DEVICE IDs
epic100.lzrom:	config-epic100.o $(PRZLOADER) $(STDDEPS)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	./lzhuf e $*.bin $*.huf
	cat $(PRZLOADER) $*.huf > $@
	./makerom -p 0x10b8,0x0005 -i'Etherboot/$(BITS) $(VERSION) $@' $@

# special case because we need to set the VENDOR and DEVICE IDs
eepro100.lzrom:	config-eepro100.o $(PRZLOADER) $(STDDEPS)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	./lzhuf e $*.bin $*.huf
	cat $(PRZLOADER) $*.huf > $@
	./makerom -p 0x8086,0x1229 -i'Etherboot/$(BITS) $(VERSION) $@' $@

# special case because we need to set the VENDOR and DEVICE IDs
rtl8139.lzrom:	config-rtl8139.o $(PRZLOADER) $(STDDEPS)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	./lzhuf e $*.bin $*.huf
	cat $(PRZLOADER) $*.huf > $@
	./makerom -p 0x10ec,0x8139 -i'Etherboot/$(BITS) $(VERSION) $@' $@

# special case because we need to set the VENDOR and DEVICE IDs
# vendor id and device id are correct for original Tulip only
tulip.lzrom:	config-tulip.o $(PRZLOADER) $(STDDEPS)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	./lzhuf e $*.bin $*.huf
	cat $(PRZLOADER) $*.huf > $@
	./makerom -p 0x1011,0x0002 -i'Etherboot/$(BITS) $(VERSION) $@' $@
	# cat $(PRZLOADER) tulip.huf > tulipclone.lzrom
	# ./makerom -p 0x1011,0x0002 -i'Etherboot/$(BITS) $(VERSION) tulipclone.lzrom' tulipclone.lzrom
# to also make a ROM for a Tulip clone with a different id pair, uncomment the
# previous two lines and edit the vendor and device ids

cs89x0.lzrom:	config-cs89x0.o $(RZLOADER) $(STDDEPS)

ne2100.lzrom:	config-ne2100.o $(RZLOADER) $(STDDEPS)

ni6510.lzrom:	config-ni6510.o $(RZLOADER) $(STDDEPS)

sk_g16.lzrom:	config-sk_g16.o $(RZLOADER) $(STDDEPS)

# special case because we need to set the VENDOR and DEVICE IDs
# vendor id and device id are correct for Realtek 8029 only
nepci.lzrom:	config-nepci.o $(PRZLOADER) $(STDDEPS)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	./lzhuf e $*.bin $*.huf
	cat $(PRZLOADER) $*.huf > $@
	./makerom -p 0x10ec,0x8029 -i'Etherboot/$(BITS) $(VERSION) $@' $@
	# cat $(PRZLOADER) nepci.huf > nepciclone.lzrom
	# ./makerom -p 0x10ec,0x8029 -i'Etherboot/$(BITS) $(VERSION) nepciclone.lzrom' nepciclone.lzrom
# to also make a ROM for a NEPCI clone with a different id pair, uncomment the
# previous two lines and edit the vendor and device ids

# special case because we need to set the VENDOR and DEVICE IDs
lancepci.lzrom:	config-lancepci.o $(PRZLOADER) $(STDDEPS)
	$(LD) $(LDFLAGS) -o $*.tmp $(START) config-$*.o $(BLIB) $(DLIB) $(LIBS)
	$(OBJCOPY) $*.tmp $*.bin
	./lzhuf e $*.bin $*.huf
	cat $(PRZLOADER) $*.huf > $@
	./makerom -p 0x1022,0x2000 -i'Etherboot/$(BITS) $(VERSION) $@' $@

3c507.lzrom:	config-3c507.o $(RZLOADER) $(STDDEPS)

ni5210.lzrom:	config-ni5210.o $(RZLOADER) $(STDDEPS)

exos205.lzrom:	config-exos205.o $(RZLOADER) $(STDDEPS)

# should we make a PCI ROM?
smc9000.lzrom:	config-smc9000.o $(RZLOADER) $(STDDEPS)

tiara.lzrom:	config-tiara.o $(RZLOADER) $(STDDEPS)

wd.fd0:		wd.rom $(FLOPPYLOAD)

3c503.fd0:	3c503.rom $(FLOPPYLOAD)

ne.fd0:		ne.rom $(FLOPPYLOAD)

3c509.fd0:	3c509.rom $(FLOPPYLOAD)

3c905b.fd0:	3c905b.rom $(FLOPPYLOAD)

eepro100.fd0:	eepro100.rom $(FLOPPYLOAD)

epic100.fd0:	epic100.rom $(FLOPPYLOAD)

rtl8139.fd0:	rtl8139.rom $(FLOPPYLOAD)

tulip.fd0:	tulip.rom $(FLOPPYLOAD)

cs89x0.fd0:	cs89x0.rom $(FLOPPYLOAD)

ne2100.fd0:	ne2100.rom $(FLOPPYLOAD)

ni6510.fd0:	ni6510.rom $(FLOPPYLOAD)

sk_g16.fd0:	sk_g16.rom $(FLOPPYLOAD)

nepci.fd0:	nepci.rom $(FLOPPYLOAD)

lancepci.fd0:	lancepci.rom $(FLOPPYLOAD)

3c507.fd0:	3c507.rom $(FLOPPYLOAD)

ni5210.fd0:	ni5210.rom $(FLOPPYLOAD)

exos205.fd0:	exos205.rom $(FLOPPYLOAD)

smc9000.fd0:	smc9000.rom $(FLOPPYLOAD)

tiara.fd0:	tiara.rom $(FLOPPYLOAD)

config-wd.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_WD -o $@ -c $<

config-3c503.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_T503 -o $@ -c $<

config-ne.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_NE -o $@ -c $<

config-3c509.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_T509 -o $@ -c $<

config-3c905b.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_T905B -o $@ -c $<

config-eepro100.o: config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_EEPRO100 -o $@ -c $<

config-epic100.o: config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_EPIC100 -o $@ -c $<

config-tulip.o: config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_TULIP -o $@ -c $<

config-cs89x0.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_CS -o $@ -c $<

config-ne2100.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_NE2100 -o $@ -c $<

config-ni6510.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_NI6510 -o $@ -c $<

config-sk_g16.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_SK_G16 -o $@ -c $<

config-nepci.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_NEPCI -o $@ -c $<

config-lancepci.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_LANCEPCI -o $@ -c $<

config-3c507.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_T507 -o $@ -c $<

config-ni5210.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_NI5210 -o $@ -c $<

config-exos205.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_EXOS205 -o $@ -c $<

config-smc9000.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_SMC9000 -o $@ -c $<

config-tiara.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_TIARA -o $@ -c $<

config-rtl8139.o:	config.c config.h
	$(CC) $(CFLAGS) -DINCLUDE_RTL8139 -o $@ -c $<

$(BLIB):	$(BOBJS)
	$(AR) rv $@ $(BOBJS)
	$(RANLIB) $@

$(DLIB):	$(DOBJS)
	$(AR) rv $@ $(DOBJS)
	$(RANLIB) $@

$(BOBJS):	linuxdef.h etherboot.h nic.h

$(TOBJS):	linuxdef.h etherboot.h nic.h

start.o:	start.S
ifeq ($(AS_PSEUDOS),n)
ifeq ($(BITS),16)
	ln -fs ../src/start16.o start.o
else
	ln -fs ../src/start32.o start.o
endif
endif

main.o:		main.c

linuxloader.o:	linuxloader.c

misc.o:		misc.c

ansiesc.o:	ansiesc.c

bootmenu.o:	bootmenu.c

md5.o:		md5.c

floppy.o:	floppy.c

wd.o:	ns8390.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(WDFLAGS) -o $@ -c $<

3c503.o:	ns8390.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(T503FLAGS) -o $@ -c $<

3c509.o:	3c509.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(T509FLAGS) -o $@ -c $<

3c905b.o:	3c905b.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(T905BFLAGS) -o $@ -c $<

eepro100.o:	eepro100.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(EEPRO100FLAGS) -o $@ -c $<

epic100.o:	epic100.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(EPIC100FLAGS) -o $@ -c $<

tulip.o:	tulip.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(TULIPFLAGS) -o $@ -c $<

ne.o:	ns8390.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(NEFLAGS) -o $@ -c $<

nepci.o:	ns8390.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(NEPCIFLAGS) -o $@ -c $<

lancepci.o:	lance.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(LANCEPCIFLAGS) -o $@ -c $<

cs89x0.o:	cs89x0.c cs89x0.h linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(CS89x0FLAGS) -o $@ -c $<

ne2100.o:	lance.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(NE2100FLAGS) -o $@ -c $<

ni6510.o:	lance.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(NI6510FLAGS) -o $@ -c $<

sk_g16.o:	sk_g16.c sk_g16.h linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(SK_G16FLAGS) -o $@ -c $<

3c507.o:	i82586.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(T507FLAGS) -o $@ -c $<

ni5210.o:	i82586.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(NI5210FLAGS) -o $@ -c $<

exos205.o:	i82586.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(EXOS205FLAGS) -o $@ -c $<

smc9000.o:	smc9000.c smc9000.h linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(SMC9000FLAGS) -o $@ -c $<

tiara.o:	tiara.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(TIARAFLAGS) -o $@ -c $<

rtl8139.o:	rtl8139.c linuxdef.h etherboot.h nic.h
	$(CC) $(CFLAGS) $(RTL8139FLAGS) -o $@ -c $<

pci.o:	pci.c pci.h
	$(CC) $(CFLAGS) -o $@ -c $<

$(RLOADER):	loader.asm loader.inc
ifeq ($(AS86),as86)
	ln -fs ../src/$(RLOADER) .
else
	$(RM) -f $(RLOADER)
	$(CPP) -DBOOTROM $(LCONFIG) $(CFLAGS) -DNO_PCI_PNP_HEADER -x assembler-with-cpp -o $*.s $<
	$(AS86) $(AS86FLAGS) -0 -b $(RLOADER) $*.s
	$(RM) -f $*.s
endif

$(PRLOADER):	loader.asm loader.inc
ifeq ($(AS86),as86)
	ln -fs ../src/$(PRLOADER) .
else
	$(RM) -f $(PRLOADER)
	$(CPP) -DBOOTROM $(LCONFIG) $(CFLAGS) -x assembler-with-cpp -o $*.s $<
	$(AS86) $(AS86FLAGS) -0 -b $(PRLOADER) $*.s
	$(RM) -f $*.s
endif

$(RZLOADER):	zloader.asm loader.inc
ifeq ($(AS86),as86)
	ln -fs ../src/$(RZLOADER) .
else
	$(RM) -f $(RZLOADER)
	$(CPP) -DBOOTROM $(LCONFIG) $(CFLAGS) -DNO_PCI_PNP_HEADER -x assembler-with-cpp -o $*.s $<
	$(AS86) $(AS86FLAGS) -0 -b $(RZLOADER) $*.s
	$(RM) -f $*.s
endif

$(PRZLOADER):	zloader.asm loader.inc
ifeq ($(AS86),as86)
	ln -fs ../src/$(PRZLOADER) .
else
	$(RM) -f $(PRZLOADER)
	$(CPP) -DBOOTROM $(LCONFIG) $(CFLAGS) -x assembler-with-cpp -o $*.s $<
	$(AS86) $(AS86FLAGS) -0 -b $(PRZLOADER) $*.s
	$(RM) -f $*.s
endif

$(FLOPPYLOAD):	floppyload.asm
ifeq ($(AS86),as86)
	ln -fs ../src/$(FLOPPYLOAD) .
else
	$(RM) -f $(FLOPPYLOAD)
	$(CPP) -x assembler-with-cpp -o $*.s $<
	$(AS86) $(AS86FLAGS) -0 -b $(FLOPPYLOAD) $*.s
	$(RM) -f $*.s
endif

makerom: makerom.c
	$(GCC) -o $@ makerom.c

lzhuf:	../contrib/compressor/lzhuf.c
	$(GCC) -DENCODE -DDECODE -DMAIN -DVERBOSE -o $@ \
		../contrib/compressor/lzhuf.c
