# $Header: /home/cvs/nistnet/kernel/Makefile,v 1.3 2005/04/14 11:27:17 cvs Exp $

# This Makefile is slightly messy, since it compiles both kernel- and
# user-level code.  The user-level flags are passed on to subdirectories.

ARCH = i386

.EXPORT_ALL_VARIABLES:

include ../Config

# We are building three separate kernel modules: nistnet + two add-ons
M_TARGET := nistnet.o
M_TARGET1 := mungemod.o
M_TARGET2 := spymod.o
# th added procfs.o
M_OBJS := knistnet.o tabledist.o nistnet_table.o jenkinshash.o random.o fast_rtc.o fast_sched.o fast_time.o rtc_capture.o procfs.o 
M_OBJS1 := linmunge.o
M_OBJS2 := knistspy.o
MODFLAGS = -DMODULE
MAKING_MODULES=1

ALL_TARGETS= $(M_TARGET) $(M_TARGET1) $(M_TARGET2)

include $(TOPDIR)/.config

# include $(TOPDIR)/Rules.make -- too many problems
# Just include needed rules directly:
# Making kernel .o files:
%.o: %.c
	$(KERNCC) $(KERNCFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<

all: all_targets

all_targets: $(ALL_TARGETS)

$(M_TARGET):	$(M_OBJS)
	$(LD) -r -o $(M_TARGET) $(M_OBJS)

$(M_TARGET1):	$(M_OBJS1)
	$(LD) -r -o $(M_TARGET1) $(M_OBJS1)

$(M_TARGET2):	$(M_OBJS2)
	$(LD) -r -o $(M_TARGET2) $(M_OBJS2)

clean:
	-rm -f *.o $(ALL_TARGETS)

# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory 
# relocations required by build roots.  This is not defined in the
# makefile but the argument can be passed to make if needed.

MODLIB=$(INSTALL_MOD_PATH)/lib/modules/`uname -r`/misc

install: all
	-mkdir $(MODLIB)
	install -o root nistnet.o $(MODLIB) 
	install -o root mungemod.o $(MODLIB)
	install -o root spymod.o $(MODLIB)
	-/sbin/depmod -a > /dev/null 2>&1
# -q flag doesn't work with older versions
# Ignore errors; can get with leftover irrelevant modules

ship: all
	# Ship target not relevant for released Makefile

knistspy.o:	knistspy.c ../include/nistnet.h ../include/nistspy.h

knistnet.o:	knistnet.c ../include/nistnet.h ../include/tabledist.h 
tabledist.o:	../math/tabledist.c ../include/normal.h ../include/pareto.h ../include/paretonormal.h ../include/experimental.h ../include/tabledist.h
	$(KERNCC) $(KERNCFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<

random.o:	../math/random.c ../include/normal.h ../include/pareto.h ../include/paretonormal.h ../include/experimental.h ../include/tabledist.h
	$(KERNCC) $(KERNCFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<


#########################################################################
