#
# 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
#
# If you have gdbm, and if you want to use it for persistent module storage,
# remove (or comment) the following line:
NO_GDBM=-DNO_GDBM
#


MANDIR=/usr/man/man8
CFLAGS = -O6 -pipe -fomit-frame-pointer -Wall $(DEBUG) $(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)

kerneld: kerneld.o

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
