# $Solaris:$

#.PATH: ${.CURDIR}/../../pci ${.CURDIR}/../dagmem
.PATH: ${.CURDIR}

.PHONY: all clean distclean install depend

INCLUDE=  -I../../include -I../common -I.

CC = gcc
# flags for gcc, 64 bit
CFLAGS += -D_KERNEL ${INCLUDE} -m64 -mcmodel=kernel -mno-red-zone -nodefaultlibs -ffreestanding

#SolCC = /opt/SUNWspro/bin/cc
#SolLD = /usr/ccs/bin/ld

#DRIVER	 = dag
#SRCS     = device_if.h bus_if.h pci_if.h
#SRC	+= dagmem.h
#SRCS	+= dag.c dagduck.c dagmon.c dagreg.c
CSRC	= dag.c ../common/dagduck.c
#KMODDEPS = dagmem

all: dag

dag: dag.o ../../lib/dagreg.o #dagduck.o
	${LD} -r  -o dag dag.o ../../lib/dagreg.o #dagduck.o

dag.o: dag.c
	$(CC) $(CFLAGS) -c dag.c -o dag.o

dagduck.o: ../common/dagduck.c
	$(CC) $(CFLAGS) -c ../common/dagduck.c -o dagduck.o

dagreg.o: ../../lib/dagreg.c
	$(CC) $(CFLAGS) -c ../../lib/dagreg.c -o dagreg.o

clean:
	rm -f dag *.o

# /tmp is a good place for drivers under test, as it will be cleaned on reboot
install:
	cp dag /tmp
	rm -f /usr/kernel/drv/amd64/dag
	ln -s /tmp/dag /usr/kernel/drv/amd64/dag
	echo "'"  | tr '\n' ' ' > pciids.txt
	grep "define PCI_DEVICE_ID_DAG" ../../include/dagpci.h | cut -f 2 | sed 's/0x/\"pcieace,/; s/$$/\"/' | tr '\n' ' ' >> pciids.txt
	echo "' dag" | tr '\n' ' ' >> pciids.txt 
	cat pciids.txt | xargs add_drv -i

pkg: dag
	cp -f dag pkg/reloc/usr/kernel/drv/amd64/; \
	cd pkg; \
	pkgmk -o -b $(PWD)/pkg/reloc/

distclean: clean
	rm -f Makefile
	

distdir:
	cp dag.c dagdrv.h Makefile.in $(distdir)

.PHONY: dvi pdf ps info html tags ctags
dvi pdf ps info html tags ctags:

