kmod.mk revision 26711
1# From: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 2# $Id: bsd.kmod.mk,v 1.36 1997/05/06 14:29:56 dfr Exp $ 3# 4# The include file <bsd.kmod.mk> handles installing Loadable Kernel Modules. 5# <bsd.kmod.mk> includes the file named "../Makefile.inc" if it exists, 6# as well as the include file <bsd.obj.mk>, <bsd.dep.mk>, and 7# may be <bsd.man.mk> 8# 9# 10# +++ variables +++ 11# 12# CLEANFILES Additional files to remove for the clean and cleandir targets. 13# 14# DISTRIBUTION Name of distribution. [bin] 15# 16# EXPORT_SYMS ??? 17# 18# KERN Main Kernel source directory. [${.CURDIR}/../../sys/kern] 19# 20# KMOD The name of the loadable kernel module to build. 21# 22# KMODDIR Base path for loadable kernel modules 23# (see lkm(4)). [/lkm] 24# 25# KMODOWN LKM owner. [${BINOWN}] 26# 27# KMODGRP LKM group. [${BINGRP}] 28# 29# KMODMODE LKM mode. [${BINMODE}] 30# 31# LINKS The list of LKM links; should be full pathnames, the 32# linked-to file coming first, followed by the linked 33# file. The files are hard-linked. For example, to link 34# /lkm/master and /lkm/meister, use: 35# 36# LINKS= /lkm/master /lkm/meister 37# 38# LN_FLAGS Flags for ln(1) (see variable LINKS) 39# 40# MODLOAD Command to load a kernel module [/sbin/modload] 41# 42# MODUNLOAD Command to unload a kernel module [/sbin/modunload] 43# 44# NOMAN LKM does not have a manual page if set. 45# 46# PROG The name of the loadable kernel module to build. 47# If not supplied, ${KMOD}.o is used. 48# 49# PSEUDO_LKM ??? 50# 51# SRCS List of source files 52# 53# SUBDIR A list of subdirectories that should be built as well. 54# Each of the targets will execute the same target in the 55# subdirectories. 56# 57# DESTDIR, DISTDIR are set by other Makefiles (e.g. bsd.own.mk) 58# 59# 60# +++ targets +++ 61# 62# distribute: 63# This is a variant of install, which will 64# put the stuff into the right "distribution". 65# 66# install: 67# install the program and its manual pages; if the Makefile 68# does not itself define the target install, the targets 69# beforeinstall and afterinstall may also be used to cause 70# actions immediately before and after the install target 71# is executed. 72# 73# load: 74# Load LKM. 75# 76# tags: 77# Create a tags file for the source files. 78# 79# unload: 80# Unload LKM. 81# 82# bsd.obj.mk: clean, cleandir and obj 83# bsd.dep.mk: depend 84# bsd.man.mk: maninstall 85# 86 87MODLOAD?= /sbin/modload 88MODUNLOAD?= /sbin/modunload 89 90.if exists(${.CURDIR}/../Makefile.inc) 91.include "${.CURDIR}/../Makefile.inc" 92.endif 93 94.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S 95 96# 97# A temporary fix to survive SMP changes. 98# 99CFLAGS+= -I. 100CLEANFILES+= ${SMPHDRS} 101SMPHDRS= opt_smp.h 102 103beforedepend: ${SMPHDRS} 104 105${SMPHDRS}: 106 touch ${.TARGET} 107 108# 109# Assume that we are in /usr/src/foo/bar, so /sys is 110# ${.CURDIR}/../../sys. We don't bother adding a .PATH since nothing 111# actually lives in /sys directly. 112# 113CFLAGS+=${COPTS} -DKERNEL -DACTUALLY_LKM_NOT_KERNEL -I${.CURDIR}/../../sys \ 114 ${CWARNFLAGS} 115.if defined(DESTDIR) 116CFLAGS+= -I${DESTDIR}/usr/include 117.endif 118 119EXPORT_SYMS?= _${KMOD} 120 121.if defined(VFS_LKM) 122CFLAGS+= -DVFS_LKM -DMODVNOPS=${KMOD}vnops -I. 123SRCS+= vnode_if.h 124CLEANFILES+= vnode_if.h vnode_if.c 125.endif 126 127.if defined(PSEUDO_LKM) 128CFLAGS+= -DPSEUDO_LKM 129.endif 130 131DPSRCS+= ${SRCS:M*.h} 132OBJS+= ${SRCS:N*.h:R:S/$/.o/g} 133 134.if !defined(PROG) 135PROG= ${KMOD}.o 136.endif 137 138${PROG}: ${DPSRCS} ${OBJS} ${DPADD} 139 ${LD} -r ${LDFLAGS} -o tmp.o ${OBJS} 140.if defined(EXPORT_SYMS) 141 @rm -f symb.tmp 142 @for i in ${EXPORT_SYMS} ; do echo $$i >> symb.tmp ; done 143 symorder -c symb.tmp tmp.o 144 @rm -f symb.tmp 145.endif 146 mv tmp.o ${.TARGET} 147 148# Temporary SMP fix continued. 149${OBJS}: ${SMPHDRS} 150 151.if !defined(NOMAN) 152.include <bsd.man.mk> 153.if !defined(_MANPAGES) || empty(_MANPAGES) 154MAN1= ${KMOD}.4 155.endif 156 157.elif !target(maninstall) 158maninstall: _SUBDIR 159all-man: 160.endif 161 162.MAIN: all 163all: objwarn ${PROG} all-man _SUBDIR 164 165CLEANFILES+=${PROG} ${OBJS} 166 167.if !target(install) 168.if !target(beforeinstall) 169beforeinstall: 170.endif 171.if !target(afterinstall) 172afterinstall: 173.endif 174 175realinstall: _SUBDIR 176 ${INSTALL} ${COPY} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \ 177 ${INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR} 178.if defined(LINKS) && !empty(LINKS) 179 @set ${LINKS}; \ 180 while test $$# -ge 2; do \ 181 l=${DESTDIR}$$1; \ 182 shift; \ 183 t=${DESTDIR}$$1; \ 184 shift; \ 185 ${ECHO} $$t -\> $$l; \ 186 rm -f $$t; \ 187 ln ${LN_FLAGS} $$l $$t; \ 188 done; true 189.endif 190 191install: afterinstall _SUBDIR 192.if !defined(NOMAN) 193afterinstall: realinstall maninstall 194.else 195afterinstall: realinstall 196.endif 197realinstall: beforeinstall 198.endif 199 200DISTRIBUTION?= bin 201.if !target(distribute) 202distribute: _SUBDIR 203 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies 204.endif 205 206.if defined(NOTAGS) 207tags: 208.endif 209 210.if !target(tags) 211tags: ${SRCS} _SUBDIR 212.if defined(PROG) 213 @cd ${.CURDIR} && gtags ${GTAGSFLAGS} 214.if defined(HTML) 215 @cd ${.CURDIR} && htags ${HTAGSFLAGS} 216.endif 217.endif 218.endif 219 220 221.if !target(load) 222load: ${PROG} 223 ${MODLOAD} -o ${KMOD} -e${KMOD} ${PROG} 224.endif 225 226.if !target(unload) 227unload: ${PROG} 228 ${MODUNLOAD} -n ${KMOD} 229.endif 230 231KERN= ${.CURDIR}/../../sys/kern 232 233vnode_if.h: ${KERN}/vnode_if.sh ${KERN}/vnode_if.src 234 sh ${KERN}/vnode_if.sh ${KERN}/vnode_if.src 235 236./vnode_if.h: vnode_if.h 237 238.include <bsd.obj.mk> 239.include <bsd.dep.mk> 240.include <bsd.kern.mk> 241