summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2015-08-08 13:49:04 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2015-08-08 17:38:18 -0700
commit56bd759df1d0c750a065b8c845e93d5dfa6b549d (patch)
tree3f91093cdb475e565ae857f1c5a7fd339e2d781e /sys-freebsd/freebsd-mk-defs
downloadgentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.gz
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.bz2
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.zip
proj/gentoo: Initial commit
This commit represents a new era for Gentoo: Storing the gentoo-x86 tree in Git, as converted from CVS. This commit is the start of the NEW history. Any historical data is intended to be grafted onto this point. Creation process: 1. Take final CVS checkout snapshot 2. Remove ALL ChangeLog* files 3. Transform all Manifests to thin 4. Remove empty Manifests 5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$ 5.1. Do not touch files with -kb/-ko keyword flags. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
Diffstat (limited to 'sys-freebsd/freebsd-mk-defs')
-rw-r--r--sys-freebsd/freebsd-mk-defs/Manifest3
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.0-gentoo.patch352
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.1-gnu.patch79
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gentoo.patch332
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gnu.patch121
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-9.1-gentoo.patch326
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-9.1-gnu.patch77
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-add-nossp-cflags.patch28
-rw-r--r--sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-10.1.ebuild42
-rw-r--r--sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-8.2.ebuild41
-rw-r--r--sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-9.1.ebuild39
-rw-r--r--sys-freebsd/freebsd-mk-defs/metadata.xml5
12 files changed, 1445 insertions, 0 deletions
diff --git a/sys-freebsd/freebsd-mk-defs/Manifest b/sys-freebsd/freebsd-mk-defs/Manifest
new file mode 100644
index 000000000000..424b8d6118d6
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/Manifest
@@ -0,0 +1,3 @@
+DIST freebsd-share-8.2.tar.bz2 3797560 SHA256 dd082c6ddbf8e08ec91d9810d51af4111339bed912b0f74d05be283780292ba0 SHA512 b3f964253f80e58cde12f26e48a23aa75c17b9ab2810f91a4bd2d7efbe902af7c73c219f8373a4fc97ee0a35d25627b8815c79c136ef18620acc8bd0ee5bd6c4 WHIRLPOOL 42326ad6139feadf80509f5e810f6a86009ad3a69aad9550c6355389773c28d5b2f7930eaa852f8442808485d13e5b758ed3420e39048bb3966785e6953119ea
+DIST freebsd-share-9.1.tar.bz2 6733003 SHA256 2bbd8aa05d52b18a1780772a8518d79d375c1eeae98f52fb6aded233ac2491d7 SHA512 9665e3d5253f49a55921012bd21a8688210a1993ba6be4ad17b5ba5619104a50f3199d49a0eb83cf29db5a06c407beb15616bfe71338c680fe34ec47564c4b43 WHIRLPOOL 7d15596888ac42af1a0c125591283524ff794dccbf9f6592963602f046a45ca073b10bda43c2d0d662fd3414753de64c05293788e03c4eea67de55d9bc083c11
+DIST freebsd-src-10.1.tar.xz 115049476 SHA256 f919287a5ef51d4f133f27c99c54f2e8054f408d3dd53bc60f4e233cc75ec03d SHA512 4ded32b451e2807e24a06305502f88ea633b2899a7ccd9cab3dc98fc865ef91324c93c512a08cf6e295313a8d7e79aa9d7af07da40e7276d986b06419b984152 WHIRLPOOL 1eff9419d89b8a70f064171883d92e160b250cd637972eb9107a19d7b3c904b554c4f51eaa9ff9642ef2c4234bde05cf9aef16d0c39280b55084f831700dea80
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.0-gentoo.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.0-gentoo.patch
new file mode 100644
index 000000000000..2b997540d5d8
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.0-gentoo.patch
@@ -0,0 +1,352 @@
+tested revision 255489
+
+diff --git a/share/mk/bsd.compiler.mk b/share/mk/bsd.compiler.mk
+index 2d648de..e456a4b 100644
+--- a/share/mk/bsd.compiler.mk
++++ b/share/mk/bsd.compiler.mk
+@@ -1,7 +1,7 @@
+ # $FreeBSD$
+
+ .if !defined(COMPILER_TYPE)
+-. if ${CC:T:Mgcc*}
++. if ${CC:T:M*gcc*}
+ COMPILER_TYPE:= gcc
+ . elif ${CC:T:Mclang}
+ COMPILER_TYPE:= clang
+diff --git a/share/mk/bsd.doc.mk b/share/mk/bsd.doc.mk
+index 49b2d9b..c2a8c5c 100644
+--- a/share/mk/bsd.doc.mk
++++ b/share/mk/bsd.doc.mk
+@@ -135,10 +135,12 @@ CLEANFILES+= ${DOC}.ascii ${DOC}.ascii${DCOMPRESS_EXT} \
+ realinstall:
+ .for _dev in ${PRINTERDEVICE:Mhtml}
+ cd ${SRCDIR}; \
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}; \
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DOC}*.html ${DESTDIR}${BINDIR}/${VOLUME}
+ .endfor
+ .for _dev in ${PRINTERDEVICE:Nhtml}
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}; \
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DFILE.${_dev}} ${DESTDIR}${BINDIR}/${VOLUME}
+ .endfor
+diff --git a/share/mk/bsd.files.mk b/share/mk/bsd.files.mk
+index 240f958..67f0cf9 100644
+--- a/share/mk/bsd.files.mk
++++ b/share/mk/bsd.files.mk
+@@ -39,6 +39,7 @@ ${group}NAME_${file:T}?= ${file:T}
+ .endif
+ installfiles: _${group}INS_${file:T}
+ _${group}INS_${file:T}: ${file}
++ ${INSTALL} -d ${DESTDIR}${${group}DIR_${.ALLSRC:T}}
+ ${INSTALL} -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+@@ -51,10 +52,12 @@ _${group}FILES+= ${file}
+ installfiles: _${group}INS
+ _${group}INS: ${_${group}FILES}
+ .if defined(${group}NAME)
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}/${${group}NAME}
+ ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
+ -m ${${group}MODE} ${.ALLSRC} \
+ ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}
+ ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
+ -m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}
+ .endif
+diff --git a/share/mk/bsd.incs.mk b/share/mk/bsd.incs.mk
+index 74c378b..7d2c7a0 100644
+--- a/share/mk/bsd.incs.mk
++++ b/share/mk/bsd.incs.mk
+@@ -41,6 +41,9 @@ ${group}NAME_${header:T}?= ${header:T}
+ .endif
+ installincludes: _${group}INS_${header:T}
+ _${group}INS_${header:T}: ${header}
++ ${INSTALL} -d -o ${${group}OWN_${.ALLSRC:T}} \
++ -g ${${group}GRP_${.ALLSRC:T}} \
++ ${DESTDIR}${${group}DIR_${.ALLSRC:T}}
+ ${INSTALL} -C -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+@@ -53,9 +56,13 @@ _${group}INCS+= ${header}
+ installincludes: _${group}INS
+ _${group}INS: ${_${group}INCS}
+ .if defined(${group}NAME)
++ ${INSTALL} -d -o ${${group}OWN} -g ${${group}GRP} \
++ ${DESTDIR}${${group}DIR}
+ ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
++ ${INSTALL} -d -o ${${group}OWN} -g ${${group}GRP} \
++ ${DESTDIR}${${group}DIR}
+ ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}
+ .endif
+diff --git a/share/mk/bsd.info.mk b/share/mk/bsd.info.mk
+index c54b435..d283240 100644
+--- a/share/mk/bsd.info.mk
++++ b/share/mk/bsd.info.mk
+@@ -83,6 +83,7 @@ INFO2HTML?= info2html
+ TEX?= tex
+ DVIPS?= dvips
+ DVIPS2ASCII?= dvips2ascii
++INSTALL?= install
+
+ .SUFFIXES: ${ICOMPRESS_EXT} .info .texi .texinfo .dvi .ps .latin1 .html
+
+@@ -144,15 +145,17 @@ ${x:S/$/${ICOMPRESS_EXT}/}: ${x}
+ INSTALLINFODIRS+= ${x:S/$/-install/}
+ ${x:S/$/-install/}:
+ .if !empty(.MAKEFLAGS:M-j)
++ ${INSTALL} -d ${DESTDIR}${INFODIR}
+ lockf -k ${DESTDIR}${INFODIR}/${INFODIRFILE} \
+ ${INSTALLINFO} ${INSTALLINFOFLAGS} \
+- --defsection=${INFOSECTION} \
+- --defentry=${INFOENTRY_${x}} \
++ --section=${INFOSECTION} \
++ --entry=${INFOENTRY_${x}} \
+ ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ .else
++ ${INSTALL} -d ${DESTDIR}${INFODIR}
+ ${INSTALLINFO} ${INSTALLINFOFLAGS} \
+- --defsection=${INFOSECTION} \
+- --defentry=${INFOENTRY_${x}} \
++ --section=${INFOSECTION} \
++ --entry=${INFOENTRY_${x}} \
+ ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ .endif
+ .endfor
+diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
+index bb3db64..dbb9bf4 100644
+--- a/share/mk/bsd.lib.mk
++++ b/share/mk/bsd.lib.mk
+@@ -39,8 +39,6 @@ CFLAGS+= ${DEBUG_FLAGS}
+ .if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != ""
+ CTFFLAGS+= -g
+ .endif
+-.else
+-STRIP?= -s
+ .endif
+
+ .if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \
+@@ -302,14 +300,17 @@ realinstall: _libinstall
+ .ORDER: beforeinstall _libinstall
+ _libinstall:
+ .if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
++ ${INSTALL} -d ${DESTDIR}${_LIBDIR}
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${_LIBDIR}
+ .endif
+ .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
++ ${INSTALL} -d ${DESTDIR}${_LIBDIR}
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${_LIBDIR}
+ .endif
+ .if defined(SHLIB_NAME)
++ ${INSTALL} -d ${DESTDIR}${_SHLIBDIR}
+ ${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
+ ${SHLIB_NAME} ${DESTDIR}${_SHLIBDIR}
+@@ -363,10 +364,12 @@ _libinstall:
+ .endif # SHLIB_LINK
+ .endif # SHIB_NAME
+ .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
++ ${INSTALL} -d ${DESTDIR}${_LIBDIR}
+ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${_LIBDIR}
+ .endif
+ .if defined(WANT_LINT) && !defined(NO_LINT) && defined(LIB) && !empty(LIB)
++ ${INSTALL} -d ${DESTDIR}${LINTLIBDIR}
+ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} ${LINTLIB} ${DESTDIR}${LINTLIBDIR}
+ .endif
+diff --git a/share/mk/bsd.libnames.mk b/share/mk/bsd.libnames.mk
+index 00d38ff..86792f4 100644
+--- a/share/mk/bsd.libnames.mk
++++ b/share/mk/bsd.libnames.mk
+@@ -53,7 +53,7 @@ LIBEDIT?= ${DESTDIR}${LIBDIR}/libedit.a
+ LIBELF?= ${DESTDIR}${LIBDIR}/libelf.a
+ LIBEXECINFO?= ${DESTDIR}${LIBDIR}/libexecinfo.a
+ LIBFETCH?= ${DESTDIR}${LIBDIR}/libfetch.a
+-LIBFL?= "don't use LIBFL, use LIBL"
++LIBFL?= ${DESTDIR}${LIBDIR}/libfl.a
+ LIBFORM?= ${DESTDIR}${LIBDIR}/libform.a
+ LIBG2C?= ${DESTDIR}${LIBDIR}/libg2c.a
+ LIBGCC?= ${DESTDIR}${LIBDIR}/libgcc.a
+@@ -88,7 +88,7 @@ LIBKEYCAP?= ${DESTDIR}${LIBDIR}/libkeycap.a
+ LIBKICONV?= ${DESTDIR}${LIBDIR}/libkiconv.a
+ LIBKRB5?= ${DESTDIR}${LIBDIR}/libkrb5.a
+ LIBKVM?= ${DESTDIR}${LIBDIR}/libkvm.a
+-LIBL?= ${DESTDIR}${LIBDIR}/libl.a
++LIBL?= ${DESTDIR}${LIBDIR}/libfl.a
+ .if ${MK_LDNS} != "no"
+ LIBLDNS?= ${DESTDIR}${LIBPRIVATEDIR}/libldns.a
+ .endif
+diff --git a/share/mk/bsd.links.mk b/share/mk/bsd.links.mk
+index 1e4d57e..fcb81fe 100644
+--- a/share/mk/bsd.links.mk
++++ b/share/mk/bsd.links.mk
+@@ -15,6 +15,8 @@ _installlinks:
+ t=${DESTDIR}$$1; \
+ shift; \
+ ${ECHO} $$t -\> $$l; \
++ d=`dirname $$t`; \
++ test -d $$d || mkdir $$d; \
+ ${INSTALL_LINK} $$l $$t; \
+ done; true
+ .endif
+@@ -26,6 +28,8 @@ _installlinks:
+ t=${DESTDIR}$$1; \
+ shift; \
+ ${ECHO} $$t -\> $$l; \
++ d=`dirname $$t`; \
++ test -d $$d || mkdir $$d; \
+ ${INSTALL_SYMLINK} $$l $$t; \
+ done; true
+ .endif
+diff --git a/share/mk/bsd.man.mk b/share/mk/bsd.man.mk
+index 6445ba3..fabffa2 100644
+--- a/share/mk/bsd.man.mk
++++ b/share/mk/bsd.man.mk
+@@ -165,9 +165,11 @@ _maninstall: ${MAN}
+ .if defined(NO_MANCOMPRESS)
+ .if defined(MANFILTER)
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}/${page}
+ ${MINSTALL} ${__page:T:S/$/${FILTEXTENSION}/g} \
+ ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/${__page}
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page}
+ .endif
+@@ -181,11 +183,14 @@ _maninstall: ${MAN}
+ esac; \
+ page=$$1; shift; sect=$$1; shift; \
+ d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \
++ ${ECHO} ${INSTALL} -d $${d}; \
++ ${INSTALL} -d $${d}; \
+ ${ECHO} ${MINSTALL} $${page} $${d}; \
+ ${MINSTALL} $${page} $${d}; \
+ done
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page:T}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}/} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T}
+ .endfor
+@@ -193,9 +198,11 @@ _maninstall: ${MAN}
+ .endif
+ .else
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}
+ ${MINSTALL} ${__page:T:S/$/${MCOMPRESS_EXT}/g} \
+ ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page:T:S/$/${MCOMPRESS_EXT}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}/}
+ .endif
+diff --git a/share/mk/bsd.nls.mk b/share/mk/bsd.nls.mk
+index 48093eb..69f56bc 100644
+--- a/share/mk/bsd.nls.mk
++++ b/share/mk/bsd.nls.mk
+@@ -62,7 +62,8 @@ NLSDIR?= ${SHAREDIR}/nls
+ # installation rules
+ #
+ .for file in ${NLS}
+-NLSNAME_${file:T}= ${file:T:R}/${NLSNAME}.cat
++NLSDIR_${file:T}= ${SHAREDIR}/nls/${file:T:R}/
++NLSNAME_${file:T}= ${NLSNAME}.cat
+ .if defined(NLSLINKS_${file:R}) && !empty(NLSLINKS_${file:R})
+ NLSLINKS+= ${file:R}
+ .endif
+diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk
+index 8f7f0b9..189ccec 100644
+--- a/share/mk/bsd.own.mk
++++ b/share/mk/bsd.own.mk
+@@ -202,9 +202,6 @@ INSTALL_LINK?= ${INSTALL} ${HRDLINK}
+ INSTALL_SYMLINK?= ${INSTALL} ${SYMLINK}
+
+ # Common variables
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+
+ COMPRESS_CMD?= gzip -cn
+ COMPRESS_EXT?= .gz
+diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
+index 22ddfb5..f6a4939 100644
+--- a/share/mk/bsd.prog.mk
++++ b/share/mk/bsd.prog.mk
+@@ -44,10 +44,6 @@ CTFFLAGS+= -g
+ .endif
+ .endif
+
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+-
+ .if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO")
+ LDFLAGS+= -static
+ .endif
+@@ -201,6 +197,7 @@ realinstall: _proginstall
+ .ORDER: beforeinstall _proginstall
+ _proginstall:
+ .if defined(PROG)
++ ${INSTALL} -d ${DESTDIR}${BINDIR}
+ ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
+ .if ${MK_DEBUG_FILES} != "no"
+@@ -234,6 +231,7 @@ SCRIPTSGRP_${script:T}?= ${SCRIPTSGRP}
+ SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE}
+ _scriptsinstall: _SCRIPTSINS_${script:T}
+ _SCRIPTSINS_${script:T}: ${script}
++ ${INSTALL} -d ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}
+ ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
+ -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
+index 72dfa61..4f21af4 100644
+--- a/share/mk/bsd.sys.mk
++++ b/share/mk/bsd.sys.mk
+@@ -30,10 +30,6 @@ CFLAGS+= -std=${CSTD}
+ .if defined(WARNS)
+ .if ${WARNS} >= 1
+ CWARNFLAGS+= -Wsystem-headers
+-.if !defined(NO_WERROR) && (${COMPILER_TYPE} != "clang" \
+- || !defined(NO_WERROR.clang))
+-CWARNFLAGS+= -Werror
+-.endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang)
+ .endif # WARNS >= 1
+ .if ${WARNS} >= 2
+ CWARNFLAGS+= -Wall -Wno-format-y2k
+@@ -99,10 +95,6 @@ CWARNFLAGS+= -Wformat=2 -Wno-format-extra-args
+ CWARNFLAGS+= -Wno-format-nonliteral
+ .endif # WARNS <= 3
+ .endif # CLANG
+-.if !defined(NO_WERROR) && (${COMPILER_TYPE} != "clang" \
+- || !defined(NO_WERROR.clang))
+-CWARNFLAGS+= -Werror
+-.endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang)
+ .endif # WFORMAT > 0
+ .endif # WFORMAT
+ .if defined(NO_WFORMAT) || (${COMPILER_TYPE} == "clang" && defined(NO_WFORMAT.clang))
+diff --git a/share/mk/sys.mk b/share/mk/sys.mk
+index eb9f2ca..09ad4cf 100644
+--- a/share/mk/sys.mk
++++ b/share/mk/sys.mk
+@@ -321,12 +321,6 @@ YFLAGS ?= -d
+ rm -f ${.PREFIX}.tmp.c
+ ${CTFCONVERT_CMD}
+
+-# FreeBSD build pollution. Hide it in the non-POSIX part of the ifdef.
+-__MAKE_CONF?=/etc/make.conf
+-.if exists(${__MAKE_CONF})
+-.include "${__MAKE_CONF}"
+-.endif
+-
+ .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
+ SHELL= ${__MAKE_SHELL}
+ .SHELL: path=${__MAKE_SHELL}
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.1-gnu.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.1-gnu.patch
new file mode 100644
index 000000000000..e566e6235a3a
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.1-gnu.patch
@@ -0,0 +1,79 @@
+diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
+index a5eacf9..01d1045 100644
+--- a/share/mk/bsd.lib.mk
++++ b/share/mk/bsd.lib.mk
+@@ -166,11 +166,7 @@ _LIBS= lib${LIB}.a
+ lib${LIB}.a: ${OBJS} ${STATICOBJS}
+ @${ECHO} building static ${LIB} library
+ @rm -f ${.TARGET}
+-.if !defined(NM)
+- @${AR} ${ARFLAGS} ${.TARGET} `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
+-.else
+- @${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
+-.endif
++ @${AR} ${ARFLAGS} ${.TARGET} ${OBJS} ${STATICOBJS} ${ARADD}
+ ${RANLIB} ${RANLIBFLAGS} ${.TARGET}
+ .endif
+
+@@ -183,11 +179,7 @@ POBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=.po}
+ lib${LIB}_p.a: ${POBJS}
+ @${ECHO} building profiled ${LIB} library
+ @rm -f ${.TARGET}
+-.if !defined(NM)
+- @${AR} ${ARFLAGS} ${.TARGET} `lorder ${POBJS} | tsort -q` ${ARADD}
+-.else
+- @${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' lorder ${POBJS} | tsort -q` ${ARADD}
+-.endif
++ @${AR} ${ARFLAGS} ${.TARGET} ${POBJS} ${ARADD}
+ ${RANLIB} ${RANLIBFLAGS} ${.TARGET}
+ .endif
+
+@@ -214,15 +206,9 @@ ${SHLIB_NAME_FULL}: ${SOBJS}
+ .if defined(SHLIB_LINK)
+ @${INSTALL_SYMLINK} ${SHLIB_NAME} ${SHLIB_LINK}
+ .endif
+-.if !defined(NM)
+ @${CC} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
+ -o ${.TARGET} -Wl,-soname,${SONAME} \
+- `lorder ${SOBJS} | tsort -q` ${LDADD}
+-.else
+- @${CC} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
+- -o ${.TARGET} -Wl,-soname,${SONAME} \
+- `NM='${NM}' lorder ${SOBJS} | tsort -q` ${LDADD}
+-.endif
++ `echo ${SOBJS} | xargs -n 1 echo | sort -u` ${LDADD}
+ .if ${MK_CTF} != "no"
+ ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}
+ .endif
+@@ -280,13 +266,6 @@ _EXTRADEPEND:
+
+ .if !target(install)
+
+-.if defined(PRECIOUSLIB)
+-.if !defined(NO_FSCHG)
+-SHLINSTALLFLAGS+= -fschg
+-.endif
+-SHLINSTALLFLAGS+= -S
+-.endif
+-
+ _INSTALLFLAGS:= ${INSTALLFLAGS}
+ .for ie in ${INSTALLFLAGS_EDIT}
+ _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
+diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
+index a53ea14..af3f37c 100644
+--- a/share/mk/bsd.prog.mk
++++ b/share/mk/bsd.prog.mk
+@@ -179,13 +179,6 @@ _EXTRADEPEND:
+
+ .if !target(install)
+
+-.if defined(PRECIOUSPROG)
+-.if !defined(NO_FSCHG)
+-INSTALLFLAGS+= -fschg
+-.endif
+-INSTALLFLAGS+= -S
+-.endif
+-
+ _INSTALLFLAGS:= ${INSTALLFLAGS}
+ .for ie in ${INSTALLFLAGS_EDIT}
+ _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gentoo.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gentoo.patch
new file mode 100644
index 000000000000..f17f6c4aad3a
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gentoo.patch
@@ -0,0 +1,332 @@
+Index: share/mk/bsd.doc.mk
+===================================================================
+--- share/mk/bsd.doc.mk.orig
++++ share/mk/bsd.doc.mk
+@@ -137,10 +137,12 @@ CLEANFILES+= ${DOC}.ascii ${DOC}.ascii${
+ realinstall:
+ .for _dev in ${PRINTERDEVICE:Mhtml}
+ cd ${SRCDIR}; \
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DOC}*.html ${DESTDIR}${BINDIR}/${VOLUME}
+ .endfor
+ .for _dev in ${PRINTERDEVICE:Nhtml}
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DFILE.${_dev}} ${DESTDIR}${BINDIR}/${VOLUME}
+ .endfor
+Index: share/mk/bsd.files.mk
+===================================================================
+--- share/mk/bsd.files.mk.orig
++++ share/mk/bsd.files.mk
+@@ -39,6 +39,7 @@ ${group}NAME_${file:T}?= ${file:T}
+ .endif
+ installfiles: _${group}INS_${file:T}
+ _${group}INS_${file:T}: ${file}
++ ${INSTALL} -d ${DESTDIR}${${group}DIR_${.ALLSRC}}/${${group}NAME_${.ALLSRC:T}:H}
+ ${INSTALL} -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+@@ -51,10 +52,12 @@ _${group}FILES+= ${file}
+ installfiles: _${group}INS
+ _${group}INS: ${_${group}FILES}
+ .if defined(${group}NAME)
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}/${${group}NAME}
+ ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
+ -m ${${group}MODE} ${.ALLSRC} \
+ ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}
+ ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
+ -m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}
+ .endif
+Index: share/mk/bsd.incs.mk
+===================================================================
+--- share/mk/bsd.incs.mk.orig
++++ share/mk/bsd.incs.mk
+@@ -41,6 +41,10 @@ ${group}NAME_${header:T}?= ${header:T}
+ .endif
+ installincludes: _${group}INS_${header:T}
+ _${group}INS_${header:T}: ${header}
++
++ ${INSTALL} -d -o ${${group}OWN_${.ALLSRC:T}} \
++ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
++ ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
+ ${INSTALL} -C -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+@@ -53,9 +57,11 @@ _${group}INCS+= ${header}
+ installincludes: _${group}INS
+ _${group}INS: ${_${group}INCS}
+ .if defined(${group}NAME)
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}
+ ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}
+ ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}
+ .endif
+Index: share/mk/bsd.info.mk
+===================================================================
+--- share/mk/bsd.info.mk.orig
++++ share/mk/bsd.info.mk
+@@ -83,6 +83,7 @@ INFO2HTML?= info2html
+ TEX?= tex
+ DVIPS?= dvips
+ DVIPS2ASCII?= dvips2ascii
++INSTALL?= install
+
+ .SUFFIXES: ${ICOMPRESS_EXT} .info .texi .texinfo .dvi .ps .latin1 .html
+
+@@ -144,12 +145,14 @@ ${x:S/$/${ICOMPRESS_EXT}/}: ${x}
+ INSTALLINFODIRS+= ${x:S/$/-install/}
+ ${x:S/$/-install/}:
+ .if !empty(.MAKEFLAGS:M-j)
++ ${INSTALL} -d ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ lockf -k ${DESTDIR}${INFODIR}/${INFODIRFILE} \
+ ${INSTALLINFO} ${INSTALLINFOFLAGS} \
+ --defsection=${INFOSECTION} \
+ --defentry=${INFOENTRY_${x}} \
+ ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ .else
++ ${INSTALL} -d ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ ${INSTALLINFO} ${INSTALLINFOFLAGS} \
+ --defsection=${INFOSECTION} \
+ --defentry=${INFOENTRY_${x}} \
+Index: share/mk/bsd.lib.mk
+===================================================================
+--- share/mk/bsd.lib.mk.orig
++++ share/mk/bsd.lib.mk
+@@ -41,10 +41,6 @@ CTFFLAGS+= -g
+ .endif
+ .endif
+
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+-
+ .include <bsd.libnames.mk>
+
+ # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
+@@ -276,14 +272,17 @@ realinstall: _libinstall
+ .ORDER: beforeinstall _libinstall
+ _libinstall:
+ .if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
++ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR}
+ .endif
+ .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
++ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR}
+ .endif
+ .if defined(SHLIB_NAME)
++ ${INSTALL} -d ${DESTDIR}${SHLIBDIR}
+ ${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
+ ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}
+Index: share/mk/bsd.libnames.mk
+===================================================================
+--- share/mk/bsd.libnames.mk.orig
++++ share/mk/bsd.libnames.mk
+@@ -46,7 +46,7 @@ LIBDWARF?= ${DESTDIR}${LIBDIR}/libdwarf.
+ LIBEDIT?= ${DESTDIR}${LIBDIR}/libedit.a
+ LIBELF?= ${DESTDIR}${LIBDIR}/libelf.a
+ LIBFETCH?= ${DESTDIR}${LIBDIR}/libfetch.a
+-LIBFL?= "don't use LIBFL, use LIBL"
++LIBFL?= ${DESTDIR}${LIBDOR}/libfl.a
+ LIBFORM?= ${DESTDIR}${LIBDIR}/libform.a
+ LIBFTPIO?= ${DESTDIR}${LIBDIR}/libftpio.a
+ LIBG2C?= ${DESTDIR}${LIBDIR}/libg2c.a
+@@ -77,7 +77,7 @@ LIBKEYCAP?= ${DESTDIR}${LIBDIR}/libkeyca
+ LIBKICONV?= ${DESTDIR}${LIBDIR}/libkiconv.a
+ LIBKRB5?= ${DESTDIR}${LIBDIR}/libkrb5.a
+ LIBKVM?= ${DESTDIR}${LIBDIR}/libkvm.a
+-LIBL?= ${DESTDIR}${LIBDIR}/libl.a
++LIBL?= ${DESTDIR}${LIBDOR}/libfl.a
+ LIBLN?= "don't use LIBLN, use LIBL"
+ .if ${MK_BIND} != "no"
+ LIBLWRES?= ${DESTDIR}${LIBDIR}/liblwres.a
+Index: share/mk/bsd.man.mk
+===================================================================
+--- share/mk/bsd.man.mk.orig
++++ share/mk/bsd.man.mk
+@@ -165,9 +165,11 @@ _maninstall: ${MAN}
+ .if defined(NO_MANCOMPRESS)
+ .if defined(MANFILTER)
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}/${page}
+ ${MINSTALL} ${__page:T:S/$/${FILTEXTENSION}/g} \
+ ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/${__page}
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}/${page}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page}
+ .endif
+@@ -181,11 +183,14 @@ _maninstall: ${MAN}
+ esac; \
+ page=$$1; shift; sect=$$1; shift; \
+ d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \
++ ${ECHO} ${INSTALL} -d $${d}; \
++ ${INSTALL} -d $${d}; \
+ ${ECHO} ${MINSTALL} $${page} $${d}; \
+ ${MINSTALL} $${page} $${d}; \
+ done
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page:T}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}/} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T}
+ .endfor
+@@ -193,9 +198,11 @@ _maninstall: ${MAN}
+ .endif
+ .else
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}
+ ${MINSTALL} ${__page:T:S/$/${MCOMPRESS_EXT}/g} \
+ ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page:T:S/$/${MCOMPRESS_EXT}/}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}/}
+ .endif
+Index: share/mk/bsd.prog.mk
+===================================================================
+--- share/mk/bsd.prog.mk.orig
++++ share/mk/bsd.prog.mk
+@@ -27,10 +27,6 @@ CTFFLAGS+= -g
+ CFLAGS+=${CRUNCH_CFLAGS}
+ .endif
+
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+-
+ .if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO")
+ LDFLAGS+= -static
+ .endif
+@@ -152,9 +148,11 @@ realinstall: _proginstall
+ _proginstall:
+ .if defined(PROG)
+ .if defined(PROGNAME)
++ ${INSTALL} -d ${DESTDIR}${BINDIR}
+ ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
+ .else
++ ${INSTALL} -d ${DESTDIR}${BINDIR}
+ ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
+ .endif
+@@ -182,6 +180,7 @@ SCRIPTSGRP_${script:T}?= ${SCRIPTSGRP}
+ SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE}
+ _scriptsinstall: _SCRIPTSINS_${script:T}
+ _SCRIPTSINS_${script:T}: ${script}
++ ${INSTALL} -d ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}
+ ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
+ -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+Index: share/mk/bsd.sys.mk
+===================================================================
+--- share/mk/bsd.sys.mk.orig
++++ share/mk/bsd.sys.mk
+@@ -28,9 +28,6 @@ CFLAGS += -std=${CSTD}
+ . if defined(WARNS)
+ . if ${WARNS} >= 1
+ CWARNFLAGS += -Wsystem-headers
+-. if !defined(NO_WERROR)
+-CWARNFLAGS += -Werror
+-. endif
+ . endif
+ . if ${WARNS} >= 2
+ CWARNFLAGS += -Wall -Wno-format-y2k
+@@ -64,9 +61,6 @@ WFORMAT = 1
+ . if ${WFORMAT} > 0
+ #CWARNFLAGS += -Wformat-nonliteral -Wformat-security -Wno-format-extra-args
+ CWARNFLAGS += -Wformat=2 -Wno-format-extra-args
+-. if !defined(NO_WERROR)
+-CWARNFLAGS += -Werror
+-. endif
+ . endif
+ . endif
+ .endif
+Index: share/mk/bsd.links.mk
+===================================================================
+--- share/mk/bsd.links.mk.orig
++++ share/mk/bsd.links.mk
+@@ -15,6 +15,8 @@ _installlinks:
+ t=${DESTDIR}$$1; \
+ shift; \
+ ${ECHO} $$t -\> $$l; \
++ d=`dirname $$t`; \
++ test -d $$d || mkdir $$d; \
+ ln -f $$l $$t; \
+ done; true
+ .endif
+@@ -26,6 +28,8 @@ _installlinks:
+ t=${DESTDIR}$$1; \
+ shift; \
+ ${ECHO} $$t -\> $$l; \
++ d=`dirname $$t`; \
++ test -d $$d || mkdir $$d; \
+ ln -fs $$l $$t; \
+ done; true
+ .endif
+Index: share/mk/bsd.own.mk
+===================================================================
+--- share/mk/bsd.own.mk.orig
++++ share/mk/bsd.own.mk
+@@ -164,11 +164,6 @@ NLSMODE?= ${NOBINMODE}
+
+ INCLUDEDIR?= /usr/include
+
+-# Common variables
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+-
+ COMPRESS_CMD?= gzip -cn
+ COMPRESS_EXT?= .gz
+
+Index: share/mk/sys.mk
+===================================================================
+--- share/mk/sys.mk.orig
++++ share/mk/sys.mk
+@@ -34,11 +34,11 @@ AFLAGS ?=
+ CC ?= c89
+ CFLAGS ?= -O
+ .else
+-CC ?= cc
++CC ?= gcc
+ .if ${MACHINE_ARCH} == "arm" || ${MACHINE_ARCH} == "mips"
+-CFLAGS ?= -O -pipe
++CFLAGS ?= -pipe
+ .else
+-CFLAGS ?= -O2 -pipe
++CFLAGS ?= -pipe
+ .endif
+ .if defined(NO_STRICT_ALIASING)
+ CFLAGS += -fno-strict-aliasing
+@@ -64,7 +64,7 @@ CFLAGS += -g
+ .endif
+ .endif
+
+-CXX ?= c++
++CXX ?= g++
+ CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign}
+
+ CPP ?= cpp
+@@ -333,12 +333,6 @@ YFLAGS ?= -d
+ ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
+ .endif
+
+-# FreeBSD build pollution. Hide it in the non-POSIX part of the ifdef.
+-__MAKE_CONF?=/etc/make.conf
+-.if exists(${__MAKE_CONF})
+-.include "${__MAKE_CONF}"
+-.endif
+-
+ .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
+ SHELL= ${__MAKE_SHELL}
+ .SHELL: path=${__MAKE_SHELL}
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gnu.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gnu.patch
new file mode 100644
index 000000000000..41c4de4f945d
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gnu.patch
@@ -0,0 +1,121 @@
+Index: mk/bsd.incs.mk
+===================================================================
+--- mk/bsd.incs.mk.orig
++++ mk/bsd.incs.mk
+@@ -45,7 +45,7 @@ _${group}INS_${header:T}: ${header}
+ ${INSTALL} -d -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
+- ${INSTALL} -C -o ${${group}OWN_${.ALLSRC:T}} \
++ ${INSTALL} -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+ ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
+@@ -58,11 +58,11 @@ installincludes: _${group}INS
+ _${group}INS: ${_${group}INCS}
+ .if defined(${group}NAME)
+ ${INSTALL} -d ${DESTDIR}${${group}DIR}
+- ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
++ ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
+ ${INSTALL} -d ${DESTDIR}${${group}DIR}
+- ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
++ ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}
+ .endif
+ .endif
+Index: mk/bsd.lib.mk
+===================================================================
+--- mk/bsd.lib.mk.orig
++++ mk/bsd.lib.mk
+@@ -156,11 +156,7 @@ _LIBS= lib${LIB}.a
+ lib${LIB}.a: ${OBJS} ${STATICOBJS}
+ @${ECHO} building static ${LIB} library
+ @rm -f ${.TARGET}
+-.if !defined(NM)
+- @${AR} cq ${.TARGET} `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
+-.else
+- @${AR} cq ${.TARGET} `NM='${NM}' lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
+-.endif
++ @${AR} cq ${.TARGET} ${OBJS} ${STATICOBJS} ${ARADD}
+ ${RANLIB} ${.TARGET}
+ .endif
+
+@@ -173,11 +169,7 @@ POBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=
+ lib${LIB}_p.a: ${POBJS}
+ @${ECHO} building profiled ${LIB} library
+ @rm -f ${.TARGET}
+-.if !defined(NM)
+- @${AR} cq ${.TARGET} `lorder ${POBJS} | tsort -q` ${ARADD}
+-.else
+- @${AR} cq ${.TARGET} `NM='${NM}' lorder ${POBJS} | tsort -q` ${ARADD}
+-.endif
++ @${AR} cq ${.TARGET} ${POBJS} ${ARADD}
+ ${RANLIB} ${.TARGET}
+ .endif
+
+@@ -195,15 +187,9 @@ ${SHLIB_NAME}: ${SOBJS}
+ .if defined(SHLIB_LINK)
+ @ln -fs ${.TARGET} ${SHLIB_LINK}
+ .endif
+-.if !defined(NM)
+- @${CC} ${LDFLAGS} ${SSP_CFLAGS} -shared -Wl,-x \
+- -o ${.TARGET} -Wl,-soname,${SONAME} \
+- `lorder ${SOBJS} | tsort -q` ${LDADD}
+-.else
+ @${CC} ${LDFLAGS} ${SSP_CFLAGS} -shared -Wl,-x \
+ -o ${.TARGET} -Wl,-soname,${SONAME} \
+- `NM='${NM}' lorder ${SOBJS} | tsort -q` ${LDADD}
+-.endif
++ `echo ${SOBJS} | xargs -n 1 echo | sort -u` ${LDADD}
+ .if defined(CTFMERGE)
+ ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}
+ .endif
+@@ -251,13 +237,6 @@ _EXTRADEPEND:
+
+ .if !target(install)
+
+-.if defined(PRECIOUSLIB)
+-.if !defined(NO_FSCHG)
+-SHLINSTALLFLAGS+= -fschg
+-.endif
+-SHLINSTALLFLAGS+= -S
+-.endif
+-
+ _INSTALLFLAGS:= ${INSTALLFLAGS}
+ .for ie in ${INSTALLFLAGS_EDIT}
+ _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
+@@ -273,12 +252,12 @@ realinstall: _libinstall
+ _libinstall:
+ .if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
+ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+- ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
++ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR}
+ .endif
+ .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
+ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+- ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
++ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR}
+ .endif
+ .if defined(SHLIB_NAME)
+Index: mk/bsd.prog.mk
+===================================================================
+--- mk/bsd.prog.mk.orig
++++ mk/bsd.prog.mk
+@@ -130,13 +130,6 @@ _EXTRADEPEND:
+
+ .if !target(install)
+
+-.if defined(PRECIOUSPROG)
+-.if !defined(NO_FSCHG)
+-INSTALLFLAGS+= -fschg
+-.endif
+-INSTALLFLAGS+= -S
+-.endif
+-
+ _INSTALLFLAGS:= ${INSTALLFLAGS}
+ .for ie in ${INSTALLFLAGS_EDIT}
+ _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-9.1-gentoo.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-9.1-gentoo.patch
new file mode 100644
index 000000000000..598d0b9145b4
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-9.1-gentoo.patch
@@ -0,0 +1,326 @@
+diff -Nur share.orig/mk/bsd.doc.mk share/mk/bsd.doc.mk
+--- share.orig/mk/bsd.doc.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.doc.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -135,10 +135,12 @@
+ realinstall:
+ .for _dev in ${PRINTERDEVICE:Mhtml}
+ cd ${SRCDIR}; \
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}; \
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DOC}*.html ${DESTDIR}${BINDIR}/${VOLUME}
+ .endfor
+ .for _dev in ${PRINTERDEVICE:Nhtml}
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}; \
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DFILE.${_dev}} ${DESTDIR}${BINDIR}/${VOLUME}
+ .endfor
+diff -Nur share.orig/mk/bsd.files.mk share/mk/bsd.files.mk
+--- share.orig/mk/bsd.files.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.files.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -39,6 +39,7 @@
+ .endif
+ installfiles: _${group}INS_${file:T}
+ _${group}INS_${file:T}: ${file}
++ ${INSTALL} -d ${DESTDIR}${${group}DIR_${.ALLSRC:T}}
+ ${INSTALL} -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+@@ -51,10 +52,12 @@
+ installfiles: _${group}INS
+ _${group}INS: ${_${group}FILES}
+ .if defined(${group}NAME)
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}/${${group}NAME}
+ ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
+ -m ${${group}MODE} ${.ALLSRC} \
+ ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}
+ ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
+ -m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}
+ .endif
+diff -Nur share.orig/mk/bsd.incs.mk share/mk/bsd.incs.mk
+--- share.orig/mk/bsd.incs.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.incs.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -41,6 +41,9 @@
+ .endif
+ installincludes: _${group}INS_${header:T}
+ _${group}INS_${header:T}: ${header}
++ ${INSTALL} -d -o ${${group}OWN_${.ALLSRC:T}} \
++ -g ${${group}GRP_${.ALLSRC:T}} \
++ ${DESTDIR}${${group}DIR_${.ALLSRC:T}}
+ ${INSTALL} -C -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+@@ -53,9 +56,13 @@
+ installincludes: _${group}INS
+ _${group}INS: ${_${group}INCS}
+ .if defined(${group}NAME)
++ ${INSTALL} -d -o ${${group}OWN} -g ${${group}GRP} \
++ ${DESTDIR}${${group}DIR}
+ ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
++ ${INSTALL} -d -o ${${group}OWN} -g ${${group}GRP} \
++ ${DESTDIR}${${group}DIR}
+ ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}
+ .endif
+diff -Nur share.orig/mk/bsd.info.mk share/mk/bsd.info.mk
+--- share.orig/mk/bsd.info.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.info.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -83,6 +83,7 @@
+ TEX?= tex
+ DVIPS?= dvips
+ DVIPS2ASCII?= dvips2ascii
++INSTALL?= install
+
+ .SUFFIXES: ${ICOMPRESS_EXT} .info .texi .texinfo .dvi .ps .latin1 .html
+
+@@ -144,15 +145,17 @@
+ INSTALLINFODIRS+= ${x:S/$/-install/}
+ ${x:S/$/-install/}:
+ .if !empty(.MAKEFLAGS:M-j)
++ ${INSTALL} -d ${DESTDIR}${INFODIR}
+ lockf -k ${DESTDIR}${INFODIR}/${INFODIRFILE} \
+ ${INSTALLINFO} ${INSTALLINFOFLAGS} \
+- --defsection=${INFOSECTION} \
+- --defentry=${INFOENTRY_${x}} \
++ --section=${INFOSECTION} \
++ --entry=${INFOENTRY_${x}} \
+ ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ .else
++ ${INSTALL} -d ${DESTDIR}${INFODIR}
+ ${INSTALLINFO} ${INSTALLINFOFLAGS} \
+- --defsection=${INFOSECTION} \
+- --defentry=${INFOENTRY_${x}} \
++ --section=${INFOSECTION} \
++ --entry=${INFOENTRY_${x}} \
+ ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ .endif
+ .endfor
+diff -Nur share.orig/mk/bsd.lib.mk share/mk/bsd.lib.mk
+--- share.orig/mk/bsd.lib.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.lib.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -46,10 +46,6 @@
+ .endif
+ .endif
+
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+-
+ .include <bsd.libnames.mk>
+
+ # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
+@@ -284,14 +280,17 @@
+ .ORDER: beforeinstall _libinstall
+ _libinstall:
+ .if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
++ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR}
+ .endif
+ .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
++ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR}
+ .endif
+ .if defined(SHLIB_NAME)
++ ${INSTALL} -d ${DESTDIR}${SHLIBDIR}
+ ${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
+ ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}
+@@ -329,10 +328,12 @@
+ .endif # SHLIB_LINK
+ .endif # SHIB_NAME
+ .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
++ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
+ .endif
+ .if defined(WANT_LINT) && !defined(NO_LINT) && defined(LIB) && !empty(LIB)
++ ${INSTALL} -d ${DESTDIR}${LINTLIBDIR}
+ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} ${LINTLIB} ${DESTDIR}${LINTLIBDIR}
+ .endif
+diff -Nur share.orig/mk/bsd.libnames.mk share/mk/bsd.libnames.mk
+--- share.orig/mk/bsd.libnames.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.libnames.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -48,7 +48,7 @@
+ LIBEDIT?= ${DESTDIR}${LIBDIR}/libedit.a
+ LIBELF?= ${DESTDIR}${LIBDIR}/libelf.a
+ LIBFETCH?= ${DESTDIR}${LIBDIR}/libfetch.a
+-LIBFL?= "don't use LIBFL, use LIBL"
++LIBFL?= ${DESTDIR}${LIBDIR}/libfl.a
+ LIBFORM?= ${DESTDIR}${LIBDIR}/libform.a
+ LIBFTPIO?= ${DESTDIR}${LIBDIR}/libftpio.a
+ LIBG2C?= ${DESTDIR}${LIBDIR}/libg2c.a
+@@ -79,7 +79,7 @@
+ LIBKICONV?= ${DESTDIR}${LIBDIR}/libkiconv.a
+ LIBKRB5?= ${DESTDIR}${LIBDIR}/libkrb5.a
+ LIBKVM?= ${DESTDIR}${LIBDIR}/libkvm.a
+-LIBL?= ${DESTDIR}${LIBDIR}/libl.a
++LIBL?= ${DESTDIR}${LIBDIR}/libfl.a
+ LIBLN?= "don't use LIBLN, use LIBL"
+ .if ${MK_BIND} != "no"
+ LIBLWRES?= ${DESTDIR}${LIBDIR}/liblwres.a
+diff -Nur share.orig/mk/bsd.links.mk share/mk/bsd.links.mk
+--- share.orig/mk/bsd.links.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.links.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -15,6 +15,8 @@
+ t=${DESTDIR}$$1; \
+ shift; \
+ ${ECHO} $$t -\> $$l; \
++ d=`dirname $$t`; \
++ test -d $$d || mkdir $$d; \
+ ln -f $$l $$t; \
+ done; true
+ .endif
+@@ -26,6 +28,8 @@
+ t=${DESTDIR}$$1; \
+ shift; \
+ ${ECHO} $$t -\> $$l; \
++ d=`dirname $$t`; \
++ test -d $$d || mkdir $$d; \
+ ln -fs $$l $$t; \
+ done; true
+ .endif
+diff -Nur share.orig/mk/bsd.man.mk share/mk/bsd.man.mk
+--- share.orig/mk/bsd.man.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.man.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -165,9 +165,11 @@
+ .if defined(NO_MANCOMPRESS)
+ .if defined(MANFILTER)
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}/${page}
+ ${MINSTALL} ${__page:T:S/$/${FILTEXTENSION}/g} \
+ ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/${__page}
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page}
+ .endif
+@@ -181,11 +183,14 @@
+ esac; \
+ page=$$1; shift; sect=$$1; shift; \
+ d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \
++ ${ECHO} ${INSTALL} -d $${d}; \
++ ${INSTALL} -d $${d}; \
+ ${ECHO} ${MINSTALL} $${page} $${d}; \
+ ${MINSTALL} $${page} $${d}; \
+ done
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page:T}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}/} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T}
+ .endfor
+@@ -193,9 +198,11 @@
+ .endif
+ .else
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}
+ ${MINSTALL} ${__page:T:S/$/${MCOMPRESS_EXT}/g} \
+ ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page:T:S/$/${MCOMPRESS_EXT}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}/}
+ .endif
+diff -Nur share.orig/mk/bsd.nls.mk share/mk/bsd.nls.mk
+--- share.orig/mk/bsd.nls.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.nls.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -62,7 +62,8 @@
+ # installation rules
+ #
+ .for file in ${NLS}
+-NLSNAME_${file:T}= ${file:T:R}/${NLSNAME}.cat
++NLSDIR_${file:T}= ${SHAREDIR}/nls/${file:T:R}/
++NLSNAME_${file:T}= ${NLSNAME}.cat
+ .if defined(NLSLINKS_${file:R}) && !empty(NLSLINKS_${file:R})
+ NLSLINKS+= ${file:R}
+ .endif
+diff -Nur share.orig/mk/bsd.own.mk share/mk/bsd.own.mk
+--- share.orig/mk/bsd.own.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.own.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -182,9 +182,6 @@
+ INCLUDEDIR?= /usr/include
+
+ # Common variables
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+
+ COMPRESS_CMD?= gzip -cn
+ COMPRESS_EXT?= .gz
+diff -Nur share.orig/mk/bsd.prog.mk share/mk/bsd.prog.mk
+--- share.orig/mk/bsd.prog.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.prog.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -33,10 +33,6 @@
+ CFLAGS+=${CRUNCH_CFLAGS}
+ .endif
+
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+-
+ .if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO")
+ LDFLAGS+= -static
+ .endif
+@@ -155,6 +151,7 @@
+ .ORDER: beforeinstall _proginstall
+ _proginstall:
+ .if defined(PROG)
++ ${INSTALL} -d ${DESTDIR}${BINDIR}
+ .if defined(PROGNAME)
+ ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
+@@ -186,6 +183,7 @@
+ SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE}
+ _scriptsinstall: _SCRIPTSINS_${script:T}
+ _SCRIPTSINS_${script:T}: ${script}
++ ${INSTALL} -d ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}
+ ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
+ -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+diff -Nur share.orig/mk/bsd.sys.mk share/mk/bsd.sys.mk
+--- share.orig/mk/bsd.sys.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.sys.mk 2012-07-16 00:04:14.000000000 +0900
+@@ -28,10 +28,6 @@
+ .if defined(WARNS)
+ .if ${WARNS} >= 1
+ CWARNFLAGS+= -Wsystem-headers
+-.if !defined(NO_WERROR) && ((${MK_CLANG_IS_CC} == "no" && \
+- ${CC:T:Mclang} != "clang") || !defined(NO_WERROR.clang))
+-CWARNFLAGS+= -Werror
+-.endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang)
+ .endif # WARNS >= 1
+ .if ${WARNS} >= 2
+ CWARNFLAGS+= -Wall -Wno-format-y2k
+@@ -95,10 +91,6 @@
+ CWARNFLAGS+= -Wno-format-nonliteral
+ .endif # WARNS <= 3
+ .endif # CLANG
+-.if !defined(NO_WERROR) && ((${MK_CLANG_IS_CC} == "no" && \
+- ${CC:T:Mclang} != "clang") || !defined(NO_WERROR.clang))
+-CWARNFLAGS+= -Werror
+-.endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang)
+ .endif # WFORMAT > 0
+ .endif # WFORMAT
+ .if defined(NO_WFORMAT) || ((${MK_CLANG_IS_CC} != "no" || \
+diff -Nur share.orig/mk/sys.mk share/mk/sys.mk
+--- share.orig/mk/sys.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/sys.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -349,12 +349,6 @@
+ (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \
+ ${CTFCONVERT} ${CTFFLAGS} ${.TARGET})
+
+-# FreeBSD build pollution. Hide it in the non-POSIX part of the ifdef.
+-__MAKE_CONF?=/etc/make.conf
+-.if exists(${__MAKE_CONF})
+-.include "${__MAKE_CONF}"
+-.endif
+-
+ .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
+ SHELL= ${__MAKE_SHELL}
+ .SHELL: path=${__MAKE_SHELL}
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-9.1-gnu.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-9.1-gnu.patch
new file mode 100644
index 000000000000..f986ed9c3e11
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-9.1-gnu.patch
@@ -0,0 +1,77 @@
+diff -Nur share.orig/mk/bsd.lib.mk share/mk/bsd.lib.mk
+--- share.orig/mk/bsd.lib.mk 2012-07-16 02:40:07.000000000 +0900
++++ share/mk/bsd.lib.mk 2012-07-16 02:41:40.000000000 +0900
+@@ -155,11 +155,7 @@
+ lib${LIB}.a: ${OBJS} ${STATICOBJS}
+ @${ECHO} building static ${LIB} library
+ @rm -f ${.TARGET}
+-.if !defined(NM)
+- @${AR} cq ${.TARGET} `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
+-.else
+- @${AR} cq ${.TARGET} `NM='${NM}' lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
+-.endif
++ @${AR} cq ${.TARGET} ${OBJS} ${STATICOBJS} ${ARADD}
+ ${RANLIB} ${.TARGET}
+ .endif
+
+@@ -172,11 +168,7 @@
+ lib${LIB}_p.a: ${POBJS}
+ @${ECHO} building profiled ${LIB} library
+ @rm -f ${.TARGET}
+-.if !defined(NM)
+- @${AR} cq ${.TARGET} `lorder ${POBJS} | tsort -q` ${ARADD}
+-.else
+- @${AR} cq ${.TARGET} `NM='${NM}' lorder ${POBJS} | tsort -q` ${ARADD}
+-.endif
++ @${AR} cq ${.TARGET} ${POBJS} ${ARADD}
+ ${RANLIB} ${.TARGET}
+ .endif
+
+@@ -203,15 +195,9 @@
+ .if defined(SHLIB_LINK)
+ @ln -fs ${.TARGET} ${SHLIB_LINK}
+ .endif
+-.if !defined(NM)
+ @${CC} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
+ -o ${.TARGET} -Wl,-soname,${SONAME} \
+- `lorder ${SOBJS} | tsort -q` ${LDADD}
+-.else
+- @${CC} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
+- -o ${.TARGET} -Wl,-soname,${SONAME} \
+- `NM='${NM}' lorder ${SOBJS} | tsort -q` ${LDADD}
+-.endif
++ `echo ${SOBJS} | xargs -n 1 echo | sort -u` ${LDADD}
+ @[ -z "${CTFMERGE}" -o -n "${NO_CTF}" ] || \
+ (${ECHO} ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS} && \
+ ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS})
+@@ -259,13 +245,6 @@
+
+ .if !target(install)
+
+-.if defined(PRECIOUSLIB)
+-.if !defined(NO_FSCHG)
+-SHLINSTALLFLAGS+= -fschg
+-.endif
+-SHLINSTALLFLAGS+= -S
+-.endif
+-
+ _INSTALLFLAGS:= ${INSTALLFLAGS}
+ .for ie in ${INSTALLFLAGS_EDIT}
+ _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
+diff -Nur share.orig/mk/bsd.prog.mk share/mk/bsd.prog.mk
+--- share.orig/mk/bsd.prog.mk 2012-07-16 02:40:07.000000000 +0900
++++ share/mk/bsd.prog.mk 2012-07-16 02:40:24.000000000 +0900
+@@ -134,13 +134,6 @@
+
+ .if !target(install)
+
+-.if defined(PRECIOUSPROG)
+-.if !defined(NO_FSCHG)
+-INSTALLFLAGS+= -fschg
+-.endif
+-INSTALLFLAGS+= -S
+-.endif
+-
+ _INSTALLFLAGS:= ${INSTALLFLAGS}
+ .for ie in ${INSTALLFLAGS_EDIT}
+ _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-add-nossp-cflags.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-add-nossp-cflags.patch
new file mode 100644
index 000000000000..8eb80c38cc7a
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-add-nossp-cflags.patch
@@ -0,0 +1,28 @@
+https://bugs.gentoo.org/show_bug.cgi?id=511698
+
+diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
+index e438633..de4a05b 100644
+--- a/share/mk/bsd.sys.mk
++++ b/share/mk/bsd.sys.mk
+@@ -111,12 +111,18 @@ CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3\
+ CFLAGS+= -Qunused-arguments
+ .endif # CLANG
+
+-.if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \
+- ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
++.if ${MACHINE_CPUARCH} != "ia64" && ${MACHINE_CPUARCH} != "arm" \
++ && ${MACHINE_CPUARCH} != "mips"
++.if ${MK_SSP} != "no"
+ # Don't use -Wstack-protector as it breaks world with -Werror.
+ SSP_CFLAGS?= -fstack-protector
++.else
++# gcc-4.9, -fstack-protector-strong is enabled by default.
++# Add -fno-stack-protector to disable it. Gentoo Bug #511698.
++SSP_CFLAGS= -fno-stack-protector
++.endif #SSP
+ CFLAGS+= ${SSP_CFLAGS}
+-.endif # SSP && !IA64 && !ARM && !MIPS
++.endif # !IA64 && !ARM && !MIPS
+
+ # Allow user-specified additional warning flags
+ CFLAGS+= ${CWARNFLAGS}
diff --git a/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-10.1.ebuild b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-10.1.ebuild
new file mode 100644
index 000000000000..c2fe42072c4b
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-10.1.ebuild
@@ -0,0 +1,42 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit bsdmk freebsd
+
+DESCRIPTION="Makefiles definitions used for building and installing libraries and system files"
+SLOT="0"
+
+IUSE="userland_GNU"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64 ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="share/"
+
+RDEPEND=""
+DEPEND=""
+
+RESTRICT="strip"
+
+S="${WORKDIR}/share/mk"
+
+src_prepare() {
+ epatch "${FILESDIR}/${PN}-10.0-gentoo.patch"
+ epatch "${FILESDIR}/${PN}-add-nossp-cflags.patch"
+ use userland_GNU && epatch "${FILESDIR}/${PN}-10.1-gnu.patch"
+}
+
+src_compile() { :; }
+
+src_install() {
+ if [[ ${CHOST} != *-freebsd* ]]; then
+ insinto /usr/share/mk/freebsd
+ else
+ insinto /usr/share/mk
+ fi
+ doins *.mk *.awk
+}
diff --git a/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-8.2.ebuild b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-8.2.ebuild
new file mode 100644
index 000000000000..5bed96a6d99a
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-8.2.ebuild
@@ -0,0 +1,41 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+inherit bsdmk freebsd
+
+DESCRIPTION="Makefiles definitions used for building and installing libraries and system files"
+SLOT="0"
+KEYWORDS="~amd64 ~x86 ~sparc-fbsd ~x86-fbsd"
+
+IUSE=""
+
+SRC_URI="mirror://gentoo/${SHARE}.tar.bz2"
+
+RDEPEND=""
+DEPEND=""
+
+RESTRICT="strip"
+
+S="${WORKDIR}/share/mk"
+
+src_unpack() {
+ unpack ${A}
+
+ cd "${S}"
+ epatch "${FILESDIR}/${PN}-8.0-gentoo.patch"
+
+ [[ ${CHOST} != *-*bsd* || ${CHOST} == *-gnu ]] && \
+ epatch "${FILESDIR}/${PN}-8.0-gnu.patch"
+}
+
+src_compile() { :; }
+
+src_install() {
+ if [[ ${CHOST} != *-freebsd* ]]; then
+ insinto /usr/share/mk/freebsd
+ else
+ insinto /usr/share/mk
+ fi
+ doins *.mk *.awk
+}
diff --git a/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-9.1.ebuild b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-9.1.ebuild
new file mode 100644
index 000000000000..3677a1320649
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-9.1.ebuild
@@ -0,0 +1,39 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=3
+
+inherit bsdmk freebsd
+
+DESCRIPTION="Makefiles definitions used for building and installing libraries and system files"
+SLOT="0"
+KEYWORDS="~amd64 ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+
+IUSE="userland_GNU"
+
+SRC_URI="mirror://gentoo/${SHARE}.tar.bz2"
+
+RDEPEND=""
+DEPEND=""
+
+RESTRICT="strip"
+
+S="${WORKDIR}/share/mk"
+
+src_prepare() {
+ epatch "${FILESDIR}/${PN}-9.1-gentoo.patch"
+ epatch "${FILESDIR}/${PN}-add-nossp-cflags.patch"
+ use userland_GNU && epatch "${FILESDIR}/${PN}-9.1-gnu.patch"
+}
+
+src_compile() { :; }
+
+src_install() {
+ if [[ ${CHOST} != *-freebsd* ]]; then
+ insinto /usr/share/mk/freebsd
+ else
+ insinto /usr/share/mk
+ fi
+ doins *.mk *.awk
+}
diff --git a/sys-freebsd/freebsd-mk-defs/metadata.xml b/sys-freebsd/freebsd-mk-defs/metadata.xml
new file mode 100644
index 000000000000..ecedda4aa2cc
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/metadata.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<herd>bsd</herd>
+</pkgmetadata>