1994-09-14 21:59:28 +00:00
|
|
|
# From: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
|
1998-03-19 13:22:46 +00:00
|
|
|
# $Id: bsd.kmod.mk,v 1.47 1998/03/12 20:02:11 eivind Exp $
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
|
|
|
# The include file <bsd.kmod.mk> handles installing Loadable Kernel Modules.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# +++ variables +++
|
|
|
|
#
|
|
|
|
# CLEANFILES Additional files to remove for the clean and cleandir targets.
|
|
|
|
#
|
|
|
|
# DISTRIBUTION Name of distribution. [bin]
|
|
|
|
#
|
|
|
|
# EXPORT_SYMS ???
|
|
|
|
#
|
|
|
|
# KERN Main Kernel source directory. [${.CURDIR}/../../sys/kern]
|
|
|
|
#
|
|
|
|
# KMOD The name of the loadable kernel module to build.
|
|
|
|
#
|
|
|
|
# KMODDIR Base path for loadable kernel modules
|
|
|
|
# (see lkm(4)). [/lkm]
|
|
|
|
#
|
|
|
|
# KMODOWN LKM owner. [${BINOWN}]
|
|
|
|
#
|
|
|
|
# KMODGRP LKM group. [${BINGRP}]
|
|
|
|
#
|
|
|
|
# KMODMODE LKM mode. [${BINMODE}]
|
|
|
|
#
|
|
|
|
# LINKS The list of LKM links; should be full pathnames, the
|
|
|
|
# linked-to file coming first, followed by the linked
|
|
|
|
# file. The files are hard-linked. For example, to link
|
|
|
|
# /lkm/master and /lkm/meister, use:
|
|
|
|
#
|
|
|
|
# LINKS= /lkm/master /lkm/meister
|
|
|
|
#
|
|
|
|
# LN_FLAGS Flags for ln(1) (see variable LINKS)
|
|
|
|
#
|
1996-10-06 22:10:35 +00:00
|
|
|
# MODLOAD Command to load a kernel module [/sbin/modload]
|
|
|
|
#
|
|
|
|
# MODUNLOAD Command to unload a kernel module [/sbin/modunload]
|
|
|
|
#
|
1996-05-25 23:09:49 +00:00
|
|
|
# NOMAN LKM does not have a manual page if set.
|
|
|
|
#
|
|
|
|
# PROG The name of the loadable kernel module to build.
|
1996-10-06 22:10:35 +00:00
|
|
|
# If not supplied, ${KMOD}.o is used.
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
|
|
|
# PSEUDO_LKM ???
|
|
|
|
#
|
|
|
|
# SRCS List of source files
|
|
|
|
#
|
|
|
|
# SUBDIR A list of subdirectories that should be built as well.
|
|
|
|
# Each of the targets will execute the same target in the
|
|
|
|
# subdirectories.
|
|
|
|
#
|
|
|
|
# DESTDIR, DISTDIR are set by other Makefiles (e.g. bsd.own.mk)
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# +++ targets +++
|
|
|
|
#
|
|
|
|
# distribute:
|
|
|
|
# This is a variant of install, which will
|
|
|
|
# put the stuff into the right "distribution".
|
|
|
|
#
|
|
|
|
# install:
|
|
|
|
# install the program and its manual pages; if the Makefile
|
|
|
|
# does not itself define the target install, the targets
|
|
|
|
# beforeinstall and afterinstall may also be used to cause
|
|
|
|
# actions immediately before and after the install target
|
|
|
|
# is executed.
|
|
|
|
#
|
|
|
|
# load:
|
|
|
|
# Load LKM.
|
|
|
|
#
|
|
|
|
# unload:
|
|
|
|
# Unload LKM.
|
|
|
|
#
|
|
|
|
# bsd.obj.mk: clean, cleandir and obj
|
1998-02-20 15:52:49 +00:00
|
|
|
# bsd.dep.mk: cleandepend, depend and tags
|
1996-05-25 23:09:49 +00:00
|
|
|
# bsd.man.mk: maninstall
|
|
|
|
#
|
1994-09-14 21:59:28 +00:00
|
|
|
|
1996-10-06 22:10:35 +00:00
|
|
|
MODLOAD?= /sbin/modload
|
|
|
|
MODUNLOAD?= /sbin/modunload
|
|
|
|
|
1994-09-14 21:59:28 +00:00
|
|
|
.if exists(${.CURDIR}/../Makefile.inc)
|
|
|
|
.include "${.CURDIR}/../Makefile.inc"
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
|
|
|
|
|
1998-01-26 20:36:38 +00:00
|
|
|
CFLAGS+= ${COPTS} -DKERNEL -DACTUALLY_LKM_NOT_KERNEL ${CWARNFLAGS}
|
|
|
|
|
1998-02-01 17:19:54 +00:00
|
|
|
# Don't use any standard or source-relative include directories.
|
|
|
|
# Since -nostdinc will annull any previous -I paths, we repeat all
|
|
|
|
# such paths after -nostdinc. It doesn't seem to be possible to
|
|
|
|
# add to the front of `make' variable.
|
|
|
|
_ICFLAGS:= ${CFLAGS:M-I*}
|
|
|
|
CFLAGS+= -nostdinc -I- ${_ICFLAGS}
|
|
|
|
|
|
|
|
# Add -I paths for system headers. Individual LKM makefiles don't
|
|
|
|
# need any -I paths for this. Similar defaults for .PATH can't be
|
|
|
|
# set because there are no standard paths for non-headers.
|
1998-01-26 20:36:38 +00:00
|
|
|
CFLAGS+= -I${.OBJDIR} -I${.OBJDIR}/@
|
|
|
|
|
1998-02-01 17:19:54 +00:00
|
|
|
# XXX this is now dubious.
|
1997-06-18 03:10:31 +00:00
|
|
|
.if defined(DESTDIR)
|
|
|
|
CFLAGS+= -I${DESTDIR}/usr/include
|
|
|
|
.endif
|
1996-04-03 12:08:52 +00:00
|
|
|
|
1995-10-15 16:56:56 +00:00
|
|
|
EXPORT_SYMS?= _${KMOD}
|
|
|
|
|
1994-09-21 03:49:59 +00:00
|
|
|
.if defined(VFS_LKM)
|
1998-01-26 20:36:38 +00:00
|
|
|
CFLAGS+= -DVFS_LKM -DMODVNOPS=${KMOD}vnops
|
1994-09-21 03:49:59 +00:00
|
|
|
SRCS+= vnode_if.h
|
|
|
|
CLEANFILES+= vnode_if.h vnode_if.c
|
|
|
|
.endif
|
|
|
|
|
1995-03-20 19:18:51 +00:00
|
|
|
.if defined(PSEUDO_LKM)
|
|
|
|
CFLAGS+= -DPSEUDO_LKM
|
|
|
|
.endif
|
|
|
|
|
1994-09-14 21:59:28 +00:00
|
|
|
OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
|
|
|
|
|
|
|
|
.if !defined(PROG)
|
|
|
|
PROG= ${KMOD}.o
|
|
|
|
.endif
|
|
|
|
|
1998-03-06 05:43:46 +00:00
|
|
|
${PROG}: ${OBJS} ${DPADD}
|
1995-10-15 14:32:26 +00:00
|
|
|
${LD} -r ${LDFLAGS} -o tmp.o ${OBJS}
|
|
|
|
.if defined(EXPORT_SYMS)
|
|
|
|
@rm -f symb.tmp
|
|
|
|
@for i in ${EXPORT_SYMS} ; do echo $$i >> symb.tmp ; done
|
|
|
|
symorder -c symb.tmp tmp.o
|
|
|
|
@rm -f symb.tmp
|
|
|
|
.endif
|
|
|
|
mv tmp.o ${.TARGET}
|
1994-09-14 21:59:28 +00:00
|
|
|
|
1996-04-11 23:03:10 +00:00
|
|
|
.if !defined(NOMAN)
|
|
|
|
.include <bsd.man.mk>
|
|
|
|
.if !defined(_MANPAGES) || empty(_MANPAGES)
|
1994-09-14 21:59:28 +00:00
|
|
|
MAN1= ${KMOD}.4
|
|
|
|
.endif
|
|
|
|
|
1996-04-11 23:03:10 +00:00
|
|
|
.elif !target(maninstall)
|
1996-06-24 04:26:21 +00:00
|
|
|
maninstall: _SUBDIR
|
1996-04-11 23:03:10 +00:00
|
|
|
all-man:
|
|
|
|
.endif
|
|
|
|
|
1998-01-26 20:36:38 +00:00
|
|
|
_ILINKS=@ machine
|
1994-09-14 21:59:28 +00:00
|
|
|
|
1998-01-26 20:36:38 +00:00
|
|
|
.MAIN: all
|
1998-03-06 05:43:46 +00:00
|
|
|
all: objwarn ${PROG} all-man _SUBDIR
|
1998-01-26 20:36:38 +00:00
|
|
|
|
1998-03-06 05:43:46 +00:00
|
|
|
beforedepend ${OBJS}: ${_ILINKS}
|
1998-01-26 20:36:38 +00:00
|
|
|
|
|
|
|
# The search for the link targets works best if we are in a normal src
|
|
|
|
# tree, and not too deeply below src/lkm. If we are near "/", then
|
|
|
|
# we may find /sys - this is harmless. Other abnormal "sys" directories
|
|
|
|
# found in the search are likely to cause problems. If nothing is found,
|
|
|
|
# then the links default to /usr/include and /usr/include/machine.
|
|
|
|
${_ILINKS}:
|
|
|
|
@for up in ../.. ../../.. ; do \
|
|
|
|
case ${.TARGET} in \
|
|
|
|
machine) \
|
|
|
|
path=${.CURDIR}/$$up/sys/${MACHINE_ARCH}/include ; \
|
|
|
|
defaultpath=/usr/include/machine ;; \
|
|
|
|
@) \
|
|
|
|
path=${.CURDIR}/$$up/sys ; \
|
|
|
|
defaultpath=/usr/include ;; \
|
|
|
|
esac ; \
|
|
|
|
if [ -d $$path ] ; then break ; fi ; \
|
|
|
|
path=$$defaultpath ; \
|
|
|
|
done ; \
|
|
|
|
path=`(cd $$path && /bin/pwd)` ; \
|
|
|
|
${ECHO} ${.TARGET} "->" $$path ; \
|
|
|
|
ln -s $$path ${.TARGET}
|
|
|
|
|
1998-03-19 13:22:46 +00:00
|
|
|
CLEANFILES+= ${KMOD} ${PROG} ${OBJS} ${_ILINKS} lkm_verify_tmp symb.tmp tmp.o
|
1994-09-14 21:59:28 +00:00
|
|
|
|
|
|
|
.if !target(install)
|
|
|
|
.if !target(beforeinstall)
|
|
|
|
beforeinstall:
|
|
|
|
.endif
|
|
|
|
.if !target(afterinstall)
|
|
|
|
afterinstall:
|
|
|
|
.endif
|
|
|
|
|
1996-06-24 04:26:21 +00:00
|
|
|
realinstall: _SUBDIR
|
1996-04-11 23:03:10 +00:00
|
|
|
${INSTALL} ${COPY} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
|
|
|
|
${INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
|
1994-09-14 21:59:28 +00:00
|
|
|
.if defined(LINKS) && !empty(LINKS)
|
|
|
|
@set ${LINKS}; \
|
|
|
|
while test $$# -ge 2; do \
|
|
|
|
l=${DESTDIR}$$1; \
|
|
|
|
shift; \
|
|
|
|
t=${DESTDIR}$$1; \
|
|
|
|
shift; \
|
|
|
|
${ECHO} $$t -\> $$l; \
|
|
|
|
rm -f $$t; \
|
1995-01-30 07:22:02 +00:00
|
|
|
ln ${LN_FLAGS} $$l $$t; \
|
1994-09-14 21:59:28 +00:00
|
|
|
done; true
|
|
|
|
.endif
|
|
|
|
|
1996-06-24 04:26:21 +00:00
|
|
|
install: afterinstall _SUBDIR
|
1994-09-14 21:59:28 +00:00
|
|
|
.if !defined(NOMAN)
|
|
|
|
afterinstall: realinstall maninstall
|
|
|
|
.else
|
|
|
|
afterinstall: realinstall
|
|
|
|
.endif
|
|
|
|
realinstall: beforeinstall
|
|
|
|
.endif
|
|
|
|
|
1995-01-14 07:51:10 +00:00
|
|
|
DISTRIBUTION?= bin
|
1994-11-13 21:05:28 +00:00
|
|
|
.if !target(distribute)
|
1996-06-24 04:26:21 +00:00
|
|
|
distribute: _SUBDIR
|
1997-06-21 15:40:34 +00:00
|
|
|
.for dist in ${DISTRIBUTION}
|
|
|
|
cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
|
|
|
|
.endfor
|
1994-11-13 21:05:28 +00:00
|
|
|
.endif
|
|
|
|
|
1994-09-14 21:59:28 +00:00
|
|
|
.if !target(load)
|
|
|
|
load: ${PROG}
|
1996-10-06 22:10:35 +00:00
|
|
|
${MODLOAD} -o ${KMOD} -e${KMOD} ${PROG}
|
1994-09-14 21:59:28 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !target(unload)
|
|
|
|
unload: ${PROG}
|
1996-10-06 22:10:35 +00:00
|
|
|
${MODUNLOAD} -n ${KMOD}
|
1994-09-14 21:59:28 +00:00
|
|
|
.endif
|
|
|
|
|
1994-09-21 03:49:59 +00:00
|
|
|
KERN= ${.CURDIR}/../../sys/kern
|
|
|
|
|
|
|
|
vnode_if.h: ${KERN}/vnode_if.sh ${KERN}/vnode_if.src
|
|
|
|
sh ${KERN}/vnode_if.sh ${KERN}/vnode_if.src
|
|
|
|
|
1998-03-12 20:02:17 +00:00
|
|
|
_sysregress: ${_INLINKS} ${PROG}
|
|
|
|
ld -A /sys/compile/LKM/kernel ${PROG} ${DEPLKMS} -o lkm_verify_tmp
|
|
|
|
rm lkm_verify_tmp
|
|
|
|
|
|
|
|
regress: _sysregress
|
|
|
|
|
1996-06-24 04:26:21 +00:00
|
|
|
.include <bsd.obj.mk>
|
1996-06-30 22:16:19 +00:00
|
|
|
.include <bsd.dep.mk>
|
1998-03-06 05:43:46 +00:00
|
|
|
|
|
|
|
.if !exists(${DEPENDFILE})
|
1998-03-06 07:28:01 +00:00
|
|
|
${OBJS}: ${SRCS:M*.h}
|
1998-03-06 05:43:46 +00:00
|
|
|
.endif
|
|
|
|
|
1996-10-08 22:09:03 +00:00
|
|
|
.include <bsd.kern.mk>
|