#
# If you got the binary distribution and want to install the
# precompiled binaries, use
# make install.bin install.man
#
# Define this if you want to abort on resource dump error
#
PNPDUMPFLAGS += -DABORT_ONRESERR
#
# Define REALTIME if you want to run with realtime scheduling, this
# cuts down the isolation and configuration time for a single card
# from 6s to less than 100ms.
# NOTE though, if it hangs, no other process will get processor time.
# You can still use ^C to kill it though.
# This can only be used with recent kernels, and I have only tested
# it on Linux.2.0.10. It certainly won't work on 1.2.13.
# nanosleep only went into the kernel at 1.3.67, but whether it
# worked or not, I know not.
#
# Depending on your libraries, you may need to define the NEED*s.
# For libc-5.2.18, you'll need them both.
# For libc-5.3.12, I suspect you may not want NEEDNANOSLEEP.
# For glibc-2.0, you don't want NEEDSETSCHEDULER or NEEDNANOSLEEP, and
#                the code will ignore these defines if it detects
#                glibc 2.0 or later.
# For cross-compiling for DOS, you don't want NEEDSETSCHEDULER or NEEDNANOSLEEP, and
#                the code will ignore these defines if it detects
#                glibc 2.0 or later.
#
#PNPFLAGS += -DREALTIME -DNEEDSETSCHEDULER -DNEEDNANOSLEEP
PNPFLAGS += -DREALTIME -DNEEDSETSCHEDULER
#
# Linux on ALPHA/AXP should already define this, but just in case..
#
#PNPFLAGS += -D_AXP_
#
# Set this if cross-compiling for DOS using djgpp
#
#CC = gcc -b i386-go32-msdos

prefix=/usr

CONFDIR = /etc
GONEFILE = isapnp.gone
INSTALLBINDIR = /sbin
INSTALLMANDIR = $(prefix)/man
INSTALLSHAREDIR=$(prefix)/share
INSTALLSCRIPTDIR=$(INSTALLSHAREDIR)/pnp/config-scripts/isa

CFLAGS = -O2 -Wall -DYY_NO_UNPUT $(PNPDUMPFLAGS) $(PNPFLAGS) -DGONEFILE=\"$(CONFDIR)/$(GONEFILE)\"

all:	pnpdump isapnp

install: pnpdump isapnp install.bin install.man
	mkdir -p $(INSTALLSCRIPTDIR)
	install config-scripts/* $(INSTALLSCRIPTDIR)/
	if test ! -f $(CONFDIR)/$(GONEFILE);\
	then\
		install $(GONEFILE) $(CONFDIR);\
		echo -e "\nSample preallocated resource file copied to $(CONFDIR)/$(GONEFILE), edit to suit\n";\
	fi

install.bin: 
	install -s -m 0755 pnpdump $(INSTALLBINDIR)
	install -s -m 0755 isapnp $(INSTALLBINDIR)

install.man:
	install -m 0644 isapnp.8 $(INSTALLMANDIR)/man8
	install -m 0644 isapnp.conf.5 $(INSTALLMANDIR)/man5
	install -m 0644 pnpdump.8 $(INSTALLMANDIR)/man8

TAGS: pnpdump.c resource.c pnp-select.c pnp.h isapnp.y
	etags $^

pnpdump: pnpdump.o resource.o pnp-select.o

pnpdump.o: pnp.h Makefile

isapnp: isapnp.o resource.o

isapnp.c: isapnp.y pnp.h Makefile
	flex -i -t isapnp.y > isapnp.c

isapnp.8.html: isapnp.8
	man2html isapnp.8

pnpdump.8.html: pnpdump.8
	man2html pnpdump.8

isapnp.conf.5.html: isapnp.conf.5
	man2html isapnp.conf.5

html: isapnp.8.html pnpdump.8.html isapnp.conf.5.html

semiclean:
	rm -f *.o isapnp.c *~

clean:
	rm -f *.o isapnp.c *~ pnpdump isapnp

dosclean: clean
	rm -f pnpdump isapnp

spotless: clean
	rm -f pnpdump isapnp *.exe

