1994-09-14 23:59:28 +02:00
|
|
|
# From: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
|
1999-07-31 22:27:33 +02:00
|
|
|
# $Id: bsd.kmod.mk,v 1.61 1999/04/23 20:53:34 peter Exp $
|
1996-05-26 01:09:49 +02: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]
|
|
|
|
#
|
|
|
|
# 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
|
1999-04-23 22:53:34 +02:00
|
|
|
# (see kld(4)). [/modules]
|
1996-05-26 01:09:49 +02:00
|
|
|
#
|
|
|
|
# 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
|
1999-04-20 16:33:24 +02:00
|
|
|
# /modules/master and /modules/meister, use:
|
1996-05-26 01:09:49 +02:00
|
|
|
#
|
1999-04-20 16:33:24 +02:00
|
|
|
# LINKS= /modules/master /modules/meister
|
1996-05-26 01:09:49 +02:00
|
|
|
#
|
1996-10-07 00:10:35 +02:00
|
|
|
# MODLOAD Command to load a kernel module [/sbin/modload]
|
|
|
|
#
|
|
|
|
# MODUNLOAD Command to unload a kernel module [/sbin/modunload]
|
|
|
|
#
|
1996-05-26 01:09:49 +02:00
|
|
|
# NOMAN LKM does not have a manual page if set.
|
|
|
|
#
|
|
|
|
# PROG The name of the loadable kernel module to build.
|
1996-10-07 00:10:35 +02:00
|
|
|
# If not supplied, ${KMOD}.o is used.
|
1996-05-26 01:09:49 +02:00
|
|
|
#
|
|
|
|
# SRCS List of source files
|
|
|
|
#
|
1998-10-02 06:51:10 +02:00
|
|
|
# KMODDEPS List of modules which this one is dependant on
|
|
|
|
#
|
1996-05-26 01:09:49 +02:00
|
|
|
# SUBDIR A list of subdirectories that should be built as well.
|
|
|
|
# Each of the targets will execute the same target in the
|
|
|
|
# subdirectories.
|
|
|
|
#
|
1999-03-23 04:06:25 +01:00
|
|
|
# SYMLINKS Same as LINKS, except it creates symlinks and the
|
|
|
|
# linked-to pathname may be relative.
|
|
|
|
#
|
1996-05-26 01:09:49 +02:00
|
|
|
# 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 16:52:49 +01:00
|
|
|
# bsd.dep.mk: cleandepend, depend and tags
|
1996-05-26 01:09:49 +02:00
|
|
|
# bsd.man.mk: maninstall
|
|
|
|
#
|
1994-09-14 23:59:28 +02:00
|
|
|
|
1996-10-07 00:10:35 +02:00
|
|
|
MODLOAD?= /sbin/modload
|
|
|
|
MODUNLOAD?= /sbin/modunload
|
|
|
|
|
1998-08-08 09:02:08 +02:00
|
|
|
.if !target(__initialized__)
|
|
|
|
__initialized__:
|
1994-09-14 23:59:28 +02:00
|
|
|
.if exists(${.CURDIR}/../Makefile.inc)
|
|
|
|
.include "${.CURDIR}/../Makefile.inc"
|
|
|
|
.endif
|
1998-08-08 09:02:08 +02:00
|
|
|
.endif
|
1994-09-14 23:59:28 +02:00
|
|
|
|
|
|
|
.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
|
|
|
|
|
1998-10-14 06:04:22 +02:00
|
|
|
CFLAGS+= ${COPTS} -DKERNEL ${CWARNFLAGS}
|
1998-10-02 07:08:09 +02:00
|
|
|
CFLAGS+= -DKLD_MODULE
|
1998-01-26 21:36:38 +01:00
|
|
|
|
1998-02-01 18:19:54 +01: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 21:36:38 +01:00
|
|
|
CFLAGS+= -I${.OBJDIR} -I${.OBJDIR}/@
|
|
|
|
|
1998-02-01 18:19:54 +01:00
|
|
|
# XXX this is now dubious.
|
1997-06-18 05:10:31 +02:00
|
|
|
.if defined(DESTDIR)
|
|
|
|
CFLAGS+= -I${DESTDIR}/usr/include
|
|
|
|
.endif
|
1996-04-03 14:08:52 +02:00
|
|
|
|
1998-10-16 05:32:03 +02:00
|
|
|
.if defined(VFS_KLD)
|
1999-04-20 16:33:24 +02:00
|
|
|
SRCS+= vnode_if.h
|
1998-10-16 05:32:03 +02:00
|
|
|
CLEANFILES+= vnode_if.h vnode_if.c
|
|
|
|
.endif
|
|
|
|
|
1999-04-20 16:33:24 +02:00
|
|
|
.if ${OBJFORMAT} == elf
|
1998-10-14 06:04:22 +02:00
|
|
|
CLEANFILES+= setdef0.c setdef1.c setdefs.h
|
|
|
|
CLEANFILES+= setdef0.o setdef1.o
|
|
|
|
.endif
|
|
|
|
|
1994-09-14 23:59:28 +02:00
|
|
|
OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
|
|
|
|
|
|
|
|
.if !defined(PROG)
|
1998-10-02 06:51:10 +02:00
|
|
|
PROG= ${KMOD}.ko
|
|
|
|
.endif
|
1994-09-14 23:59:28 +02:00
|
|
|
|
1998-10-14 06:04:22 +02:00
|
|
|
${PROG}: ${OBJS} ${DPADD} ${KMODDEPS}
|
|
|
|
.if ${OBJFORMAT} == elf
|
|
|
|
gensetdefs ${OBJS}
|
|
|
|
${CC} ${CFLAGS} -c setdef0.c
|
|
|
|
${CC} ${CFLAGS} -c setdef1.c
|
|
|
|
${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} setdef0.o ${OBJS} setdef1.o ${KMODDEPS}
|
|
|
|
.else
|
1998-10-02 06:51:10 +02:00
|
|
|
${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${OBJS} ${KMODDEPS}
|
1998-10-14 06:04:22 +02:00
|
|
|
.endif
|
1994-09-14 23:59:28 +02:00
|
|
|
|
1998-10-14 06:04:22 +02:00
|
|
|
.if defined(KMODDEPS)
|
|
|
|
.for dep in ${KMODDEPS}
|
1998-11-11 08:40:44 +01:00
|
|
|
CLEANFILES+= ${dep} __${dep}_hack_dep.c
|
1998-10-14 06:04:22 +02:00
|
|
|
|
|
|
|
${dep}:
|
1998-11-11 08:40:44 +01:00
|
|
|
touch __${dep}_hack_dep.c
|
|
|
|
${CC} -shared ${CFLAGS} -o ${dep} __${dep}_hack_dep.c
|
1998-10-14 06:04:22 +02:00
|
|
|
.endfor
|
|
|
|
.endif
|
|
|
|
|
1996-04-12 01:03:10 +02:00
|
|
|
.if !defined(NOMAN)
|
|
|
|
.include <bsd.man.mk>
|
|
|
|
.if !defined(_MANPAGES) || empty(_MANPAGES)
|
1994-09-14 23:59:28 +02:00
|
|
|
MAN1= ${KMOD}.4
|
|
|
|
.endif
|
|
|
|
|
1996-04-12 01:03:10 +02:00
|
|
|
.elif !target(maninstall)
|
1996-06-24 06:26:21 +02:00
|
|
|
maninstall: _SUBDIR
|
1996-04-12 01:03:10 +02:00
|
|
|
all-man:
|
|
|
|
.endif
|
|
|
|
|
1998-01-26 21:36:38 +01:00
|
|
|
_ILINKS=@ machine
|
1994-09-14 23:59:28 +02:00
|
|
|
|
1998-01-26 21:36:38 +01:00
|
|
|
.MAIN: all
|
1998-03-06 06:43:46 +01:00
|
|
|
all: objwarn ${PROG} all-man _SUBDIR
|
1998-01-26 21:36:38 +01:00
|
|
|
|
1998-03-06 06:43:46 +01:00
|
|
|
beforedepend ${OBJS}: ${_ILINKS}
|
1998-01-26 21:36:38 +01:00
|
|
|
|
|
|
|
# The search for the link targets works best if we are in a normal src
|
1999-04-20 16:33:24 +02:00
|
|
|
# tree, and not too deeply below src/sys/modules. If we are near "/", then
|
1998-01-26 21:36:38 +01:00
|
|
|
# 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.
|
1998-10-16 05:32:03 +02:00
|
|
|
${_ILINKS}:
|
|
|
|
@set +x; for up in ../.. ../../.. ; do \
|
|
|
|
case ${.TARGET} in \
|
|
|
|
machine) \
|
|
|
|
testpath=${.CURDIR}/$$up/${MACHINE_ARCH}/include ; \
|
|
|
|
path=${.CURDIR}/$$up/${MACHINE_ARCH}/include ; \
|
|
|
|
defaultpath=/usr/include/machine ;; \
|
|
|
|
@) \
|
|
|
|
testpath=${.CURDIR}/$$up/sys ; \
|
|
|
|
path=${.CURDIR}/$$up ; \
|
|
|
|
defaultpath=/usr/include ;; \
|
|
|
|
esac ; \
|
|
|
|
if [ -d $$testpath ] ; then break ; fi ; \
|
|
|
|
path=$$defaultpath ; \
|
|
|
|
done ; \
|
|
|
|
path=`(cd $$path && /bin/pwd)` ; \
|
|
|
|
${ECHO} ${.TARGET} "->" $$path ; \
|
|
|
|
ln -s $$path ${.TARGET}
|
1998-01-26 21:36:38 +01:00
|
|
|
|
1999-04-20 16:33:24 +02:00
|
|
|
CLEANFILES+= ${PROG} ${OBJS} ${_ILINKS} symb.tmp tmp.o
|
1994-09-14 23:59:28 +02:00
|
|
|
|
|
|
|
.if !target(install)
|
|
|
|
.if !target(beforeinstall)
|
|
|
|
beforeinstall:
|
|
|
|
.endif
|
|
|
|
.if !target(afterinstall)
|
|
|
|
afterinstall:
|
|
|
|
.endif
|
|
|
|
|
1999-07-31 22:27:33 +02:00
|
|
|
_INSTALLFLAGS:= ${INSTALLFLAGS}
|
|
|
|
.for ie in ${INSTALLFLAGS_EDIT}
|
|
|
|
_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
|
|
|
|
.endfor
|
|
|
|
|
1996-06-24 06:26:21 +02:00
|
|
|
realinstall: _SUBDIR
|
1996-04-12 01:03:10 +02:00
|
|
|
${INSTALL} ${COPY} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
|
1999-07-31 22:27:33 +02:00
|
|
|
${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
|
1994-09-14 23:59:28 +02:00
|
|
|
.if defined(LINKS) && !empty(LINKS)
|
|
|
|
@set ${LINKS}; \
|
|
|
|
while test $$# -ge 2; do \
|
|
|
|
l=${DESTDIR}$$1; \
|
|
|
|
shift; \
|
|
|
|
t=${DESTDIR}$$1; \
|
|
|
|
shift; \
|
|
|
|
${ECHO} $$t -\> $$l; \
|
1999-03-23 04:06:25 +01:00
|
|
|
ln -f $$l $$t; \
|
|
|
|
done; true
|
|
|
|
.endif
|
|
|
|
.if defined(SYMLINKS) && !empty(SYMLINKS)
|
|
|
|
@set ${SYMLINKS}; \
|
|
|
|
while test $$# -ge 2; do \
|
|
|
|
l=$$1; \
|
|
|
|
shift; \
|
|
|
|
t=${DESTDIR}$$1; \
|
|
|
|
shift; \
|
|
|
|
${ECHO} $$t -\> $$l; \
|
|
|
|
ln -fs $$l $$t; \
|
1994-09-14 23:59:28 +02:00
|
|
|
done; true
|
|
|
|
.endif
|
|
|
|
|
1996-06-24 06:26:21 +02:00
|
|
|
install: afterinstall _SUBDIR
|
1994-09-14 23:59:28 +02:00
|
|
|
.if !defined(NOMAN)
|
|
|
|
afterinstall: realinstall maninstall
|
|
|
|
.else
|
|
|
|
afterinstall: realinstall
|
|
|
|
.endif
|
|
|
|
realinstall: beforeinstall
|
|
|
|
.endif
|
|
|
|
|
1995-01-14 08:51:10 +01:00
|
|
|
DISTRIBUTION?= bin
|
1994-11-13 22:05:28 +01:00
|
|
|
.if !target(distribute)
|
1996-06-24 06:26:21 +02:00
|
|
|
distribute: _SUBDIR
|
1997-06-21 17:40:34 +02:00
|
|
|
.for dist in ${DISTRIBUTION}
|
|
|
|
cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
|
|
|
|
.endfor
|
1994-11-13 22:05:28 +01:00
|
|
|
.endif
|
|
|
|
|
1994-09-14 23:59:28 +02:00
|
|
|
.if !target(load)
|
|
|
|
load: ${PROG}
|
1996-10-07 00:10:35 +02:00
|
|
|
${MODLOAD} -o ${KMOD} -e${KMOD} ${PROG}
|
1994-09-14 23:59:28 +02:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !target(unload)
|
|
|
|
unload: ${PROG}
|
1996-10-07 00:10:35 +02:00
|
|
|
${MODUNLOAD} -n ${KMOD}
|
1994-09-14 23:59:28 +02:00
|
|
|
.endif
|
|
|
|
|
1998-10-16 05:32:03 +02:00
|
|
|
.if exists(${.CURDIR}/../../kern)
|
|
|
|
KERN= ${.CURDIR}/../../kern
|
|
|
|
.else
|
1994-09-21 05:49:59 +02:00
|
|
|
KERN= ${.CURDIR}/../../sys/kern
|
1998-10-16 05:32:03 +02:00
|
|
|
.endif
|
1994-09-21 05:49:59 +02:00
|
|
|
|
|
|
|
vnode_if.h: ${KERN}/vnode_if.sh ${KERN}/vnode_if.src
|
|
|
|
sh ${KERN}/vnode_if.sh ${KERN}/vnode_if.src
|
|
|
|
|
1999-04-20 16:33:24 +02:00
|
|
|
regress:
|
1998-03-12 21:02:17 +01:00
|
|
|
|
1996-07-01 00:16:19 +02:00
|
|
|
.include <bsd.dep.mk>
|
1998-03-06 06:43:46 +01:00
|
|
|
|
|
|
|
.if !exists(${DEPENDFILE})
|
1998-03-06 08:28:01 +01:00
|
|
|
${OBJS}: ${SRCS:M*.h}
|
1998-03-06 06:43:46 +01:00
|
|
|
.endif
|
|
|
|
|
1998-06-09 04:55:40 +02:00
|
|
|
.include <bsd.obj.mk>
|
|
|
|
|
1996-10-09 00:09:03 +02:00
|
|
|
.include <bsd.kern.mk>
|