-# $OpenBSD: bsd.own.mk,v 1.150 2014/04/22 14:42:53 reyk Exp $
+# $OpenBSD: bsd.own.mk,v 1.151 2014/12/23 16:35:53 deraadt Exp $
# $NetBSD: bsd.own.mk,v 1.24 1996/04/13 02:08:09 thorpej Exp $
# Host-specific overrides
# m88k unknown
# hppa64 unknown
PIE_ARCH=alpha amd64 hppa i386 mips64 mips64el powerpc sh sparc64
+STATICPIE_ARCH=amd64
.for _arch in ${MACHINE_ARCH}
.if !empty(GCC3_ARCH:M${_arch})
BINUTILS_VERSION=binutils
.endif
+.if !empty(STATICPIE_ARCH:M${_arch})
+STATICPIE?=-pie -Wl,-Bsymbolic
+.endif
+
.if !empty(PIE_ARCH:M${_arch})
NOPIE_FLAGS?=-fno-pie
NOPIE_LDFLAGS?=-nopie
# This may be changed for _single filesystem_ configurations (such as
# routers and other embedded systems); normal systems should leave it alone!
-STATIC?= -static
+STATIC?= -static ${STATICPIE}
# Define SYS_INCLUDE to indicate whether you want symbolic links to the system
# source (``symlinks''), or a separate copy (``copies''); (latter useful
-# $OpenBSD: bsd.prog.mk,v 1.65 2014/10/31 13:46:17 jsing Exp $
+# $OpenBSD: bsd.prog.mk,v 1.66 2014/12/23 16:35:53 deraadt Exp $
# $NetBSD: bsd.prog.mk,v 1.55 1996/04/08 21:19:26 jtc Exp $
# @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
.SUFFIXES: .out .o .c .cc .cpp .C .cxx .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
-.if defined(LDSTATIC) || defined(NOPIE)
+.if (defined(LDSTATIC) && !defined(STATICPIE)) || defined(NOPIE)
CFLAGS+= ${NOPIE_FLAGS}
AFLAGS+= ${NOPIE_FLAGS}
LDFLAGS+= ${NOPIE_LDFLAGS}