summaryrefslogtreecommitdiffstats
path: root/share/mk/bsd.kmod.mk
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1998-01-26 20:36:38 +0000
committerbde <bde@FreeBSD.org>1998-01-26 20:36:38 +0000
commit7cbf61054433c203440b914e844eb387461c7894 (patch)
tree4a4a74666120d338a4818b311f91543fdef9896c /share/mk/bsd.kmod.mk
parent24ee1b21514a9b58d5b37717ce99492d6b120b07 (diff)
downloadFreeBSD-src-7cbf61054433c203440b914e844eb387461c7894.zip
FreeBSD-src-7cbf61054433c203440b914e844eb387461c7894.tar.gz
Generate symlinks to the "sys" and <machine> directories and put
them in the include path. This fixes recent breakage of the syscons LKMs and general brokenness of the include paths (headers under /usr/include were used in many cases).
Diffstat (limited to 'share/mk/bsd.kmod.mk')
-rw-r--r--share/mk/bsd.kmod.mk49
1 files changed, 37 insertions, 12 deletions
diff --git a/share/mk/bsd.kmod.mk b/share/mk/bsd.kmod.mk
index 5d50208..9cf946e 100644
--- a/share/mk/bsd.kmod.mk
+++ b/share/mk/bsd.kmod.mk
@@ -1,5 +1,5 @@
# From: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
-# $Id: bsd.kmod.mk,v 1.40 1997/07/21 16:04:41 bde Exp $
+# $Id: bsd.kmod.mk,v 1.41 1997/11/09 15:03:13 wosch Exp $
#
# The include file <bsd.kmod.mk> handles installing Loadable Kernel Modules.
#
@@ -90,13 +90,12 @@ MODUNLOAD?= /sbin/modunload
.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
-#
-# Assume that we are in /usr/src/foo/bar, so /sys is
-# ${.CURDIR}/../../sys. We don't bother adding a .PATH since nothing
-# actually lives in /sys directly.
-#
-CFLAGS+=${COPTS} -DKERNEL -DACTUALLY_LKM_NOT_KERNEL -I${.CURDIR}/../../sys \
- ${CWARNFLAGS}
+CFLAGS+= ${COPTS} -DKERNEL -DACTUALLY_LKM_NOT_KERNEL ${CWARNFLAGS}
+
+# Add -I paths for system headers. Individual LKM makefiles don't need any
+# -I paths for this. Most of them need .PATH statement(s) for non-headers.
+CFLAGS+= -I${.OBJDIR} -I${.OBJDIR}/@
+
.if defined(DESTDIR)
CFLAGS+= -I${DESTDIR}/usr/include
.endif
@@ -104,7 +103,7 @@ CFLAGS+= -I${DESTDIR}/usr/include
EXPORT_SYMS?= _${KMOD}
.if defined(VFS_LKM)
-CFLAGS+= -DVFS_LKM -DMODVNOPS=${KMOD}vnops -I.
+CFLAGS+= -DVFS_LKM -DMODVNOPS=${KMOD}vnops
SRCS+= vnode_if.h
CLEANFILES+= vnode_if.h vnode_if.c
.endif
@@ -141,10 +140,36 @@ maninstall: _SUBDIR
all-man:
.endif
-.MAIN: all
-all: objwarn ${PROG} all-man _SUBDIR
+_ILINKS=@ machine
-CLEANFILES+= ${KMOD} ${PROG} ${OBJS}
+.MAIN: all
+all: ${_ILINKS} objwarn ${PROG} all-man _SUBDIR
+
+beforedepend: ${_ILINKS}
+
+# The search for the link targets works best if we are in a normal src
+# tree, and not too deeply below src/lkm. If we are near "/", then
+# 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.
+${_ILINKS}:
+ @for up in ../.. ../../.. ; do \
+ case ${.TARGET} in \
+ machine) \
+ path=${.CURDIR}/$$up/sys/${MACHINE_ARCH}/include ; \
+ defaultpath=/usr/include/machine ;; \
+ @) \
+ path=${.CURDIR}/$$up/sys ; \
+ defaultpath=/usr/include ;; \
+ esac ; \
+ if [ -d $$path ] ; then break ; fi ; \
+ path=$$defaultpath ; \
+ done ; \
+ path=`(cd $$path && /bin/pwd)` ; \
+ ${ECHO} ${.TARGET} "->" $$path ; \
+ ln -s $$path ${.TARGET}
+
+CLEANFILES+= ${KMOD} ${PROG} ${OBJS} ${_ILINKS}
.if !target(install)
.if !target(beforeinstall)
OpenPOWER on IntegriCloud