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]
|
|
|
|
#
|
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
|
|
|
# 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
|
|
|
#
|
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
|
|
|
#
|
|
|
|
# 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)
|
|
|
|
#
|
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
|
|
|
#
|
|
|
|
# +++ 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.
|
|
|
|
#
|
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
|
|
|
# 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
|
|
|
|
2001-03-04 05:29:10 +00:00
|
|
|
TARGET_ARCH?= ${MACHINE_ARCH}
|
|
|
|
|
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*}
|
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
|
|
|
|
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
|
|
|
|
2000-05-01 18:06:49 +00:00
|
|
|
${PROG}: ${KMOD}.kld
|
|
|
|
${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld
|
1994-09-14 21:59:28 +00:00
|
|
|
|
2000-05-01 18:06:49 +00:00
|
|
|
${KMOD}.kld: ${OBJS}
|
|
|
|
${LD} ${LDFLAGS} -r -o ${.TARGET} ${OBJS}
|
1998-10-14 04:04:22 +00:00
|
|
|
|
1996-04-11 23:03:10 +00:00
|
|
|
.if !defined(NOMAN)
|
2001-03-27 11:50:44 +00:00
|
|
|
.if 0
|
|
|
|
MAN?= ${KMOD}.4
|
|
|
|
.endif
|
1996-04-11 23:03:10 +00:00
|
|
|
.include <bsd.man.mk>
|
2001-03-27 11:50:44 +00:00
|
|
|
.else
|
|
|
|
.if !target(all-man)
|
|
|
|
all-man: _SUBDIR
|
1994-09-14 21:59:28 +00:00
|
|
|
.endif
|
2001-03-27 11:50:44 +00:00
|
|
|
.if !target(maninstall)
|
1996-06-24 04:26:21 +00:00
|
|
|
maninstall: _SUBDIR
|
2001-03-27 11:50:44 +00:00
|
|
|
.endif
|
1996-04-11 23:03:10 +00:00
|
|
|
.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
|
|
|
|
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
|
|
|
|
2000-03-20 01:29:59 +00:00
|
|
|
CLEANFILES+= ${PROG} ${KMOD}.kld ${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
|
|
|
|
|
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
|
|
|
|
|
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)
|
2000-04-08 17:20:00 +00:00
|
|
|
load: ${PROG}
|
2000-06-22 02:07:18 +00:00
|
|
|
${KMODLOAD} -v ./${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 \
|
2001-02-27 01:23:34 +00:00
|
|
|
dev/sound/pcm/feeder_if.m dev/sound/pcm/mixer_if.m pci/agp_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(@)
|
2000-04-08 15:31:28 +00:00
|
|
|
${_src}: @/kern/makeobjops.pl @/${_srcsrc}
|
1999-11-28 17:52:40 +00:00
|
|
|
.endif
|
2000-04-08 15:31:28 +00:00
|
|
|
perl @/kern/makeobjops.pl -${_ext} @/${_srcsrc}
|
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(@)
|
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>
|