kernel - x86_64 - Remove intrframe->if_gs
[dragonfly.git] / sys / conf / kmod.mk
blob759b4504bb86a662242cdf861bba4662ebce5276
1 # From: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
2 # $FreeBSD: src/sys/conf/kmod.mk,v 1.82.2.15 2003/02/10 13:11:50 nyan Exp $
4 # The include file <bsd.kmod.mk> handles installing Kernel Loadable Device
5 # drivers (KLD's).
8 # +++ variables +++
9 # CLEANFILES Additional files to remove for the clean and cleandir targets.
11 # KMOD The name of the kernel module to build.
13 # KMODDIR Base path for kernel modules (see kld(4)).
14 # [${DESTKERNDIR}]
16 # KMODOWN KLD owner. [${BINOWN}]
18 # KMODGRP KLD group. [${BINGRP}]
20 # KMODMODE KLD mode. [${BINMODE}]
22 # KMODLOAD Command to load a kernel module [/sbin/kldload]
24 # KMODUNLOAD Command to unload a kernel module [/sbin/kldunload]
26 # PROG The name of the kernel module to build.
27 # If not supplied, ${KMOD}.o is used.
29 # SRCS List of source files
31 # DESTKERNDIR Change the tree where the kernel and the modules get
32 # installed. [/boot] ${DESTDIR} changes the root of the tree
33 # pointed to by ${DESTKERNDIR}.
35 # MFILES Optionally a list of interfaces used by the module.
36 # This file contains a default list of interfaces.
38 # FIRMWS Firmware module in the form filename:shortname:version
40 # +++ targets +++
42 # install:
43 # install the kernel module and its manual pages; if the Makefile
44 # does not itself define the target install, the targets
45 # beforeinstall and afterinstall may also be used to cause
46 # actions immediately before and after the install target
47 # is executed.
49 # load:
50 # Load KLD.
52 # unload:
53 # Unload KLD.
55 # bsd.obj.mk: clean, cleandir and obj
56 # bsd.dep.mk: cleandepend, depend and tags
59 OBJCOPY?= objcopy
60 KMODLOAD?= /sbin/kldload
61 KMODUNLOAD?= /sbin/kldunload
63 # KERNEL is needed when running make install directly from
64 # the obj directory.
65 KERNEL?= kernel
67 KMODDIR?= ${DESTKERNDIR}
68 KMODOWN?= ${BINOWN}
69 KMODGRP?= ${BINGRP}
70 KMODMODE?= ${BINMODE}
72 .include <bsd.init.mk>
74 .SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
76 CFLAGS+= ${COPTS} -D_KERNEL ${CWARNFLAGS}
77 CFLAGS+= -DKLD_MODULE
79 # Don't use any standard include directories.
80 # Since -nostdinc will annull any previous -I paths, we repeat all
81 # such paths after -nostdinc. It doesn't seem to be possible to
82 # add to the front of `make' variable.
84 # Don't use -I- anymore, source-relative includes are desireable.
85 _ICFLAGS:= ${CFLAGS:M-I*}
86 CFLAGS+= -nostdinc ${_ICFLAGS}
88 # Add -I paths for system headers. Individual KLD makefiles don't
89 # need any -I paths for this. Similar defaults for .PATH can't be
90 # set because there are no standard paths for non-headers.
92 # NOTE! Traditional architecture paths such as <i386/i386/blah.h>
93 # must run through the "machine_base" softlink using
94 # <machine_base/i386/blah.h>. An explicit cross-architecture path must
95 # operate relative to /usr/src/sys using e.g. <arch/i386/i386/blah.h>
97 CFLAGS+= -I. -I@
99 # Add -I paths for headers in the kernel build directory
101 .if defined(BUILDING_WITH_KERNEL)
102 CFLAGS+= -I${BUILDING_WITH_KERNEL}
103 _MACHINE_FWD= ${BUILDING_WITH_KERNEL}
104 .else
105 .if defined(MAKEOBJDIRPREFIX)
106 _MACHINE_FWD= ${MAKEOBJDIRPREFIX}/${SYSDIR}/forwarder_${MACHINE_ARCH}
107 .else
108 _MACHINE_FWD= ${.OBJDIR}/forwarder_${MACHINE_ARCH}
109 CLEANDIRS+= ${_MACHINE_FWD}
110 .endif
111 .endif
112 CFLAGS+= -I${_MACHINE_FWD}/include
113 .include "kern.fwd.mk"
115 # Add a -I path to standard headers like <stddef.h>. Use a relative
116 # path to src/include if possible. If the @ symlink hasn't been built
117 # yet, then we can't tell if the relative path exists. Add both the
118 # potential relative path and an absolute path in that case.
119 .if exists(@)
120 .if exists(@/../include)
121 CFLAGS+= -I@/../include
122 .else
123 CFLAGS+= -I${DESTDIR}/usr/include
124 .endif
125 .else # !@
126 CFLAGS+= -I@/../include -I${DESTDIR}/usr/include
127 .endif # @
129 .if defined(BUILDING_WITH_KERNEL) && \
130 exists(${BUILDING_WITH_KERNEL}/opt_global.h)
131 CFLAGS+= -include ${BUILDING_WITH_KERNEL}/opt_global.h
132 .endif
134 CFLAGS+= ${DEBUG_FLAGS}
135 .if ${MACHINE_ARCH} == x86_64
136 CFLAGS+= -fno-omit-frame-pointer
137 .endif
139 .include <bsd.patch.mk>
141 .if defined(FIRMWS)
142 AWK=/usr/bin/awk
143 .if !exists(@)
144 ${KMOD:S/$/.c/}: @
145 .else
146 ${KMOD:S/$/.c/}: @/tools/fw_stub.awk
147 .endif
148 ${AWK} -f @/tools/fw_stub.awk ${FIRMWS} -m${KMOD} -c${KMOD:S/$/.c/g} \
149 ${FIRMWARE_LICENSE:C/.+/-l/}${FIRMWARE_LICENSE}
151 SRCS+= ${KMOD:S/$/.c/}
152 CLEANFILES+= ${KMOD:S/$/.c/}
154 .for _firmw in ${FIRMWS}
155 ${_firmw:C/\:.*$/.fwo/}: ${_firmw:C/\:.*$//}
156 @${ECHO} ${_firmw:C/\:.*$//} ${.ALLSRC:M*${_firmw:C/\:.*$//}}
157 @if [ -e ${_firmw:C/\:.*$//} ]; then \
158 ${LD} -b binary --no-warn-mismatch ${LDFLAGS} \
159 -r -d -o ${.TARGET} ${_firmw:C/\:.*$//}; \
160 else \
161 ln -s ${.ALLSRC:M*${_firmw:C/\:.*$//}} ${_firmw:C/\:.*$//}; \
162 ${LD} -b binary --no-warn-mismatch ${LDFLAGS} \
163 -r -d -o ${.TARGET} ${_firmw:C/\:.*$//}; \
164 rm ${_firmw:C/\:.*$//}; \
167 OBJS+= ${_firmw:C/\:.*$/.fwo/}
168 .endfor
169 .endif
171 OBJS+= ${SRCS:N*.h:N*.patch:R:S/$/.o/g}
173 .if !defined(PROG)
174 PROG= ${KMOD}.ko
175 .endif
177 .if ${MACHINE_ARCH} != x86_64
178 ${PROG}: ${KMOD}.kld
179 ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld
180 .endif
182 .if ${MACHINE_ARCH} != x86_64
183 ${KMOD}.kld: ${OBJS}
184 ${LD} ${LDFLAGS} -r -o ${.TARGET} ${OBJS}
185 .else
186 ${PROG}: ${OBJS}
187 ${LD} ${LDFLAGS} -r -d -o ${.TARGET} ${OBJS}
188 .endif
190 # links to platform and cpu architecture include files. If we are
191 # building with a kernel these already exist in the kernel build dir.
192 # '@' is a link to the system source.
193 .if defined(BUILDING_WITH_KERNEL)
194 _ILINKS=@
195 .else
196 _ILINKS=@ machine_base machine cpu_base cpu
197 .endif
199 .if defined(ARCH)
200 _ILINKS+=${ARCH}
201 .endif
203 all: objwarn fwheaders ${PROG}
205 beforedepend: fwheaders
206 fwheaders: ${_ILINKS} ${FORWARD_HEADERS_COOKIE}
207 # Ensure that the links exist without depending on it when it exists which
208 # causes all the modules to be rebuilt when the directory pointed to changes.
209 .for _link in ${_ILINKS}
210 .if !exists(${.OBJDIR}/${_link})
211 ${OBJS}: ${_link}
212 .endif
213 .endfor
215 # Search for kernel source tree in standard places.
216 .for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. ${.CURDIR}/../../../.. /sys /usr/src/sys
217 .if !defined(SYSDIR) && exists(${_dir}/kern/)
218 SYSDIR= ${_dir}
219 .endif
220 .endfor
221 .if !defined(SYSDIR) || !exists(${SYSDIR}/kern)
222 .error "can't find kernel source tree"
223 .endif
224 S= ${SYSDIR}
226 # path=`(cd $$path && /bin/pwd)` ;
228 ${_ILINKS}:
229 @case ${.TARGET} in \
230 machine) \
231 path=${SYSDIR}/platform/${MACHINE_PLATFORM}/include ;; \
232 machine_base) \
233 path=${SYSDIR}/platform/${MACHINE_PLATFORM} ;; \
234 cpu) \
235 path=${SYSDIR}/cpu/${MACHINE_ARCH}/include ;; \
236 cpu_base) \
237 path=${SYSDIR}/cpu/${MACHINE_ARCH} ;; \
238 @) \
239 path=${SYSDIR} ;; \
240 arch_*) \
241 path=${.CURDIR}/${MACHINE_ARCH} ;; \
242 esac ; \
243 ${ECHO} ${.TARGET} "->" $$path ; \
244 ${LN} -s $$path ${.TARGET}
246 CLEANFILES+= ${PROG} ${KMOD}.kld ${OBJS} ${_ILINKS} symb.tmp tmp.o
248 .if !target(install)
250 _INSTALLFLAGS:= ${INSTALLFLAGS}
251 .for ie in ${INSTALLFLAGS_EDIT}
252 _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
253 .endfor
255 .if !target(realinstall)
256 realinstall: _kmodinstall
257 .ORDER: beforeinstall _kmodinstall
258 _kmodinstall:
259 .if defined(INSTALLSTRIPPEDMODULES)
260 ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
261 ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
262 ${OBJCOPY} --strip-debug ${DESTDIR}${KMODDIR}/${PROG}
263 .else
264 ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
265 ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
266 .endif
267 .endif # !target(realinstall)
269 .include <bsd.links.mk>
271 .endif # !target(install)
273 .if !target(load)
274 load: ${PROG}
275 ${KMODLOAD} -v ./${KMOD}.ko
276 .endif
278 .if !target(unload)
279 unload:
280 ${KMODUNLOAD} -v ${KMOD}
281 .endif
283 .for _src in ${SRCS:Mopt_*.h} ${SRCS:Muse_*.h}
284 CLEANFILES+= ${_src}
285 .if !target(${_src})
286 .if defined(BUILDING_WITH_KERNEL) && exists(${BUILDING_WITH_KERNEL}/${_src})
287 ${_src}: ${BUILDING_WITH_KERNEL}/${_src}
288 # we do not have to copy these files any more, the kernel build
289 # directory is included in the path now.
290 # cp ${BUILDING_WITH_KERNEL}/${_src} ${.TARGET}
291 .else
292 ${_src}:
293 touch ${.TARGET}
294 .endif # BUILDING_WITH_KERNEL
295 .endif
296 .endfor
298 MFILES?= kern/bus_if.m kern/device_if.m bus/iicbus/iicbb_if.m \
299 bus/iicbus/iicbus_if.m bus/isa/isa_if.m dev/netif/mii_layer/miibus_if.m \
300 bus/pccard/card_if.m bus/pccard/power_if.m bus/pci/pci_if.m \
301 bus/pci/pcib_if.m \
302 bus/ppbus/ppbus_if.m bus/smbus/smbus_if.m bus/usb/usb_if.m \
303 dev/acpica5/acpi_if.m dev/disk/nata/ata_if.m \
304 dev/sound/pcm/ac97_if.m dev/sound/pcm/channel_if.m \
305 dev/sound/pcm/feeder_if.m dev/sound/pcm/mixer_if.m \
306 libiconv/iconv_converter_if.m dev/agp/agp_if.m opencrypto/cryptodev_if.m \
307 bus/mmc/mmcbus_if.m bus/mmc/mmcbr_if.m
309 .for _srcsrc in ${MFILES}
310 .for _ext in c h
311 .for _src in ${SRCS:M${_srcsrc:T:R}.${_ext}}
312 CLEANFILES+= ${_src}
313 .if !target(${_src})
314 ${_src}: @
315 .if exists(@)
316 ${_src}: @/tools/makeobjops.awk @/${_srcsrc}
317 .endif
319 .if defined(BUILDING_WITH_KERNEL) && \
320 exists(${BUILDING_WITH_KERNEL}/${_src})
321 .else
322 awk -f @/tools/makeobjops.awk -- -${_ext} @/${_srcsrc}
323 .endif
324 .endif
325 .endfor # _src
326 .endfor # _ext
327 .endfor # _srcsrc
329 #.for _ext in c h
330 #.if ${SRCS:Mvnode_if.${_ext}} != ""
331 #CLEANFILES+= vnode_if.${_ext}
332 #vnode_if.${_ext}: @
333 #.if exists(@)
334 #vnode_if.${_ext}: @/tools/vnode_if.awk @/kern/vnode_if.src
335 #.endif
336 # awk -f @/tools/vnode_if.awk -- -${_ext} @/kern/vnode_if.src
337 #.endif
338 #.endfor
340 .if !empty(SRCS:Massym.s)
341 CLEANFILES+= assym.s genassym.o
342 assym.s: genassym.o
343 .if defined(BUILDING_WITH_KERNEL)
344 genassym.o: opt_global.h
345 .endif
346 .if !exists(@)
347 assym.s: @
348 .else
349 assym.s: @/kern/genassym.sh
350 .endif
351 sh @/kern/genassym.sh genassym.o > ${.TARGET}
352 .if exists(@)
353 genassym.o: @/platform/${MACHINE_PLATFORM}/${MACHINE_ARCH}/genassym.c
354 .endif
355 genassym.o: @ ${SRCS:Mopt_*.h}
356 ${CC} -c ${CFLAGS:N-fno-common:N-mcmodel=small} ${WERROR} \
357 @/platform/${MACHINE_PLATFORM}/${MACHINE_ARCH}/genassym.c
358 .endif
360 regress:
362 .include <bsd.dep.mk>
364 .if !exists(${DEPENDFILE})
365 ${OBJS}: ${SRCS:M*.h}
366 .endif
368 .include <bsd.obj.mk>
369 .include "bsd.kern.mk"
371 # Behaves like MODULE_OVERRIDE
372 .if defined(KLD_DEPS)
373 all: _kdeps_all
374 _kdeps_all: @
375 .for _mdep in ${KLD_DEPS}
376 cd ${SYSDIR}/${_mdep} && make all
377 .endfor
378 depend: _kdeps_depend
379 _kdeps_depend: @
380 .for _mdep in ${KLD_DEPS}
381 cd ${SYSDIR}/${_mdep} && make depend
382 .endfor
383 install: _kdeps_install
384 _kdeps_install: @
385 .for _mdep in ${KLD_DEPS}
386 cd ${SYSDIR}/${_mdep} && make install
387 .endfor
388 clean: _kdeps_clean
389 _kdeps_clean: @
390 .for _mdep in ${KLD_DEPS}
391 cd ${SYSDIR}/${_mdep} && make clean
392 .endfor
393 .endif