#
# Enable debugging by adding the option  debug  to kerneld: "kerneld debug"
# (Debugging can also be enabled via the kdstat utility: "kdstat debug")
#
# You'll want to have this one enabled!
DEBUG=-DDEBUG
#
# Remove the comment ('#') marker before the XTRA line if you are using
# a modprobe utility earlier than the one from "modules-1.2.8.tar.gz".
#XTRA=-DNO_EXTRA_OPTS
#
# If you don't have gdbm, or if you don't want to use it for persistent
# module storage, remove the comment marker ('#') before the line below
NO_GDBM=-DNO_GDBM


MANDIR=/usr/man/man8
CFLAGS = -O6 -pipe -fomit-frame-pointer -Wall $(DEBUG) $(XTRA) $(NO_GDBM)
LDFLAGS = -s
PROGS= kerneld

ifndef NO_GDBM
PROGS += admpersist
LDLIBS = -lgdbm
BELT_AND_SUSPENDERS=/usr/include/gdbm.h
endif
UTILS= kdstat
TESTPROGS= kdsend
SRCS= kerneld.c kdstat.c kdsend.c

all: $(BELT_AND_SUSPENDERS) $(PROGS)

install-binaries: all
	@set -x; for i in $(PROGS); do install -m 0700 -o root -s -c $$i /sbin; done
	@echo "Do 'make install-scripts' in the kerneld directory to get a default /sbin/request-route"

install-scripts:
	install -m 0700 -o root request-route.sh /sbin/request-route

install-docs:
	install -c kerneld.8 $(MANDIR)

install: install-binaries install-docs

#
# Build the fake kerneld message generator: kdsend and the kdstat "utility"
# Used for debugging purposes only
#
test: all $(TESTPROGS)

utils: all $(UTILS)

install_utils: utils
	@set -x; for i in $(UTILS); do install -m 0700 -o root -s -c $$i /sbin; done

clean:
	rm -f $(PROGS) $(TESTPROGS) $(UTILS) *.o .depend

depend dep:
	$(CPP) -M $(SRCS) > .depend

check_persist.o: check_persist.c
	cc -O -Wall -DMODULE -D__KERNEL__ -c check_persist.c

# include a dependency file if one exists

ifeq (.depend,$(wildcard .depend))
include .depend
endif
