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.
This commit is contained in:
Gianluca Guida 2011-03-03 16:41:19 +00:00
parent f4814901af
commit 6567e50a6f
5 changed files with 28 additions and 1 deletions

View file

@ -156,6 +156,6 @@ cleanuudecodefiles: .PHONY
##### Pull in related .mk logic
.include <bsd.obj.mk>
#.include <bsd.sys.mk>
.include <bsd.sys.mk>
.endif # !defined(_MINIX_FILES_MK_)

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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