# Usage: all (load+stat+read+unload) or separately, or build KERNELNAME = GENKERNEL KERNELBASEDIR = sys # some heuristics to automate KERNELNAME: #.if ${MACHINE} == "i386" #.if ${HOSTNAME} == "idli.cs.rice.edu" # KERNELNAME = IDLI #.else # KERNELNAME = KERNEL #.endif KMODMK = ${SHAREDIR}/mk/bsd.kmod.mk #.elif ${MACHINE} == "alpha" # KERNELNAME = ALKERNEL # KMODMK = /usr/src/sys.orig/conf/kmod.mk #.endif #otherwise set this# KERNELNAME = KERNEL # ------------ don't touch anything below this ------------ RELPATH != echo $(KERNELBASEDIR) | grep ^/ >/dev/null || echo n .if $(RELPATH) == "n" KERNELBASEDIR := ../$(KERNELBASEDIR) .endif FULL_KERNELDIR = $(KERNELBASEDIR)/compile/$(KERNELNAME) MODNAME = antsched SRCS != cd ..; /bin/ls *.c *.s 2>/dev/null; true KMOD = $(MODNAME)_mod CC = gcc CFLAGS = -Wall -Werror -O -DMODULE -DKMOD=$(MODNAME) -DKMODSTR='"$(MODNAME)"'\ -fvolatile -I. -I.. -I$(KERNELBASEDIR) -I$(FULL_KERNELDIR) CWARNFLAGS = CLEANFILES = *.o KLDMOD = true NOOBJ = 1 VERBOSE = -v ODIR = ${.CURDIR}/obj.${MACHINE} KILLONEXIT = rc prop bench util vmstat monitor httpd aio mysqld OS != uname -s .if ${OS} != "FreeBSD" .error OSs other than FreeBSD unsupported. .endif .if $(.CURDIR) == $(.OBJDIR) .error You should have an OBJ directory $(ODIR) .elif $(ODIR) != $(.OBJDIR) .error Weird OBJ directory $(.OBJDIR); was expecting $(ODIR) .endif V != test -f kmod.mk; echo $$? .if ${V} == 1 V != grep -v '^CFLAGS.*nostdinc' $(KMODMK) >kmod.mk .endif .ifnmake clean && distclean && tags && depend X != test -f .depend_done || (>.depend_done; cd ..; (make depend >&2) || echo make-depend failed) .if $(X) != "" Y != rm -f .depend_done .error $(X) .endif .endif all: load stat read unload reload: unload load re: reload build: $(KMOD).ko load: build @#rosh -c mountr @purge /larder/file/file* @if kldstat -n $(KMOD) >/dev/null 2>&1; then echo "Uggh: load: $(KMOD) already loaded"; false; else true; fi @eval "rosh -c 'killall syslogd portmap cron >/dev/null 2>&1; sync; kldload $(VERBOSE) `pwd`/${KMOD}.ko'" @#eval "killall -USR1 hang; true" stat: @[ "x$(VERBOSE)" != "x" ] && kldstat; true read: @echo "Press enter to unload $(KMOD).." >/dev/tty; read x /dev/null 2>&1; then true; else echo "Uggh: unload: $(KMOD) not loaded"; false; fi @bash -c 'killall -TERM $(KILLONEXIT) 2>/dev/null; true' @bash -c 'killall -KILL $(KILLONEXIT) 2>/dev/null; true' @bash -c 'killall -CONT $(KILLONEXIT) 2>/dev/null; true' @eval "rosh -c 'kldunload $(VERBOSE) -n ${KMOD}'" @#rosh -c mountr apic.o: apic.s gcc -O2 -Wall -DLOCORE -c -x assembler-with-cpp $< .include "./kmod.mk" distclean: clean rm -f ../tags ../obj.*/.depend* ../obj.*/* ../errors.err @(cd ../postime && make clean) @(cd ../etc && make clean) tags: _tags # to force remaking for every make tags _tags: @(cd ..; bash -c 'ctags {,{postime,$(KERNELBASEDIR)/{sys,vm,net,netinet,{cam,cam/scsi},compile/$(KERNELNAME),i386/{i386,isa,include},kern,pci,ufs/{ufs,ffs},dev/{ata,syscons}}}/}*.{c,h}')