kmod.mk revision 26760
1254721Semaste# From: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 2254721Semaste# $Id: bsd.kmod.mk,v 1.37 1997/06/18 03:10:31 asami Exp $ 3254721Semaste# 4254721Semaste# The include file <bsd.kmod.mk> handles installing Loadable Kernel Modules. 5254721Semaste# <bsd.kmod.mk> includes the file named "../Makefile.inc" if it exists, 6254721Semaste# as well as the include file <bsd.obj.mk>, <bsd.dep.mk>, and 7254721Semaste# may be <bsd.man.mk> 8254721Semaste# 9254721Semaste# 10254721Semaste# +++ variables +++ 11254721Semaste# 12254721Semaste# CLEANFILES Additional files to remove for the clean and cleandir targets. 13254721Semaste# 14254721Semaste# DISTRIBUTION Name of distribution. [bin] 15254721Semaste# 16254721Semaste# EXPORT_SYMS ??? 17254721Semaste# 18254721Semaste# KERN Main Kernel source directory. [${.CURDIR}/../../sys/kern] 19254721Semaste# 20254721Semaste# KMOD The name of the loadable kernel module to build. 21254721Semaste# 22254721Semaste# KMODDIR Base path for loadable kernel modules 23254721Semaste# (see lkm(4)). [/lkm] 24254721Semaste# 25254721Semaste# KMODOWN LKM owner. [${BINOWN}] 26254721Semaste# 27254721Semaste# KMODGRP LKM group. [${BINGRP}] 28254721Semaste# 29254721Semaste# KMODMODE LKM mode. [${BINMODE}] 30254721Semaste# 31254721Semaste# LINKS The list of LKM links; should be full pathnames, the 32254721Semaste# linked-to file coming first, followed by the linked 33254721Semaste# file. The files are hard-linked. For example, to link 34254721Semaste# /lkm/master and /lkm/meister, use: 35254721Semaste# 36254721Semaste# LINKS= /lkm/master /lkm/meister 37254721Semaste# 38254721Semaste# LN_FLAGS Flags for ln(1) (see variable LINKS) 39254721Semaste# 40254721Semaste# MODLOAD Command to load a kernel module [/sbin/modload] 41254721Semaste# 42254721Semaste# MODUNLOAD Command to unload a kernel module [/sbin/modunload] 43254721Semaste# 44254721Semaste# NOMAN LKM does not have a manual page if set. 45254721Semaste# 46254721Semaste# PROG The name of the loadable kernel module to build. 47254721Semaste# If not supplied, ${KMOD}.o is used. 48254721Semaste# 49254721Semaste# PSEUDO_LKM ??? 50254721Semaste# 51254721Semaste# SRCS List of source files 52254721Semaste# 53254721Semaste# SUBDIR A list of subdirectories that should be built as well. 54254721Semaste# Each of the targets will execute the same target in the 55254721Semaste# subdirectories. 56254721Semaste# 57254721Semaste# DESTDIR, DISTDIR are set by other Makefiles (e.g. bsd.own.mk) 58254721Semaste# 59254721Semaste# 60254721Semaste# +++ targets +++ 61254721Semaste# 62254721Semaste# distribute: 63254721Semaste# This is a variant of install, which will 64254721Semaste# put the stuff into the right "distribution". 65254721Semaste# 66254721Semaste# install: 67254721Semaste# install the program and its manual pages; if the Makefile 68254721Semaste# does not itself define the target install, the targets 69254721Semaste# beforeinstall and afterinstall may also be used to cause 70254721Semaste# actions immediately before and after the install target 71254721Semaste# is executed. 72254721Semaste# 73254721Semaste# load: 74254721Semaste# Load LKM. 75254721Semaste# 76254721Semaste# tags: 77254721Semaste# Create a tags file for the source files. 78254721Semaste# 79254721Semaste# unload: 80254721Semaste# Unload LKM. 81254721Semaste# 82254721Semaste# bsd.obj.mk: clean, cleandir and obj 83254721Semaste# bsd.dep.mk: depend 84254721Semaste# bsd.man.mk: maninstall 85254721Semaste# 86254721Semaste 87254721SemasteMODLOAD?= /sbin/modload 88254721SemasteMODUNLOAD?= /sbin/modunload 89254721Semaste 90254721Semaste.if exists(${.CURDIR}/../Makefile.inc) 91254721Semaste.include "${.CURDIR}/../Makefile.inc" 92254721Semaste.endif 93254721Semaste 94254721Semaste.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S 95254721Semaste 96254721Semaste# 97254721Semaste# A temporary fix to survive SMP changes. 98254721Semaste# 99254721SemasteCFLAGS+= -I. 100254721SemasteCLEANFILES+= ${SMPHDRS} 101254721SemasteSMPHDRS= opt_smp.h 102254721Semaste 103254721Semastebeforedepend: ${SMPHDRS} 104254721Semaste 105254721Semaste${SMPHDRS}: 106254721Semaste touch ${.TARGET} 107254721Semaste 108254721Semaste# 109254721Semaste# Assume that we are in /usr/src/foo/bar, so /sys is 110254721Semaste# ${.CURDIR}/../../sys. We don't bother adding a .PATH since nothing 111254721Semaste# actually lives in /sys directly. 112254721Semaste# 113254721SemasteCFLAGS+=${COPTS} -DKERNEL -DACTUALLY_LKM_NOT_KERNEL -I${.CURDIR}/../../sys \ 114254721Semaste ${CWARNFLAGS} 115254721Semaste.if defined(DESTDIR) 116254721SemasteCFLAGS+= -I${DESTDIR}/usr/include 117254721Semaste.endif 118254721Semaste 119254721SemasteEXPORT_SYMS?= _${KMOD} 120254721Semaste 121254721Semaste.if defined(VFS_LKM) 122254721SemasteCFLAGS+= -DVFS_LKM -DMODVNOPS=${KMOD}vnops -I. 123254721SemasteSRCS+= vnode_if.h 124254721SemasteCLEANFILES+= vnode_if.h vnode_if.c 125254721Semaste.endif 126254721Semaste 127254721Semaste.if defined(PSEUDO_LKM) 128254721SemasteCFLAGS+= -DPSEUDO_LKM 129254721Semaste.endif 130254721Semaste 131254721SemasteDPSRCS+= ${SRCS:M*.h} 132254721SemasteOBJS+= ${SRCS:N*.h:R:S/$/.o/g} 133254721Semaste 134254721Semaste.if !defined(PROG) 135254721SemastePROG= ${KMOD}.o 136254721Semaste.endif 137254721Semaste 138254721Semaste${PROG}: ${DPSRCS} ${OBJS} ${DPADD} 139254721Semaste ${LD} -r ${LDFLAGS} -o tmp.o ${OBJS} 140254721Semaste.if defined(EXPORT_SYMS) 141254721Semaste @rm -f symb.tmp 142254721Semaste @for i in ${EXPORT_SYMS} ; do echo $$i >> symb.tmp ; done 143254721Semaste symorder -c symb.tmp tmp.o 144254721Semaste @rm -f symb.tmp 145254721Semaste.endif 146254721Semaste mv tmp.o ${.TARGET} 147254721Semaste 148254721Semaste# Temporary SMP fix continued. 149254721Semaste${OBJS}: ${SMPHDRS} 150254721Semaste 151254721Semaste.if !defined(NOMAN) 152254721Semaste.include <bsd.man.mk> 153254721Semaste.if !defined(_MANPAGES) || empty(_MANPAGES) 154254721SemasteMAN1= ${KMOD}.4 155254721Semaste.endif 156254721Semaste 157254721Semaste.elif !target(maninstall) 158254721Semastemaninstall: _SUBDIR 159254721Semasteall-man: 160254721Semaste.endif 161254721Semaste 162254721Semaste.MAIN: all 163254721Semasteall: objwarn ${PROG} all-man _SUBDIR 164254721Semaste 165254721SemasteCLEANFILES+=${PROG} ${OBJS} 166254721Semaste 167254721Semaste.if !target(install) 168254721Semaste.if !target(beforeinstall) 169254721Semastebeforeinstall: 170254721Semaste.endif 171254721Semaste.if !target(afterinstall) 172254721Semasteafterinstall: 173254721Semaste.endif 174254721Semaste 175254721Semasterealinstall: _SUBDIR 176254721Semaste ${INSTALL} ${COPY} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \ 177254721Semaste ${INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR} 178254721Semaste.if defined(LINKS) && !empty(LINKS) 179254721Semaste @set ${LINKS}; \ 180254721Semaste while test $$# -ge 2; do \ 181254721Semaste l=${DESTDIR}$$1; \ 182254721Semaste shift; \ 183254721Semaste t=${DESTDIR}$$1; \ 184254721Semaste shift; \ 185254721Semaste ${ECHO} $$t -\> $$l; \ 186254721Semaste rm -f $$t; \ 187254721Semaste ln ${LN_FLAGS} $$l $$t; \ 188254721Semaste done; true 189254721Semaste.endif 190254721Semaste 191254721Semasteinstall: afterinstall _SUBDIR 192254721Semaste.if !defined(NOMAN) 193254721Semasteafterinstall: realinstall maninstall 194254721Semaste.else 195254721Semasteafterinstall: realinstall 196254721Semaste.endif 197254721Semasterealinstall: beforeinstall 198254721Semaste.endif 199254721Semaste 200254721SemasteDISTRIBUTION?= bin 201254721Semaste.if !target(distribute) 202254721Semastedistribute: _SUBDIR 203254721Semaste.for dist in ${DISTRIBUTION} 204254721Semaste cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies 205254721Semaste.endfor 206254721Semaste.endif 207254721Semaste 208254721Semaste.if defined(NOTAGS) 209254721Semastetags: 210254721Semaste.endif 211254721Semaste 212254721Semaste.if !target(tags) 213254721Semastetags: ${SRCS} _SUBDIR 214254721Semaste.if defined(PROG) 215254721Semaste @cd ${.CURDIR} && gtags ${GTAGSFLAGS} 216254721Semaste.if defined(HTML) 217254721Semaste @cd ${.CURDIR} && htags ${HTAGSFLAGS} 218254721Semaste.endif 219254721Semaste.endif 220254721Semaste.endif 221254721Semaste 222254721Semaste 223254721Semaste.if !target(load) 224254721Semasteload: ${PROG} 225254721Semaste ${MODLOAD} -o ${KMOD} -e${KMOD} ${PROG} 226254721Semaste.endif 227254721Semaste 228254721Semaste.if !target(unload) 229254721Semasteunload: ${PROG} 230254721Semaste ${MODUNLOAD} -n ${KMOD} 231254721Semaste.endif 232254721Semaste 233254721SemasteKERN= ${.CURDIR}/../../sys/kern 234254721Semaste 235254721Semastevnode_if.h: ${KERN}/vnode_if.sh ${KERN}/vnode_if.src 236254721Semaste sh ${KERN}/vnode_if.sh ${KERN}/vnode_if.src 237254721Semaste 238254721Semaste./vnode_if.h: vnode_if.h 239254721Semaste 240254721Semaste.include <bsd.obj.mk> 241254721Semaste.include <bsd.dep.mk> 242254721Semaste.include <bsd.kern.mk> 243254721Semaste