Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Jul 2011 21:46:12 +0200
From:      Robert Millan <rmh@debian.org>
To:        freebsd-hackers@freebsd.org, Ed Maste <emaste@freebsd.org>
Subject:   [PATCH] fake pre-processor macros when building on non-FreeBSD system
Message-ID:  <CAOfDtXNqydD_hyvo25Arkm=gdqVcSJB8RPfnFL9xozQfS=UeEQ@mail.gmail.com>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
When building kernel code on a non-FreeBSD system, kernel source still
expects pre-processor macros to be those of a FreeBSD system.  If
__linux__ is defined, build will break.  If __FreeBSD__ isn't defined,
build will break too.

This small patch "fakes" the pre-processor macros of FreeBSD so that
non-FreeBSD systems such as GNU/Linux can build the kernel of FreeBSD
too.

-- 
Robert Millan

[-- Attachment #2 --]
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@ -90,6 +90,14 @@
 .endif
 WERROR?= -Werror
 
+.if !defined(OPSYS)
+OPSYS!= uname -s
+.endif
+
+.if ${OPSYS} != "FreeBSD"
+CFLAGS+= -Ulinux -U__linux__ -D__FreeBSD__
+.endif
+
 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
 
--- a/sys/conf/kmod.mk
+++ b/sys/conf/kmod.mk
@@ -96,6 +96,14 @@
 CFLAGS+=	-D_KERNEL
 CFLAGS+=	-DKLD_MODULE
 
+.if !defined(OPSYS)
+OPSYS!=		uname -s
+.endif
+
+.if ${OPSYS} != "FreeBSD"
+CFLAGS+=	-Ulinux -U__linux__ -D__FreeBSD__
+.endif
+
 # Don't use any standard or source-relative include directories.
 CSTD=		c99
 NOSTDINC=	-nostdinc

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOfDtXNqydD_hyvo25Arkm=gdqVcSJB8RPfnFL9xozQfS=UeEQ>