
DEBUG=4095
LINUXSRC=/usr/src/linux
INSTALLDIR=/lib/modules/$(shell uname -r)/net
#REQUIRE_RFC1201=-DCONFIG_ARCNET_REQUIRE_RFC1201

OBJS=arcnet.o \
	rfc1201.o rfc1051.o arc-rawmode.o \
	com90xx.o com20020base.o com20020.o com20020pci.o
# com90io.o arc-rimi.o arc-ethercap.o

all: $(OBJS)

install: all
	mkdir -p $(INSTALLDIR)
	cp $(OBJS) $(INSTALLDIR)

uninstall:
	rm -f $(addprefix $(INSTALLDIR)/,$(OBJS))

dist: clean
	$(MAKE) -C howto html

# Be careful.  This is mainly for Avery's use.
up: go
	ifconfig arc0 192.168.4.4

# This sort of gets things started, with the DEBUG mode you set above.
go: all ungo
	sync
	dmesg -n 8
	insmod ./arcnet.o debug=$(DEBUG)
	insmod ./rfc1201.o
	insmod ./arc-rawmode.o
	#insmod ./com90xx.o
	#insmod ./com20020.o io=0x300

# unload all the driver modules from memory
ungo:
	sync
	-ifconfig arc0 down
	-rmmod com20020
	-rmmod com20020pci
	-rmmod com20020base
	-rmmod com90xx
	-rmmod rfc1201
	-rmmod arc-rawmode
	-rmmod rfc1051
	-rmmod arcnet

# Test various different ping sizes.  Change 'discovery' to a host
# on your own network if you want this to work.
ping:
	d=12; \
	while :; do \
		echo -n "Size $$d: "; \
		fping -b $$d -r 1 -e discovery || break; \
		d=$$(($$d + 1)); \
	done

clean:
	make -C examples clean
	make -C stresstest clean
	make -C howto clean
	rm -f *.o *~

$(addsuffix .o,$(basename $(wildcard *.c))): *.h


KFLAGS=-D__KERNEL__ -I$(LINUXSRC)/include -Wall \
	-Wstrict-prototypes -O2 -fomit-frame-pointer -pipe \
	-fno-strength-reduce -m486 -malign-loops=2 -malign-jumps=2 \
	-malign-functions=2 -DCPU=586 -DMODULE -DMODVERSIONS \
	-include $(LINUXSRC)/include/linux/modversions.h \
	-DEXPORT_SYMTAB
CFLAGS=$(KFLAGS) $(REQUIRE_RFC1201)

%.o: %.c
	gcc ${CFLAGS} -c -o $@ $<

%.s: %.c
	gcc ${CFLAGS} -S -o $@ $<

%.E: %.c
	gcc ${CFLAGS} -E >$@ $<
