Subject: lkm building mods.
To: None <tech-kern@netbsd.org>
From: Simon Burge <simonb@wasabisystems.com>
List: tech-kern
Date: 09/27/2001 18:51:02
Folks,

Here's some changes to the lkm building framework to assist building
working LKMs on mips (and possibly powerpc and/or arm).  In a nutshell,
the existing "include a Makefile.inc" is made more robust and also looks
in cpu include directory as well as the machine one.

The reason for ".-include"ing the full path names is that the machine
links aren't set up before the first make(1) is run.  For the alpha
case, MACHINE and MACHINE_CPU are the same, so the Makefile.inc fragment
has multiple include protection.

Anyone see any problems with this?  I'll commit it in a couple of days
otherwise...

Simon.
--
Simon Burge                            <simonb@wasabisystems.com>
NetBSD CDs, Support and Service:    http://www.wasabisystems.com/


Index: share/mk/bsd.kmod.mk
===================================================================
RCS file: /cvsroot/sharesrc/share/mk/bsd.kmod.mk,v
retrieving revision 1.40
diff -d -p -u -r1.40 bsd.kmod.mk
--- share/mk/bsd.kmod.mk	2001/08/14 07:02:13	1.40
+++ share/mk/bsd.kmod.mk	2001/09/27 08:47:41
@@ -47,9 +47,9 @@ beforedepend: machine-links
 machine-links:
 	-rm -f machine && \
 	    ln -s $S/arch/${MACHINE}/include machine
-	-rm -f ${MACHINE_ARCH} && \
-	    ln -s $S/arch/${MACHINE_ARCH}/include ${MACHINE_ARCH}
-CLEANFILES+=machine ${MACHINE_ARCH}
+	-rm -f ${MACHINE_CPU} && \
+	    ln -s $S/arch/${MACHINE_CPU}/include ${MACHINE_CPU}
+CLEANFILES+=machine ${MACHINE_CPU}
 
 cleankmod:
 	rm -f a.out [Ee]rrs mklog core *.core \
@@ -95,4 +95,5 @@ unload:
 .include <bsd.dep.mk>
 .include <bsd.sys.mk>
 
-.-include "machine/Makefile.inc"
+.-include "$S/arch/${MACHINE_CPU}/include/Makefile.inc"
+.-include "$S/arch/${MACHINE}/include/Makefile.inc"
Index: sys/arch/alpha/include/Makefile.inc
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/alpha/include/Makefile.inc,v
retrieving revision 1.1
diff -d -p -u -r1.1 Makefile.inc
--- sys/arch/alpha/include/Makefile.inc	1999/03/10 06:41:48	1.1
+++ sys/arch/alpha/include/Makefile.inc	2001/09/27 08:47:41
@@ -1,3 +1,8 @@
 # $NetBSD: Makefile.inc,v 1.1 1999/03/10 06:41:48 ross Exp $
 
+.if !defined(_ALPHA_MAKEFILE_INC)
+_ALPHA_MAKEFILE_INC=	yes
+
 CFLAGS += -mno-fp-regs
+
+.endif
Index: sys/arch/mips/include/Makefile.inc
===================================================================
RCS file: Makefile.inc
diff -N Makefile.inc
--- /dev/null	Thu Sep 27 05:39:44 2001
+++ Makefile.inc	Thu Sep 27 11:47:41 2001
@@ -0,0 +1,7 @@
+# $NetBSD$
+
+# Standard kernel compile flags
+CFLAGS += -G 0 -mno-abicalls -mno-half-pic
+
+# Needed so modules loaded in KSEG2 can make calls to KSEG0
+CFLAGS += -mlong-calls