1994-09-14 21:59:28 +00:00
|
|
|
# From: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
|
1999-08-28 00:22:10 +00:00
|
|
|
# $FreeBSD$
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
1999-09-06 20:11:59 +00:00
|
|
|
# The include file <bsd.kmod.mk> handles installing Kernel Loadable Device
|
|
|
|
# drivers (KLD's).
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# +++ variables +++
|
|
|
|
#
|
|
|
|
# CLEANFILES Additional files to remove for the clean and cleandir targets.
|
|
|
|
#
|
1999-09-06 20:11:59 +00:00
|
|
|
# KMOD The name of the kernel module to build.
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
2000-09-05 22:37:46 +00:00
|
|
|
# KMODDIR Base path for kernel modules (see kld(4)). [/boot/kernel]
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
1999-09-06 20:11:59 +00:00
|
|
|
# KMODOWN KLD owner. [${BINOWN}]
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
1999-09-06 20:11:59 +00:00
|
|
|
# KMODGRP KLD group. [${BINGRP}]
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
1999-09-06 20:11:59 +00:00
|
|
|
# KMODMODE KLD mode. [${BINMODE}]
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
1999-09-06 20:11:59 +00:00
|
|
|
# KMODLOAD Command to load a kernel module [/sbin/kldload]
|
1996-10-06 22:10:35 +00:00
|
|
|
#
|
1999-09-06 20:11:59 +00:00
|
|
|
# KMODUNLOAD Command to unload a kernel module [/sbin/kldunload]
|
1996-10-06 22:10:35 +00:00
|
|
|
#
|
2000-12-18 01:36:41 +00:00
|
|
|
# PROG The name of the kernel module to build.
|
1996-10-06 22:10:35 +00:00
|
|
|
# If not supplied, ${KMOD}.o is used.
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
2000-12-18 01:36:41 +00:00
|
|
|
# SRCS List of source files
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
2002-07-17 08:21:50 +00:00
|
|
|
# DESTDIR Change the tree where the module gets installed. [not set]
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
2000-04-05 10:13:05 +00:00
|
|
|
# MFILES Optionally a list of interfaces used by the module.
|
|
|
|
# This file contains a default list of interfaces.
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
2002-01-10 03:52:01 +00:00
|
|
|
# EXPORT_SYMS A list of symbols that should be exported from the module,
|
2002-01-11 01:11:44 +00:00
|
|
|
# or the name of a file containing a list of symbols, or YES
|
|
|
|
# to export all symbols. If not defined, no symbols are
|
2002-01-10 03:52:01 +00:00
|
|
|
# exported.
|
|
|
|
#
|
1996-05-25 23:09:49 +00:00
|
|
|
# +++ targets +++
|
|
|
|
#
|
|
|
|
# install:
|
2002-01-11 15:49:02 +00:00
|
|
|
# install the kernel module; if the Makefile
|
1996-05-25 23:09:49 +00:00
|
|
|
# does not itself define the target install, the targets
|
|
|
|
# beforeinstall and afterinstall may also be used to cause
|
|
|
|
# actions immediately before and after the install target
|
|
|
|
# is executed.
|
|
|
|
#
|
2000-12-18 01:36:41 +00:00
|
|
|
# load:
|
1999-09-06 20:11:59 +00:00
|
|
|
# Load KLD.
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
|
|
|
# unload:
|
1999-09-06 20:11:59 +00:00
|
|
|
# Unload KLD.
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
|
|
|
# bsd.obj.mk: clean, cleandir and obj
|
1998-02-20 15:52:49 +00:00
|
|
|
# bsd.dep.mk: cleandepend, depend and tags
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
1994-09-14 21:59:28 +00:00
|
|
|
|
2002-03-01 01:21:29 +00:00
|
|
|
AWK?= awk
|
1999-09-06 20:11:59 +00:00
|
|
|
KMODLOAD?= /sbin/kldload
|
|
|
|
KMODUNLOAD?= /sbin/kldunload
|
2001-08-02 09:22:18 +00:00
|
|
|
OBJCOPY?= objcopy
|
1996-10-06 22:10:35 +00:00
|
|
|
|
2002-05-01 01:32:28 +00:00
|
|
|
.if defined(KMODDEPS)
|
|
|
|
.error "Do not use KMODDEPS on 5.0+, use MODULE_VERSION/MODULE_DEPEND"
|
|
|
|
.endif
|
|
|
|
|
2002-04-22 15:47:11 +00:00
|
|
|
.include <bsd.init.mk>
|
1994-09-14 21:59:28 +00:00
|
|
|
|
|
|
|
.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
|
|
|
|
|
1999-12-29 05:07:58 +00:00
|
|
|
CFLAGS+= ${COPTS} -D_KERNEL ${CWARNFLAGS}
|
1998-10-02 05:08:09 +00:00
|
|
|
CFLAGS+= -DKLD_MODULE
|
1998-01-26 20:36:38 +00:00
|
|
|
|
1998-02-01 17:19:54 +00:00
|
|
|
# Don't use any standard or source-relative include directories.
|
|
|
|
# Since -nostdinc will annull any previous -I paths, we repeat all
|
|
|
|
# such paths after -nostdinc. It doesn't seem to be possible to
|
|
|
|
# add to the front of `make' variable.
|
|
|
|
_ICFLAGS:= ${CFLAGS:M-I*}
|
2000-10-29 09:47:50 +00:00
|
|
|
CFLAGS+= -nostdinc -I- ${INCLMAGIC} ${_ICFLAGS}
|
1998-02-01 17:19:54 +00:00
|
|
|
|
1999-09-06 20:11:59 +00:00
|
|
|
# Add -I paths for system headers. Individual KLD makefiles don't
|
1998-02-01 17:19:54 +00:00
|
|
|
# need any -I paths for this. Similar defaults for .PATH can't be
|
|
|
|
# set because there are no standard paths for non-headers.
|
2000-12-08 22:26:48 +00:00
|
|
|
CFLAGS+= -I. -I@ -I@/dev
|
1998-01-26 20:36:38 +00:00
|
|
|
|
2000-01-08 18:48:57 +00:00
|
|
|
# Add a -I path to standard headers like <stddef.h>. Use a relative
|
|
|
|
# path to src/include if possible. If the @ symlink hasn't been built
|
|
|
|
# yet, then we can't tell if the relative path exists. Add both the
|
|
|
|
# potential relative path and an absolute path in that case.
|
|
|
|
.if exists(@)
|
|
|
|
.if exists(@/../include)
|
|
|
|
CFLAGS+= -I@/../include
|
|
|
|
.else
|
1997-06-18 03:10:31 +00:00
|
|
|
CFLAGS+= -I${DESTDIR}/usr/include
|
|
|
|
.endif
|
2000-01-08 18:48:57 +00:00
|
|
|
.else # !@
|
|
|
|
CFLAGS+= -I@/../include -I${DESTDIR}/usr/include
|
|
|
|
.endif # @
|
1996-04-03 12:08:52 +00:00
|
|
|
|
2002-01-10 03:52:01 +00:00
|
|
|
# Disallow common variables, and if we end up with commons from
|
|
|
|
# somewhere unexpected, allocate storage for them in the module itself.
|
|
|
|
CFLAGS+= -fno-common
|
|
|
|
LDFLAGS+= -d -warn-common
|
|
|
|
|
2000-01-28 11:26:46 +00:00
|
|
|
CFLAGS+= ${DEBUG_FLAGS}
|
|
|
|
|
1994-09-14 21:59:28 +00:00
|
|
|
OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
|
|
|
|
|
|
|
|
.if !defined(PROG)
|
1998-10-02 04:51:10 +00:00
|
|
|
PROG= ${KMOD}.ko
|
|
|
|
.endif
|
1994-09-14 21:59:28 +00:00
|
|
|
|
2001-08-02 09:22:18 +00:00
|
|
|
.if !defined(DEBUG)
|
|
|
|
FULLPROG= ${PROG}
|
|
|
|
.else
|
|
|
|
FULLPROG= ${PROG}.debug
|
|
|
|
${PROG}: ${FULLPROG}
|
|
|
|
${OBJCOPY} --strip-debug ${FULLPROG} ${PROG}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
${FULLPROG}: ${KMOD}.kld
|
2000-05-01 18:06:49 +00:00
|
|
|
${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld
|
1994-09-14 21:59:28 +00:00
|
|
|
|
2002-01-11 01:11:44 +00:00
|
|
|
EXPORT_SYMS?= NO
|
|
|
|
.if ${EXPORT_SYMS} != YES
|
2002-01-10 03:52:01 +00:00
|
|
|
CLEANFILES+= ${.OBJDIR}/export_syms
|
|
|
|
.endif
|
|
|
|
|
2000-05-01 18:06:49 +00:00
|
|
|
${KMOD}.kld: ${OBJS}
|
2002-01-10 03:52:01 +00:00
|
|
|
${LD} ${LDFLAGS} -r -d -o ${.TARGET} ${OBJS}
|
|
|
|
.if defined(EXPORT_SYMS)
|
2002-01-11 01:11:44 +00:00
|
|
|
.if ${EXPORT_SYMS} != YES
|
2002-01-10 03:52:01 +00:00
|
|
|
.if ${EXPORT_SYMS} == NO
|
|
|
|
touch ${.OBJDIR}/export_syms
|
|
|
|
.elif !exists(${.CURDIR}/${EXPORT_SYMS})
|
|
|
|
echo ${EXPORT_SYMS} > ${.OBJDIR}/export_syms
|
|
|
|
.else
|
|
|
|
grep -v '^#' < ${EXPORT_SYMS} > ${.OBJDIR}/export_syms
|
|
|
|
.endif
|
|
|
|
awk -f ${SYSDIR}/conf/kmod_syms.awk ${.TARGET} \
|
|
|
|
${.OBJDIR}/export_syms | \
|
2002-01-11 01:11:44 +00:00
|
|
|
xargs -J% ${OBJCOPY} % ${.TARGET}
|
|
|
|
.endif
|
2002-01-10 03:52:01 +00:00
|
|
|
.endif
|
|
|
|
|
1998-01-26 20:36:38 +00:00
|
|
|
_ILINKS=@ machine
|
1994-09-14 21:59:28 +00:00
|
|
|
|
2002-04-23 09:03:56 +00:00
|
|
|
all: objwarn ${PROG}
|
1998-01-26 20:36:38 +00:00
|
|
|
|
2001-03-05 06:19:29 +00:00
|
|
|
beforedepend: ${_ILINKS}
|
|
|
|
@rm -f .depend
|
|
|
|
|
2001-02-23 04:49:31 +00:00
|
|
|
# Ensure that the links exist without depending on it when it exists which
|
|
|
|
# causes all the modules to be rebuilt when the directory pointed to changes.
|
|
|
|
.for _link in ${_ILINKS}
|
|
|
|
.if !exists(${.OBJDIR}/${_link})
|
|
|
|
${OBJS}: ${_link}
|
|
|
|
.endif
|
|
|
|
.endfor
|
1998-01-26 20:36:38 +00:00
|
|
|
|
2000-04-08 17:20:00 +00:00
|
|
|
# Search for kernel source tree in standard places.
|
|
|
|
.for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. /sys /usr/src/sys
|
|
|
|
.if !defined(SYSDIR) && exists(${_dir}/kern/)
|
|
|
|
SYSDIR= ${_dir}
|
|
|
|
.endif
|
|
|
|
.endfor
|
2000-12-08 20:36:32 +00:00
|
|
|
.if !defined(SYSDIR) || !exists(${SYSDIR}/kern)
|
2000-04-08 17:20:00 +00:00
|
|
|
.error "can't find kernel source tree"
|
|
|
|
.endif
|
|
|
|
|
1998-10-16 03:32:03 +00:00
|
|
|
${_ILINKS}:
|
2000-04-08 17:20:00 +00:00
|
|
|
@case ${.TARGET} in \
|
|
|
|
machine) \
|
|
|
|
path=${SYSDIR}/${MACHINE_ARCH}/include ;; \
|
|
|
|
@) \
|
|
|
|
path=${SYSDIR} ;; \
|
|
|
|
esac ; \
|
1998-10-16 03:32:03 +00:00
|
|
|
path=`(cd $$path && /bin/pwd)` ; \
|
|
|
|
${ECHO} ${.TARGET} "->" $$path ; \
|
|
|
|
ln -s $$path ${.TARGET}
|
1998-01-26 20:36:38 +00:00
|
|
|
|
2001-08-02 09:22:18 +00:00
|
|
|
CLEANFILES+= ${PROG} ${FULLPROG} ${KMOD}.kld ${OBJS} ${_ILINKS} symb.tmp tmp.o
|
1994-09-14 21:59:28 +00:00
|
|
|
|
|
|
|
.if !target(install)
|
|
|
|
|
2001-04-25 20:56:15 +00:00
|
|
|
_INSTALLFLAGS:= ${INSTALLFLAGS}
|
1999-07-31 20:27:33 +00:00
|
|
|
.for ie in ${INSTALLFLAGS_EDIT}
|
|
|
|
_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
|
|
|
|
.endfor
|
|
|
|
|
2002-04-24 11:26:19 +00:00
|
|
|
.if defined(DEBUG)
|
2002-04-23 09:03:56 +00:00
|
|
|
install.debug:
|
2002-04-24 11:26:19 +00:00
|
|
|
cd ${.CURDIR}; ${MAKE} -DINSTALL_DEBUG install
|
|
|
|
.endif
|
2001-10-27 00:52:50 +00:00
|
|
|
|
2002-07-17 08:21:50 +00:00
|
|
|
.if !target(realinstall)
|
|
|
|
realinstall: _kmodinstall
|
|
|
|
.ORDER: beforeinstall _kmodinstall
|
2002-04-24 11:26:19 +00:00
|
|
|
.if defined(DEBUG) && defined(INSTALL_DEBUG)
|
2002-07-17 08:21:50 +00:00
|
|
|
_kmodinstall:
|
2002-07-29 09:40:17 +00:00
|
|
|
${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
|
2002-07-17 08:21:50 +00:00
|
|
|
${_INSTALLFLAGS} ${FULLPROG} ${DESTDIR}${KMODDIR}
|
2002-04-24 11:26:19 +00:00
|
|
|
.else
|
2002-07-17 08:21:50 +00:00
|
|
|
_kmodinstall:
|
2002-07-29 09:40:17 +00:00
|
|
|
${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
|
2002-07-17 08:21:50 +00:00
|
|
|
${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
|
|
|
|
|
|
|
|
.include <bsd.links.mk>
|
|
|
|
|
2001-09-11 01:09:24 +00:00
|
|
|
.if !defined(NO_XREF)
|
2002-07-17 08:21:50 +00:00
|
|
|
afterinstall: _kldxref
|
|
|
|
.ORDER: realinstall _kldxref
|
|
|
|
.ORDER: _installlinks _kldxref
|
|
|
|
_kldxref:
|
2002-05-14 07:49:12 +00:00
|
|
|
@if type kldxref >/dev/null 2>&1; then \
|
|
|
|
${ECHO} kldxref ${DESTDIR}${KMODDIR}; \
|
|
|
|
kldxref ${DESTDIR}${KMODDIR}; \
|
|
|
|
fi
|
2001-09-11 01:09:24 +00:00
|
|
|
.endif
|
2002-04-24 11:26:19 +00:00
|
|
|
.endif
|
2002-07-17 08:21:50 +00:00
|
|
|
.endif !target(realinstall)
|
1994-09-14 21:59:28 +00:00
|
|
|
|
2002-07-17 08:21:50 +00:00
|
|
|
.endif !target(install)
|
1994-09-14 21:59:28 +00:00
|
|
|
|
|
|
|
.if !target(load)
|
2000-04-08 17:20:00 +00:00
|
|
|
load: ${PROG}
|
2002-06-17 20:01:06 +00:00
|
|
|
${KMODLOAD} -v ${.OBJDIR}/${KMOD}.ko
|
1994-09-14 21:59:28 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !target(unload)
|
1999-09-06 20:11:59 +00:00
|
|
|
unload:
|
2000-04-08 17:20:00 +00:00
|
|
|
${KMODUNLOAD} -v ${KMOD}
|
1998-10-16 03:32:03 +00:00
|
|
|
.endif
|
1994-09-21 03:49:59 +00:00
|
|
|
|
1999-11-28 17:52:40 +00:00
|
|
|
.for _src in ${SRCS:Mopt_*.h}
|
|
|
|
CLEANFILES+= ${_src}
|
|
|
|
.if !target(${_src})
|
|
|
|
${_src}:
|
|
|
|
touch ${.TARGET}
|
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
|
2000-04-05 10:13:05 +00:00
|
|
|
MFILES?= kern/bus_if.m kern/device_if.m dev/iicbus/iicbb_if.m \
|
2001-04-09 09:39:29 +00:00
|
|
|
dev/iicbus/iicbus_if.m isa/isa_if.m \
|
|
|
|
libkern/iconv_converter_if.m \
|
|
|
|
dev/mii/miibus_if.m \
|
2000-12-08 22:26:48 +00:00
|
|
|
dev/pccard/card_if.m dev/pccard/power_if.m dev/pci/pci_if.m \
|
|
|
|
dev/pci/pcib_if.m dev/ppbus/ppbus_if.m dev/smbus/smbus_if.m \
|
2000-12-18 01:36:41 +00:00
|
|
|
dev/usb/usb_if.m dev/sound/pcm/ac97_if.m dev/sound/pcm/channel_if.m \
|
2002-10-04 20:36:39 +00:00
|
|
|
dev/sound/pcm/feeder_if.m dev/sound/pcm/mixer_if.m pci/agp_if.m \
|
|
|
|
opencrypto/crypto_if.m
|
2000-04-05 10:13:05 +00:00
|
|
|
|
|
|
|
.for _srcsrc in ${MFILES}
|
1999-11-28 17:52:40 +00:00
|
|
|
.for _ext in c h
|
|
|
|
.for _src in ${SRCS:M${_srcsrc:T:R}.${_ext}}
|
|
|
|
CLEANFILES+= ${_src}
|
|
|
|
.if !target(${_src})
|
2001-02-23 04:49:31 +00:00
|
|
|
.if !exists(@)
|
1999-11-28 17:52:40 +00:00
|
|
|
${_src}: @
|
2001-02-23 04:49:31 +00:00
|
|
|
.endif
|
1999-11-28 17:52:40 +00:00
|
|
|
.if exists(@)
|
2002-05-01 03:28:14 +00:00
|
|
|
${_src}: @/tools/makeobjops.awk @/${_srcsrc}
|
1999-11-28 17:52:40 +00:00
|
|
|
.endif
|
2002-05-01 03:28:14 +00:00
|
|
|
${AWK} -f @/tools/makeobjops.awk @/${_srcsrc} -${_ext}
|
1999-11-28 17:52:40 +00:00
|
|
|
.endif
|
|
|
|
.endfor # _src
|
|
|
|
.endfor # _ext
|
|
|
|
.endfor # _srcsrc
|
|
|
|
|
1999-12-12 16:45:58 +00:00
|
|
|
.for _ext in c h
|
|
|
|
.if ${SRCS:Mvnode_if.${_ext}} != ""
|
|
|
|
CLEANFILES+= vnode_if.${_ext}
|
2001-02-23 04:49:31 +00:00
|
|
|
.if !exists(@)
|
1999-12-12 16:45:58 +00:00
|
|
|
vnode_if.${_ext}: @
|
2001-02-23 04:49:31 +00:00
|
|
|
.endif
|
1999-11-28 17:52:40 +00:00
|
|
|
.if exists(@)
|
2002-03-01 01:21:29 +00:00
|
|
|
vnode_if.${_ext}: @/tools/vnode_if.awk @/kern/vnode_if.src
|
1999-11-28 17:52:40 +00:00
|
|
|
.endif
|
2002-03-01 01:21:29 +00:00
|
|
|
${AWK} -f @/tools/vnode_if.awk @/kern/vnode_if.src -${_ext}
|
1999-11-28 17:52:40 +00:00
|
|
|
.endif
|
1999-12-12 16:45:58 +00:00
|
|
|
.endfor
|
1994-09-21 03:49:59 +00:00
|
|
|
|
1999-04-20 14:33:24 +00:00
|
|
|
regress:
|
1998-03-12 20:02:17 +00:00
|
|
|
|
2002-03-17 10:05:57 +00:00
|
|
|
lint: ${SRCS}
|
2002-03-18 09:35:45 +00:00
|
|
|
${LINT} ${LINTKERNFLAGS} ${CFLAGS:M-[DILU]*} ${.ALLSRC:M*.c}
|
2002-03-17 10:05:57 +00:00
|
|
|
|
1996-06-30 22:16:19 +00:00
|
|
|
.include <bsd.dep.mk>
|
1998-03-06 05:43:46 +00:00
|
|
|
|
|
|
|
.if !exists(${DEPENDFILE})
|
1998-03-06 07:28:01 +00:00
|
|
|
${OBJS}: ${SRCS:M*.h}
|
1998-03-06 05:43:46 +00:00
|
|
|
.endif
|
|
|
|
|
1998-06-09 02:55:40 +00:00
|
|
|
.include <bsd.obj.mk>
|
1996-10-08 22:09:03 +00:00
|
|
|
.include <bsd.kern.mk>
|