From 6567e50a6f33db706cd617e4e5ec1674f160a719 Mon Sep 17 00:00:00 2001 From: Gianluca Guida Date: Thu, 3 Mar 2011 16:41:19 +0000 Subject: [PATCH] mk scripts: add flag for compiling with nbsd libc. This patch changes the system mk scripts to enable compilation of programs using the BSD make system to compile with the new libc. In details, it does the following: - it always defines the __MINIX make variable. This can be used, in porting applications, to specialize Makefiles for Minix. - If the environment variable NBSD is set to something different than 'no' and if the compiler is not ack, set NBSD_LIBC to 'yes'. This will set the destination lib directory to '/usr/netbsd/lib' and set up CPPFLAGS and LDFLAGS to use new libc's includes and library directory. --- share/mk/bsd.files.mk | 2 +- share/mk/bsd.own.mk | 3 +++ share/mk/bsd.prog.mk | 8 ++++++++ share/mk/bsd.sys.mk | 5 +++++ share/mk/sys.mk | 11 +++++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/share/mk/bsd.files.mk b/share/mk/bsd.files.mk index c44c5d0a9..ee5956c33 100644 --- a/share/mk/bsd.files.mk +++ b/share/mk/bsd.files.mk @@ -156,6 +156,6 @@ cleanuudecodefiles: .PHONY ##### Pull in related .mk logic .include -#.include +.include .endif # !defined(_MINIX_FILES_MK_) diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index 975bffce6..e8bcb7678 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -541,6 +541,9 @@ OBJECT_FMT= ELF OBJECT_FMT= a.out .endif .if ${COMPILER_TYPE} == "gnu" +.if defined(NBSD_LIBC) && (${NBSD_LIBC} != "no") +LIBDIR?= /usr/netbsd/lib +.endif .if ${OBJECT_FMT} == "a.out" LIBDIR?= /usr/lib .elif ${OBJECT_FMT} == "ELF" diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index 52adbfffc..074e01033 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -28,8 +28,12 @@ cleanprog: .PHONY cleanobjs cleanextra ##### Default values .if empty(CPPFLAGS:M-nostdinc) +.if (${NBSD_LIBC} == "yes") +CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/netbsd/include} +.else CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include} .endif +.endif .if empty(CXXFLAGS:M-nostdinc++) CXXFLAGS+= ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} ${DESTDIR}/usr/include/g++} .endif @@ -65,8 +69,12 @@ LIB${_lib:tu}= ${DESTDIR}/usr/lib/lib${_lib}.a .if ${COMPILER_TYPE} == "ack" LIB${_lib:tu}= ${DESTDIR}/usr/lib/i386/lib${_lib}.a .elif ${COMPILER_TYPE} == "gnu" +.if defined(NBSD_LIBC) && (${NBSD_LIBC} != "no") +LIB${_lib:tu}= ${DESTDIR}/usr/netbsd/lib/lib${_lib}.a +.else LIB${_lib:tu}= ${DESTDIR}/usr/lib/lib${_lib}.a .endif +.endif .MADE: ${LIB${_lib:tu}} # Note: ${DESTDIR} will be expanded .endif .endfor diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index e36cea11b..efa998e6a 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -61,6 +61,11 @@ HAS_SSP= no HAS_SSP= yes .endif +.if defined(NBSD_LIBC) && (${NBSD_LIBC} != "no") +CPPFLAGS+= -nostdinc -D__NBSD_LIBC -I /usr/netbsd/include +LDFLAGS+= -L /usr/netbsd/lib +.endif + .if defined(USE_FORT) && (${USE_FORT} != "no") USE_SSP?= yes .if !defined(KERNSRCDIR) && !defined(KERN) # not for kernels nor kern modules diff --git a/share/mk/sys.mk b/share/mk/sys.mk index c5694e31c..686ce224c 100644 --- a/share/mk/sys.mk +++ b/share/mk/sys.mk @@ -3,6 +3,9 @@ unix?= We run MINIX. +# This variable should be used to differentiate Minix builds in Makefiles. +__MINIX= yes + .SUFFIXES: .a .o .ln .s .S .c .cc .cpp .cxx .C .f .F .r .p .l .y #.sh .LIBS: .a @@ -236,3 +239,11 @@ AR=i386-pc-minix3-ar LD=i386-pc-minix3-ld OBJCOPY=i386-pc-minix3-objcopy .endif + +# Set NBSD_LIBC to either "yes" or "no". +.if !defined(NBSD) || (${NBSD} == "no") \ + || (${COMPILER_TYPE} == "ack") +NBSD_LIBC= no +.else +NBSD_LIBC= yes +.endif