1639a2e50SGarrett Wollman# From: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 269b87d3eSEivind Eklund# $Id: bsd.kmod.mk,v 1.46 1998/03/06 07:28:01 bde Exp $ 353996fadSWolfram Schneider# 453996fadSWolfram Schneider# The include file <bsd.kmod.mk> handles installing Loadable Kernel Modules. 553996fadSWolfram Schneider# 653996fadSWolfram Schneider# 753996fadSWolfram Schneider# +++ variables +++ 853996fadSWolfram Schneider# 953996fadSWolfram Schneider# CLEANFILES Additional files to remove for the clean and cleandir targets. 1053996fadSWolfram Schneider# 1153996fadSWolfram Schneider# DISTRIBUTION Name of distribution. [bin] 1253996fadSWolfram Schneider# 1353996fadSWolfram Schneider# EXPORT_SYMS ??? 1453996fadSWolfram Schneider# 1553996fadSWolfram Schneider# KERN Main Kernel source directory. [${.CURDIR}/../../sys/kern] 1653996fadSWolfram Schneider# 1753996fadSWolfram Schneider# KMOD The name of the loadable kernel module to build. 1853996fadSWolfram Schneider# 1953996fadSWolfram Schneider# KMODDIR Base path for loadable kernel modules 2053996fadSWolfram Schneider# (see lkm(4)). [/lkm] 2153996fadSWolfram Schneider# 2253996fadSWolfram Schneider# KMODOWN LKM owner. [${BINOWN}] 2353996fadSWolfram Schneider# 2453996fadSWolfram Schneider# KMODGRP LKM group. [${BINGRP}] 2553996fadSWolfram Schneider# 2653996fadSWolfram Schneider# KMODMODE LKM mode. [${BINMODE}] 2753996fadSWolfram Schneider# 2853996fadSWolfram Schneider# LINKS The list of LKM links; should be full pathnames, the 2953996fadSWolfram Schneider# linked-to file coming first, followed by the linked 3053996fadSWolfram Schneider# file. The files are hard-linked. For example, to link 3153996fadSWolfram Schneider# /lkm/master and /lkm/meister, use: 3253996fadSWolfram Schneider# 3353996fadSWolfram Schneider# LINKS= /lkm/master /lkm/meister 3453996fadSWolfram Schneider# 3553996fadSWolfram Schneider# LN_FLAGS Flags for ln(1) (see variable LINKS) 3653996fadSWolfram Schneider# 377bc830bbSWolfram Schneider# MODLOAD Command to load a kernel module [/sbin/modload] 387bc830bbSWolfram Schneider# 397bc830bbSWolfram Schneider# MODUNLOAD Command to unload a kernel module [/sbin/modunload] 407bc830bbSWolfram Schneider# 4153996fadSWolfram Schneider# NOMAN LKM does not have a manual page if set. 4253996fadSWolfram Schneider# 4353996fadSWolfram Schneider# PROG The name of the loadable kernel module to build. 447bc830bbSWolfram Schneider# If not supplied, ${KMOD}.o is used. 4553996fadSWolfram Schneider# 4653996fadSWolfram Schneider# PSEUDO_LKM ??? 4753996fadSWolfram Schneider# 4853996fadSWolfram Schneider# SRCS List of source files 4953996fadSWolfram Schneider# 5053996fadSWolfram Schneider# SUBDIR A list of subdirectories that should be built as well. 5153996fadSWolfram Schneider# Each of the targets will execute the same target in the 5253996fadSWolfram Schneider# subdirectories. 5353996fadSWolfram Schneider# 5453996fadSWolfram Schneider# DESTDIR, DISTDIR are set by other Makefiles (e.g. bsd.own.mk) 5553996fadSWolfram Schneider# 5653996fadSWolfram Schneider# 5753996fadSWolfram Schneider# +++ targets +++ 5853996fadSWolfram Schneider# 5953996fadSWolfram Schneider# distribute: 6053996fadSWolfram Schneider# This is a variant of install, which will 6153996fadSWolfram Schneider# put the stuff into the right "distribution". 6253996fadSWolfram Schneider# 6353996fadSWolfram Schneider# install: 6453996fadSWolfram Schneider# install the program and its manual pages; if the Makefile 6553996fadSWolfram Schneider# does not itself define the target install, the targets 6653996fadSWolfram Schneider# beforeinstall and afterinstall may also be used to cause 6753996fadSWolfram Schneider# actions immediately before and after the install target 6853996fadSWolfram Schneider# is executed. 6953996fadSWolfram Schneider# 7053996fadSWolfram Schneider# load: 7153996fadSWolfram Schneider# Load LKM. 7253996fadSWolfram Schneider# 7353996fadSWolfram Schneider# unload: 7453996fadSWolfram Schneider# Unload LKM. 7553996fadSWolfram Schneider# 7653996fadSWolfram Schneider# bsd.obj.mk: clean, cleandir and obj 77161e8999SBruce Evans# bsd.dep.mk: cleandepend, depend and tags 7853996fadSWolfram Schneider# bsd.man.mk: maninstall 7953996fadSWolfram Schneider# 80639a2e50SGarrett Wollman 817bc830bbSWolfram SchneiderMODLOAD?= /sbin/modload 827bc830bbSWolfram SchneiderMODUNLOAD?= /sbin/modunload 837bc830bbSWolfram Schneider 84639a2e50SGarrett Wollman.if exists(${.CURDIR}/../Makefile.inc) 85639a2e50SGarrett Wollman.include "${.CURDIR}/../Makefile.inc" 86639a2e50SGarrett Wollman.endif 87639a2e50SGarrett Wollman 88639a2e50SGarrett Wollman.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S 89639a2e50SGarrett Wollman 904a2d2630SBruce EvansCFLAGS+= ${COPTS} -DKERNEL -DACTUALLY_LKM_NOT_KERNEL ${CWARNFLAGS} 914a2d2630SBruce Evans 92021886ffSBruce Evans# Don't use any standard or source-relative include directories. 93021886ffSBruce Evans# Since -nostdinc will annull any previous -I paths, we repeat all 94021886ffSBruce Evans# such paths after -nostdinc. It doesn't seem to be possible to 95021886ffSBruce Evans# add to the front of `make' variable. 96021886ffSBruce Evans_ICFLAGS:= ${CFLAGS:M-I*} 97021886ffSBruce EvansCFLAGS+= -nostdinc -I- ${_ICFLAGS} 98021886ffSBruce Evans 99021886ffSBruce Evans# Add -I paths for system headers. Individual LKM makefiles don't 100021886ffSBruce Evans# need any -I paths for this. Similar defaults for .PATH can't be 101021886ffSBruce Evans# set because there are no standard paths for non-headers. 1024a2d2630SBruce EvansCFLAGS+= -I${.OBJDIR} -I${.OBJDIR}/@ 1034a2d2630SBruce Evans 104021886ffSBruce Evans# XXX this is now dubious. 105b3e17ba2SSatoshi Asami.if defined(DESTDIR) 106b3e17ba2SSatoshi AsamiCFLAGS+= -I${DESTDIR}/usr/include 107b3e17ba2SSatoshi Asami.endif 10856bac51bSPoul-Henning Kamp 109e9dcb6beSPoul-Henning KampEXPORT_SYMS?= _${KMOD} 110e9dcb6beSPoul-Henning Kamp 1111aa57be3SGarrett Wollman.if defined(VFS_LKM) 1124a2d2630SBruce EvansCFLAGS+= -DVFS_LKM -DMODVNOPS=${KMOD}vnops 1131aa57be3SGarrett WollmanSRCS+= vnode_if.h 1141aa57be3SGarrett WollmanCLEANFILES+= vnode_if.h vnode_if.c 1151aa57be3SGarrett Wollman.endif 1161aa57be3SGarrett Wollman 11727a15c94SGarrett Wollman.if defined(PSEUDO_LKM) 11827a15c94SGarrett WollmanCFLAGS+= -DPSEUDO_LKM 11927a15c94SGarrett Wollman.endif 12027a15c94SGarrett Wollman 121639a2e50SGarrett WollmanOBJS+= ${SRCS:N*.h:R:S/$/.o/g} 122639a2e50SGarrett Wollman 123639a2e50SGarrett Wollman.if !defined(PROG) 124639a2e50SGarrett WollmanPROG= ${KMOD}.o 125639a2e50SGarrett Wollman.endif 126639a2e50SGarrett Wollman 12747da63c3SBruce Evans${PROG}: ${OBJS} ${DPADD} 128a304bf73SPoul-Henning Kamp ${LD} -r ${LDFLAGS} -o tmp.o ${OBJS} 129a304bf73SPoul-Henning Kamp.if defined(EXPORT_SYMS) 130a304bf73SPoul-Henning Kamp @rm -f symb.tmp 131a304bf73SPoul-Henning Kamp @for i in ${EXPORT_SYMS} ; do echo $$i >> symb.tmp ; done 132a304bf73SPoul-Henning Kamp symorder -c symb.tmp tmp.o 133a304bf73SPoul-Henning Kamp @rm -f symb.tmp 134a304bf73SPoul-Henning Kamp.endif 135a304bf73SPoul-Henning Kamp mv tmp.o ${.TARGET} 136639a2e50SGarrett Wollman 1375ce6c3cfSWolfram Schneider.if !defined(NOMAN) 1385ce6c3cfSWolfram Schneider.include <bsd.man.mk> 1395ce6c3cfSWolfram Schneider.if !defined(_MANPAGES) || empty(_MANPAGES) 140639a2e50SGarrett WollmanMAN1= ${KMOD}.4 141639a2e50SGarrett Wollman.endif 142639a2e50SGarrett Wollman 1435ce6c3cfSWolfram Schneider.elif !target(maninstall) 144cd9a2f5cSJordan K. Hubbardmaninstall: _SUBDIR 1455ce6c3cfSWolfram Schneiderall-man: 1465ce6c3cfSWolfram Schneider.endif 1475ce6c3cfSWolfram Schneider 1484a2d2630SBruce Evans_ILINKS=@ machine 149639a2e50SGarrett Wollman 1504a2d2630SBruce Evans.MAIN: all 15147da63c3SBruce Evansall: objwarn ${PROG} all-man _SUBDIR 1524a2d2630SBruce Evans 15347da63c3SBruce Evansbeforedepend ${OBJS}: ${_ILINKS} 1544a2d2630SBruce Evans 1554a2d2630SBruce Evans# The search for the link targets works best if we are in a normal src 1564a2d2630SBruce Evans# tree, and not too deeply below src/lkm. If we are near "/", then 1574a2d2630SBruce Evans# we may find /sys - this is harmless. Other abnormal "sys" directories 1584a2d2630SBruce Evans# found in the search are likely to cause problems. If nothing is found, 1594a2d2630SBruce Evans# then the links default to /usr/include and /usr/include/machine. 1604a2d2630SBruce Evans${_ILINKS}: 1614a2d2630SBruce Evans @for up in ../.. ../../.. ; do \ 1624a2d2630SBruce Evans case ${.TARGET} in \ 1634a2d2630SBruce Evans machine) \ 1644a2d2630SBruce Evans path=${.CURDIR}/$$up/sys/${MACHINE_ARCH}/include ; \ 1654a2d2630SBruce Evans defaultpath=/usr/include/machine ;; \ 1664a2d2630SBruce Evans @) \ 1674a2d2630SBruce Evans path=${.CURDIR}/$$up/sys ; \ 1684a2d2630SBruce Evans defaultpath=/usr/include ;; \ 1694a2d2630SBruce Evans esac ; \ 1704a2d2630SBruce Evans if [ -d $$path ] ; then break ; fi ; \ 1714a2d2630SBruce Evans path=$$defaultpath ; \ 1724a2d2630SBruce Evans done ; \ 1734a2d2630SBruce Evans path=`(cd $$path && /bin/pwd)` ; \ 1744a2d2630SBruce Evans ${ECHO} ${.TARGET} "->" $$path ; \ 1754a2d2630SBruce Evans ln -s $$path ${.TARGET} 1764a2d2630SBruce Evans 1774a2d2630SBruce EvansCLEANFILES+= ${KMOD} ${PROG} ${OBJS} ${_ILINKS} 178639a2e50SGarrett Wollman 179639a2e50SGarrett Wollman.if !target(install) 180639a2e50SGarrett Wollman.if !target(beforeinstall) 181639a2e50SGarrett Wollmanbeforeinstall: 182639a2e50SGarrett Wollman.endif 183639a2e50SGarrett Wollman.if !target(afterinstall) 184639a2e50SGarrett Wollmanafterinstall: 185639a2e50SGarrett Wollman.endif 186639a2e50SGarrett Wollman 187cd9a2f5cSJordan K. Hubbardrealinstall: _SUBDIR 1885ce6c3cfSWolfram Schneider ${INSTALL} ${COPY} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \ 1895ce6c3cfSWolfram Schneider ${INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR} 190639a2e50SGarrett Wollman.if defined(LINKS) && !empty(LINKS) 191639a2e50SGarrett Wollman @set ${LINKS}; \ 192639a2e50SGarrett Wollman while test $$# -ge 2; do \ 193639a2e50SGarrett Wollman l=${DESTDIR}$$1; \ 194639a2e50SGarrett Wollman shift; \ 195639a2e50SGarrett Wollman t=${DESTDIR}$$1; \ 196639a2e50SGarrett Wollman shift; \ 197639a2e50SGarrett Wollman ${ECHO} $$t -\> $$l; \ 198639a2e50SGarrett Wollman rm -f $$t; \ 19960983531SJordan K. Hubbard ln ${LN_FLAGS} $$l $$t; \ 200639a2e50SGarrett Wollman done; true 201639a2e50SGarrett Wollman.endif 202639a2e50SGarrett Wollman 203cd9a2f5cSJordan K. Hubbardinstall: afterinstall _SUBDIR 204639a2e50SGarrett Wollman.if !defined(NOMAN) 205639a2e50SGarrett Wollmanafterinstall: realinstall maninstall 206639a2e50SGarrett Wollman.else 207639a2e50SGarrett Wollmanafterinstall: realinstall 208639a2e50SGarrett Wollman.endif 209639a2e50SGarrett Wollmanrealinstall: beforeinstall 210639a2e50SGarrett Wollman.endif 211639a2e50SGarrett Wollman 212d9584d76SJordan K. HubbardDISTRIBUTION?= bin 21355ff8fb1SPoul-Henning Kamp.if !target(distribute) 214cd9a2f5cSJordan K. Hubbarddistribute: _SUBDIR 215398ac038SJordan K. Hubbard.for dist in ${DISTRIBUTION} 216398ac038SJordan K. Hubbard cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies 217398ac038SJordan K. Hubbard.endfor 21855ff8fb1SPoul-Henning Kamp.endif 21955ff8fb1SPoul-Henning Kamp 220639a2e50SGarrett Wollman.if !target(load) 221639a2e50SGarrett Wollmanload: ${PROG} 2227bc830bbSWolfram Schneider ${MODLOAD} -o ${KMOD} -e${KMOD} ${PROG} 223639a2e50SGarrett Wollman.endif 224639a2e50SGarrett Wollman 225639a2e50SGarrett Wollman.if !target(unload) 226639a2e50SGarrett Wollmanunload: ${PROG} 2277bc830bbSWolfram Schneider ${MODUNLOAD} -n ${KMOD} 228639a2e50SGarrett Wollman.endif 229639a2e50SGarrett Wollman 2301aa57be3SGarrett WollmanKERN= ${.CURDIR}/../../sys/kern 2311aa57be3SGarrett Wollman 2321aa57be3SGarrett Wollmanvnode_if.h: ${KERN}/vnode_if.sh ${KERN}/vnode_if.src 2331aa57be3SGarrett Wollman sh ${KERN}/vnode_if.sh ${KERN}/vnode_if.src 2341aa57be3SGarrett Wollman 23569b87d3eSEivind Eklund_sysregress: ${_INLINKS} ${PROG} 23669b87d3eSEivind Eklund ld -A /sys/compile/LKM/kernel ${PROG} ${DEPLKMS} -o lkm_verify_tmp 23769b87d3eSEivind Eklund rm lkm_verify_tmp 23869b87d3eSEivind Eklund 23969b87d3eSEivind Eklundregress: _sysregress 24069b87d3eSEivind Eklund 241cd9a2f5cSJordan K. Hubbard.include <bsd.obj.mk> 24268e00b92SJordan K. Hubbard.include <bsd.dep.mk> 24347da63c3SBruce Evans 24447da63c3SBruce Evans.if !exists(${DEPENDFILE}) 245589d9341SBruce Evans${OBJS}: ${SRCS:M*.h} 24647da63c3SBruce Evans.endif 24747da63c3SBruce Evans 2489e72552fSBruce Evans.include <bsd.kern.mk> 249