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.
|
|
|
|
#
|
|
|
|
# DISTRIBUTION Name of distribution. [bin]
|
|
|
|
#
|
|
|
|
# KERN Main Kernel source directory. [${.CURDIR}/../../sys/kern]
|
|
|
|
#
|
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
|
|
|
#
|
1999-09-06 20:11:59 +00:00
|
|
|
# KMODDIR Base path for kernel modules (see kld(4)). [/modules]
|
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
|
|
|
# LINKS The list of KLD links; should be full pathnames, the
|
1996-05-25 23:09:49 +00:00
|
|
|
# linked-to file coming first, followed by the linked
|
|
|
|
# file. The files are hard-linked. For example, to link
|
1999-04-20 14:33:24 +00:00
|
|
|
# /modules/master and /modules/meister, use:
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
1999-04-20 14:33:24 +00:00
|
|
|
# LINKS= /modules/master /modules/meister
|
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
|
|
|
#
|
1999-09-06 20:11:59 +00:00
|
|
|
# NOMAN KLD does not have a manual page if set.
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
1999-09-06 20:11:59 +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
|
|
|
#
|
|
|
|
# SRCS List of source files
|
|
|
|
#
|
1998-10-02 04:51:10 +00:00
|
|
|
# KMODDEPS List of modules which this one is dependant on
|
|
|
|
#
|
1996-05-25 23:09:49 +00:00
|
|
|
# SUBDIR A list of subdirectories that should be built as well.
|
|
|
|
# Each of the targets will execute the same target in the
|
|
|
|
# subdirectories.
|
|
|
|
#
|
1999-03-23 03:06:25 +00:00
|
|
|
# SYMLINKS Same as LINKS, except it creates symlinks and the
|
|
|
|
# linked-to pathname may be relative.
|
|
|
|
#
|
1996-05-25 23:09:49 +00:00
|
|
|
# DESTDIR, DISTDIR are set by other Makefiles (e.g. bsd.own.mk)
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# +++ targets +++
|
|
|
|
#
|
|
|
|
# distribute:
|
|
|
|
# This is a variant of install, which will
|
|
|
|
# put the stuff into the right "distribution".
|
|
|
|
#
|
|
|
|
# install:
|
|
|
|
# install the program and its manual pages; if the Makefile
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# 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
|
|
|
# bsd.man.mk: maninstall
|
|
|
|
#
|
1994-09-14 21:59:28 +00:00
|
|
|
|
1999-09-06 20:11:59 +00:00
|
|
|
KMODLOAD?= /sbin/kldload
|
|
|
|
KMODUNLOAD?= /sbin/kldunload
|
1996-10-06 22:10:35 +00:00
|
|
|
|
1998-08-08 07:02:08 +00:00
|
|
|
.if !target(__initialized__)
|
|
|
|
__initialized__:
|
1994-09-14 21:59:28 +00:00
|
|
|
.if exists(${.CURDIR}/../Makefile.inc)
|
|
|
|
.include "${.CURDIR}/../Makefile.inc"
|
|
|
|
.endif
|
1998-08-08 07:02:08 +00:00
|
|
|
.endif
|
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*}
|
|
|
|
CFLAGS+= -nostdinc -I- ${_ICFLAGS}
|
|
|
|
|
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-01-08 18:48:57 +00:00
|
|
|
CFLAGS+= -I. -I@
|
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
|
|
|
|
2000-01-28 11:26:46 +00:00
|
|
|
CFLAGS+= ${DEBUG_FLAGS}
|
|
|
|
|
1999-04-20 14:33:24 +00:00
|
|
|
.if ${OBJFORMAT} == elf
|
1998-10-14 04:04:22 +00:00
|
|
|
CLEANFILES+= setdef0.c setdef1.c setdefs.h
|
|
|
|
CLEANFILES+= setdef0.o setdef1.o
|
|
|
|
.endif
|
|
|
|
|
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
|
|
|
|
1998-10-14 04:04:22 +00:00
|
|
|
${PROG}: ${OBJS} ${DPADD} ${KMODDEPS}
|
|
|
|
.if ${OBJFORMAT} == elf
|
|
|
|
gensetdefs ${OBJS}
|
|
|
|
${CC} ${CFLAGS} -c setdef0.c
|
|
|
|
${CC} ${CFLAGS} -c setdef1.c
|
|
|
|
${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} setdef0.o ${OBJS} setdef1.o ${KMODDEPS}
|
|
|
|
.else
|
1998-10-02 04:51:10 +00:00
|
|
|
${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${OBJS} ${KMODDEPS}
|
1998-10-14 04:04:22 +00:00
|
|
|
.endif
|
1994-09-14 21:59:28 +00:00
|
|
|
|
1998-10-14 04:04:22 +00:00
|
|
|
.if defined(KMODDEPS)
|
|
|
|
.for dep in ${KMODDEPS}
|
1998-11-11 07:40:44 +00:00
|
|
|
CLEANFILES+= ${dep} __${dep}_hack_dep.c
|
1998-10-14 04:04:22 +00:00
|
|
|
|
|
|
|
${dep}:
|
1998-11-11 07:40:44 +00:00
|
|
|
touch __${dep}_hack_dep.c
|
|
|
|
${CC} -shared ${CFLAGS} -o ${dep} __${dep}_hack_dep.c
|
1998-10-14 04:04:22 +00:00
|
|
|
.endfor
|
|
|
|
.endif
|
|
|
|
|
1996-04-11 23:03:10 +00:00
|
|
|
.if !defined(NOMAN)
|
|
|
|
.include <bsd.man.mk>
|
|
|
|
.if !defined(_MANPAGES) || empty(_MANPAGES)
|
1994-09-14 21:59:28 +00:00
|
|
|
MAN1= ${KMOD}.4
|
|
|
|
.endif
|
|
|
|
|
1996-04-11 23:03:10 +00:00
|
|
|
.elif !target(maninstall)
|
1996-06-24 04:26:21 +00:00
|
|
|
maninstall: _SUBDIR
|
1996-04-11 23:03:10 +00:00
|
|
|
all-man:
|
|
|
|
.endif
|
|
|
|
|
1998-01-26 20:36:38 +00:00
|
|
|
_ILINKS=@ machine
|
1994-09-14 21:59:28 +00:00
|
|
|
|
1998-01-26 20:36:38 +00:00
|
|
|
.MAIN: all
|
1998-03-06 05:43:46 +00:00
|
|
|
all: objwarn ${PROG} all-man _SUBDIR
|
1998-01-26 20:36:38 +00:00
|
|
|
|
1998-03-06 05:43:46 +00:00
|
|
|
beforedepend ${OBJS}: ${_ILINKS}
|
1998-01-26 20:36:38 +00:00
|
|
|
|
|
|
|
# The search for the link targets works best if we are in a normal src
|
1999-04-20 14:33:24 +00:00
|
|
|
# tree, and not too deeply below src/sys/modules. If we are near "/", then
|
1998-01-26 20:36:38 +00:00
|
|
|
# we may find /sys - this is harmless. Other abnormal "sys" directories
|
|
|
|
# found in the search are likely to cause problems. If nothing is found,
|
|
|
|
# then the links default to /usr/include and /usr/include/machine.
|
1998-10-16 03:32:03 +00:00
|
|
|
${_ILINKS}:
|
|
|
|
@set +x; for up in ../.. ../../.. ; do \
|
|
|
|
case ${.TARGET} in \
|
|
|
|
machine) \
|
|
|
|
testpath=${.CURDIR}/$$up/${MACHINE_ARCH}/include ; \
|
|
|
|
path=${.CURDIR}/$$up/${MACHINE_ARCH}/include ; \
|
|
|
|
defaultpath=/usr/include/machine ;; \
|
|
|
|
@) \
|
|
|
|
testpath=${.CURDIR}/$$up/sys ; \
|
|
|
|
path=${.CURDIR}/$$up ; \
|
|
|
|
defaultpath=/usr/include ;; \
|
|
|
|
esac ; \
|
|
|
|
if [ -d $$testpath ] ; then break ; fi ; \
|
|
|
|
path=$$defaultpath ; \
|
|
|
|
done ; \
|
|
|
|
path=`(cd $$path && /bin/pwd)` ; \
|
|
|
|
${ECHO} ${.TARGET} "->" $$path ; \
|
|
|
|
ln -s $$path ${.TARGET}
|
1998-01-26 20:36:38 +00:00
|
|
|
|
1999-04-20 14:33:24 +00:00
|
|
|
CLEANFILES+= ${PROG} ${OBJS} ${_ILINKS} symb.tmp tmp.o
|
1994-09-14 21:59:28 +00:00
|
|
|
|
|
|
|
.if !target(install)
|
|
|
|
.if !target(beforeinstall)
|
|
|
|
beforeinstall:
|
|
|
|
.endif
|
|
|
|
.if !target(afterinstall)
|
|
|
|
afterinstall:
|
|
|
|
.endif
|
|
|
|
|
1999-07-31 20:27:33 +00:00
|
|
|
_INSTALLFLAGS:= ${INSTALLFLAGS}
|
|
|
|
.for ie in ${INSTALLFLAGS_EDIT}
|
|
|
|
_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
|
|
|
|
.endfor
|
|
|
|
|
1996-06-24 04:26:21 +00:00
|
|
|
realinstall: _SUBDIR
|
1996-04-11 23:03:10 +00:00
|
|
|
${INSTALL} ${COPY} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
|
1999-07-31 20:27:33 +00:00
|
|
|
${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
|
1994-09-14 21:59:28 +00:00
|
|
|
.if defined(LINKS) && !empty(LINKS)
|
|
|
|
@set ${LINKS}; \
|
|
|
|
while test $$# -ge 2; do \
|
|
|
|
l=${DESTDIR}$$1; \
|
|
|
|
shift; \
|
|
|
|
t=${DESTDIR}$$1; \
|
|
|
|
shift; \
|
|
|
|
${ECHO} $$t -\> $$l; \
|
1999-03-23 03:06:25 +00:00
|
|
|
ln -f $$l $$t; \
|
|
|
|
done; true
|
|
|
|
.endif
|
|
|
|
.if defined(SYMLINKS) && !empty(SYMLINKS)
|
|
|
|
@set ${SYMLINKS}; \
|
|
|
|
while test $$# -ge 2; do \
|
|
|
|
l=$$1; \
|
|
|
|
shift; \
|
|
|
|
t=${DESTDIR}$$1; \
|
|
|
|
shift; \
|
|
|
|
${ECHO} $$t -\> $$l; \
|
|
|
|
ln -fs $$l $$t; \
|
1994-09-14 21:59:28 +00:00
|
|
|
done; true
|
|
|
|
.endif
|
|
|
|
|
1996-06-24 04:26:21 +00:00
|
|
|
install: afterinstall _SUBDIR
|
1994-09-14 21:59:28 +00:00
|
|
|
.if !defined(NOMAN)
|
|
|
|
afterinstall: realinstall maninstall
|
|
|
|
.else
|
|
|
|
afterinstall: realinstall
|
|
|
|
.endif
|
|
|
|
realinstall: beforeinstall
|
|
|
|
.endif
|
|
|
|
|
1995-01-14 07:51:10 +00:00
|
|
|
DISTRIBUTION?= bin
|
1994-11-13 21:05:28 +00:00
|
|
|
.if !target(distribute)
|
1996-06-24 04:26:21 +00:00
|
|
|
distribute: _SUBDIR
|
1997-06-21 15:40:34 +00:00
|
|
|
.for dist in ${DISTRIBUTION}
|
|
|
|
cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
|
|
|
|
.endfor
|
1994-11-13 21:05:28 +00:00
|
|
|
.endif
|
|
|
|
|
1994-09-14 21:59:28 +00:00
|
|
|
.if !target(load)
|
1999-09-06 20:11:59 +00:00
|
|
|
load: ${PROG} install
|
|
|
|
${KMODLOAD} ${KMOD}
|
1994-09-14 21:59:28 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !target(unload)
|
1999-09-06 20:11:59 +00:00
|
|
|
unload:
|
|
|
|
${KMODUNLOAD} ${KMOD}
|
1994-09-14 21:59:28 +00:00
|
|
|
.endif
|
|
|
|
|
1998-10-16 03:32:03 +00:00
|
|
|
.if exists(${.CURDIR}/../../kern)
|
|
|
|
KERN= ${.CURDIR}/../../kern
|
|
|
|
.else
|
1994-09-21 03:49:59 +00:00
|
|
|
KERN= ${.CURDIR}/../../sys/kern
|
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
|
|
|
|
|
|
|
|
.for _srcsrc in kern/bus_if.m kern/device_if.m dev/iicbus/iicbb_if.m \
|
2000-01-23 15:42:44 +00:00
|
|
|
dev/iicbus/iicbus_if.m isa/isa_if.m dev/mii/miibus_if.m \
|
|
|
|
dev/pccard/card_if.m dev/pccard/power_if.m pci/pci_if.m \
|
|
|
|
dev/ppbus/ppbus_if.m dev/smbus/smbus_if.m dev/usb/usb_if.m
|
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})
|
|
|
|
${_src}: @
|
|
|
|
.if exists(@)
|
|
|
|
${_src}: @/kern/makedevops.pl @/${_srcsrc}
|
|
|
|
.endif
|
|
|
|
perl @/kern/makedevops.pl -${_ext} @/${_srcsrc}
|
|
|
|
.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}
|
|
|
|
vnode_if.${_ext}: @
|
1999-11-28 17:52:40 +00:00
|
|
|
.if exists(@)
|
1999-12-22 01:07:30 +00:00
|
|
|
vnode_if.${_ext}: @/kern/vnode_if.pl @/kern/vnode_if.src
|
1999-11-28 17:52:40 +00:00
|
|
|
.endif
|
1999-12-22 01:07:30 +00:00
|
|
|
perl @/kern/vnode_if.pl -${_ext} @/kern/vnode_if.src
|
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
|
|
|
|
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>
|