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