diff --git a/Mk/Features/debug.mk b/Mk/Features/debug.mk new file mode 100644 --- /dev/null +++ b/Mk/Features/debug.mk @@ -0,0 +1,24 @@ +# DEBUG Support +# +# Add WITH_DEBUG into make.conf: +# - If set, debugging flags are added to CFLAGS and the binaries don't get +# stripped by INSTALL_PROGRAM or INSTALL_LIB. Besides, individual ports might +# add their specific to produce binaries for debugging purposes. You can +# override the debug flags that are passed to the compiler by setting +# DEBUG_FLAGS. It is set to "-g" at default. + +.if !defined(_DEBUG_MK_INCLUDED) +_DEBUG_MK_INCLUDED= yes +DEBUG_Include_MAINTAINER= portmgr@FreeBSD.org + +. if !defined(INSTALL_STRIPPED) +STRIP= #none +MAKE_ENV+= DONTSTRIP=yes +STRIP_CMD= ${TRUE} +. endif +DEBUG_FLAGS?= -g +CFLAGS:= ${CFLAGS:N-O*:N-fno-strict*} ${DEBUG_FLAGS} +. if defined(INSTALL_TARGET) +INSTALL_TARGET:= ${INSTALL_TARGET:S/^install-strip$/install/g} +. endif +.endif diff --git a/Mk/bsd.lto.mk b/Mk/Features/lto.mk rename from Mk/bsd.lto.mk rename to Mk/Features/lto.mk --- a/Mk/bsd.lto.mk +++ b/Mk/Features/lto.mk @@ -1,13 +1,17 @@ # LTO Support +# # This file enforces Link Time Optimization for ports. -# In order to use it, add USE_LTO=yes to your /etc/make.conf. +# In order to use it, add WITH_LTO=yes to your /etc/make.conf. +.if !defined(_LTO_MK_INCLUDED) +_LTO_MK_INCLUDED= yes LTO_Include_MAINTAINER= pkubaj@FreeBSD.org -.if !defined(LTO_UNSAFE) +. if !defined(LTO_UNSAFE) # Overridable as a user may want to use -flto LTO_FLAGS?= -flto=thin CFLAGS+= ${LTO_FLAGS} CXXFLAGS+= ${LTO_FLAGS} LDFLAGS+= ${LTO_FLAGS} +. endif .endif diff --git a/Mk/bsd.ssp.mk b/Mk/Features/ssp.mk rename from Mk/bsd.ssp.mk rename to Mk/Features/ssp.mk --- a/Mk/bsd.ssp.mk +++ b/Mk/Features/ssp.mk @@ -1,11 +1,14 @@ # SSP Support +.if !defined(_SSP_MK_INCLUDED) +_SSP_MK_INCLUDED= yes SSP_Include_MAINTAINER= portmgr@FreeBSD.org -.if !defined(SSP_UNSAFE) && \ +. if !defined(SSP_UNSAFE) && \ (! ${ARCH:Mmips*}) # Overridable as a user may want to use -fstack-protector-all SSP_CFLAGS?= -fstack-protector-strong CFLAGS+= ${SSP_CFLAGS} LDFLAGS+= ${SSP_CFLAGS} +. endif .endif diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk --- a/Mk/bsd.port.mk +++ b/Mk/bsd.port.mk @@ -325,17 +325,6 @@ # usage inside the ports framework, and the latter are reserved for user- # settable options. (Setting USE_* in /etc/make.conf is always wrong). # -# WITH_DEBUG - If set, debugging flags are added to CFLAGS and the -# binaries don't get stripped by INSTALL_PROGRAM or -# INSTALL_LIB. Besides, individual ports might -# add their specific to produce binaries for debugging -# purposes. You can override the debug flags that are -# passed to the compiler by setting DEBUG_FLAGS. It is -# set to "-g" at default. -# -# NOTE: to override a globally defined WITH_DEBUG at a -# later time ".undef WITH_DEBUG" can be used -# # WITH_DEBUG_PORTS - A list of origins for which WITH_DEBUG will be set # # WITHOUT_SSP - Disable SSP. @@ -1019,6 +1008,8 @@ # These need to be absolute since we don't know how deep in the ports # tree we are and thus can't go relative. They can, of course, be overridden # by individual Makefiles or local system make configuration. +_LIST_OF_WITH_FEATURES= debug lto ssp +_DEFAULT_WITH_FEATURES= ssp PORTSDIR?= /usr/ports LOCALBASE?= /usr/local LINUXBASE?= /compat/linux @@ -1312,6 +1303,11 @@ . endif . endif +. if defined(USE_LTO) +WITH_LTO= ${USE_LTO} +WARNING+= USE_LTO is precrecated in favor of WITH_LTO +. endif + .include "${PORTSDIR}/Mk/bsd.default-versions.mk" .include "${PORTSDIR}/Mk/bsd.options.mk" @@ -1766,27 +1762,11 @@ . endif . endif -# Reset value from bsd.own.mk. -. if defined(WITH_DEBUG) -. if !defined(INSTALL_STRIPPED) -STRIP= #none -MAKE_ENV+= DONTSTRIP=yes -STRIP_CMD= ${TRUE} -. endif -DEBUG_FLAGS?= -g -CFLAGS:= ${CFLAGS:N-O*:N-fno-strict*} ${DEBUG_FLAGS} -. if defined(INSTALL_TARGET) -INSTALL_TARGET:= ${INSTALL_TARGET:S/^install-strip$/install/g} +. for f in ${_LIST_OF_WITH_FEATURES} +. if defined(WITH_${f:tu}) || ( ${_DEFAULT_WITH_FEATURES:M${f}} && !defined(WITHOUT_${f:tu}) ) +.include "${PORTSDIR}/Mk/Features/$f.mk" . endif -. endif - -. if defined(USE_LTO) -.include "${PORTSDIR}/Mk/bsd.lto.mk" -. endif - -. if !defined(WITHOUT_SSP) -.include "${PORTSDIR}/Mk/bsd.ssp.mk" -. endif +. endfor # XXX PIE support to be added here MAKE_ENV+= NO_PIE=yes