Introduce NOPIE and NOCTF so that standalone programs build properly.

This commit is contained in:
christos 2016-01-31 15:30:14 +00:00
parent f56c05e9f6
commit dc084e400e
4 changed files with 14 additions and 7 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: bsd.lib.mk,v 1.362 2015/09/08 16:06:42 uebayasi Exp $
# $NetBSD: bsd.lib.mk,v 1.363 2016/01/31 15:30:14 christos Exp $
# @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94
.include <bsd.init.mk>
@ -42,7 +42,7 @@ realinstall: checkver libinstall
# XXX: This is needed for programs that link with .a libraries
# Perhaps a more correct solution is to always generate _pic.a
# files or always have a shared library.
.if defined(MKPIE) && (${MKPIE} != "no")
.if defined(MKPIE) && (${MKPIE} != "no") && !defined(NOPIE)
CFLAGS+= ${PIE_CFLAGS}
AFLAGS+= ${PIE_AFLAGS}
.endif

View File

@ -1,4 +1,4 @@
# $NetBSD: bsd.own.mk,v 1.889 2016/01/29 15:33:51 christos Exp $
# $NetBSD: bsd.own.mk,v 1.890 2016/01/31 15:30:14 christos Exp $
# This needs to be before bsd.init.mk
.if defined(BSD_MK_COMPAT_FILE)
@ -528,6 +528,13 @@ TOOL_ZIC= zic
.endif # USETOOLS != yes # }
# Standalone code should not be compiled with PIE or CTF
# Should create a better test
.if defined(BINDIR) && ${BINDIR} == "/usr/mdec"
NOPIE= # defined
NOCTF= # defined
.endif
# Fallback to ensure that all variables are defined to something
TOOL_CC.false= false
TOOL_CPP.false= false

View File

@ -1,4 +1,4 @@
# $NetBSD: bsd.prog.mk,v 1.294 2016/01/23 21:22:47 christos Exp $
# $NetBSD: bsd.prog.mk,v 1.295 2016/01/31 15:30:14 christos Exp $
# @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
.ifndef HOSTPROG
@ -48,7 +48,7 @@ CLEANFILES+=strings
@rm -f x.cc
.endif
.if defined(MKPIE) && (${MKPIE} != "no")
.if defined(MKPIE) && (${MKPIE} != "no") && !defined(NOPIE)
CFLAGS+= ${PIE_CFLAGS}
AFLAGS+= ${PIE_AFLAGS}
LDFLAGS+= ${PIE_LDFLAGS}

View File

@ -1,4 +1,4 @@
# $NetBSD: bsd.sys.mk,v 1.250 2016/01/10 16:22:57 christos Exp $
# $NetBSD: bsd.sys.mk,v 1.251 2016/01/31 15:30:14 christos Exp $
#
# Build definitions used for NetBSD source tree builds.
@ -174,7 +174,7 @@ CPUFLAGS+= -Wa,--fatal-warnings
CFLAGS+= ${CPUFLAGS}
AFLAGS+= ${CPUFLAGS}
.if !defined(LDSTATIC) || ${LDSTATIC} != "-static"
.if !defined(NOPIE) && (!defined(LDSTATIC) || ${LDSTATIC} != "-static")
# Position Independent Executable flags
PIE_CFLAGS?= -fPIC
PIE_LDFLAGS?= -Wl,-pie ${${ACTIVE_CC} == "gcc":? -shared-libgcc :}