summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuta SATOH <nigoro.dev@gmail.com>2016-09-28 20:57:21 +0900
committerYuta SATOH <nigoro.dev@gmail.com>2016-09-28 20:57:21 +0900
commit7808fa178a26089ff2fc0c338a3e1835b290ffea (patch)
tree5c0ed322a3a07b6937d6406c785d218f008f57be /sys-freebsd
parentsys-freebsd: remove 10.3_rc3 ebuilds (diff)
downloadgentoo-bsd-7808fa178a26089ff2fc0c338a3e1835b290ffea.tar.gz
gentoo-bsd-7808fa178a26089ff2fc0c338a3e1835b290ffea.tar.bz2
gentoo-bsd-7808fa178a26089ff2fc0c338a3e1835b290ffea.zip
sys-freebsd: import 10.3 from latest tree
Diffstat (limited to 'sys-freebsd')
-rw-r--r--sys-freebsd/boot0/boot0-11.0.ebuild83
-rw-r--r--sys-freebsd/boot0/files/boot0-10.1-drop-unsupport-cflags.patch26
-rw-r--r--sys-freebsd/boot0/files/boot0-10.1-gcc46.patch67
-rw-r--r--sys-freebsd/boot0/files/boot0-10.3-clang.patch30
-rw-r--r--sys-freebsd/boot0/files/boot0-10.3-drop-unsupport-cflags.patch28
-rw-r--r--sys-freebsd/boot0/files/boot0-10.3-uefi-support.patch33
-rw-r--r--sys-freebsd/boot0/files/boot0-8.2-zfsboot-makefile.patch13
-rw-r--r--sys-freebsd/boot0/files/boot0-9.2-gcc46.patch66
-rw-r--r--sys-freebsd/boot0/files/boot0-add-nossp-cflags.patch11
-rw-r--r--sys-freebsd/boot0/metadata.xml12
-rw-r--r--sys-freebsd/freebsd-bin/freebsd-bin-11.0.ebuild42
-rw-r--r--sys-freebsd/freebsd-bin/metadata.xml8
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-10.2-libpaths.patch220
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-10.3-underlink.patch12
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-8.0-libpaths.patch114
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-8.2-libpaths.patch22
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-bsdxml.patch28
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-libpaths.patch167
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-underlink.patch22
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.2-libpaths.patch220
-rw-r--r--sys-freebsd/freebsd-cddl/files/zfs.initd24
-rw-r--r--sys-freebsd/freebsd-cddl/files/zvol.initd47
-rw-r--r--sys-freebsd/freebsd-cddl/files/zvol.initd-9.045
-rw-r--r--sys-freebsd/freebsd-cddl/freebsd-cddl-11.0.ebuild75
-rw-r--r--sys-freebsd/freebsd-cddl/metadata.xml8
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-atfcxx.patch49
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-liblink.patch98
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-libproc-libcxx.patch16
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-libusb.patch19
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-10.2-bsdxml2expat.patch39
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-10.2-liblink.patch26
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-10.3-libusb.patch13
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-flex-2.5.31.patch13
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-gccfloat.patch16
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-pmc.patch13
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-6.1-csu.patch20
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-6.2-bluetooth.patch11
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-7.1-types.h-fix.patch15
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-gcc45.patch28
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-log2.patch21
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-rpcsec_gss.patch12
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-8.2-liblink.patch19
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-8.2-nlm_syscall.patch10
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-bluetooth.patch12
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-cve-2010-2632.patch215
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-liblink.patch21
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-netware.patch11
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-opieincludes.patch122
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-.eh_frame_hdr-fix.patch17
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-aligned_alloc.patch51
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-rmgssapi.patch16
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-add-nossp-cflags.patch30
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-bsdxml.patch13
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-bsdxml2expat.patch26
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-includes.patch13
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-new_as.patch68
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-sources-9.0-sysctluint.patch13
-rw-r--r--sys-freebsd/freebsd-lib/files/libmap.conf8
-rw-r--r--sys-freebsd/freebsd-lib/files/libusb-1.0.pc.in11
-rw-r--r--sys-freebsd/freebsd-lib/files/libusb.pc.in11
-rw-r--r--sys-freebsd/freebsd-lib/freebsd-lib-11.0.ebuild647
-rw-r--r--sys-freebsd/freebsd-lib/metadata.xml16
-rw-r--r--sys-freebsd/freebsd-libexec/files/bootpd.confd7
-rw-r--r--sys-freebsd/freebsd-libexec/files/bootpd.initd27
-rw-r--r--sys-freebsd/freebsd-libexec/files/freebsd-libexec-10.2-atf-check.patch28
-rw-r--r--sys-freebsd/freebsd-libexec/files/freebsd-libexec-7.2-pic.patch13
-rw-r--r--sys-freebsd/freebsd-libexec/files/freebsd-libexec-8.2-rtld.patch40
-rw-r--r--sys-freebsd/freebsd-libexec/files/freebsd-libexec-9.2-no_ld32.patch15
-rw-r--r--sys-freebsd/freebsd-libexec/files/ftpd.pamd8
-rw-r--r--sys-freebsd/freebsd-libexec/files/rquotad.xinetd11
-rw-r--r--sys-freebsd/freebsd-libexec/files/rstatd.xinetd11
-rw-r--r--sys-freebsd/freebsd-libexec/files/rusersd.xinetd11
-rw-r--r--sys-freebsd/freebsd-libexec/files/sprayd.xinetd11
-rw-r--r--sys-freebsd/freebsd-libexec/files/walld.xinetd11
-rw-r--r--sys-freebsd/freebsd-libexec/freebsd-libexec-11.0.ebuild112
-rw-r--r--sys-freebsd/freebsd-libexec/metadata.xml8
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.2-gnu.patch63
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.3-gentoo.patch337
-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-11.0.ebuild42
-rw-r--r--sys-freebsd/freebsd-mk-defs/metadata.xml8
-rw-r--r--sys-freebsd/freebsd-pam-modules/files/README.pamd63
-rw-r--r--sys-freebsd/freebsd-pam-modules/files/freebsd-pam-modules-6.0-gentoo.patch24
-rw-r--r--sys-freebsd/freebsd-pam-modules/files/freebsd-pam-modules-9.0-gentoo.patch22
-rw-r--r--sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-11.0.ebuild48
-rw-r--r--sys-freebsd/freebsd-pam-modules/metadata.xml8
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-10.0-libevent.patch16
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-10.0-pflogd.patch15
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-7.0-libevent.patch12
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-7.0-pcap_pollution.patch18
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-bpf.patch10
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-getline.patch38
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-libevent.patch15
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-pcap_pollution.patch17
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-pflogd.patch13
-rw-r--r--sys-freebsd/freebsd-pf/files/pf.confd9
-rw-r--r--sys-freebsd/freebsd-pf/files/pf.initd50
-rw-r--r--sys-freebsd/freebsd-pf/freebsd-pf-11.0.ebuild73
-rw-r--r--sys-freebsd/freebsd-pf/metadata.xml8
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-rescue-10.0-zlib.patch22
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-rescue-7.1-zlib.patch21
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-rescue-8.0-pkgconfig_static_libarchive.patch11
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-rescue-8.2-libzcleverlink.patch20
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-rescue-9.1-bsdtar.patch12
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-rescue-9.1-libcleverlink.patch21
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-sbin-bsdxml2expat.patch13
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-ubin-10.2-bsdxml.patch13
-rw-r--r--sys-freebsd/freebsd-rescue/freebsd-rescue-11.0.ebuild82
-rw-r--r--sys-freebsd/freebsd-rescue/metadata.xml12
-rw-r--r--sys-freebsd/freebsd-sbin/files/adjkerntz-crontab4
-rw-r--r--sys-freebsd/freebsd-sbin/files/devd.conf153
-rw-r--r--sys-freebsd/freebsd-sbin/files/devd.initd47
-rw-r--r--sys-freebsd/freebsd-sbin/files/devd_queue50
-rw-r--r--sys-freebsd/freebsd-sbin/files/freebsd-sbin-10.0-zlib.patch22
-rw-r--r--sys-freebsd/freebsd-sbin/files/freebsd-sbin-6.1-pr102701.patch17
-rw-r--r--sys-freebsd/freebsd-sbin/files/freebsd-sbin-6.2-ldconfig.patch13
-rw-r--r--sys-freebsd/freebsd-sbin/files/freebsd-sbin-7.1-zlib.patch21
-rw-r--r--sys-freebsd/freebsd-sbin/files/freebsd-sbin-bsdxml2expat.patch13
-rw-r--r--sys-freebsd/freebsd-sbin/files/freebsd-sbin-setXid.patch20
-rw-r--r--sys-freebsd/freebsd-sbin/files/idmapd.initd20
-rw-r--r--sys-freebsd/freebsd-sbin/files/ipfw.confd10
-rw-r--r--sys-freebsd/freebsd-sbin/files/ipfw.initd110
-rw-r--r--sys-freebsd/freebsd-sbin/files/sysctl.initd28
-rw-r--r--sys-freebsd/freebsd-sbin/freebsd-sbin-11.0.ebuild101
-rw-r--r--sys-freebsd/freebsd-sbin/metadata.xml20
-rw-r--r--sys-freebsd/freebsd-share/files/freebsd-share-10.0-gentoo-eapi3.patch17
-rw-r--r--sys-freebsd/freebsd-share/files/freebsd-share-10.2-gnu-miscfiles.patch30
-rw-r--r--sys-freebsd/freebsd-share/files/freebsd-share-10.3-gentoo-skel.patch20
-rw-r--r--sys-freebsd/freebsd-share/files/freebsd-share-5.3-doc-locations.patch20
-rw-r--r--sys-freebsd/freebsd-share/files/freebsd-share-5.4-gentoo-skel.patch20
-rw-r--r--sys-freebsd/freebsd-share/files/freebsd-share-8.0-gnu-miscfiles.patch26
-rw-r--r--sys-freebsd/freebsd-share/files/freebsd-share-9.2-gnu-miscfiles.patch28
-rw-r--r--sys-freebsd/freebsd-share/freebsd-share-11.0.ebuild113
-rw-r--r--sys-freebsd/freebsd-share/metadata.xml12
-rw-r--r--sys-freebsd/freebsd-sources/files/config-GENTOO4
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-10.0-gentoo.patch22
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-10.1-gcc48.patch18
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-6.0-flex-2.5.31.patch22
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-6.1-ntfs.patch32
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-7.0-tmpfs_whiteout_stub.patch44
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-binutils_link.patch37
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-includes.patch13
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-types.h-fix.patch15
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-7.2-debug-O2.patch27
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-8.0-gentoo.patch33
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-8.0-subnet-route-pr40133.patch21
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-8.2-unix2.patch55
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-disable-optimization.patch32
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-ipv6refcount.patch128
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-sysctluint.patch13
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-ciss.patch65
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-3077.patch26
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-3266.patch13
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5209.patch19
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5691.patch89
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5710.patch28
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2014-1453.patch70
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-exec.patch66
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-gentoo.patch21
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-ktrace.patch12
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-mmap-2014.patch20
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-mmap.patch20
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-nfsserver.patch16
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-random.patch27
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-tcp.patch32
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.2-gentoo-gcc.patch13
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-cve-2012-0217.patch26
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-ubin-10.3-bmake-workaround.patch13
-rw-r--r--sys-freebsd/freebsd-sources/freebsd-sources-11.0.ebuild174
-rw-r--r--sys-freebsd/freebsd-sources/metadata.xml13
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-atf.patch15
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-dtc-gcc46.patch25
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-kdump-ioctl.patch26
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-mandoc.patch13
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.1-kdump-workaround.patch13
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.2-bsdxml.patch13
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.2-talk-workaround.patch12
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.3-bmake-workaround.patch13
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-bsdcmp.patch13
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-fixmakefiles.patch35
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-kdump-ioctl.patch28
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.0-bsdar.patch21
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.0-xinstall.patch26
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.2-compress.patch55
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.0-fixmakefiles.patch11
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-ar-libarchive3.patch19
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-bsdar.patch25
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-grep.patch17
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-kdump-ioctl.patch24
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-minigzip.patch10
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-lint-stdarg.patch24
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-setXid.patch129
-rw-r--r--sys-freebsd/freebsd-ubin/files/locate-updatedb-cron6
-rw-r--r--sys-freebsd/freebsd-ubin/files/login.1.pamd4
-rw-r--r--sys-freebsd/freebsd-ubin/files/login.pamd20
-rw-r--r--sys-freebsd/freebsd-ubin/files/passwd.1.pamd9
-rw-r--r--sys-freebsd/freebsd-ubin/files/passwd.pamd11
-rw-r--r--sys-freebsd/freebsd-ubin/files/su.1.pamd17
-rw-r--r--sys-freebsd/freebsd-ubin/files/su.pamd17
-rw-r--r--sys-freebsd/freebsd-ubin/freebsd-ubin-11.0.ebuild210
-rw-r--r--sys-freebsd/freebsd-ubin/metadata.xml24
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-10.0-bsdxml2expat.patch24
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-10.3-bsdxml2expat.patch13
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-7.0-nowrap.patch45
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-8.2-newsyslog.patch10
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.0-libarchive.patch12
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.0-newsyslog.patch12
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.1-bsdxml2expat.patch12
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.1-kldxref.patch30
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-adduser.patch20
-rw-r--r--sys-freebsd/freebsd-usbin/files/iscsid.initd20
-rw-r--r--sys-freebsd/freebsd-usbin/files/mountd.patch15
-rw-r--r--sys-freebsd/freebsd-usbin/files/moused.confd20
-rw-r--r--sys-freebsd/freebsd-usbin/files/moused.initd66
-rw-r--r--sys-freebsd/freebsd-usbin/files/nfs.confd10
-rw-r--r--sys-freebsd/freebsd-usbin/files/nfs.initd54
-rw-r--r--sys-freebsd/freebsd-usbin/files/nfsmount.initd63
-rw-r--r--sys-freebsd/freebsd-usbin/files/nfsuserd.confd5
-rw-r--r--sys-freebsd/freebsd-usbin/files/nfsuserd.initd20
-rw-r--r--sys-freebsd/freebsd-usbin/files/powerd.confd14
-rw-r--r--sys-freebsd/freebsd-usbin/files/powerd.initd27
-rw-r--r--sys-freebsd/freebsd-usbin/files/pw.conf5
-rw-r--r--sys-freebsd/freebsd-usbin/files/rarpd.confd7
-rw-r--r--sys-freebsd/freebsd-usbin/files/rarpd.initd35
-rw-r--r--sys-freebsd/freebsd-usbin/files/rpc.lockd.initd20
-rw-r--r--sys-freebsd/freebsd-usbin/files/rpc.statd.initd20
-rw-r--r--sys-freebsd/freebsd-usbin/files/rpcbind.initd30
-rw-r--r--sys-freebsd/freebsd-usbin/files/syscons.confd14
-rw-r--r--sys-freebsd/freebsd-usbin/files/syscons.initd78
-rw-r--r--sys-freebsd/freebsd-usbin/files/syslogd.initd25
-rw-r--r--sys-freebsd/freebsd-usbin/freebsd-usbin-11.0.ebuild187
-rw-r--r--sys-freebsd/freebsd-usbin/metadata.xml19
236 files changed, 9546 insertions, 0 deletions
diff --git a/sys-freebsd/boot0/boot0-11.0.ebuild b/sys-freebsd/boot0/boot0-11.0.ebuild
new file mode 100644
index 0000000..49521d0
--- /dev/null
+++ b/sys-freebsd/boot0/boot0-11.0.ebuild
@@ -0,0 +1,83 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic toolchain-funcs
+
+DESCRIPTION="FreeBSD's bootloader"
+SLOT="0"
+
+IUSE="bzip2 ieee1394 tftp zfs"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ sys/
+ lib/
+ contrib/bzip2/
+"
+
+RDEPEND=""
+DEPEND="=sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-lib-${RV}*"
+
+S="${WORKDIR}/sys/boot"
+
+PATCHES=( "${FILESDIR}/${PN}-10.1-gcc46.patch"
+ "${FILESDIR}/${PN}-10.3-clang.patch"
+ "${FILESDIR}/${PN}-10.3-drop-unsupport-cflags.patch"
+ "${FILESDIR}/${PN}-10.3-uefi-support.patch"
+ "${FILESDIR}/${PN}-add-nossp-cflags.patch" )
+
+boot0_use_enable() {
+ use ${1} && mymakeopts="${mymakeopts} LOADER_${2}_SUPPORT=\"yes\""
+ use ${1} || mymakeopts="${mymakeopts} WITHOUT_${2}= "
+}
+
+pkg_setup() {
+ boot0_use_enable ieee1394 FIREWIRE
+ boot0_use_enable zfs ZFS
+ boot0_use_enable tftp TFTP
+ boot0_use_enable bzip2 BZIP2
+}
+
+src_prepare() {
+ sed -e '/-mno-align-long-strings/d' \
+ -i "${S}"/i386/boot2/Makefile \
+ -i "${S}"/i386/gptboot/Makefile \
+ -i "${S}"/i386/gptzfsboot/Makefile \
+ -i "${S}"/i386/zfsboot/Makefile || die
+
+ export MAKEOBJDIRPREFIX="${WORKDIR}/build"
+}
+
+src_compile() {
+ strip-flags
+ append-flags "-fno-strict-aliasing"
+
+ cd "${WORKDIR}/lib/libstand" || die
+ freebsd_src_compile
+
+ CFLAGS="${CFLAGS} -I${WORKDIR}/lib/libstand"
+ LDFLAGS="${LDFLAGS} -L${WORKDIR}/lib/libstand"
+ export LIBSTAND="${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libstand/libstand.a"
+
+ cd "${S}" || die
+ NOFLAGSTRIP="yes" freebsd_src_compile
+}
+
+src_install() {
+ dodir /boot/defaults
+ mkinstall FILESDIR=/boot || die "mkinstall failed"
+
+ cd "${WORKDIR}/sys/$(tc-arch-kernel)/conf" || die
+ insinto /boot
+ newins GENERIC.hints device.hints
+
+ echo 'CONFIG_PROTECT="/boot/device.hints"' > "${T}"/50boot0
+ doenvd "${T}"/50boot0
+}
diff --git a/sys-freebsd/boot0/files/boot0-10.1-drop-unsupport-cflags.patch b/sys-freebsd/boot0/files/boot0-10.1-drop-unsupport-cflags.patch
new file mode 100644
index 0000000..4ab415b
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-10.1-drop-unsupport-cflags.patch
@@ -0,0 +1,26 @@
+diff --git a/sys/boot/efi/libefi/Makefile b/sys/boot/efi/libefi/Makefile
+index 76ed0ca..2d1d39d 100644
+--- a/sys/boot/efi/libefi/Makefile
++++ b/sys/boot/efi/libefi/Makefile
+@@ -17,7 +17,4 @@ CFLAGS+= -I${.CURDIR}/../../../../lib/libstand
+ CFLAGS+= -I${.CURDIR}/../../common
+
+
+-# Suppress warning from clang for FreeBSD %b and %D formats
+-CFLAGS+= -fformat-extensions
+-
+ .include <bsd.lib.mk>
+diff --git a/sys/boot/i386/libi386/Makefile b/sys/boot/i386/libi386/Makefile
+index d714c74..a5cfa3c 100644
+--- a/sys/boot/i386/libi386/Makefile
++++ b/sys/boot/i386/libi386/Makefile
+@@ -52,9 +52,6 @@ CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../common \
+ # the location of libstand
+ CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
+
+-# Suppress warning from clang for FreeBSD %b and %D formats
+-CFLAGS+= -fformat-extensions
+-
+ .if ${MACHINE_CPUARCH} == "amd64"
+ CLEANFILES+= machine
+ machine:
diff --git a/sys-freebsd/boot0/files/boot0-10.1-gcc46.patch b/sys-freebsd/boot0/files/boot0-10.1-gcc46.patch
new file mode 100644
index 0000000..9b31e7c
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-10.1-gcc46.patch
@@ -0,0 +1,67 @@
+diff --git a/sys/boot/i386/Makefile.inc b/sys/boot/i386/Makefile.inc
+index 472b275..0c9409d 100644
+--- a/sys/boot/i386/Makefile.inc
++++ b/sys/boot/i386/Makefile.inc
+@@ -13,8 +13,6 @@ LDFLAGS+= -nostdlib
+ .if ${MACHINE_CPUARCH} == "amd64"
+ CFLAGS+= -m32
+ ACFLAGS+= -m32
+-# LD_FLAGS is passed directly to ${LD}, not via ${CC}:
+-LD_FLAGS+= -m elf_i386_fbsd
+ AFLAGS+= --32
+ .endif
+
+diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile
+index 428950e..6a15450 100644
+--- a/sys/boot/i386/boot2/Makefile
++++ b/sys/boot/i386/boot2/Makefile
+@@ -113,3 +113,10 @@ machine:
+ # XXX: clang integrated-as doesn't grok .codeNN directives yet
+ CFLAGS.boot1.S= ${CLANG_NO_IAS}
+ CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
++
++# gcc 4.6 or later version, -fno-asynchronous-unwind-tables is required to build.
++CFLAGS+= -fno-asynchronous-unwind-tables
++
++.if ${MACHINE_CPUARCH} == "amd64"
++LD_FLAGS+= -m elf_i386_fbsd
++.endif
+diff --git a/sys/boot/i386/gptboot/Makefile b/sys/boot/i386/gptboot/Makefile
+index a90e712..d60ae00 100644
+--- a/sys/boot/i386/gptboot/Makefile
++++ b/sys/boot/i386/gptboot/Makefile
+@@ -81,3 +81,8 @@ machine:
+ # XXX: clang integrated-as doesn't grok .codeNN directives yet
+ CFLAGS.gptldr.S= ${CLANG_NO_IAS}
+ CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
++
++.if ${MACHINE_CPUARCH} == "amd64"
++LD_FLAGS+= -m elf_i386_fbsd
++.endif
++
+diff --git a/sys/boot/i386/gptzfsboot/Makefile b/sys/boot/i386/gptzfsboot/Makefile
+index 5eb2383..c10a917 100644
+--- a/sys/boot/i386/gptzfsboot/Makefile
++++ b/sys/boot/i386/gptzfsboot/Makefile
+@@ -78,3 +78,8 @@ machine:
+ # XXX: clang integrated-as doesn't grok .codeNN directives yet
+ CFLAGS.gptldr.S= ${CLANG_NO_IAS}
+ CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
++
++.if ${MACHINE_CPUARCH} == "amd64"
++LD_FLAGS+= -m elf_i386_fbsd
++.endif
++
+diff --git a/sys/boot/i386/zfsboot/Makefile b/sys/boot/i386/zfsboot/Makefile
+index 149f43a..be1e46a 100644
+--- a/sys/boot/i386/zfsboot/Makefile
++++ b/sys/boot/i386/zfsboot/Makefile
+@@ -91,3 +91,8 @@ machine:
+ # XXX: clang integrated-as doesn't grok .codeNN directives yet
+ CFLAGS.zfsldr.S= ${CLANG_NO_IAS}
+ CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
++
++.if ${MACHINE_CPUARCH} == "amd64"
++LD_FLAGS+= -m elf_i386_fbsd
++.endif
++
diff --git a/sys-freebsd/boot0/files/boot0-10.3-clang.patch b/sys-freebsd/boot0/files/boot0-10.3-clang.patch
new file mode 100644
index 0000000..4245e21
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-10.3-clang.patch
@@ -0,0 +1,30 @@
+Gentoo Bug: https://bugs.gentoo.org/show_bug.cgi?id=542676
+
+https://svnweb.freebsd.org/base/head/sys/boot/i386/boot2/Makefile?r1=272249&r2=276479
+
+diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile
+index 8a6e771..c030853 100644
+--- a/sys/boot/i386/boot2/Makefile
++++ b/sys/boot/i386/boot2/Makefile
+@@ -22,8 +22,7 @@ BOOT2_UFS?= UFS1_AND_UFS2
+ #BOOT2_UFS?= UFS2_ONLY
+ #BOOT2_UFS?= UFS1_ONLY
+
+-CFLAGS= -Os \
+- -fomit-frame-pointer \
++CFLAGS= -fomit-frame-pointer \
+ -mrtd \
+ -mregparm=3 \
+ -DUSE_XREAD \
+@@ -40,7 +39,10 @@ CFLAGS= -Os \
+ -Winline \
+ ${CLANG_OPT_SMALL}
+
+-CFLAGS.gcc+= -fno-guess-branch-probability \
++CFLAGS.clang+= -Oz
++
++CFLAGS.gcc+= -Os \
++ -fno-guess-branch-probability \
+ -fno-unit-at-a-time \
+ --param max-inline-insns-single=100
+ .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} <= 40201
diff --git a/sys-freebsd/boot0/files/boot0-10.3-drop-unsupport-cflags.patch b/sys-freebsd/boot0/files/boot0-10.3-drop-unsupport-cflags.patch
new file mode 100644
index 0000000..af1d351
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-10.3-drop-unsupport-cflags.patch
@@ -0,0 +1,28 @@
+diff --git a/sys/boot/efi/libefi/Makefile b/sys/boot/efi/libefi/Makefile
+index fc66e01..470453d 100644
+--- a/sys/boot/efi/libefi/Makefile
++++ b/sys/boot/efi/libefi/Makefile
+@@ -17,9 +17,6 @@ CFLAGS+= -I${.CURDIR}/../../../../lib/libstand
+ # Pick up the bootstrap header for some interface items
+ CFLAGS+= -I${.CURDIR}/../../common
+
+-
+-# Suppress warning from clang for FreeBSD %b and %D formats
+-CFLAGS+= -fformat-extensions
+ CFLAGS+= -DTERM_EMU
+
+ .include <bsd.lib.mk>
+diff --git a/sys/boot/i386/libi386/Makefile b/sys/boot/i386/libi386/Makefile
+index 24cc4c1..e5d2bae 100644
+--- a/sys/boot/i386/libi386/Makefile
++++ b/sys/boot/i386/libi386/Makefile
+@@ -55,9 +55,6 @@ CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../common \
+ # the location of libstand
+ CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
+
+-# Suppress warning from clang for FreeBSD %b and %D formats
+-CFLAGS+= -fformat-extensions
+-
+ .if ${MACHINE_CPUARCH} == "amd64"
+ CLEANFILES+= machine
+ machine:
diff --git a/sys-freebsd/boot0/files/boot0-10.3-uefi-support.patch b/sys-freebsd/boot0/files/boot0-10.3-uefi-support.patch
new file mode 100644
index 0000000..fdafe74
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-10.3-uefi-support.patch
@@ -0,0 +1,33 @@
+diff --git a/efi/Makefile b/efi/Makefile
+index 30024e3..a33efb2 100644
+--- a/efi/Makefile
++++ b/efi/Makefile
+@@ -2,15 +2,10 @@
+
+ .include <bsd.own.mk>
+
+-# In-tree GCC does not support __attribute__((ms_abi)).
+-.if ${COMPILER_TYPE} != "gcc"
+-
+ .if ${MACHINE_CPUARCH} == "amd64"
+ SUBDIR+= libefi loader boot1
+ .endif
+
+-.endif # ${COMPILER_TYPE} != "gcc"
+-
+ .if ${MACHINE_CPUARCH} == "ia64"
+ SUBDIR+= libefi
+ .endif
+diff --git a/efi/boot1/Makefile b/efi/boot1/Makefile
+index 4ffdfda..8ec0e00 100644
+--- a/efi/boot1/Makefile
++++ b/efi/boot1/Makefile
+@@ -64,7 +64,7 @@ LDFLAGS+= -Wl,-znocombreloc
+ # Add libstand for required string and memory functions for all platforms.
+ #
+ DPADD+= ${LIBSTAND}
+-LDADD+= -lstand
++LDADD+= ${LIBSTAND}
+
+ DPADD+= ${LDSCRIPT}
+
diff --git a/sys-freebsd/boot0/files/boot0-8.2-zfsboot-makefile.patch b/sys-freebsd/boot0/files/boot0-8.2-zfsboot-makefile.patch
new file mode 100644
index 0000000..a3a33d5
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-8.2-zfsboot-makefile.patch
@@ -0,0 +1,13 @@
+diff --git a/sys/boot/i386/zfsboot/Makefile b/sys/boot/i386/zfsboot/Makefile
+index bb16ea3..7dedb49 100644
+--- a/sys/boot/i386/zfsboot/Makefile
++++ b/sys/boot/i386/zfsboot/Makefile
+@@ -83,6 +83,8 @@ zfsboot.bin: zfsboot.out
+ zfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o util.o
+ ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND}
+
++drv.o: drv.c xreadorg.h
++
+ zfsboot.o: zfsboot.s
+
+ SRCS= zfsboot.c xreadorg.h
diff --git a/sys-freebsd/boot0/files/boot0-9.2-gcc46.patch b/sys-freebsd/boot0/files/boot0-9.2-gcc46.patch
new file mode 100644
index 0000000..ffd9f43
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-9.2-gcc46.patch
@@ -0,0 +1,66 @@
+diff --git a/sys/boot/i386/Makefile.inc b/sys/boot/i386/Makefile.inc
+index f5faec7..a9cf593 100644
+--- a/sys/boot/i386/Makefile.inc
++++ b/sys/boot/i386/Makefile.inc
+@@ -12,7 +12,6 @@ LDFLAGS+= -nostdlib
+ .if ${MACHINE_CPUARCH} == "amd64"
+ CFLAGS+= -m32
+ ACFLAGS+= -m32
+-LDFLAGS+= -m elf_i386_fbsd
+ AFLAGS+= --32
+ .endif
+
+diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile
+index 65815a5..61840dd 100644
+--- a/sys/boot/i386/boot2/Makefile
++++ b/sys/boot/i386/boot2/Makefile
+@@ -109,3 +109,10 @@ machine:
+ # XXX: clang integrated-as doesn't grok .codeNN directives yet
+ CFLAGS.boot1.S= ${CLANG_NO_IAS}
+ CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
++
++# gcc 4.6 or later version, -fno-asynchronous-unwind-tables is required to build.
++CFLAGS+= -fno-asynchronous-unwind-tables
++
++.if ${MACHINE_CPUARCH} == "amd64"
++LDFLAGS+= -m elf_i386_fbsd
++.endif
+diff --git a/sys/boot/i386/gptboot/Makefile b/sys/boot/i386/gptboot/Makefile
+index e1a640a..29886cc 100644
+--- a/sys/boot/i386/gptboot/Makefile
++++ b/sys/boot/i386/gptboot/Makefile
+@@ -78,3 +78,8 @@ machine:
+ # XXX: clang integrated-as doesn't grok .codeNN directives yet
+ CFLAGS.gptldr.S= ${CLANG_NO_IAS}
+ CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
++
++.if ${MACHINE_CPUARCH} == "amd64"
++LDFLAGS+= -m elf_i386_fbsd
++.endif
++
+diff --git a/sys/boot/i386/gptzfsboot/Makefile b/sys/boot/i386/gptzfsboot/Makefile
+index a2b8fcc..107f531 100644
+--- a/sys/boot/i386/gptzfsboot/Makefile
++++ b/sys/boot/i386/gptzfsboot/Makefile
+@@ -76,3 +76,8 @@ machine:
+ # XXX: clang integrated-as doesn't grok .codeNN directives yet
+ CFLAGS.gptldr.S= ${CLANG_NO_IAS}
+ CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
++
++.if ${MACHINE_CPUARCH} == "amd64"
++LDFLAGS+= -m elf_i386_fbsd
++.endif
++
+diff --git a/sys/boot/i386/zfsboot/Makefile b/sys/boot/i386/zfsboot/Makefile
+index b2db778..252dc62 100644
+--- a/sys/boot/i386/zfsboot/Makefile
++++ b/sys/boot/i386/zfsboot/Makefile
+@@ -89,3 +89,8 @@ machine:
+ # XXX: clang integrated-as doesn't grok .codeNN directives yet
+ CFLAGS.zfsldr.S= ${CLANG_NO_IAS}
+ CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
++
++.if ${MACHINE_CPUARCH} == "amd64"
++LDFLAGS+= -m elf_i386_fbsd
++.endif
++
diff --git a/sys-freebsd/boot0/files/boot0-add-nossp-cflags.patch b/sys-freebsd/boot0/files/boot0-add-nossp-cflags.patch
new file mode 100644
index 0000000..abc6a57
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-add-nossp-cflags.patch
@@ -0,0 +1,11 @@
+https://bugs.gentoo.org/show_bug.cgi?id=511698
+
+diff --git a/sys/boot/Makefile.inc b/sys/boot/Makefile.inc
+index e0039b9..533dea0 100644
+--- a/sys/boot/Makefile.inc
++++ b/sys/boot/Makefile.inc
+@@ -1,3 +1,3 @@
+ # $FreeBSD: release/10.0.0/sys/boot/Makefile.inc 188895 2009-02-21 15:04:31Z ru $
+
+-SSP_CFLAGS=
++SSP_CFLAGS= -fno-stack-protector
diff --git a/sys-freebsd/boot0/metadata.xml b/sys-freebsd/boot0/metadata.xml
new file mode 100644
index 0000000..d9f0c83
--- /dev/null
+++ b/sys-freebsd/boot0/metadata.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+ </maintainer>
+ <use>
+ <flag name="tftp">Enable PXE/TFTP boot support.</flag>
+ <flag name="zfs">Enable booting on ZFS filesystems.</flag>
+ </use>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-bin/freebsd-bin-11.0.ebuild b/sys-freebsd/freebsd-bin/freebsd-bin-11.0.ebuild
new file mode 100644
index 0000000..d4bf7e3
--- /dev/null
+++ b/sys-freebsd/freebsd-bin/freebsd-bin-11.0.ebuild
@@ -0,0 +1,42 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit bsdmk freebsd
+
+DESCRIPTION="FreeBSD /bin tools"
+SLOT="0"
+
+IUSE=""
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ bin/
+ usr.bin/
+ sbin/
+ lib/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ >=dev-libs/libedit-20120311.3.0-r1
+ sys-libs/ncurses:0=
+ sys-apps/ed
+ !app-misc/realpath
+ !<sys-freebsd/freebsd-ubin-8"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ >=sys-devel/flex-2.5.31-r2"
+
+S=${WORKDIR}/bin
+
+# csh and tcsh are provided by tcsh package, rmail is sendmail stuff.
+REMOVE_SUBDIRS="csh rmail ed freebsd-version"
+
+pkg_setup() {
+ mymakeopts="${mymakeopts} WITHOUT_TCSH= WITHOUT_SENDMAIL= WITHOUT_RCMDS= "
+}
diff --git a/sys-freebsd/freebsd-bin/metadata.xml b/sys-freebsd/freebsd-bin/metadata.xml
new file mode 100644
index 0000000..a00f3ae
--- /dev/null
+++ b/sys-freebsd/freebsd-bin/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+</maintainer>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-10.2-libpaths.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-10.2-libpaths.patch
new file mode 100644
index 0000000..9af7cfb
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-10.2-libpaths.patch
@@ -0,0 +1,220 @@
+diff --git a/cddl/lib/libzfs/Makefile b/cddl/lib/libzfs/Makefile
+index d8bcccb..2cebbcb 100644
+--- a/cddl/lib/libzfs/Makefile
++++ b/cddl/lib/libzfs/Makefile
+@@ -59,6 +59,11 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libnvpair
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs_core/common
+
+diff --git a/cddl/lib/libzfs_core/Makefile b/cddl/lib/libzfs_core/Makefile
+index 262d3e9..9643210 100644
+--- a/cddl/lib/libzfs_core/Makefile
++++ b/cddl/lib/libzfs_core/Makefile
+@@ -34,4 +34,6 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs_core/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++
+ .include <bsd.lib.mk>
+diff --git a/cddl/lib/libzpool/Makefile b/cddl/lib/libzpool/Makefile
+index 83cefca..55c56d5 100644
+--- a/cddl/lib/libzpool/Makefile
++++ b/cddl/lib/libzpool/Makefile
+@@ -56,6 +56,10 @@ CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/thread
+ CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/sys
+ CFLAGS+= -I${.CURDIR}/../../../lib/libthr/arch/${MACHINE_CPUARCH}/include
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++
+ DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBZ} ${LIBNVPAIR} \
+ ${LIBAVL} ${LIBUMEM}
+ LDADD= -lmd -lpthread -lz -lnvpair -lavl -lumem
+diff --git a/cddl/sbin/zfs/Makefile b/cddl/sbin/zfs/Makefile
+index 1f909aa..2590302 100644
+--- a/cddl/sbin/zfs/Makefile
++++ b/cddl/sbin/zfs/Makefile
+@@ -22,6 +22,12 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBGEOM} ${LIBJAIL} ${LIBNVPAIR} ${LIBUMEM} \
+ ${LIBUTIL} ${LIBUUTIL} ${LIBZFS_CORE} ${LIBZFS}
+ LDADD= -lgeom -ljail -lnvpair -lumem -lutil -luutil -lzfs_core -lzfs
+diff --git a/cddl/sbin/zpool/Makefile b/cddl/sbin/zpool/Makefile
+index 4b5b898..f89d010 100644
+--- a/cddl/sbin/zpool/Makefile
++++ b/cddl/sbin/zpool/Makefile
+@@ -27,6 +27,13 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/cmd/stat/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBAVL} ${LIBGEOM} ${LIBNVPAIR} \
+ ${LIBUMEM} ${LIBUTIL} ${LIBUUTIL} ${LIBZFS_CORE} ${LIBZFS}
+ LDADD= -lavl -lgeom -lnvpair -lumem -lutil -luutil -lzfs_core -lzfs
+diff --git a/cddl/usr.bin/ctfconvert/Makefile b/cddl/usr.bin/ctfconvert/Makefile
+index 6cb9529..e76fbc4 100644
+--- a/cddl/usr.bin/ctfconvert/Makefile
++++ b/cddl/usr.bin/ctfconvert/Makefile
+@@ -36,6 +36,8 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
+ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \
+ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
++
+ DPADD= ${LIBCTF} ${LIBDWARF} ${LIBELF} ${LIBZ} ${LIBPTHREAD}
+ LDADD= -lctf -ldwarf -lelf -lz -lpthread
+
+diff --git a/cddl/usr.bin/ctfmerge/Makefile b/cddl/usr.bin/ctfmerge/Makefile
+index 673c7e3..5fff940 100644
+--- a/cddl/usr.bin/ctfmerge/Makefile
++++ b/cddl/usr.bin/ctfmerge/Makefile
+@@ -33,6 +33,8 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
+ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \
+ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
++
+ DPADD= ${LIBCTF} ${LIBDWARF} ${LIBELF} ${LIBZ} ${LIBPTHREAD}
+ LDADD= -lctf -ldwarf -lelf -lz -lpthread
+
+diff --git a/cddl/usr.bin/zinject/Makefile b/cddl/usr.bin/zinject/Makefile
+index b6605cb..7028630 100644
+--- a/cddl/usr.bin/zinject/Makefile
++++ b/cddl/usr.bin/zinject/Makefile
+@@ -21,6 +21,14 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs/
+ CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBUUTIL} \
+ ${LIBZFS_CORE} ${LIBZFS} ${LIBZPOOL}
+ LDADD= -lgeom -lm -lnvpair -lumem -luutil -lzfs_core -lzfs -lzpool
+diff --git a/cddl/usr.bin/zstreamdump/Makefile b/cddl/usr.bin/zstreamdump/Makefile
+index 888b9af..523ba44 100644
+--- a/cddl/usr.bin/zstreamdump/Makefile
++++ b/cddl/usr.bin/zstreamdump/Makefile
+@@ -18,6 +18,11 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
+ CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++
+ DPADD= ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBZPOOL} \
+ ${LIBPTHREAD} ${LIBZ} ${LIBAVL}
+ LDADD= -lm -lnvpair -lumem -lzpool -lpthread -lz -lavl
+diff --git a/cddl/usr.bin/ztest/Makefile b/cddl/usr.bin/ztest/Makefile
+index f6f7e03..6fed691 100644
+--- a/cddl/usr.bin/ztest/Makefile
++++ b/cddl/usr.bin/ztest/Makefile
+@@ -18,6 +18,14 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
+ CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBZPOOL} \
+ ${LIBPTHREAD} ${LIBAVL} ${LIBZFS_CORE} ${LIBZFS} ${LIBUUTIL}
+ LDADD= -lgeom -lm -lnvpair -lumem -lzpool -lpthread -lavl -lzfs_core -lzfs \
+diff --git a/cddl/usr.sbin/dtrace/Makefile b/cddl/usr.sbin/dtrace/Makefile
+index fb5729f..ea9a752 100644
+--- a/cddl/usr.sbin/dtrace/Makefile
++++ b/cddl/usr.sbin/dtrace/Makefile
+@@ -25,4 +25,7 @@ DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBFL} ${LIBPROC} \
+ LDADD= -lpthread -ldtrace -ly -lfl -lproc -lctf -lelf -lz -lutil \
+ -lrtld_db
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libdtrace
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
++
+ .include <bsd.prog.mk>
+diff --git a/cddl/usr.sbin/lockstat/Makefile b/cddl/usr.sbin/lockstat/Makefile
+index ccd8189..827a197 100644
+--- a/cddl/usr.sbin/lockstat/Makefile
++++ b/cddl/usr.sbin/lockstat/Makefile
+@@ -20,6 +20,9 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
+
+ CFLAGS+= -DNEED_ERRLOC -g
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libdtrace
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
++
+ #YFLAGS+= -d
+
+ DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBFL} ${LIBPROC} \
+diff --git a/cddl/usr.sbin/zdb/Makefile b/cddl/usr.sbin/zdb/Makefile
+index c2a6b1d..f411fc0 100644
+--- a/cddl/usr.sbin/zdb/Makefile
++++ b/cddl/usr.sbin/zdb/Makefile
+@@ -24,6 +24,14 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBPTHREAD} ${LIBUMEM} \
+ ${LIBUUTIL} ${LIBZFS_CORE} ${LIBZFS} ${LIBZPOOL}
+ LDADD= -lgeom -lm -lnvpair -lpthread -lumem -luutil -lzfs_core -lzfs -lzpool
+diff --git a/cddl/usr.sbin/zhack/Makefile b/cddl/usr.sbin/zhack/Makefile
+index 1957aad..9a5570a 100644
+--- a/cddl/usr.sbin/zhack/Makefile
++++ b/cddl/usr.sbin/zhack/Makefile
+@@ -23,6 +23,13 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBPTHREAD} ${LIBUMEM} \
+ ${LIBUUTIL} ${LIBZFS_CORE} ${LIBZFS} ${LIBZPOOL}
+ LDADD= -lgeom -lm -lnvpair -lpthread -lumem -luutil -lzfs_core -lzfs -lzpool
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-10.3-underlink.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-10.3-underlink.patch
new file mode 100644
index 0000000..c8ce8e1
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-10.3-underlink.patch
@@ -0,0 +1,12 @@
+diff --git a/cddl/lib/libzfs/Makefile b/cddl/lib/libzfs/Makefile
+index 2a66337..04988d7 100644
+--- a/cddl/lib/libzfs/Makefile
++++ b/cddl/lib/libzfs/Makefile
+@@ -12,6 +12,7 @@ DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBUMEM} ${LIBUTIL} ${LIBM} ${LIBNVPAIR} \
+
+ LDADD= -lmd -lpthread -lumem -lutil -luutil -lm -lnvpair -lavl \
+ -lbsdxml -lgeom -lnvpair -lz -lzfs_core
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
+
+ SRCS= deviceid.c \
+ fsshare.c \
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-8.0-libpaths.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-8.0-libpaths.patch
new file mode 100644
index 0000000..ad5c83e
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-8.0-libpaths.patch
@@ -0,0 +1,114 @@
+diff -ru cddl.orig/lib/libctf/Makefile cddl/lib/libctf/Makefile
+--- cddl.orig/lib/libctf/Makefile 2009-01-24 03:36:33 -0200
++++ cddl/lib/libctf/Makefile 2009-01-24 03:55:10 -0200
+@@ -4,6 +4,7 @@
+
+ LIB= ctf
+ SHLIB_MAJOR= 2
++LDADD+=-lz
+
+ SRCS= ctf_create.c \
+ ctf_decl.c \
+diff -ru cddl.orig/lib/libdtrace/Makefile cddl/lib/libdtrace/Makefile
+--- cddl.orig/lib/libdtrace/Makefile 2009-01-24 00:18:47 -0200
++++ cddl/lib/libdtrace/Makefile 2009-01-24 03:31:06 -0200
+@@ -74,7 +74,7 @@
+ .endif
+
+ LFLAGS+=-l
+-
++LDADD+=-lz -lproc
+ YFLAGS+=-d
+
+ CLEANFILES= dt_errtags.c dt_names.c
+diff -ru cddl.orig/lib/libzfs/Makefile cddl/lib/libzfs/Makefile
+--- cddl.orig/lib/libzfs/Makefile 2008-06-22 10:26:18 -0300
++++ cddl/lib/libzfs/Makefile 2008-06-22 10:26:26 -0300
+@@ -7,7 +7,8 @@
+
+ LIB= zfs
+ DPADD= ${LIBUTIL}
+-LDADD= -lutil
++LDADD= -lutil -lgeom -lm -luutil -lumem
++LDFLAGS+= -L${.CURDIR}/../libuutil -L${.CURDIR}/../libumem
+
+ SRCS= deviceid.c \
+ mnttab.c \
+diff -ru cddl.orig/lib/libzpool/Makefile cddl/lib/libzpool/Makefile
+--- cddl.orig/lib/libzpool/Makefile 2008-06-22 10:35:15 -0300
++++ cddl/lib/libzpool/Makefile 2008-06-22 10:37:06 -0300
+@@ -42,7 +42,8 @@
+ CFLAGS+= -I${.CURDIR}/../../../contrib/opensolaris/lib/libnvpair
+
+ DPADD= ${LIBPTHREAD} ${LIBZ}
+-LDADD= -lpthread -lz
++LDADD= -lpthread -lz -lavl -lumem
++LDFLAGS+= -L${.CURDIR}/../libavl -L${.CURDIR}/../libumem
+
+ # atomic.S doesn't like profiling.
+ NO_PROFILE=
+diff -ru cddl.orig/sbin/zfs/Makefile cddl/sbin/zfs/Makefile
+--- cddl.orig/sbin/zfs/Makefile 2008-06-22 10:02:30 -0300
++++ cddl/sbin/zfs/Makefile 2008-06-22 10:14:23 -0300
+@@ -23,5 +23,7 @@
+ ${LIBM} ${LIBNVPAIR} ${LIBUUTIL} ${LIBUTIL}
+ LDADD= -lzfs -lgeom -lbsdxml -lsbuf \
+ -lm -lnvpair -luutil -lutil
++LDFLAGS+=-L${.CURDIR}/../../lib/libzfs -L${.CURDIR}/../../lib/libnvpair \
++ -L${.CURDIR}/../../lib/libuutil -L/lib -L/usr/lib
+
+ .include <bsd.prog.mk>
+diff -ru cddl.orig/sbin/zpool/Makefile cddl/sbin/zpool/Makefile
+--- cddl.orig/sbin/zpool/Makefile 2008-06-22 10:02:30 -0300
++++ cddl/sbin/zpool/Makefile 2008-06-22 10:14:47 -0300
+@@ -23,5 +23,7 @@
+ ${LIBM} ${LIBNVPAIR} ${LIBUUTIL} ${LIBUTIL}
+ LDADD= -lavl -lzfs -lgeom -lbsdxml -lsbuf \
+ -lm -lnvpair -luutil -lutil
++LDFLAGS+=-L${.CURDIR}/../../lib/libzfs -L${.CURDIR}/../../lib/libavl -L/lib -L/usr/lib \
++ -L${.CURDIR}/../../lib/libnvpair -L${.CURDIR}/../../lib/libuutil
+
+ .include <bsd.prog.mk>
+diff -ru cddl.orig/usr.bin/ztest/Makefile cddl/usr.bin/ztest/Makefile
+--- cddl.orig/usr.bin/ztest/Makefile 2008-06-22 10:02:30 -0300
++++ cddl/usr.bin/ztest/Makefile 2008-06-22 10:12:40 -0300
+@@ -18,5 +18,7 @@
+ DPADD= ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBZPOOL} \
+ ${LIBPTHREAD} ${LIBZ} ${LIBAVL}
+ LDADD= -lm -lnvpair -lumem -lzpool -lpthread -lz -lavl
++LDFLAGS+=-L${.CURDIR}/../../lib/libnvpair -L${.CURDIR}/../../lib/libumem \
++ -L${.CURDIR}/../../lib/libzpool -L${.CURDIR}/../../lib/libavl -L/lib -L/usr/lib
+
+ .include <bsd.prog.mk>
+diff -ru cddl.orig/usr.bin/Makefile.inc cddl/usr.bin/Makefile.inc
+--- cddl.orig/usr.bin/Makefile.inc 2009-01-10 07:21:10 +0000
++++ cddl/usr.bin/Makefile.inc 2009-01-10 07:18:55 +0000
+@@ -1,5 +1,6 @@
+ # $FreeBSD: src/cddl/usr.bin/Makefile.inc,v 1.1.6.1 2008/11/25 02:59:29 kensmith Exp $
+
+ BINDIR?= /usr/bin
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
+
+ .include "../Makefile.inc"
+--- cddl.orig/usr.sbin/zdb/Makefile 2010-03-11 13:19:48 +0100
++++ cddl/usr.sbin/zdb/Makefile 2010-03-11 13:20:08 +0100
+@@ -22,6 +22,8 @@
+ DPADD= ${LIBAVL} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBPTHREAD} ${LIBUMEM} \
+ ${LIBUUTIL} ${LIBZ} ${LIBZFS} ${LIBZPOOL}
+ LDADD= -lavl -lgeom -lm -lnvpair -lpthread -lumem -luutil -lz -lzfs -lzpool
++LDFLAGS+=-L${.CURDIR}/../../lib/libnvpair -L${.CURDIR}/../../lib/libumem \
++ -L${.CURDIR}/../../lib/libzpool -L${.CURDIR}/../../lib/libavl -L${.CURDIR}/../../lib/libuutil -L${.CURDIR}/../../lib/libzfs
+
+ CSTD= c99
+
+--- cddl.orig/usr.bin/zinject/Makefile 2010-03-11 13:30:32 +0100
++++ cddl/usr.bin/zinject/Makefile 2010-03-11 13:33:27 +0100
+@@ -21,5 +21,8 @@
+ DPADD= ${LIBAVL} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBUUTIL} \
+ ${LIBZFS} ${LIBZPOOL} ${LIBUUTIL}
+ LDADD= -lavl -lgeom -lm -lnvpair -lumem -luutil -lzfs -lzpool
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl -L${.CURDIR}/../../lib/libnvpair \
++ -L${.CURDIR}/../../lib/libumem -L${.CURDIR}/../../lib/libuutil \
++ -L${.CURDIR}/../../lib/libzfs -L${.CURDIR}/../../lib/libzpool
+
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-8.2-libpaths.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-8.2-libpaths.patch
new file mode 100644
index 0000000..a0e5677
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-8.2-libpaths.patch
@@ -0,0 +1,22 @@
+--- cddl/usr.sbin/dtrace/Makefile.old 2011-07-06 00:09:01.000000000 +0000
++++ cddl/usr.sbin/dtrace/Makefile 2011-07-06 00:09:48.000000000 +0000
+@@ -24,6 +24,8 @@
+ #CFLAGS+= -DNEED_ERRLOC
+ #YFLAGS+= -d
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libdtrace -L${.CURDIR}/../../lib/libctf
++
+ DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBL} ${LIBPROC} \
+ ${LIBCTF} ${LIBELF} ${LIBZ} ${LIBUTIL} ${LIBRTLD_DB}
+ LDADD= -lpthread -ldtrace -ly -lfl -lproc -lctf -lelf -lz -lutil \
+--- cddl/usr.sbin/lockstat/Makefile.old 2011-07-06 00:10:33.000000000 +0000
++++ cddl/usr.sbin/lockstat/Makefile 2011-07-06 00:10:57.000000000 +0000
+@@ -23,6 +23,8 @@
+
+ CFLAGS+= -DNEED_ERRLOC -g
+
++LDFLAGS+=-L${.CURDIR}/../../lib/libdtrace -L${.CURDIR}/../../lib/libctf
++
+ #YFLAGS+= -d
+
+ DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBL} ${LIBPROC} \
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-bsdxml.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-bsdxml.patch
new file mode 100644
index 0000000..b3d95bb
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-bsdxml.patch
@@ -0,0 +1,28 @@
+diff -ur cddl.old/sbin/zfs/Makefile cddl/sbin/zfs/Makefile
+--- cddl.old/sbin/zfs/Makefile 2011-11-04 10:01:46.000000000 +0000
++++ cddl/sbin/zfs/Makefile 2011-11-04 10:07:15.000000000 +0000
+@@ -21,8 +21,8 @@
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+
+-DPADD= ${LIBBSDXML} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBSBUF} ${LIBUMEM} \
++DPADD= ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBSBUF} ${LIBUMEM} \
+ ${LIBUTIL} ${LIBUUTIL} ${LIBZFS}
+-LDADD= -lbsdxml -lgeom -lm -lnvpair -lsbuf -lumem -lutil -luutil -lzfs
++LDADD= -lgeom -lm -lnvpair -lsbuf -lumem -lutil -luutil -lzfs
+
+ .include <bsd.prog.mk>
+diff -ur cddl.old/sbin/zpool/Makefile cddl/sbin/zpool/Makefile
+--- cddl.old/sbin/zpool/Makefile 2011-11-04 10:01:46.000000000 +0000
++++ cddl/sbin/zpool/Makefile 2011-11-04 10:06:38.000000000 +0000
+@@ -26,8 +26,8 @@
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/cmd/stat/common
+
+-DPADD= ${LIBAVL} ${LIBBSDXML} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBSBUF} \
++DPADD= ${LIBAVL} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBSBUF} \
+ ${LIBUMEM} ${LIBUTIL} ${LIBUUTIL} ${LIBZFS}
+-LDADD= -lavl -lbsdxml -lgeom -lm -lnvpair -lsbuf -lumem -lutil -luutil -lzfs
++LDADD= -lavl -lgeom -lm -lnvpair -lsbuf -lumem -lutil -luutil -lzfs
+
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-libpaths.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-libpaths.patch
new file mode 100644
index 0000000..c81a2c3
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-libpaths.patch
@@ -0,0 +1,167 @@
+diff -upNr a/cddl/lib/libzfs/Makefile b/cddl/lib/libzfs/Makefile
+--- a/cddl/lib/libzfs/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/lib/libzfs/Makefile 2012-03-30 19:04:39.904906253 +0000
+@@ -54,4 +54,8 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/cont
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++
+ .include <bsd.lib.mk>
+diff -upNr a/cddl/lib/libzpool/Makefile b/cddl/lib/libzpool/Makefile
+--- a/cddl/lib/libzpool/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/lib/libzpool/Makefile 2012-03-30 19:04:55.839233753 +0000
+@@ -56,6 +56,10 @@ CFLAGS+= -I${.CURDIR}/../../../lib/libpt
+ CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/sys
+ CFLAGS+= -I${.CURDIR}/../../../lib/libthr/arch/${MACHINE_CPUARCH}/include
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++
+ DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBZ}
+ LDADD= -lmd -lpthread -lz -lumem -lnvpair -lavl
+
+diff -upNr a/cddl/sbin/zfs/Makefile b/cddl/sbin/zfs/Makefile
+--- a/cddl/sbin/zfs/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/sbin/zfs/Makefile 2012-03-30 19:05:11.094859502 +0000
+@@ -21,6 +21,11 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++
+ DPADD= ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBSBUF} ${LIBUMEM} \
+ ${LIBUTIL} ${LIBUUTIL} ${LIBZFS}
+ LDADD= -lgeom -lm -lnvpair -lsbuf -lumem -lutil -luutil -lzfs
+diff -upNr a/cddl/sbin/zpool/Makefile b/cddl/sbin/zpool/Makefile
+--- a/cddl/sbin/zpool/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/sbin/zpool/Makefile 2012-03-30 19:05:24.830721002 +0000
+@@ -26,6 +26,12 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/cmd/stat/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++
+ DPADD= ${LIBAVL} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBSBUF} \
+ ${LIBUMEM} ${LIBUTIL} ${LIBUUTIL} ${LIBZFS}
+ LDADD= -lavl -lgeom -lm -lnvpair -lsbuf -lumem -lutil -luutil -lzfs
+diff -upNr a/cddl/usr.bin/ctfconvert/Makefile b/cddl/usr.bin/ctfconvert/Makefile
+--- a/cddl/usr.bin/ctfconvert/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/usr.bin/ctfconvert/Makefile 2012-03-30 19:05:49.454897012 +0000
+@@ -36,6 +36,8 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/
+ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \
+ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
++
+ DPADD= ${LIBCTF} ${LIBDWARF} ${LIBELF} ${LIBZ} ${LIBPTHREAD}
+ LDADD= -lctf -ldwarf -lelf -lz -lpthread
+
+diff -upNr a/cddl/usr.bin/ctfmerge/Makefile b/cddl/usr.bin/ctfmerge/Makefile
+--- a/cddl/usr.bin/ctfmerge/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/usr.bin/ctfmerge/Makefile 2012-03-30 19:06:08.084858412 +0000
+@@ -33,6 +33,8 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/
+ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \
+ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
++
+ DPADD= ${LIBCTF} ${LIBDWARF} ${LIBELF} ${LIBZ} ${LIBPTHREAD}
+ LDADD= -lctf -ldwarf -lelf -lz -lpthread
+
+diff -upNr a/cddl/usr.bin/zinject/Makefile b/cddl/usr.bin/zinject/Makefile
+--- a/cddl/usr.bin/zinject/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/usr.bin/zinject/Makefile 2012-03-30 19:06:25.084865592 +0000
+@@ -19,6 +19,13 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/
+ CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++
+ DPADD= ${LIBAVL} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBUUTIL} \
+ ${LIBZFS} ${LIBZPOOL}
+ LDADD= -lavl -lgeom -lm -lnvpair -lumem -luutil -lzfs -lzpool
+diff -upNr a/cddl/usr.bin/zstreamdump/Makefile b/cddl/usr.bin/zstreamdump/Makefile
+--- a/cddl/usr.bin/zstreamdump/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/usr.bin/zstreamdump/Makefile 2012-03-30 19:06:44.544860132 +0000
+@@ -18,6 +18,11 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/
+ CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++
+ DPADD= ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBZPOOL} \
+ ${LIBPTHREAD} ${LIBZ} ${LIBAVL}
+ LDADD= -lm -lnvpair -lumem -lzpool -lpthread -lz -lavl
+diff -upNr a/cddl/usr.bin/ztest/Makefile b/cddl/usr.bin/ztest/Makefile
+--- a/cddl/usr.bin/ztest/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/usr.bin/ztest/Makefile 2012-03-30 19:06:58.344895642 +0000
+@@ -17,6 +17,11 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/
+ CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++
+ DPADD= ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBZPOOL} \
+ ${LIBPTHREAD} ${LIBZ} ${LIBAVL}
+ LDADD= -lm -lnvpair -lumem -lzpool -lpthread -lz -lavl
+diff -upNr a/cddl/usr.sbin/zdb/Makefile b/cddl/usr.sbin/zdb/Makefile
+--- a/cddl/usr.sbin/zdb/Makefile 2012-03-30 18:58:53.164736000 +0000
++++ b/cddl/usr.sbin/zdb/Makefile 2012-03-30 19:07:17.454861002 +0000
+@@ -23,6 +23,13 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++
+ DPADD= ${LIBAVL} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBPTHREAD} ${LIBUMEM} \
+ ${LIBUUTIL} ${LIBZ} ${LIBZFS} ${LIBZPOOL}
+ LDADD= -lavl -lgeom -lm -lnvpair -lpthread -lumem -luutil -lz -lzfs -lzpool
+--- a/cddl/usr.sbin/dtrace/Makefile.old 2011-07-06 00:09:01.000000000 +0000
++++ b/cddl/usr.sbin/dtrace/Makefile 2011-07-06 00:09:48.000000000 +0000
+@@ -24,6 +24,8 @@
+ #CFLAGS+= -DNEED_ERRLOC
+ #YFLAGS+= -d
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libdtrace -L${.CURDIR}/../../lib/libctf
++
+ DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBL} ${LIBPROC} \
+ ${LIBCTF} ${LIBELF} ${LIBZ} ${LIBUTIL} ${LIBRTLD_DB}
+ LDADD= -lpthread -ldtrace -ly -lfl -lproc -lctf -lelf -lz -lutil \
+--- a/cddl/usr.sbin/lockstat/Makefile.old 2011-07-06 00:10:33.000000000 +0000
++++ b/cddl/usr.sbin/lockstat/Makefile 2011-07-06 00:10:57.000000000 +0000
+@@ -23,6 +23,8 @@
+
+ CFLAGS+= -DNEED_ERRLOC -g
+
++LDFLAGS+=-L${.CURDIR}/../../lib/libdtrace -L${.CURDIR}/../../lib/libctf
++
+ #YFLAGS+= -d
+
+ DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBL} ${LIBPROC} \
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-underlink.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-underlink.patch
new file mode 100644
index 0000000..ff87d2c
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-underlink.patch
@@ -0,0 +1,22 @@
+--- cddl/lib/libzfs/Makefile.old 2011-11-04 10:27:30.000000000 +0000
++++ cddl/lib/libzfs/Makefile 2011-11-04 10:28:59.000000000 +0000
+@@ -7,7 +7,7 @@
+
+ LIB= zfs
+ DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBUMEM} ${LIBUTIL}
+-LDADD= -lmd -lpthread -lumem -lutil
++LDADD= -lmd -lpthread -lumem -lutil -luutil -lnvpair -lm -lgeom
+
+ SRCS= deviceid.c \
+ fsshare.c \
+--- cddl/lib/libzpool/Makefile.old 2011-11-04 18:22:28.000000000 +0000
++++ cddl/lib/libzpool/Makefile 2011-11-04 18:24:01.000000000 +0000
+@@ -57,7 +57,7 @@
+ CFLAGS+= -I${.CURDIR}/../../../lib/libthr/arch/${MACHINE_CPUARCH}/include
+
+ DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBZ}
+-LDADD= -lmd -lpthread -lz
++LDADD= -lmd -lpthread -lz -lumem -lnvpair -lavl
+
+ # atomic.S doesn't like profiling.
+ NO_PROFILE=
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.2-libpaths.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.2-libpaths.patch
new file mode 100644
index 0000000..36eb570
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.2-libpaths.patch
@@ -0,0 +1,220 @@
+diff --git a/lib/libzfs/Makefile b/lib/libzfs/Makefile
+index 5b6b47d..c8549b4 100644
+--- a/lib/libzfs/Makefile
++++ b/lib/libzfs/Makefile
+@@ -55,6 +55,11 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libnvpair
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs_core/common
+
+diff --git a/lib/libzfs_core/Makefile b/lib/libzfs_core/Makefile
+index a470fbc..ae8c649 100644
+--- a/lib/libzfs_core/Makefile
++++ b/lib/libzfs_core/Makefile
+@@ -34,4 +34,6 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs_core/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++
+ .include <bsd.lib.mk>
+diff --git a/lib/libzpool/Makefile b/lib/libzpool/Makefile
+index 417c1cc..838cdb5 100644
+--- a/lib/libzpool/Makefile
++++ b/lib/libzpool/Makefile
+@@ -56,6 +56,10 @@ CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/thread
+ CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/sys
+ CFLAGS+= -I${.CURDIR}/../../../lib/libthr/arch/${MACHINE_CPUARCH}/include
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++
+ DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBZ}
+ LDADD= -lmd -lpthread -lz
+
+diff --git a/sbin/zfs/Makefile b/sbin/zfs/Makefile
+index a49d278..b22442e 100644
+--- a/sbin/zfs/Makefile
++++ b/sbin/zfs/Makefile
+@@ -22,6 +22,12 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBGEOM} ${LIBJAIL} ${LIBNVPAIR} ${LIBUMEM} \
+ ${LIBUTIL} ${LIBUUTIL} ${LIBZFS_CORE} ${LIBZFS}
+ LDADD= -lgeom -ljail -lnvpair -lumem -lutil -luutil -lzfs_core -lzfs
+diff --git a/sbin/zpool/Makefile b/sbin/zpool/Makefile
+index 1884d24..5f06d5f 100644
+--- a/sbin/zpool/Makefile
++++ b/sbin/zpool/Makefile
+@@ -26,6 +26,13 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/cmd/stat/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBAVL} ${LIBGEOM} ${LIBNVPAIR} \
+ ${LIBUMEM} ${LIBUTIL} ${LIBUUTIL} ${LIBZFS_CORE} ${LIBZFS}
+ LDADD= -lavl -lgeom -lnvpair -lumem -lutil -luutil -lzfs_core -lzfs
+diff --git a/usr.bin/ctfconvert/Makefile b/usr.bin/ctfconvert/Makefile
+index 7e4a05a..72327ad 100644
+--- a/usr.bin/ctfconvert/Makefile
++++ b/usr.bin/ctfconvert/Makefile
+@@ -36,6 +36,8 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
+ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \
+ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
++
+ DPADD= ${LIBCTF} ${LIBDWARF} ${LIBELF} ${LIBZ} ${LIBPTHREAD}
+ LDADD= -lctf -ldwarf -lelf -lz -lpthread
+
+diff --git a/usr.bin/ctfmerge/Makefile b/usr.bin/ctfmerge/Makefile
+index ba4840e..845d28c 100644
+--- a/usr.bin/ctfmerge/Makefile
++++ b/usr.bin/ctfmerge/Makefile
+@@ -33,6 +33,8 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
+ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \
+ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
++
+ DPADD= ${LIBCTF} ${LIBDWARF} ${LIBELF} ${LIBZ} ${LIBPTHREAD}
+ LDADD= -lctf -ldwarf -lelf -lz -lpthread
+
+diff --git a/usr.bin/zinject/Makefile b/usr.bin/zinject/Makefile
+index 8c5c141..3db2b29 100644
+--- a/usr.bin/zinject/Makefile
++++ b/usr.bin/zinject/Makefile
+@@ -19,6 +19,14 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
+ CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBUUTIL} \
+ ${LIBZFS_CORE} ${LIBZFS} ${LIBZPOOL}
+ LDADD= -lgeom -lm -lnvpair -lumem -luutil -lzfs_core -lzfs -lzpool
+diff --git a/usr.bin/zstreamdump/Makefile b/usr.bin/zstreamdump/Makefile
+index 304ff7c..5f0b00e 100644
+--- a/usr.bin/zstreamdump/Makefile
++++ b/usr.bin/zstreamdump/Makefile
+@@ -18,6 +18,11 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
+ CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++
+ DPADD= ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBZPOOL} \
+ ${LIBPTHREAD} ${LIBZ} ${LIBAVL}
+ LDADD= -lm -lnvpair -lumem -lzpool -lpthread -lz -lavl
+diff --git a/usr.bin/ztest/Makefile b/usr.bin/ztest/Makefile
+index 965300e..ad40a92 100644
+--- a/usr.bin/ztest/Makefile
++++ b/usr.bin/ztest/Makefile
+@@ -18,6 +18,14 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
+ CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBZPOOL} \
+ ${LIBPTHREAD} ${LIBAVL} ${LIBZFS_CORE} ${LIBZFS} ${LIBUUTIL}
+ LDADD= -lgeom -lm -lnvpair -lumem -lzpool -lpthread -lavl -lzfs_core -lzfs \
+diff --git a/usr.sbin/dtrace/Makefile b/usr.sbin/dtrace/Makefile
+index 3930f01..4bdbd1a 100644
+--- a/usr.sbin/dtrace/Makefile
++++ b/usr.sbin/dtrace/Makefile
+@@ -25,4 +25,7 @@ DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBL} ${LIBPROC} \
+ LDADD= -lpthread -ldtrace -ly -ll -lproc -lctf -lelf -lz -lutil \
+ -lrtld_db
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libdtrace
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
++
+ .include <bsd.prog.mk>
+diff --git a/usr.sbin/lockstat/Makefile b/usr.sbin/lockstat/Makefile
+index 70515ef..d65e4c3 100644
+--- a/usr.sbin/lockstat/Makefile
++++ b/usr.sbin/lockstat/Makefile
+@@ -20,6 +20,9 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
+
+ CFLAGS+= -DNEED_ERRLOC -g
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libdtrace
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
++
+ #YFLAGS+= -d
+
+ DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBFL} ${LIBPROC} \
+diff --git a/usr.sbin/zdb/Makefile b/usr.sbin/zdb/Makefile
+index 8068385..337e324 100644
+--- a/usr.sbin/zdb/Makefile
++++ b/usr.sbin/zdb/Makefile
+@@ -23,6 +23,14 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBPTHREAD} ${LIBUMEM} \
+ ${LIBUUTIL} ${LIBZFS_CORE} ${LIBZFS} ${LIBZPOOL}
+ LDADD= -lgeom -lm -lnvpair -lpthread -lumem -luutil -lzfs_core -lzfs -lzpool
+diff --git a/usr.sbin/zhack/Makefile b/usr.sbin/zhack/Makefile
+index f09d2d8..fc3d7a4 100644
+--- a/usr.sbin/zhack/Makefile
++++ b/usr.sbin/zhack/Makefile
+@@ -22,6 +22,13 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBPTHREAD} ${LIBUMEM} \
+ ${LIBUUTIL} ${LIBZFS_CORE} ${LIBZFS} ${LIBZPOOL}
+ LDADD= -lgeom -lm -lnvpair -lpthread -lumem -luutil -lzfs_core -lzfs -lzpool
diff --git a/sys-freebsd/freebsd-cddl/files/zfs.initd b/sys-freebsd/freebsd-cddl/files/zfs.initd
new file mode 100644
index 0000000..7daf445
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/zfs.initd
@@ -0,0 +1,24 @@
+#!/sbin/openrc-run
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+depend() {
+ need hostid
+ before fsck
+}
+
+start() {
+ einfo "Starting zfs ..."
+ zfs mount -a
+ zfs share -a
+ if [ ! -r /etc/zfs/exports ]; then
+ touch /etc/zfs/exports
+ fi
+}
+
+stop() {
+ einfo "Stopping zfs ..."
+ zfs unshare -a
+ zfs unmount -a
+}
diff --git a/sys-freebsd/freebsd-cddl/files/zvol.initd b/sys-freebsd/freebsd-cddl/files/zvol.initd
new file mode 100644
index 0000000..0f9fcb9
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/zvol.initd
@@ -0,0 +1,47 @@
+#!/sbin/openrc-run
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+depend() {
+ need hostid
+ before fsck
+}
+
+start() {
+ einfo "Starting zfs volumes..."
+ zfs volinit
+ eend $?
+ # Enable swap on ZVOLs that have org.freebsd:swap=on.
+ zfs list -H -o org.freebsd:swap,name -t volume | \
+ while read state name; do
+ case "${state}" in
+ [oO][nN])
+ einfo "Enabling swap on zvol ${name}"
+ swapon /dev/zvol/${name}
+ eend $?
+ ;;
+ esac
+ done
+}
+
+stop() {
+ # Disable what we had enabled before.
+ zfs list -H -o org.freebsd:swap,name -t volume | \
+ while read state name; do
+ case "${state}" in
+ [oO][nN])
+ einfo "Disabling swap on zvol ${name}"
+ swapoff /dev/zvol/${name}
+ eend $?
+ ;;
+ esac
+ done
+ einfo "Stopping zfs volumes..."
+ zfs volfini
+ eend $?
+}
+
+restart() {
+ :
+}
diff --git a/sys-freebsd/freebsd-cddl/files/zvol.initd-9.0 b/sys-freebsd/freebsd-cddl/files/zvol.initd-9.0
new file mode 100644
index 0000000..bfba28f
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/zvol.initd-9.0
@@ -0,0 +1,45 @@
+#!/sbin/openrc-run
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+depend() {
+ need hostid
+ before fsck
+}
+
+start() {
+ einfo "Starting zfs volumes..."
+ eend $?
+ # Enable swap on ZVOLs that have org.freebsd:swap=on.
+ zfs list -H -o org.freebsd:swap,name -t volume | \
+ while read state name; do
+ case "${state}" in
+ [oO][nN])
+ einfo "Enabling swap on zvol ${name}"
+ swapon /dev/zvol/${name}
+ eend $?
+ ;;
+ esac
+ done
+}
+
+stop() {
+ # Disable what we had enabled before.
+ zfs list -H -o org.freebsd:swap,name -t volume | \
+ while read state name; do
+ case "${state}" in
+ [oO][nN])
+ einfo "Disabling swap on zvol ${name}"
+ swapoff /dev/zvol/${name}
+ eend $?
+ ;;
+ esac
+ done
+ einfo "Stopping zfs volumes..."
+ eend $?
+}
+
+restart() {
+ :
+}
diff --git a/sys-freebsd/freebsd-cddl/freebsd-cddl-11.0.ebuild b/sys-freebsd/freebsd-cddl/freebsd-cddl-11.0.ebuild
new file mode 100644
index 0000000..afc5c8d
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/freebsd-cddl-11.0.ebuild
@@ -0,0 +1,75 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit bsdmk freebsd toolchain-funcs multilib
+
+DESCRIPTION="FreeBSD CDDL (opensolaris/zfs) extra software"
+SLOT="0"
+
+IUSE="build"
+LICENSE="CDDL GPL-2"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~x86-fbsd"
+fi
+
+# sys is required.
+EXTRACTONLY="
+ cddl/
+ contrib/
+ usr.bin/
+ lib/
+ sbin/
+ sys/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ =sys-freebsd/freebsd-libexec-${RV}*
+ build? ( sys-apps/baselayout )"
+
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )"
+
+S="${WORKDIR}/cddl"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-10.2-libpaths.patch"
+ "${FILESDIR}/${PN}-10.3-underlink.patch"
+ )
+
+pkg_setup() {
+ # Add the required source files.
+ use build && EXTRACTONLY+="include/ "
+}
+
+src_prepare() {
+ if [[ ! -e "${WORKDIR}/include" ]]; then
+ # Link in include headers.
+ ln -s "/usr/include" "${WORKDIR}/include" || die "Symlinking /usr/include.."
+ fi
+}
+
+src_compile() {
+ # Disable parallel make.
+ freebsd_src_compile -j1
+}
+
+src_install() {
+ # Install libraries proper place
+ local mylibdir=$(get_libdir)
+ mkinstall SHLIBDIR="/usr/${mylibdir}" LIBDIR="/usr/${mylibdir}" || die
+
+ gen_usr_ldscript -a avl nvpair umem uutil zfs zpool zfs_core
+
+ # Install zfs volinit script.
+ newinitd "${FILESDIR}"/zvol.initd-9.0 zvol
+
+ # Install zfs script
+ newinitd "${FILESDIR}"/zfs.initd zfs
+
+ keepdir /etc/zfs
+}
diff --git a/sys-freebsd/freebsd-cddl/metadata.xml b/sys-freebsd/freebsd-cddl/metadata.xml
new file mode 100644
index 0000000..a00f3ae
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+</maintainer>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-atfcxx.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-atfcxx.patch
new file mode 100644
index 0000000..42b64b5
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-atfcxx.patch
@@ -0,0 +1,49 @@
+diff --git a/lib/atf/Makefile.inc b/lib/atf/Makefile.inc
+index 937187a..d5277f3 100644
+--- a/lib/atf/Makefile.inc
++++ b/lib/atf/Makefile.inc
+@@ -49,6 +49,24 @@ CFLAGS+= -DATF_PKGDATADIR='"${SHAREDIR}/atf"'
+ CFLAGS+= -DATF_SHELL='"/bin/sh"'
+ CFLAGS+= -DATF_WORKDIR='"/tmp"'
+
++CXXFLAGS+= -DHAVE_CONFIG_H
++CXXFLAGS+= -DATF_ARCH='"${MACHINE}"'
++CXXFLAGS+= -DATF_BUILD_CC='"${CC}"'
++CXXFLAGS+= -DATF_BUILD_CXXFLAGS='"${_CXXFLAGS}"'
++CXXFLAGS+= -DATF_BUILD_CPP='"${CPP}"'
++CXXFLAGS+= -DATF_BUILD_CPPFLAGS='"${_CPPFLAGS}"'
++CXXFLAGS+= -DATF_BUILD_CXX='"${CXX}"'
++CXXFLAGS+= -DATF_BUILD_CXXFLAGS='"${_CXXFLAGS}"'
++CXXFLAGS+= -DATF_CONFDIR='"${CONFDIR}/atf"'
++CXXFLAGS+= -DATF_INCLUDEDIR='"${INCLUDEDIR}"'
++CXXFLAGS+= -DATF_LIBDIR='"${LIBDIR}"'
++CXXFLAGS+= -DATF_LIBEXECDIR='"${LIBEXECDIR}"'
++CXXFLAGS+= -DATF_MACHINE='"${MACHINE_ARCH}"'
++CXXFLAGS+= -DATF_M4='"/usr/bin/m4"'
++CXXFLAGS+= -DATF_PKGDATADIR='"${SHAREDIR}/atf"'
++CXXFLAGS+= -DATF_SHELL='"/bin/sh"'
++CXXFLAGS+= -DATF_WORKDIR='"/tmp"'
++
+ WARNS?= 3
+
+ # vim: syntax=make
+diff --git a/lib/atf/libatf-c++/Makefile b/lib/atf/libatf-c++/Makefile
+index 37d6073..90a2687 100644
+--- a/lib/atf/libatf-c++/Makefile
++++ b/lib/atf/libatf-c++/Makefile
+@@ -40,11 +40,11 @@ LDFLAGS+= -L${.OBJDIR}/../libatf-c
+ .PATH: ${ATF}/atf-c++
+ .PATH: ${ATF}/atf-c++/detail
+
+-CFLAGS+= -I${ATF}
+-CFLAGS+= -I${.CURDIR}/../libatf-c
+-CFLAGS+= -I.
++CXXFLAGS+= -I${ATF}
++CXXFLAGS+= -I${.CURDIR}/../libatf-c
++CXXFLAGS+= -I.
+
+-CFLAGS+= -DHAVE_CONFIG_H
++CXXFLAGS+= -DHAVE_CONFIG_H
+
+ SRCS= application.cpp \
+ build.cpp \
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-liblink.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-liblink.patch
new file mode 100644
index 0000000..6ef3f07
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-liblink.patch
@@ -0,0 +1,98 @@
+diff --git a/lib/libcam/Makefile b/lib/libcam/Makefile
+index 9a21dde..0815f0a 100644
+--- a/lib/libcam/Makefile
++++ b/lib/libcam/Makefile
+@@ -8,6 +8,7 @@ INCS= camlib.h
+
+ DPADD= ${LIBSBUF}
+ LDADD= -lsbuf
++LDFLAGS+= -L${.OBJDIR}/../libsbuf
+
+ MAN= cam.3 cam_cdbparse.3
+
+diff --git a/lib/libdwarf/Makefile b/lib/libdwarf/Makefile
+index dbd7895..607b1f6 100644
+--- a/lib/libdwarf/Makefile
++++ b/lib/libdwarf/Makefile
+@@ -21,6 +21,7 @@ SRCS= \
+ INCS= dwarf.h libdwarf.h
+
+ CFLAGS+= -I${.CURDIR}
++CFLAGS+= -I${.CURDIR}/../libelf
+
+ SHLIB_MAJOR= 3
+
+diff --git a/lib/libproc/Makefile b/lib/libproc/Makefile
+index 4449c06..f024cf0 100644
+--- a/lib/libproc/Makefile
++++ b/lib/libproc/Makefile
+@@ -14,6 +14,7 @@ SRCS= proc_bkpt.c \
+ INCS= libproc.h
+
+ CFLAGS+= -I${.CURDIR}
++CFLAGS+= -I${.CURDIR}/../libelf
+
+ .if ${MK_LIBCPLUSPLUS} != "no"
+ LDADD+= -lcxxrt
+@@ -27,4 +28,7 @@ SHLIB_MAJOR= 2
+
+ WITHOUT_MAN=
+
++LDADD+= -lelf
++LDFLAGS+= -L${.OBJDIR}/../libelf
++
+ .include <bsd.lib.mk>
+diff --git a/lib/libprocstat/Makefile b/lib/libprocstat/Makefile
+index af5a775..c01aa05 100644
+--- a/lib/libprocstat/Makefile
++++ b/lib/libprocstat/Makefile
+@@ -16,6 +16,8 @@ VERSION_DEF= ${.CURDIR}/Versions.def
+ SYMBOL_MAPS= ${.CURDIR}/Symbol.map
+
+ INCS= libprocstat.h
++CFLAGS+= -I${.CURDIR}/../libelf
++LDFLAGS+= -L${.OBJDIR}/../libelf
+ CFLAGS+= -I. -I${.CURDIR} -D_KVM_VNODE
+ SHLIB_MAJOR= 1
+
+diff --git a/lib/librtld_db/Makefile b/lib/librtld_db/Makefile
+index 2815a07..e992662 100644
+--- a/lib/librtld_db/Makefile
++++ b/lib/librtld_db/Makefile
+@@ -10,5 +10,8 @@ SRCS= rtld_db.c
+ INCS= rtld_db.h
+
+ CFLAGS+= -I${.CURDIR}
++CFLAGS+= -I${.CURDIR}/../libelf
++LDADD+= -lutil -lproc
++LDFLAGS+= -L${.OBJDIR}/../libutil -L${.OBJDIR}/../libproc
+
+ .include <bsd.lib.mk>
+diff --git a/lib/libtelnet/Makefile b/lib/libtelnet/Makefile
+index 1cf52a0..3d25fae 100644
+--- a/lib/libtelnet/Makefile
++++ b/lib/libtelnet/Makefile
+@@ -13,6 +13,8 @@ INTERNALLIB=
+ SRCS= genget.c getent.c misc.c
+ CFLAGS+= -I${TELNETDIR}
+
++CFLAGS+= -I${.CURDIR}/../libmp
++
+ WARNS?= 2
+
+ .if !defined(RELEASE_CRUNCH)
+diff --git a/lib/libexecinfo/Makefile b/lib/libexecinfo/Makefile
+index 30a1dfb..9f8a99c 100644
+--- a/lib/libexecinfo/Makefile
++++ b/lib/libexecinfo/Makefile
+@@ -10,8 +10,10 @@ SHLIB_MAJOR= 1
+ INCS= execinfo.h
+ SRCS= backtrace.c symtab.c unwind.c
+
++CFLAGS+= -I${.CURDIR}/../libelf
+ DPADD= ${LIBELF}
+ LDADD= -lelf
++LDFLAGS+= -L${.OBJDIR}/../libelf
+
+ MAN= backtrace.3
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-libproc-libcxx.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-libproc-libcxx.patch
new file mode 100644
index 0000000..55987aa
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-libproc-libcxx.patch
@@ -0,0 +1,16 @@
+diff --git a/lib/libproc/Makefile b/lib/libproc/Makefile
+index f9e01ab..15b27d8 100644
+--- a/lib/libproc/Makefile
++++ b/lib/libproc/Makefile
+@@ -15,7 +15,10 @@ INCS= libproc.h
+
+ CFLAGS+= -I${.CURDIR}
+
+-.if ${MK_LIBCPLUSPLUS} != "no"
++.if ${CXX:T:M*-stdlib=libc++*}
++LDADD+= -lcxxrt
++DPADD+= ${LIBCXXRT}
++.elif ${CXXFLAGS:T:M*-stdlib=libc++*}
+ LDADD+= -lcxxrt
+ DPADD+= ${LIBCXXRT}
+ .else
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-libusb.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-libusb.patch
new file mode 100644
index 0000000..2968252
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-libusb.patch
@@ -0,0 +1,19 @@
+diff --git a/lib/libusb/Makefile b/lib/libusb/Makefile
+index 21016a9..26010e8 100644
+--- a/lib/libusb/Makefile
++++ b/lib/libusb/Makefile
+@@ -40,11 +40,11 @@ CFLAGS+= -DCOMPAT_32BIT
+
+ beforeinstall:
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+- ${.CURDIR}/libusb-0.1.pc ${DESTDIR}${LIBDATADIR}/pkgconfig
++ ${.CURDIR}/libusb-0.1.pc ${DESTDIR}${LIBDIR}/pkgconfig
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+- ${.CURDIR}/libusb-1.0.pc ${DESTDIR}${LIBDATADIR}/pkgconfig
++ ${.CURDIR}/libusb-1.0.pc ${DESTDIR}${LIBDIR}/pkgconfig
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+- ${.CURDIR}/libusb-2.0.pc ${DESTDIR}${LIBDATADIR}/pkgconfig
++ ${.CURDIR}/libusb-2.0.pc ${DESTDIR}${LIBDIR}/pkgconfig
+
+ #
+ # Cross platform support
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-10.2-bsdxml2expat.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.2-bsdxml2expat.patch
new file mode 100644
index 0000000..303f422
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.2-bsdxml2expat.patch
@@ -0,0 +1,39 @@
+diff --git a/lib/libgeom/Makefile b/lib/libgeom/Makefile
+index bbfb57b..a7c17e3 100644
+--- a/lib/libgeom/Makefile
++++ b/lib/libgeom/Makefile
+@@ -13,7 +13,7 @@ CFLAGS += -I${.CURDIR}
+
+ WARNS?= 3
+
+-DPADD= ${LIBBSDXML} ${LIBSBUF}
++DPADD= ${LIBSBUF}
+ LDADD= -lbsdxml -lsbuf
+
+ MAN= libgeom.3
+diff --git a/lib/libgeom/geom_xml2tree.c b/lib/libgeom/geom_xml2tree.c
+index 9dedb8e..d96420c 100644
+--- a/lib/libgeom/geom_xml2tree.c
++++ b/lib/libgeom/geom_xml2tree.c
+@@ -43,7 +43,7 @@
+ #include <sys/sbuf.h>
+ #include <sys/sysctl.h>
+ #include <err.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <libgeom.h>
+
+ struct mystate {
+diff --git a/lib/libmt/mtlib.c b/lib/libmt/mtlib.c
+index d1fc0b1..89ac55e 100644
+--- a/lib/libmt/mtlib.c
++++ b/lib/libmt/mtlib.c
+@@ -48,7 +48,7 @@ __FBSDID("$FreeBSD: stable/10/lib/libmt/mtlib.c 280438 2015-03-24 14:36:10Z ken
+ #include <unistd.h>
+ #include <stdint.h>
+ #include <errno.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <mtlib.h>
+
+ /*
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-10.2-liblink.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.2-liblink.patch
new file mode 100644
index 0000000..b08d95f
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.2-liblink.patch
@@ -0,0 +1,26 @@
+diff --git a/lib/libmt/Makefile b/lib/libmt/Makefile
+index cb1da71..43de5a5 100644
+--- a/lib/libmt/Makefile
++++ b/lib/libmt/Makefile
+@@ -5,6 +5,7 @@ SHLIBDIR?= /lib
+ SRCS= mtlib.c
+ INCS= mtlib.h
+
++CFLAGS+= -I${.CURDIR}
+ DPADD= ${LIBSBUF}
+ LDADD= -lsbuf
+
+diff --git a/lib/libdpv/Makefile b/lib/libdpv/Makefile
+index e9384b7..085ef62 100644
+--- a/lib/libdpv/Makefile
++++ b/lib/libdpv/Makefile
+@@ -11,7 +11,8 @@ LDADD= -ldialog -lfigpar -lncursesw -lutil
+
+ SRCS= dialog_util.c dialogrc.c dprompt.c dpv.c status.c util.c
+
+-CFLAGS+= -I${.CURDIR}
++CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../libfigpar
++LDFLAGS+= -L${.OBJDIR}/../libfigpar
+
+ WARNS?= 6
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-10.3-libusb.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.3-libusb.patch
new file mode 100644
index 0000000..813a42b
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.3-libusb.patch
@@ -0,0 +1,13 @@
+diff --git a/lib/libusb/Makefile b/lib/libusb/Makefile
+index 88ec3fe..076b8d4 100644
+--- a/lib/libusb/Makefile
++++ b/lib/libusb/Makefile
+@@ -38,7 +38,7 @@ SRCS+= libusb10_io.c
+ CFLAGS+= -DCOMPAT_32BIT
+ .else
+ FILES= libusb-0.1.pc libusb-1.0.pc libusb-2.0.pc
+-FILESDIR= ${LIBDATADIR}/pkgconfig
++FILESDIR= ${LIBDIR}/pkgconfig
+ .endif
+
+ #
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-flex-2.5.31.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-flex-2.5.31.patch
new file mode 100644
index 0000000..00de8a6
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-flex-2.5.31.patch
@@ -0,0 +1,13 @@
+Index: fbsd-6/lib/libipsec/policy_token.l
+===================================================================
+--- fbsd-6.orig/lib/libipsec/policy_token.l
++++ fbsd-6/lib/libipsec/policy_token.l
+@@ -138,8 +138,6 @@ void
+ __policy__strbuffer__init__(msg)
+ char *msg;
+ {
+- if (yy_current_buffer)
+- yy_delete_buffer(yy_current_buffer);
+ strbuffer = (YY_BUFFER_STATE)yy_scan_string(msg);
+ yy_switch_to_buffer(strbuffer);
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-gccfloat.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-gccfloat.patch
new file mode 100644
index 0000000..a3e7d5e
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-gccfloat.patch
@@ -0,0 +1,16 @@
+This patch is needed to avoid inclusion of GCC's float.h that defines
+LDBL_MANT_DIG at 53 (while the source file checks for 113 or 64.
+
+Index: freebsd-6.0_beta4/lib/msun/src/s_fmal.c
+===================================================================
+--- freebsd-6.0_beta4.orig/lib/msun/src/s_fmal.c
++++ freebsd-6.0_beta4/lib/msun/src/s_fmal.c
+@@ -28,7 +28,7 @@
+ __FBSDID("$FreeBSD: src/lib/msun/src/s_fmal.c,v 1.2 2005/03/18 02:27:59 das Exp $");
+
+ #include <fenv.h>
+-#include <float.h>
++#include <machine/float.h>
+ #include <math.h>
+
+ /*
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-pmc.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-pmc.patch
new file mode 100644
index 0000000..2f6de46
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-pmc.patch
@@ -0,0 +1,13 @@
+Index: freebsd-6.0_beta4/lib/libpmc/Makefile
+===================================================================
+--- freebsd-6.0_beta4.orig/lib/libpmc/Makefile
++++ freebsd-6.0_beta4/lib/libpmc/Makefile
+@@ -9,6 +9,8 @@ WARNS?= 6
+
+ MAN= pmc.3 pmclog.3
+
++CFLAGS+= -I${.CURDIR}
++
+ MLINKS+= \
+ pmc.3 pmc_allocate.3 \
+ pmc.3 pmc_attach.3 \
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-6.1-csu.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.1-csu.patch
new file mode 100644
index 0000000..075f278
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.1-csu.patch
@@ -0,0 +1,20 @@
+--- lib/csu/amd64/Makefile.orig 2006-07-04 07:49:58 -0300
++++ lib/csu/amd64/Makefile 2006-07-04 07:50:15 -0300
+@@ -16,6 +16,7 @@
+ ${CC} ${CFLAGS} -DGCRT -c -o gcrt1.o ${.CURDIR}/crt1.c
+
+ realinstall:
++ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${OBJS} ${DESTDIR}${LIBDIR}
+
+--- lib/csu/sparc64/Makefile.orig 2006-10-06 15:13:55 +0100
++++ lib/csu/sparc64/Makefile 2006-10-06 15:15:06 +0100
+@@ -15,6 +15,7 @@
+ ${CC} ${CFLAGS} -DGCRT -c -o gcrt1.o ${.ALLSRC}
+
+ realinstall:
++ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${OBJS} ${DESTDIR}${LIBDIR}
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-6.2-bluetooth.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.2-bluetooth.patch
new file mode 100644
index 0000000..a9b8435
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.2-bluetooth.patch
@@ -0,0 +1,11 @@
+--- lib/libsdp/Makefile 2007-06-15 12:04:37 +0200
++++ lib.sdp/libsdp/Makefile 2007-06-15 12:26:14 +0200
+@@ -5,7 +5,7 @@
+ MAN= sdp.3
+
+ WARNS?= 2
+-CFLAGS+= -I${.CURDIR}
++CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../libbluetooth
+
+ SHLIB_MAJOR= 2
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-7.1-types.h-fix.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-7.1-types.h-fix.patch
new file mode 100644
index 0000000..8de5df2
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-7.1-types.h-fix.patch
@@ -0,0 +1,15 @@
+Fixes a compile error if XOPEN_SOURCE 600 is defined.
+
+See: http://www.mailinglistarchive.com/freebsd-current@freebsd.org/msg15011.html
+
+--- sys/sys/types.h.orig
++++ sys/sys/types.h
+@@ -46,7 +46,7 @@
+
+ #include <sys/_pthreadtypes.h>
+
+-#if __BSD_VISIBLE
++#ifndef _POSIX_SOURCE
+ typedef unsigned char u_char;
+ typedef unsigned short u_short;
+ typedef unsigned int u_int;
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-gcc45.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-gcc45.patch
new file mode 100644
index 0000000..2ddb9ea
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-gcc45.patch
@@ -0,0 +1,28 @@
+diff -Nur work.orig/include/rpcsvc/nis.x work/include/rpcsvc/nis.x
+--- work.orig/include/rpcsvc/nis.x 2009-10-25 10:10:29.000000000 +0900
++++ work/include/rpcsvc/nis.x 2011-04-13 21:25:13.000000000 +0900
+@@ -399,10 +399,7 @@
+ %#define OARIGHTS(d, n) (((d)->do_armask.do_armask_val+n)->oa_rights)
+ %#define WORLD_DEFAULT (NIS_READ_ACC)
+ %#define GROUP_DEFAULT (NIS_READ_ACC << 8)
+-%#define OWNER_DEFAULT ((NIS_READ_ACC +\
+- NIS_MODIFY_ACC +\
+- NIS_CREATE_ACC +\
+- NIS_DESTROY_ACC) << 16)
++%#define OWNER_DEFAULT ((NIS_READ_ACC + NIS_MODIFY_ACC + NIS_CREATE_ACC + NIS_DESTROY_ACC) << 16)
+ %#define DEFAULT_RIGHTS (WORLD_DEFAULT | GROUP_DEFAULT | OWNER_DEFAULT)
+ %
+ %/* Result manipulation defines ... */
+@@ -431,10 +428,8 @@
+ % * these definitions they take an nis_object *, and an int and return
+ % * a u_char * for Value, and an int for length.
+ % */
+-%#define ENTRY_VAL(obj, col) \
+- (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val
+-%#define ENTRY_LEN(obj, col) \
+- (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len
++%#define ENTRY_VAL(obj, col) (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val
++%#define ENTRY_LEN(obj, col) (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len
+ %
+ %#ifdef __cplusplus
+ %}
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-log2.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-log2.patch
new file mode 100644
index 0000000..a9fd189
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-log2.patch
@@ -0,0 +1,21 @@
+log2 and log2f are required by C99 and are not implemented.
+Workaround the deficiency.
+
+--- lib/msun/src/math.h.old 2010-03-14 17:02:25.000000000 +0100
++++ lib/msun/src/math.h 2010-03-14 17:07:03.000000000 +0100
+@@ -203,6 +203,7 @@
+ double frexp(double, int *); /* fundamentally !__pure2 */
+ double ldexp(double, int);
+ double log(double);
++#define log2(x) log(x)/log(2.0)
+ double log10(double);
+ double modf(double, double *); /* fundamentally !__pure2 */
+
+@@ -319,6 +320,7 @@
+ float log10f(float);
+ float log1pf(float);
+ float logf(float);
++#define log2f(x) logf(x)/logf(2.0)
+ float modff(float, float *); /* fundamentally !__pure2 */
+
+ float powf(float, float);
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-rpcsec_gss.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-rpcsec_gss.patch
new file mode 100644
index 0000000..a7de06f
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-rpcsec_gss.patch
@@ -0,0 +1,12 @@
+Without this linking fails during a stage3 build.
+
+--- lib/librpcsec_gss/Makefile.orig
++++ lib/librpcsec_gss/Makefile
+@@ -8,6 +8,7 @@
+
+ DPADD+= ${LIBGSSAPI}
+ LDADD+= -lgssapi
++LDFLAGS+= -L${.OBJDIR}/../libgssapi
+
+ VERSION_DEF= ${.CURDIR}/../libc/Versions.def
+ SYMBOL_MAPS= ${.CURDIR}/Symbol.map
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-8.2-liblink.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.2-liblink.patch
new file mode 100644
index 0000000..c8be7f4
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.2-liblink.patch
@@ -0,0 +1,19 @@
+--- lib/libproc/Makefile.old 2011-07-06 00:58:04.000000000 +0000
++++ lib/libproc/Makefile 2011-07-06 00:58:58.000000000 +0000
+@@ -18,5 +18,6 @@
+ WARNS?= 6
+
+ WITHOUT_MAN= yes
++LDADD=-lelf
+
+ .include <bsd.lib.mk>
+--- lib/librtld_db/Makefile.old 2011-07-06 00:58:12.000000000 +0000
++++ lib/librtld_db/Makefile 2011-07-06 00:59:27.000000000 +0000
+@@ -10,5 +10,7 @@
+ INCS= rtld_db.h
+
+ CFLAGS+= -I${.CURDIR}
++LDADD=-lutil -lproc
++LDFLAGS+=-L${.CURDIR}/../libutil -L${.CURDIR}/../libproc
+
+ .include <bsd.lib.mk>
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-8.2-nlm_syscall.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.2-nlm_syscall.patch
new file mode 100644
index 0000000..556ade5
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.2-nlm_syscall.patch
@@ -0,0 +1,10 @@
+--- include/unistd.h 2010/12/20 20:39:49 216602
++++ include/unistd.h 2010/12/20 21:12:18 216603
+@@ -529,6 +529,7 @@
+ #define _MKTEMP_DECLARED
+ #endif
+ int nfssvc(int, void *);
++int nlm_syscall(int, int, int, char **);
+ int profil(char *, size_t, vm_offset_t, int);
+ int rcmd(char **, int, const char *, const char *, const char *, int *);
+ int rcmd_af(char **, int, const char *,
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-bluetooth.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-bluetooth.patch
new file mode 100644
index 0000000..cf1172a
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-bluetooth.patch
@@ -0,0 +1,12 @@
+diff -Nur lib.orig/libsdp/Makefile lib/libsdp/Makefile
+--- lib.orig/libsdp/Makefile 2012-12-25 20:28:50.000000000 +0900
++++ lib/libsdp/Makefile 2012-12-25 20:31:19.000000000 +0900
+@@ -5,7 +5,7 @@
+ MAN= sdp.3
+
+ WARNS?= 2
+-CFLAGS+= -I${.CURDIR}
++CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../libbluetooth
+
+ SHLIB_MAJOR= 4
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-cve-2010-2632.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-cve-2010-2632.patch
new file mode 100644
index 0000000..ad9b960
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-cve-2010-2632.patch
@@ -0,0 +1,215 @@
+Index: lib/libc/gen/glob.c
+===================================================================
+--- lib/libc/gen/glob.c (revision 246357)
++++ lib/libc/gen/glob.c (working copy)
+@@ -94,6 +94,25 @@ __FBSDID("$FreeBSD$");
+
+ #include "collate.h"
+
++/*
++ * glob(3) expansion limits. Stop the expansion if any of these limits
++ * is reached. This caps the runtime in the face of DoS attacks. See
++ * also CVE-2010-2632
++ */
++#define GLOB_LIMIT_BRACE 128 /* number of brace calls */
++#define GLOB_LIMIT_PATH 65536 /* number of path elements */
++#define GLOB_LIMIT_READDIR 16384 /* number of readdirs */
++#define GLOB_LIMIT_STAT 1024 /* number of stat system calls */
++#define GLOB_LIMIT_STRING ARG_MAX /* maximum total size for paths */
++
++struct glob_limit {
++ size_t l_brace_cnt;
++ size_t l_path_lim;
++ size_t l_readdir_cnt;
++ size_t l_stat_cnt;
++ size_t l_string_cnt;
++};
++
+ #define DOLLAR '$'
+ #define DOT '.'
+ #define EOS '\0'
+@@ -153,15 +172,18 @@ static const Char *g_strchr(const Char *, wchar_t)
+ static Char *g_strcat(Char *, const Char *);
+ #endif
+ static int g_stat(Char *, struct stat *, glob_t *);
+-static int glob0(const Char *, glob_t *, size_t *);
+-static int glob1(Char *, glob_t *, size_t *);
+-static int glob2(Char *, Char *, Char *, Char *, glob_t *, size_t *);
+-static int glob3(Char *, Char *, Char *, Char *, Char *, glob_t *, size_t *);
+-static int globextend(const Char *, glob_t *, size_t *);
+-static const Char *
++static int glob0(const Char *, glob_t *, struct glob_limit *);
++static int glob1(Char *, glob_t *, struct glob_limit *);
++static int glob2(Char *, Char *, Char *, Char *, glob_t *,
++ struct glob_limit *);
++static int glob3(Char *, Char *, Char *, Char *, Char *, glob_t *,
++ struct glob_limit *);
++static int globextend(const Char *, glob_t *, struct glob_limit *);
++static const Char *
+ globtilde(const Char *, Char *, size_t, glob_t *);
+-static int globexp1(const Char *, glob_t *, size_t *);
+-static int globexp2(const Char *, const Char *, glob_t *, int *, size_t *);
++static int globexp1(const Char *, glob_t *, struct glob_limit *);
++static int globexp2(const Char *, const Char *, glob_t *, int *,
++ struct glob_limit *);
+ static int match(Char *, Char *, Char *);
+ #ifdef DEBUG
+ static void qprintf(const char *, Char *);
+@@ -171,8 +193,8 @@ int
+ glob(const char * __restrict pattern, int flags,
+ int (*errfunc)(const char *, int), glob_t * __restrict pglob)
+ {
++ struct glob_limit limit = { 0, 0, 0, 0, 0 };
+ const char *patnext;
+- size_t limit;
+ Char *bufnext, *bufend, patbuf[MAXPATHLEN], prot;
+ mbstate_t mbs;
+ wchar_t wc;
+@@ -186,11 +208,10 @@ glob(const char * __restrict pattern, int flags,
+ pglob->gl_offs = 0;
+ }
+ if (flags & GLOB_LIMIT) {
+- limit = pglob->gl_matchc;
+- if (limit == 0)
+- limit = ARG_MAX;
+- } else
+- limit = 0;
++ limit.l_path_lim = pglob->gl_matchc;
++ if (limit.l_path_lim == 0)
++ limit.l_path_lim = GLOB_LIMIT_PATH;
++ }
+ pglob->gl_flags = flags & ~GLOB_MAGCHAR;
+ pglob->gl_errfunc = errfunc;
+ pglob->gl_matchc = 0;
+@@ -243,11 +264,17 @@ glob(const char * __restrict pattern, int flags,
+ * characters
+ */
+ static int
+-globexp1(const Char *pattern, glob_t *pglob, size_t *limit)
++globexp1(const Char *pattern, glob_t *pglob, struct glob_limit *limit)
+ {
+ const Char* ptr = pattern;
+ int rv;
+
++ if ((pglob->gl_flags & GLOB_LIMIT) &&
++ limit->l_brace_cnt++ >= GLOB_LIMIT_BRACE) {
++ errno = 0;
++ return (GLOB_NOSPACE);
++ }
++
+ /* Protect a single {}, for find(1), like csh */
+ if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS)
+ return glob0(pattern, pglob, limit);
+@@ -266,7 +293,8 @@ static int
+ * If it fails then it tries to glob the rest of the pattern and returns.
+ */
+ static int
+-globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv, size_t *limit)
++globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv,
++ struct glob_limit *limit)
+ {
+ int i;
+ Char *lm, *ls;
+@@ -436,7 +464,7 @@ globtilde(const Char *pattern, Char *patbuf, size_
+ * if things went well, nonzero if errors occurred.
+ */
+ static int
+-glob0(const Char *pattern, glob_t *pglob, size_t *limit)
++glob0(const Char *pattern, glob_t *pglob, struct glob_limit *limit)
+ {
+ const Char *qpatnext;
+ int err;
+@@ -529,7 +557,7 @@ compare(const void *p, const void *q)
+ }
+
+ static int
+-glob1(Char *pattern, glob_t *pglob, size_t *limit)
++glob1(Char *pattern, glob_t *pglob, struct glob_limit *limit)
+ {
+ Char pathbuf[MAXPATHLEN];
+
+@@ -547,7 +575,7 @@ static int
+ */
+ static int
+ glob2(Char *pathbuf, Char *pathend, Char *pathend_last, Char *pattern,
+- glob_t *pglob, size_t *limit)
++ glob_t *pglob, struct glob_limit *limit)
+ {
+ struct stat sb;
+ Char *p, *q;
+@@ -563,6 +591,15 @@ glob2(Char *pathbuf, Char *pathend, Char *pathend_
+ if (g_lstat(pathbuf, &sb, pglob))
+ return(0);
+
++ if ((pglob->gl_flags & GLOB_LIMIT) &&
++ limit->l_stat_cnt++ >= GLOB_LIMIT_STAT) {
++ errno = 0;
++ if (pathend + 1 > pathend_last)
++ return (GLOB_ABORTED);
++ *pathend++ = SEP;
++ *pathend = EOS;
++ return (GLOB_NOSPACE);
++ }
+ if (((pglob->gl_flags & GLOB_MARK) &&
+ pathend[-1] != SEP) && (S_ISDIR(sb.st_mode)
+ || (S_ISLNK(sb.st_mode) &&
+@@ -606,7 +643,7 @@ glob2(Char *pathbuf, Char *pathend, Char *pathend_
+ static int
+ glob3(Char *pathbuf, Char *pathend, Char *pathend_last,
+ Char *pattern, Char *restpattern,
+- glob_t *pglob, size_t *limit)
++ glob_t *pglob, struct glob_limit *limit)
+ {
+ struct dirent *dp;
+ DIR *dirp;
+@@ -652,6 +689,19 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_
+ size_t clen;
+ mbstate_t mbs;
+
++ if ((pglob->gl_flags & GLOB_LIMIT) &&
++ limit->l_readdir_cnt++ >= GLOB_LIMIT_READDIR) {
++ errno = 0;
++ if (pathend + 1 > pathend_last)
++ err = GLOB_ABORTED;
++ else {
++ *pathend++ = SEP;
++ *pathend = EOS;
++ err = GLOB_NOSPACE;
++ }
++ break;
++ }
++
+ /* Initial DOT must be matched literally. */
+ if (dp->d_name[0] == DOT && *pattern != DOT)
+ continue;
+@@ -702,14 +752,15 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_
+ * gl_pathv points to (gl_offs + gl_pathc + 1) items.
+ */
+ static int
+-globextend(const Char *path, glob_t *pglob, size_t *limit)
++globextend(const Char *path, glob_t *pglob, struct glob_limit *limit)
+ {
+ char **pathv;
+ size_t i, newsize, len;
+ char *copy;
+ const Char *p;
+
+- if (*limit && pglob->gl_pathc > *limit) {
++ if ((pglob->gl_flags & GLOB_LIMIT) &&
++ pglob->gl_matchc > limit->l_path_lim) {
+ errno = 0;
+ return (GLOB_NOSPACE);
+ }
+@@ -737,6 +788,12 @@ static int
+ for (p = path; *p++;)
+ continue;
+ len = MB_CUR_MAX * (size_t)(p - path); /* XXX overallocation */
++ limit->l_string_cnt += len;
++ if ((pglob->gl_flags & GLOB_LIMIT) &&
++ limit->l_string_cnt >= GLOB_LIMIT_STRING) {
++ errno = 0;
++ return (GLOB_NOSPACE);
++ }
+ if ((copy = malloc(len)) != NULL) {
+ if (g_Ctoc(path, copy, len)) {
+ free(copy);
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-liblink.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-liblink.patch
new file mode 100644
index 0000000..f8e4707
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-liblink.patch
@@ -0,0 +1,21 @@
+diff -uNr lib.ol/libproc/Makefile lib/libproc/Makefile
+--- lib.ol/libproc/Makefile 2011-11-02 14:02:17.000000000 +0000
++++ lib/libproc/Makefile 2011-11-02 14:03:09.000000000 +0000
+@@ -16,5 +16,6 @@
+ SHLIB_MAJOR= 2
+
+ WITHOUT_MAN=
++LDADD+=-lelf
+
+ .include <bsd.lib.mk>
+diff -uNr lib.ol/librtld_db/Makefile lib/librtld_db/Makefile
+--- lib.ol/librtld_db/Makefile 2011-11-02 14:02:13.000000000 +0000
++++ lib/librtld_db/Makefile 2011-11-02 14:04:00.000000000 +0000
+@@ -10,5 +10,7 @@
+ INCS= rtld_db.h
+
+ CFLAGS+= -I${.CURDIR}
++LDADD+=-lutil -lproc
++LDFLAGS+=-L${.OBJDIR}/../libutil -L${.OBJDIR}/../libproc
+
+ .include <bsd.lib.mk>
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-netware.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-netware.patch
new file mode 100644
index 0000000..c1c2a0e
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-netware.patch
@@ -0,0 +1,11 @@
+diff -Nur lib.orig/libncp/Makefile lib/libncp/Makefile
+--- lib.orig/libncp/Makefile 2012-12-25 20:35:16.000000000 +0900
++++ lib/libncp/Makefile 2012-12-25 20:36:23.000000000 +0900
+@@ -6,6 +6,7 @@
+
+ DPADD= ${LIBIPX}
+ LDADD= -lipx
++LDFLAGS+=-L${.OBJDIR}/../libipx
+
+ SRCS= ncpl_subr.c ncpl_bind.c ncpl_queue.c ncpl_file.c ncpl_misc.c \
+ ncpl_net.c ncpl_rcfile.c ncpl_conn.c ncpl_nls.c ncpl_msg.c \
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-opieincludes.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-opieincludes.patch
new file mode 100644
index 0000000..bf77a0a
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-opieincludes.patch
@@ -0,0 +1,122 @@
+Fixes warnings like:
+/var/tmp/portage/sys-freebsd/freebsd-lib-9.0-r2/work/lib/libopie/../../contrib/opie/libopie/randomchallenge.c:43:5:
+warning: incompatible implicit declaration of built-in function ‘strcpy’
+
+diff -uNr contrib.old/opie/libopie/accessfile.c contrib/opie/libopie/accessfile.c
+--- contrib.old/opie/libopie/accessfile.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/accessfile.c 2012-05-25 09:12:34.000000000 -0400
+@@ -46,6 +46,7 @@
+ #ifdef DEBUG
+ #include <syslog.h>
+ #endif /* DEBUG */
++#include <ctype.h>
+
+ #include "opie.h"
+
+diff -uNr contrib.old/opie/libopie/generator.c contrib/opie/libopie/generator.c
+--- contrib.old/opie/libopie/generator.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/generator.c 2012-05-25 08:58:10.000000000 -0400
+@@ -50,6 +50,7 @@
+ #include <syslog.h>
+ #endif /* DEBUG */
+ #include "opie.h"
++#include <stdio.h>
+
+ static char *algids[] = { NULL, NULL, NULL, "sha1", "md4", "md5" };
+
+diff -uNr contrib.old/opie/libopie/lookup.c contrib/opie/libopie/lookup.c
+--- contrib.old/opie/libopie/lookup.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/lookup.c 2012-05-25 09:15:08.000000000 -0400
+@@ -14,6 +14,7 @@
+ #include "opie_cfg.h"
+ #include <stdio.h>
+ #include "opie.h"
++#include <string.h>
+
+ int opielookup FUNCTION((opie, principal), struct opie *opie AND char *principal)
+ {
+diff -uNr contrib.old/opie/libopie/newseed.c contrib/opie/libopie/newseed.c
+--- contrib.old/opie/libopie/newseed.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/newseed.c 2012-05-25 09:14:37.000000000 -0400
+@@ -36,6 +36,9 @@
+ #include <syslog.h>
+ #endif /* DEBUG */
+ #include "opie.h"
++#include <stdio.h>
++#include <stdlib.h>
++#include <time.h>
+
+ int opienewseed FUNCTION((seed), char *seed)
+ {
+diff -uNr contrib.old/opie/libopie/parsechallenge.c contrib/opie/libopie/parsechallenge.c
+--- contrib.old/opie/libopie/parsechallenge.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/parsechallenge.c 2012-05-25 09:15:54.000000000 -0400
+@@ -20,6 +20,8 @@
+ #include <string.h>
+ #endif /* HAVE_STRING_H */
+ #include "opie.h"
++#include <stdlib.h>
++#include <ctype.h>
+
+ struct algorithm {
+ char *name;
+diff -uNr contrib.old/opie/libopie/passwd.c contrib/opie/libopie/passwd.c
+--- contrib.old/opie/libopie/passwd.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/passwd.c 2012-05-25 09:13:45.000000000 -0400
+@@ -22,6 +22,7 @@
+
+ #include "opie_cfg.h"
+ #include "opie.h"
++#include <string.h>
+
+ int opiepasswd FUNCTION((old, flags, principal, n, seed, ks), struct opie *old AND int flags AND char *principal AND int n AND char *seed AND char *ks)
+ {
+diff -uNr contrib.old/opie/libopie/randomchallenge.c contrib/opie/libopie/randomchallenge.c
+--- contrib.old/opie/libopie/randomchallenge.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/randomchallenge.c 2012-05-25 09:00:27.000000000 -0400
+@@ -28,6 +28,9 @@
+
+ #include "opie_cfg.h"
+ #include "opie.h"
++#include <stdio.h>
++#include <string.h>
++#include <stdlib.h>
+
+ static char *algids[] = { 0, 0, 0, "sha1", "md4", "md5" };
+
+diff -uNr contrib.old/opie/libopie/verify.c contrib/opie/libopie/verify.c
+--- contrib.old/opie/libopie/verify.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/verify.c 2012-05-25 09:12:09.000000000 -0400
+@@ -25,6 +25,7 @@
+ #include <string.h>
+ #endif /* HAVE_STRING_H */
+ #include "opie.h"
++#include <ctype.h>
+
+ #define RESPONSE_STANDARD 0
+ #define RESPONSE_WORD 1
+diff -uNr contrib.old/opie/libopie/version.c contrib/opie/libopie/version.c
+--- contrib.old/opie/libopie/version.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/version.c 2012-05-25 09:13:15.000000000 -0400
+@@ -19,6 +19,8 @@
+ */
+ #include "opie_cfg.h"
+ #include "opie.h"
++#include <stdio.h>
++#include <stdlib.h>
+
+ VOIDRET opieversion FUNCTION_NOARGS
+ {
+diff -uNr contrib.old/opie/opie.h contrib/opie/opie.h
+--- contrib.old/opie/opie.h 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/opie.h 2012-05-25 09:21:28.000000000 -0400
+@@ -158,6 +158,9 @@
+ int __opiereadrec __P((struct opie *));
+ int __opiewriterec __P((struct opie *));
+ int __opieparsechallenge __P((char *buffer, int *algorithm, int *sequence, char **seed, int *exts));
++VOIDRET opiehashlen FUNCTION((algorithm, in, out, n), int algorithm AND VOIDPTR in AND struct opie_otpkey *out AND int n);
++int opieinsecure FUNCTION_NOARGS;
++int opienewseed FUNCTION((seed), char *seed);
+ __END_DECLS
+
+ #define opiestrncpy(dst, src, n) \
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-.eh_frame_hdr-fix.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-.eh_frame_hdr-fix.patch
new file mode 100644
index 0000000..fdb7e16
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-.eh_frame_hdr-fix.patch
@@ -0,0 +1,17 @@
+Fix "no .eh_frame_hdr table will be created" error.
+
+http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47829
+http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/4a0e0cd7377c45dc21d5c71bcab931b5e5727e74
+
+diff -Nur lib.orig/csu/i386-elf/Makefile lib/csu/i386-elf/Makefile
+--- lib.orig/csu/i386-elf/Makefile 2013-03-06 01:07:57.000000000 +0900
++++ lib/csu/i386-elf/Makefile 2013-03-06 01:10:09.000000000 +0900
+@@ -10,6 +10,8 @@
+ FILESDIR= ${LIBDIR}
+ CFLAGS+= -I${.CURDIR}/../common \
+ -I${.CURDIR}/../../libc/include
++CFLAGS+= -fno-omit-frame-pointer
++CFLAGS+= -fno-asynchronous-unwind-tables
+ CLEANFILES= ${FILES} crt1_c.o crt1_s.o gcrt1_c.o Scrt1_c.o
+ CLEANFILES+= crt1_c.s gcrt1_c.s Scrt1_c.s
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-aligned_alloc.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-aligned_alloc.patch
new file mode 100644
index 0000000..97ac141
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-aligned_alloc.patch
@@ -0,0 +1,51 @@
+Backport aligned_alloc for C++11 support.
+
+http://lists.freebsd.org/pipermail/svn-src-stable-9/2012-November/003313.html
+
+diff -uNr lib.old/libc/stdlib/Symbol.map lib/libc/stdlib/Symbol.map
+--- lib.old/libc/stdlib/Symbol.map 2013-05-24 17:03:55.000000000 -0400
++++ lib/libc/stdlib/Symbol.map 2013-05-24 17:06:03.000000000 -0400
+@@ -97,6 +97,7 @@
+ atoi_l;
+ atol_l;
+ atoll_l;
++ aligned_alloc;
+ at_quick_exit;
+ quick_exit;
+ strtod_l;
+diff -uNr lib.old/libc/stdlib/malloc.c lib/libc/stdlib/malloc.c
+--- lib.old/libc/stdlib/malloc.c 2013-05-24 17:03:55.000000000 -0400
++++ lib/libc/stdlib/malloc.c 2013-05-24 17:05:40.000000000 -0400
+@@ -6046,6 +6046,21 @@
+ }
+
+ void *
++aligned_alloc(size_t alignment, size_t size)
++{
++ void *memptr;
++ int ret;
++
++ ret = posix_memalign(&memptr, alignment, size);
++ if (ret != 0) {
++ errno = ret;
++ return (NULL);
++ }
++ return (memptr);
++}
++
++
++void *
+ calloc(size_t num, size_t size)
+ {
+ void *ret;
+diff -uNr includeold/stdlib.h include/stdlib.h
+--- includeold/stdlib.h 2013-05-24 17:03:46.000000000 -0400
++++ include/stdlib.h 2013-05-24 17:04:46.000000000 -0400
+@@ -155,6 +155,7 @@
+ * If we're in a mode greater than C99, expose C1x functions.
+ */
+ #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
++void * aligned_alloc(size_t, size_t);
+ _Noreturn void
+ quick_exit(int);
+ int at_quick_exit(void (*)(void));
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-rmgssapi.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-rmgssapi.patch
new file mode 100644
index 0000000..62357e0
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-rmgssapi.patch
@@ -0,0 +1,16 @@
+--- include/Makefile.orig 2013-06-16 10:47:52.000000000 +0200
++++ include/Makefile 2013-06-16 10:47:37.000000000 +0200
+@@ -6,11 +6,11 @@
+ .include <bsd.own.mk>
+
+ CLEANFILES= osreldate.h version vers.c
++SUBDIR= arpa protocols rpcsvc rpc xlocale
+-SUBDIR= arpa gssapi protocols rpcsvc rpc xlocale
+ INCS= a.out.h ar.h assert.h bitstring.h complex.h cpio.h _ctype.h ctype.h \
+ db.h \
+ dirent.h dlfcn.h elf.h elf-hints.h err.h fmtmsg.h fnmatch.h fstab.h \
++ fts.h ftw.h getopt.h glob.h grp.h \
+- fts.h ftw.h getopt.h glob.h grp.h gssapi.h \
+ ieeefp.h ifaddrs.h \
+ inttypes.h iso646.h kenv.h langinfo.h libgen.h limits.h link.h \
+ locale.h malloc.h malloc_np.h memory.h monetary.h mpool.h mqueue.h \
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-add-nossp-cflags.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-add-nossp-cflags.patch
new file mode 100644
index 0000000..00b39f7
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-add-nossp-cflags.patch
@@ -0,0 +1,30 @@
+Please do not disable this patch.
+All commands will be non-executable.
+Abort trap: 6 (core dumped) is displayed...
+
+Details see Gentoo Bug #511698.
+https://bugs.gentoo.org/show_bug.cgi?id=511698
+
+diff --git a/lib/libc/Makefile b/lib/libc/Makefile
+index 1cc23b7..7dd458e 100644
+--- a/lib/libc/Makefile
++++ b/lib/libc/Makefile
+@@ -149,6 +149,6 @@ CWARNFLAGS:= ${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/}
+ # in the future to circumvent this.
+ SSP_CFLAGS:= ${SSP_CFLAGS:S/^-fstack-protector-all$/-fstack-protector/}
+ # Disable stack protection for SSP symbols.
+-SSP_CFLAGS:= ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/}
++SSP_CFLAGS:= ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/:C/^$/-fno-stack-protector/}
+ # Generate stack unwinding tables for cancellation points
+ CANCELPOINTS_CFLAGS:= ${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//}
+diff --git a/lib/csu/Makefile.inc b/lib/csu/Makefile.inc
+index f92d87d..7a3a2f3 100644
+--- a/lib/csu/Makefile.inc
++++ b/lib/csu/Makefile.inc
+@@ -1,5 +1,5 @@
+ # $FreeBSD: release/9.1.0/lib/csu/Makefile.inc 204757 2010-03-05 13:29:05Z uqs $
+
+-SSP_CFLAGS=
++SSP_CFLAGS= -fno-stack-protector
+
+ .include "../Makefile.inc"
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-bsdxml.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-bsdxml.patch
new file mode 100644
index 0000000..ec90def
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-bsdxml.patch
@@ -0,0 +1,13 @@
+diff -u lib/libgeom/Makefile lib.xml/libgeom/Makefile
+--- lib/libgeom/Makefile 2004-03-07 16:07:57 +0000
++++ lib.xml/libgeom/Makefile 2005-05-06 10:38:41 +0000
+@@ -8,7 +8,8 @@
+ SRCS+= geom_ctl.c
+ INCS= libgeom.h
+
+-CFLAGS += -I${.CURDIR}
++CFLAGS += -I${.CURDIR} -I${.CURDIR}/../libexpat
++LDFLAGS += -L${.CURDIR}/../libexpat
+
+ WARNS?= 3
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-bsdxml2expat.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-bsdxml2expat.patch
new file mode 100644
index 0000000..1b4e791
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-bsdxml2expat.patch
@@ -0,0 +1,26 @@
+diff -ur lib/libgeom.old/Makefile lib/libgeom/Makefile
+--- lib/libgeom.old/Makefile 2011-07-10 14:23:51.000000000 +0000
++++ lib/libgeom/Makefile 2011-07-10 15:12:39.000000000 +0000
+@@ -13,8 +13,8 @@
+
+ WARNS?= 3
+
+-DPADD= ${LIBBSDXML} ${LIBSBUF}
+-LDADD= -lbsdxml -lsbuf
++DPADD= ${LIBSBUF}
++LDADD= -lexpat -lsbuf
+
+ MAN= libgeom.3
+
+diff -ur lib/libgeom.old/geom_xml2tree.c lib/libgeom/geom_xml2tree.c
+--- lib/libgeom.old/geom_xml2tree.c 2010-12-21 17:09:25.000000000 +0000
++++ lib/libgeom/geom_xml2tree.c 2011-07-10 15:12:52.000000000 +0000
+@@ -43,7 +43,7 @@
+ #include <sys/sbuf.h>
+ #include <sys/sysctl.h>
+ #include <err.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <libgeom.h>
+
+ struct mystate {
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-includes.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-includes.patch
new file mode 100644
index 0000000..c2cf142
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-includes.patch
@@ -0,0 +1,13 @@
+Fix headers dependencies so that they can be included alone.
+
+--- include/ifaddrs.h.old 2009-05-15 13:50:10 +0000
++++ include/ifaddrs.h 2009-05-15 13:50:23 +0000
+@@ -28,6 +28,8 @@
+ #ifndef _IFADDRS_H_
+ #define _IFADDRS_H_
+
++#include <sys/types.h>
++
+ struct ifaddrs {
+ struct ifaddrs *ifa_next;
+ char *ifa_name;
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-new_as.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-new_as.patch
new file mode 100644
index 0000000..c9288a4
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-new_as.patch
@@ -0,0 +1,68 @@
+--- lib/msun/i387/fenv.c.orig 2007-01-05 04:15:26 -0300
++++ lib/msun/i387/fenv.c 2008-06-14 00:49:30 -0300
+@@ -152,7 +152,8 @@
+ int
+ feupdateenv(const fenv_t *envp)
+ {
+- int mxcsr, status;
++ int mxcsr;
++ short status;
+
+ __fnstsw(&status);
+ if (__HAS_SSE())
+--- lib/msun/i387/fenv.h.orig 2007-01-06 18:46:23 -0300
++++ lib/msun/i387/fenv.h 2008-06-14 01:06:40 -0300
+@@ -134,7 +134,8 @@
+ static __inline int
+ fegetexceptflag(fexcept_t *__flagp, int __excepts)
+ {
+- int __mxcsr, __status;
++ int __mxcsr;
++ short __status;
+
+ __fnstsw(&__status);
+ if (__HAS_SSE())
+@@ -151,7 +152,8 @@
+ static __inline int
+ fetestexcept(int __excepts)
+ {
+- int __mxcsr, __status;
++ int __mxcsr;
++ short __status;
+
+ __fnstsw(&__status);
+ if (__HAS_SSE())
+--- lib/msun/amd64/fenv.c.orig 2007-01-05 04:15:26 -0300
++++ lib/msun/amd64/fenv.c 2008-06-14 01:02:41 -0300
+@@ -101,7 +101,8 @@
+ int
+ feupdateenv(const fenv_t *envp)
+ {
+- int mxcsr, status;
++ int mxcsr;
++ short status;
+
+ __fnstsw(&status);
+ __stmxcsr(&mxcsr);
+--- lib/msun/amd64/fenv.h.orig 2007-01-06 18:46:23 -0300
++++ lib/msun/amd64/fenv.h 2008-06-14 01:08:23 -0300
+@@ -110,7 +110,8 @@
+ static __inline int
+ fegetexceptflag(fexcept_t *__flagp, int __excepts)
+ {
+- int __mxcsr, __status;
++ int __mxcsr;
++ short __status;
+
+ __stmxcsr(&__mxcsr);
+ __fnstsw(&__status);
+@@ -124,7 +125,8 @@
+ static __inline int
+ fetestexcept(int __excepts)
+ {
+- int __mxcsr, __status;
++ int __mxcsr;
++ short __status;
+
+ __stmxcsr(&__mxcsr);
+ __fnstsw(&__status);
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-sources-9.0-sysctluint.patch b/sys-freebsd/freebsd-lib/files/freebsd-sources-9.0-sysctluint.patch
new file mode 100644
index 0000000..751a77c
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-sources-9.0-sysctluint.patch
@@ -0,0 +1,13 @@
+u_int is defined in sys/types.h
+makes header usable alone.
+
+--- sys/sys/sysctl.h.old 2012-05-25 11:08:53.000000000 -0400
++++ sys/sys/sysctl.h 2012-05-25 11:09:16.000000000 -0400
+@@ -788,6 +788,7 @@
+ struct sysctl_req *);
+ #else /* !_KERNEL */
+ #include <sys/cdefs.h>
++#include <sys/types.h> /* for u_int */
+
+ __BEGIN_DECLS
+ int sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
diff --git a/sys-freebsd/freebsd-lib/files/libmap.conf b/sys-freebsd/freebsd-lib/files/libmap.conf
new file mode 100644
index 0000000..7a879f9
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/libmap.conf
@@ -0,0 +1,8 @@
+# /etc/libmap.conf
+
+# Ensure that libthr does all threading
+libpthread.so.2 libthr.so.2
+libpthread.so libthr.so
+libc_r.so.6 libthr.so.2
+libc_r.so libthr.so
+
diff --git a/sys-freebsd/freebsd-lib/files/libusb-1.0.pc.in b/sys-freebsd/freebsd-lib/files/libusb-1.0.pc.in
new file mode 100644
index 0000000..058ecb4
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/libusb-1.0.pc.in
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=@LIBDIR@
+includedir=${prefix}/include
+
+Name: libusb
+Description: USB access library (FreeBSD version)
+Version: 1.0.1
+Libs: -L${libdir} -lusb
+Cflags: -I${includedir}
+
diff --git a/sys-freebsd/freebsd-lib/files/libusb.pc.in b/sys-freebsd/freebsd-lib/files/libusb.pc.in
new file mode 100644
index 0000000..f63c6e3
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/libusb.pc.in
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=@LIBDIR@
+includedir=${prefix}/include
+
+Name: libusb
+Description: USB access library (FreeBSD version)
+Version: 0.1.12
+Libs: -L${libdir} -lusb
+Cflags: -I${includedir}
+
diff --git a/sys-freebsd/freebsd-lib/freebsd-lib-11.0.ebuild b/sys-freebsd/freebsd-lib/freebsd-lib-11.0.ebuild
new file mode 100644
index 0000000..ed4d9a8
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/freebsd-lib-11.0.ebuild
@@ -0,0 +1,647 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic multilib toolchain-funcs eutils multibuild multilib-build
+
+DESCRIPTION="FreeBSD's base system libraries"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+# Security Advisory and Errata patches.
+UPSTREAM_PATCHES=( "EN-16:06/libc.patch" )
+
+# Crypto is needed to have an internal OpenSSL header
+# sys is needed for libalias, probably we can just extract that instead of
+# extracting the whole tarball
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ lib/
+ contrib/
+ crypto/
+ libexec/
+ etc/
+ include/
+ usr.sbin/
+ gnu/
+ secure/
+"
+
+if [ "${CATEGORY#*cross-}" = "${CATEGORY}" ]; then
+ RDEPEND="ssl? ( dev-libs/openssl:0= )
+ hesiod? ( net-dns/hesiod )
+ kerberos? ( app-crypt/heimdal )
+ usb? ( !dev-libs/libusb )
+ zfs? ( =sys-freebsd/freebsd-cddl-${RV}* )
+ >=dev-libs/expat-2.0.1
+ >=dev-util/dialog-1.2.20150225
+ =sys-freebsd/freebsd-libexec-${RV}*
+ !sys-libs/libutempter
+ !dev-libs/libelf
+ !dev-libs/libexecinfo
+ !dev-libs/libiconv
+ !sys-freebsd/freebsd-headers"
+ DEPEND="${RDEPEND}
+ >=sys-devel/flex-2.5.31-r2
+ >=sys-freebsd/freebsd-sources-10.3-r5"
+ RDEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-share-${RV}*
+ >=virtual/libiconv-0-r2"
+else
+ EXTRACTONLY+="sys/ "
+fi
+
+DEPEND="${DEPEND}
+ userland_GNU? ( sys-apps/mtree )
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+S="${WORKDIR}/lib"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [ "${CTARGET}" = "${CHOST}" -a "${CATEGORY#*cross-}" != "${CATEGORY}" ]; then
+ export CTARGET=${CATEGORY/cross-}
+fi
+
+IUSE="atm bluetooth ssl hesiod ipv6 kerberos usb netware
+ build crosscompile_opts_headers-only zfs
+ userland_GNU userland_BSD"
+
+QA_DT_NEEDED="lib/libc.so.7 usr/lib32/libc.so.7"
+
+pkg_setup() {
+ # Add the required source files.
+ use build && EXTRACTONLY+="sys/ "
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ [ -c /dev/zero ] || \
+ die "You forgot to mount /dev; the compiled libc would break."
+
+ if ! use ssl && use kerberos; then
+ eerror "If you want kerberos support you need to enable ssl support, too."
+ fi
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use hesiod || mymakeopts="${mymakeopts} WITHOUT_HESIOD= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= WITHOUT_GSSAPI= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+
+ mymakeopts="${mymakeopts} WITHOUT_SENDMAIL= WITHOUT_CLANG= WITHOUT_LIBCPLUSPLUS= WITHOUT_LDNS= WITHOUT_UNBOUND= "
+
+ if [ "${CTARGET}" != "${CHOST}" ]; then
+ mymakeopts="${mymakeopts} MACHINE=$(tc-arch-kernel ${CTARGET})"
+ mymakeopts="${mymakeopts} MACHINE_ARCH=$(tc-arch-kernel ${CTARGET})"
+ fi
+}
+
+PATCHES=(
+ "${FILESDIR}/${PN}-6.0-pmc.patch"
+ "${FILESDIR}/${PN}-6.1-csu.patch"
+ "${FILESDIR}/${PN}-10.0-liblink.patch"
+ "${FILESDIR}/${PN}-10.2-liblink.patch"
+ "${FILESDIR}/${PN}-10.0-atfcxx.patch"
+ "${FILESDIR}/${PN}-10.3-libusb.patch"
+ "${FILESDIR}/${PN}-10.0-libproc-libcxx.patch"
+ "${FILESDIR}/${PN}-10.2-bsdxml2expat.patch"
+ "${FILESDIR}/${PN}-9.0-bluetooth.patch"
+ "${FILESDIR}/${PN}-9.1-.eh_frame_hdr-fix.patch"
+ "${FILESDIR}/${PN}-add-nossp-cflags.patch"
+ )
+# Here we disable and remove source which we don't need or want
+# In order:
+# - ncurses stuff
+# - libexpat creates a bsdxml library which is the same as expat
+# - archiving libraries (have their own ebuild)
+# - sendmail libraries (they are installed by sendmail)
+# - SNMP library and dependency (have their own ebuilds)
+# - libstand: static library, 32bits on amd64 used for boot0, we build it from
+# boot0 instead.
+#
+# The rest are libraries we already have somewhere else because
+# they are contribution.
+REMOVE_SUBDIRS="ncurses \
+ libexpat \
+ libz libbz2 libarchive liblzma \
+ libsm libsmdb libsmutil \
+ libbegemot libbsnmp \
+ libpam libpcap libwrap libmagic \
+ libcom_err
+ libedit
+ libstand
+ libgssapi"
+
+# Are we building a cross-compiler?
+is_crosscompile() {
+ [ "${CATEGORY#*cross-}" != "${CATEGORY}" ]
+}
+
+src_prepare() {
+ # gcc-5.0 or later, Workaround for critical issue. bug 573358.
+ use x86-fbsd && [[ "$(gcc-major-version)" -ge 5 ]] && replace-flags -O? -O1
+
+ sed -i.bak -e 's:-o/dev/stdout:-t:' "${S}/libc/net/Makefile.inc"
+
+ # Upstream Display Managers default to using VT7
+ # We should make FreeBSD allow this by default
+ local x=
+ for x in "${WORKDIR}"/etc/etc.*/ttys ; do
+ sed -i.bak \
+ -e '/ttyv5[[:space:]]/ a\
+# Display Managers default to VT7.\
+# If you use the xdm init script, keep ttyv6 commented out\
+# unless you force a different VT for the DM being used.' \
+ -e '/^ttyv[678][[:space:]]/ s/^/# /' "${x}" \
+ || die "Failed to sed ${x}"
+ rm "${x}".bak
+ done
+
+ # This one is here because it also
+ # patches "${WORKDIR}/include"
+ cd "${WORKDIR}"
+ epatch "${FILESDIR}/${PN}-includes.patch"
+ epatch "${FILESDIR}/${PN}-8.0-gcc45.patch"
+ epatch "${FILESDIR}/${PN}-9.0-opieincludes.patch"
+
+ # Don't install the hesiod man page or header
+ rm "${WORKDIR}"/include/hesiod.h || die
+ sed -i.bak -e 's:hesiod.h::' "${WORKDIR}"/include/Makefile || die
+ sed -i.bak -e 's:hesiod.c::' -e 's:hesiod.3::' \
+ "${WORKDIR}"/lib/libc/net/Makefile.inc || die
+
+ # Fix the Makefiles of these few libraries that will overwrite our LDADD.
+ cd "${S}"
+ for dir in libradius libtacplus libcam libdevstat libfetch libgeom libmemstat libopie \
+ libsmb libprocstat libulog; do sed -i.bak -e 's:LDADD=:LDADD+=:g' "${dir}/Makefile" || \
+ die "Problem fixing \"${dir}/Makefile"
+ done
+ # Call LD with LDFLAGS, rename them to RAW_LDFLAGS
+ sed -e 's/LDFLAGS/RAW_LDFLAGS/g' \
+ -i "${S}/csu/i386-elf/Makefile" \
+ -i "${S}/csu/ia64/Makefile" || die
+
+ if install --version 2> /dev/null | grep -q GNU; then
+ sed -i.bak -e 's:${INSTALL} -C:${INSTALL}:' "${WORKDIR}/include/Makefile"
+ fi
+
+ # Try to fix sed calls for GNU sed. Do it only with GNU userland and force
+ # BSD's sed on BSD.
+ cd "${S}"
+ if [[ ${CBUILD:-${CHOST}} != *bsd* ]]; then
+ find . -name Makefile -exec sed -ibak 's/sed -i /sed -i/' {} \;
+ sed -i -e 's/-i ""/-i""/' "${S}/csu/Makefile.inc" || die
+ fi
+
+ if use build; then
+ cd "${WORKDIR}"
+ # This patch has to be applied on ${WORKDIR}/sys, so we do it here since it
+ # shouldn't be a symlink to /usr/src/sys (which should be already patched)
+ epatch "${FILESDIR}"/freebsd-sources-9.0-sysctluint.patch
+ return 0
+ fi
+
+ if ! is_crosscompile ; then
+ if [[ ! -e "${WORKDIR}/sys" ]]; then
+ ln -s "${SYSROOT}/usr/src/sys" "${WORKDIR}/sys" || die "Couldn't make sys symlink!"
+ fi
+ else
+ sed -i.bak -e "s:/usr/include:/usr/${CTARGET}/usr/include:g" \
+ "${S}/libc/rpc/Makefile.inc" \
+ "${S}/libc/yp/Makefile.inc"
+ fi
+}
+
+bootstrap_lib() {
+ for i ; do
+ cd "${WORKDIR}/${i}" || die "missing ${i}"
+ freebsd_src_compile
+ append-ldflags "-L${MAKEOBJDIRPREFIX}/${WORKDIR}/${i}"
+ done
+}
+
+get_csudir() {
+ if [ -d "${WORKDIR}/lib/csu/$1-elf" ]; then
+ echo "lib/csu/$1-elf"
+ else
+ echo "lib/csu/$1"
+ fi
+}
+
+bootstrap_csu() {
+ local csudir="$(get_csudir $(tc-arch-kernel ${CTARGET}))"
+ export RAW_LDFLAGS=$(raw-ldflags)
+ bootstrap_lib "${csudir}"
+
+ CFLAGS="${CFLAGS} -B ${MAKEOBJDIRPREFIX}/${WORKDIR}/${csudir}"
+ append-ldflags "-B ${MAKEOBJDIRPREFIX}/${WORKDIR}/${csudir}"
+
+ bootstrap_lib "gnu/lib/csu"
+
+ cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
+ for i in *.So ; do
+ ln -s $i ${i%.So}S.o
+ done
+ CFLAGS="${CFLAGS} -B ${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
+ append-ldflags "-B ${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
+}
+
+# Compile libssp_nonshared.a and add it's path to LDFLAGS.
+bootstrap_libssp_nonshared() {
+ bootstrap_lib "gnu/lib/libssp/libssp_nonshared"
+ export LDADD="-lssp_nonshared"
+}
+
+bootstrap_libgcc() {
+ bootstrap_lib "lib/libcompiler_rt"
+ cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libcompiler_rt" || die
+ ln -s libcompiler_rt.a libgcc.a || die
+
+ bootstrap_lib "lib/libc" "gnu/lib/libgcc"
+}
+
+bootstrap_libthr() {
+ bootstrap_lib "lib/libthr"
+ cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libthr" || die
+ ln -s libthr.so libpthread.so
+}
+
+# What to build for a cross-compiler.
+# We also need the csu but this has to be handled separately.
+CROSS_SUBDIRS="lib/libc lib/msun gnu/lib/libssp/libssp_nonshared lib/libthr lib/libutil lib/librt lib/libc_nonshared"
+
+# What to build for non-default ABIs.
+NON_NATIVE_SUBDIRS="${CROSS_SUBDIRS} gnu/lib/csu lib/libcompiler_rt gnu/lib/libgcc lib/libmd lib/libcrypt lib/libsbuf lib/libcam lib/libelf lib/libiconv_modules"
+
+# Subdirs for a native build:
+NATIVE_SUBDIRS="lib gnu/lib/libssp/libssp_nonshared gnu/lib/libregex gnu/lib/csu gnu/lib/libgcc lib/libiconv_modules"
+
+# Is my $ABI native ?
+is_native_abi() {
+ is_crosscompile && return 1
+ multilib_is_native_abi
+}
+
+# Do we need to bootstrap the csu and libssp_nonshared?
+need_bootstrap() {
+ is_crosscompile || use build || { ! is_native_abi && ! has_version '>=sys-freebsd/freebsd-lib-9.1-r8[multilib]' && ! has_version ">=sys-freebsd/freebsd-lib-9.1-r11[${MULTILIB_USEDEP}]" ; } || has_version "<${CATEGORY}/${P}"
+}
+
+# Get the subdirs we are building.
+get_subdirs() {
+ local ret=""
+ if is_native_abi ; then
+ # If we are building for the native ABI, build everything
+ ret="${NATIVE_SUBDIRS}"
+ elif is_crosscompile ; then
+ # With a cross-compiler we only build the very core parts.
+ ret="${CROSS_SUBDIRS}"
+ if [ "${EBUILD_PHASE}" = "install" ]; then
+ # Add the csu dir first when installing. We treat it separately for
+ # compiling.
+ ret="$(get_csudir $(tc-arch-kernel ${CTARGET})) ${ret}"
+ fi
+ else
+ # For the non-native ABIs we only build the csu parts and very core
+ # libraries for now.
+ ret="${NON_NATIVE_SUBDIRS} $(get_csudir $(tc-arch-kernel ${CHOST}))"
+ fi
+ echo "${ret}"
+}
+
+# Bootstrap the core libraries and setup the flags so that the other parts can
+# build against it.
+do_bootstrap() {
+ einfo "Bootstrapping on ${CHOST} for ${CTARGET}"
+ if ! is_crosscompile ; then
+ # Pre-install headers, but not when building a cross-compiler since we
+ # assume they have been installed in the previous pass.
+ einfo "Pre-installing includes in include_proper_${ABI}"
+ mkdir "${WORKDIR}/include_proper_${ABI}" || die
+ CTARGET="${CHOST}" install_includes "/include_proper_${ABI}"
+ CFLAGS="${CFLAGS} -isystem ${WORKDIR}/include_proper_${ABI}"
+ CXXFLAGS="${CXXFLAGS} -isystem ${WORKDIR}/include_proper_${ABI}"
+ mymakeopts="${mymakeopts} RPCDIR=${WORKDIR}/include_proper_${ABI}/rpcsvc"
+ fi
+ bootstrap_csu
+ bootstrap_libssp_nonshared
+ is_crosscompile && bootstrap_lib "lib/libc"
+ is_crosscompile || is_native_abi || bootstrap_libgcc
+ is_native_abi || bootstrap_libthr
+}
+
+# Compile it. Assume we have the toolchain setup correctly.
+do_compile() {
+ # Bootstrap if needed, otherwise assume the system headers are in
+ # /usr/include.
+ if need_bootstrap ; then
+ do_bootstrap
+ else
+ CFLAGS="${CFLAGS} -isystem /usr/include"
+ CXXFLAGS="${CXXFLAGS} -isystem /usr/include"
+ fi
+
+ export RAW_LDFLAGS=$(raw-ldflags)
+
+ # Everything is now setup, build it!
+ for i in $(get_subdirs) ; do
+ einfo "Building in ${i}... with CC=${CC} and CFLAGS=${CFLAGS}"
+ cd "${WORKDIR}/${i}/" || die "missing ${i}."
+ freebsd_src_compile || die "make ${i} failed"
+ done
+}
+
+src_compile() {
+ # Does not work with GNU sed
+ # Force BSD's sed on BSD.
+ if [[ ${CBUILD:-${CHOST}} == *bsd* ]]; then
+ export ESED=/usr/bin/sed
+ unalias sed
+ fi
+
+ use usb && export NON_NATIVE_SUBDIRS="${NON_NATIVE_SUBDIRS} lib/libusb lib/libusbhid"
+
+ cd "${WORKDIR}/include"
+ $(freebsd_get_bmake) CC="$(tc-getCC)" || die "make include failed"
+
+ use crosscompile_opts_headers-only && return 0
+
+ # Bug #270098
+ append-flags $(test-flags -fno-strict-aliasing)
+
+ # Bug #324445
+ append-flags $(test-flags -fno-strict-overflow)
+
+ # strip flags and do not do it later, we only add safe, and in fact
+ # needed flags after all
+ strip-flags
+ export NOFLAGSTRIP=yes
+ if is_crosscompile ; then
+ export YACC='yacc -by'
+ CHOST=${CTARGET} tc-export CC LD CXX RANLIB
+ mymakeopts="${mymakeopts} NLS="
+ CFLAGS="${CFLAGS} -isystem /usr/${CTARGET}/usr/include"
+ CXXFLAGS="${CXXFLAGS} -isystem /usr/${CTARGET}/usr/include"
+ append-ldflags "-L${WORKDIR}/${CHOST}/${WORKDIR}/lib/libc"
+ fi
+
+ if is_crosscompile ; then
+ do_compile
+ else
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper do_compile
+ fi
+}
+
+gen_libc_ldscript() {
+ # Parameters:
+ # $1 = target libdir
+ # $2 = source libc dir
+ # $3 = source libssp_nonshared dir
+
+ # Clear the symlink.
+ rm -f "${DESTDIR}/$2/libc.so" || die
+
+ # Move the library if needed
+ if [ "$1" != "$2" ] ; then
+ mv "${DESTDIR}/$2/libc.so.7" "${DESTDIR}/$1/" || die
+ fi
+
+ # Generate libc.so ldscript for inclusion of libssp_nonshared.a when linking
+ # this is done to avoid having to touch gcc spec file as it is currently
+ # done on FreeBSD upstream, mostly because their binutils aren't able to
+ # cope with linker scripts yet.
+ # Taken from toolchain-funcs.eclass:
+ local output_format
+ output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p')
+ [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )"
+
+ # iconv symbol provided by libc_nonshared.a.
+ # http://svnweb.freebsd.org/base?view=revision&amp;revision=258283
+ cat > "${DESTDIR}/$2/libc.so" <<-END_LDSCRIPT
+/* GNU ld script
+ SSP (-fstack-protector) requires __stack_chk_fail_local to be local.
+ GCC invokes this symbol in a non-PIC way, which results in TEXTRELs if
+ this symbol was provided by a shared libc. So we link in
+ libssp_nonshared.a from here.
+ */
+${output_format}
+GROUP ( /$1/libc.so.7 /$3/libc_nonshared.a /$3/libssp_nonshared.a )
+END_LDSCRIPT
+}
+
+header_list=""
+
+move_header() {
+ local dirname=$(dirname ${1})
+ local filename=$(basename ${1})
+
+ if [ ! -d "${dirname}/${ABI}" ] ; then
+ mkdir "${dirname}/${ABI}" || die
+ fi
+
+ mv "${1}" "${dirname}/${ABI}/" || die
+
+ export header_list="${header_list} ${1}"
+}
+
+make_header_template() {
+ cat <<-END_HEADER
+/*
+ * Wrapped header for multilib support.
+ * See the real headers included below.
+ */
+
+#if defined(__x86_64__)
+ @ABI_amd64_fbsd@
+#elif defined(__i386__)
+ @ABI_x86_fbsd@
+#else
+ @ABI_${DEFAULT_ABI}@
+#endif
+END_HEADER
+}
+
+wrap_header() {
+ local dirname=$(dirname ${1})
+ local filename=$(basename ${1})
+
+ if [ -n "${dirname#.}" ] ; then
+ dirname="${dirname}/${2}"
+ else
+ dirname="${2}"
+ fi
+
+ if [ -f "${dirname}/${filename}" ] ; then
+ sed -e "s:@ABI_${2}@:#include <${dirname}/${filename}>:" ${1}
+ else
+ cat ${1}
+ fi
+}
+
+wrap_header_end() {
+ sed -e "s:@ABI_.*@:#error \"Sorry, no support for your ABI.\":" ${1}
+}
+
+do_install() {
+ if is_crosscompile ; then
+ INCLUDEDIR="/usr/${CTARGET}/usr/include"
+ else
+ INCLUDEDIR="/usr/include"
+ fi
+
+ dodir ${INCLUDEDIR}
+ CTARGET="${CHOST}" \
+ install_includes ${INCLUDEDIR}
+
+ is_crosscompile && use crosscompile_opts_headers-only && return 0
+
+ # Install a libusb.pc for better compat with Linux's libusb
+ if use usb ; then
+ dodir /usr/$(get_libdir)/pkgconfig
+ sed -i.bkp "s:^libdir=.*:libdir=/usr/$(get_libdir):g" "${S}"/libusb/libusb-*.pc
+ fi
+
+ for i in $(get_subdirs) ; do
+ if [[ ${i} != *libiconv_modules* ]] ; then
+ einfo "Installing in ${i}..."
+ cd "${WORKDIR}/${i}/" || die "missing ${i}."
+ freebsd_src_install || die "Install ${i} failed"
+ fi
+ done
+
+ if ! is_crosscompile; then
+ local mymakeopts_save="${mymakeopts}"
+ mymakeopts="${mymakeopts} SHLIBDIR=/usr/$(get_libdir)/i18n LIBDIR=/usr/$(get_libdir)/i18n"
+
+ einfo "Installing in lib/libiconv_modules..."
+ cd "${WORKDIR}/lib/libiconv_modules/" || die "missing libiconv_modules."
+ freebsd_src_install || die "Install lib/libiconv_modules failed"
+
+ mymakeopts="${mymakeopts_save}"
+ fi
+
+ if ! is_crosscompile ; then
+ if ! multilib_is_native_abi ; then
+ DESTDIR="${D}" gen_libc_ldscript "usr/$(get_libdir)" "usr/$(get_libdir)" "usr/$(get_libdir)"
+ else
+ dodir "$(get_libdir)"
+ DESTDIR="${D}" gen_libc_ldscript "$(get_libdir)" "usr/$(get_libdir)" "usr/$(get_libdir)"
+ fi
+ else
+ CHOST=${CTARGET} DESTDIR="${D}/usr/${CTARGET}/" gen_libc_ldscript "usr/lib" "usr/lib" "usr/lib"
+ # We're done for the cross libc here.
+ return 0
+ fi
+
+ # Generate ldscripts for core libraries that will go in /
+ multilib_is_native_abi && \
+ gen_usr_ldscript -a alias cam geom ipsec jail kiconv \
+ kvm m md procstat sbuf thr ufs util elf
+
+ if [[ ${#MULTIBUILD_VARIANTS[@]} -gt 1 ]] ; then
+ cd "${D}/usr/include"
+ for i in machine/*.h fenv.h ; do
+ move_header ${i}
+ done
+ if multilib_is_native_abi ; then
+ # Supposedly the last one!
+ local uniq_headers="$(echo ${header_list} | tr ' ' '\n' | sort | uniq | tr '\n' ' ')"
+ for j in ${uniq_headers} ; do
+ make_header_template > ${j}
+ for i in $(get_all_abis) ; do
+ wrap_header ${j} ${i} > ${j}.new
+ cp ${j}.new ${j}
+ rm -f ${j}.new
+ done
+ wrap_header_end ${j} > ${j}.new
+ cp ${j}.new ${j}
+ rm -f ${j}.new
+ done
+ fi
+ fi
+}
+
+src_install() {
+ if is_crosscompile ; then
+ einfo "Installing for ${CTARGET} in ${CHOST}.."
+ # From this point we need to force: get stripped with the correct tools,
+ # get tc-arch-kernel to return the right value, etc.
+ export CHOST=${CTARGET}
+
+ mymakeopts="${mymakeopts} NO_MAN= \
+ INCLUDEDIR=/usr/${CTARGET}/usr/include \
+ SHLIBDIR=/usr/${CTARGET}/usr/lib \
+ LIBDIR=/usr/${CTARGET}/usr/lib"
+
+ dosym "usr/include" "/usr/${CTARGET}/sys-include"
+ do_install
+
+ return 0
+ else
+ export STRIP_MASK="*/usr/lib*/*crt*.o"
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper do_install
+ fi
+
+ cd "${WORKDIR}/etc/"
+ insinto /etc
+ doins nls.alias mac.conf netconfig
+
+ # Install ttys file
+ local MACHINE="$(tc-arch-kernel)"
+ doins "etc.${MACHINE}"/*
+}
+
+install_includes()
+{
+ local INCLUDEDIR="$1"
+
+ # The idea is to be called from either install or unpack.
+ # During unpack it's required to install them as portage's user.
+ if [[ "${EBUILD_PHASE}" == "install" ]]; then
+ local DESTDIR="${D}"
+ BINOWN="root"
+ BINGRP="wheel"
+ else
+ local DESTDIR="${WORKDIR}"
+ [[ -z "${USER}" ]] && USER="portage"
+ BINOWN="${USER}"
+ [[ -z "${GROUPS}" ]] && GROUPS="portage"
+ BINGRP="${GROUPS}"
+ fi
+
+ # Must exist before we use it.
+ [[ -d "${DESTDIR}${INCLUDEDIR}" ]] || die "dodir or mkdir ${INCLUDEDIR} before using install_includes."
+ cd "${WORKDIR}/include"
+
+ local MACHINE="$(tc-arch-kernel)"
+
+ einfo "Installing includes into ${INCLUDEDIR} as ${BINOWN}:${BINGRP}..."
+ $(freebsd_get_bmake) installincludes \
+ MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE} \
+ DESTDIR="${DESTDIR}" \
+ INCLUDEDIR="${INCLUDEDIR}" BINOWN="${BINOWN}" \
+ BINGRP="${BINGRP}" \
+ WITHOUT_GSSAPI= || die "install_includes() failed"
+ einfo "includes installed ok."
+ EXTRA_INCLUDES="lib/librtld_db lib/libutil lib/msun gnu/lib/libregex"
+ for i in $EXTRA_INCLUDES; do
+ einfo "Installing $i includes into ${INCLUDEDIR} as ${BINOWN}:${BINGRP}..."
+ cd "${WORKDIR}/$i" || die
+ $(freebsd_get_bmake) installincludes DESTDIR="${DESTDIR}" \
+ MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE} \
+ INCLUDEDIR="${INCLUDEDIR}" BINOWN="${BINOWN}" \
+ BINGRP="${BINGRP}" || die "problem installing $i includes."
+ einfo "$i includes installed ok."
+ done
+}
diff --git a/sys-freebsd/freebsd-lib/metadata.xml b/sys-freebsd/freebsd-lib/metadata.xml
new file mode 100644
index 0000000..24ca540
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/metadata.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+ </maintainer>
+ <use>
+ <flag name="hesiod">Enable support for net-dns/hesiod</flag>
+ <flag name="netware">
+ Build libraries and tools to work with NetWare protocols (IPX
+ and NCP).
+ </flag>
+ <flag name="zfs">Enable ZFS support.</flag>
+ </use>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-libexec/files/bootpd.confd b/sys-freebsd/freebsd-libexec/files/bootpd.confd
new file mode 100644
index 0000000..6d238e4
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/bootpd.confd
@@ -0,0 +1,7 @@
+# Configuration file for /etc/init.d/bootpd
+
+# Name of the configuration file for bootpd
+# bootptab_file="/etc/bootptab"
+
+# Options to pass to bootpd. See bootpd(8).
+# bootpd_opts=""
diff --git a/sys-freebsd/freebsd-libexec/files/bootpd.initd b/sys-freebsd/freebsd-libexec/files/bootpd.initd
new file mode 100644
index 0000000..82288eb
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/bootpd.initd
@@ -0,0 +1,27 @@
+#!/sbin/openrc-run
+# Copyright 2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net
+}
+
+start() {
+ local bootptab=${bootptab_file:-/etc/bootptab}
+
+ if ! [ -f "${bootptab}" ]; then
+ eerror "Unable to find the bootptab file: ${bootptab}"
+ eend 1
+ return 1
+ fi
+
+ ebegin "Starting BOOTP server"
+ start-stop-daemon --start --exec /usr/libexec/bootpd -- ${bootpd_opts} ${bootptab}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping BOOTP server"
+ start-stop-daemon --stop --exec /usr/libexec/bootpd
+ eend $?
+}
diff --git a/sys-freebsd/freebsd-libexec/files/freebsd-libexec-10.2-atf-check.patch b/sys-freebsd/freebsd-libexec/files/freebsd-libexec-10.2-atf-check.patch
new file mode 100644
index 0000000..e9c0925
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/freebsd-libexec-10.2-atf-check.patch
@@ -0,0 +1,28 @@
+diff --git a/libexec/atf/Makefile.inc b/libexec/atf/Makefile.inc
+index b50e14e..e59a413 100644
+--- a/libexec/atf/Makefile.inc
++++ b/libexec/atf/Makefile.inc
+@@ -25,7 +25,7 @@
+ #
+ # $FreeBSD: stable/10/libexec/atf/Makefile.inc 271298 2014-09-09 04:00:30Z ngie $
+
+-CFLAGS+= -DHAVE_CONFIG_H
++CXXFLAGS+= -DHAVE_CONFIG_H
+
+ WARNS?= 3
+
+diff --git a/libexec/atf/atf-check/Makefile b/libexec/atf/atf-check/Makefile
+index 77c11db..7449ddb 100644
+--- a/libexec/atf/atf-check/Makefile
++++ b/libexec/atf/atf-check/Makefile
+@@ -34,8 +34,8 @@ PROG_CXX= atf-check
+ SRCS= atf-check.cpp
+ MAN= atf-check.1
+
+-CFLAGS+= -I${ATF}
+-CFLAGS+= -DATF_SHELL='"/bin/sh"'
++CXXFLAGS+= -I${ATF}
++CXXFLAGS+= -DATF_SHELL='"/bin/sh"'
+
+ LDFLAGS+= -L${.OBJDIR}/../../../lib/atf/libatf-c++
+ LDFLAGS+= -L${.OBJDIR}/../../../lib/atf/libatf-c
diff --git a/sys-freebsd/freebsd-libexec/files/freebsd-libexec-7.2-pic.patch b/sys-freebsd/freebsd-libexec/files/freebsd-libexec-7.2-pic.patch
new file mode 100644
index 0000000..22d5658
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/freebsd-libexec-7.2-pic.patch
@@ -0,0 +1,13 @@
+Fails to build on sparc without using -fPIC
+
+--- libexec/rtld-elf/Makefile.old 2010-01-09 17:17:21 +0100
++++ libexec/rtld-elf/Makefile 2010-01-09 17:17:33 +0100
+@@ -19,7 +19,7 @@
+ MLINKS= rtld.1 ld-elf.so.1.1 \
+ rtld.1 ld.so.1
+
+-CFLAGS+= -fpic -DPIC
++CFLAGS+= -fPIC -DPIC
+ LDFLAGS+= -shared -Wl,-Bsymbolic
+ DPADD= ${LIBC_PIC}
+ LDADD= -lc_pic
diff --git a/sys-freebsd/freebsd-libexec/files/freebsd-libexec-8.2-rtld.patch b/sys-freebsd/freebsd-libexec/files/freebsd-libexec-8.2-rtld.patch
new file mode 100644
index 0000000..c60b2fe
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/freebsd-libexec-8.2-rtld.patch
@@ -0,0 +1,40 @@
+--- head/libexec/rtld-elf/rtld.c 2011/09/15 11:50:09 225582
++++ head/libexec/rtld-elf/rtld.c 2011/10/08 12:39:47 226155
+@@ -495,8 +495,12 @@
+ exit (0);
+ }
+
+- /* setup TLS for main thread */
+- dbg("initializing initial thread local storage");
++ /*
++ * Processing tls relocations requires having the tls offsets
++ * initialized. Prepare offsets before starting initial
++ * relocation processing.
++ */
++ dbg("initializing initial thread local storage offsets");
+ STAILQ_FOREACH(entry, &list_main, link) {
+ /*
+ * Allocate all the initial objects out of the static TLS
+@@ -504,7 +508,6 @@
+ */
+ allocate_tls_offset(entry->obj);
+ }
+- allocate_initial_tls(obj_list);
+
+ if (relocate_objects(obj_main,
+ ld_bind_now != NULL && *ld_bind_now != '\0', &obj_rtld, NULL) == -1)
+@@ -519,6 +522,14 @@
+ exit (0);
+ }
+
++ /*
++ * Setup TLS for main thread. This must be done after the
++ * relocations are processed, since tls initialization section
++ * might be the subject for relocations.
++ */
++ dbg("initializing initial thread local storage");
++ allocate_initial_tls(obj_list);
++
+ dbg("initializing key program variables");
+ set_program_var("__progname", argv[0] != NULL ? basename(argv[0]) : "");
+ set_program_var("environ", env);
diff --git a/sys-freebsd/freebsd-libexec/files/freebsd-libexec-9.2-no_ld32.patch b/sys-freebsd/freebsd-libexec/files/freebsd-libexec-9.2-no_ld32.patch
new file mode 100644
index 0000000..d330009
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/freebsd-libexec-9.2-no_ld32.patch
@@ -0,0 +1,15 @@
+Use LD_* variables for 32bits too instead of the FreeBSD invention LD_32_*.
+We use LD_* everywhere on Gentoo and things like libtool wrappers have no clue
+about LD_32_* and thus fail to run from the build directory.
+
+diff -uNr libexec.old/rtld-elf/rtld.h libexec/rtld-elf/rtld.h
+--- libexec.old/rtld-elf/rtld.h 2013-08-24 12:30:26.000000000 -0400
++++ libexec/rtld-elf/rtld.h 2013-08-26 17:10:19.000000000 -0400
+@@ -47,7 +47,6 @@
+ #define _PATH_ELF_HINTS "/var/run/ld-elf32.so.hints"
+ /* For running 32 bit binaries */
+ #define STANDARD_LIBRARY_PATH "/lib32:/usr/lib32"
+-#define LD_ "LD_32_"
+ #endif
+
+ #ifndef STANDARD_LIBRARY_PATH
diff --git a/sys-freebsd/freebsd-libexec/files/ftpd.pamd b/sys-freebsd/freebsd-libexec/files/ftpd.pamd
new file mode 100644
index 0000000..8e90823
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/ftpd.pamd
@@ -0,0 +1,8 @@
+# PAM configuration for the "ftpd" service
+#
+
+auth include system-auth
+account include system-auth
+password include system-auth
+session include system-auth
+
diff --git a/sys-freebsd/freebsd-libexec/files/rquotad.xinetd b/sys-freebsd/freebsd-libexec/files/rquotad.xinetd
new file mode 100644
index 0000000..876cd16
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/rquotad.xinetd
@@ -0,0 +1,11 @@
+service rquotad
+{
+ type = rpc
+ socket_type = dgram
+ protocol = udp
+ wait = yes
+ user = root
+ server = /usr/libexec/rpc.rquotad
+ rpc_version = 1
+ disabled = yes
+}
diff --git a/sys-freebsd/freebsd-libexec/files/rstatd.xinetd b/sys-freebsd/freebsd-libexec/files/rstatd.xinetd
new file mode 100644
index 0000000..ba1b819
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/rstatd.xinetd
@@ -0,0 +1,11 @@
+service rstatd
+{
+ type = rpc
+ socket_type = dgram
+ protocol = udp
+ wait = yes
+ user = root
+ server = /usr/libexec/rpc.rstatd
+ rpc_version = 1-3
+ disabled = yes
+}
diff --git a/sys-freebsd/freebsd-libexec/files/rusersd.xinetd b/sys-freebsd/freebsd-libexec/files/rusersd.xinetd
new file mode 100644
index 0000000..5cbe091
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/rusersd.xinetd
@@ -0,0 +1,11 @@
+service rusersd
+{
+ type = rpc
+ socket_type = dgram
+ protocol = udp
+ wait = yes
+ user = root
+ server = /usr/libexec/rpc.rusersd
+ rpc_version = 1-2
+ disabled = yes
+}
diff --git a/sys-freebsd/freebsd-libexec/files/sprayd.xinetd b/sys-freebsd/freebsd-libexec/files/sprayd.xinetd
new file mode 100644
index 0000000..7be5577
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/sprayd.xinetd
@@ -0,0 +1,11 @@
+service sprayd
+{
+ type = rpc
+ socket_type = dgram
+ protocol = udp
+ wait = yes
+ user = root
+ server = /usr/libexec/rpc.sprayd
+ rpc_version = 1
+ disabled = yes
+}
diff --git a/sys-freebsd/freebsd-libexec/files/walld.xinetd b/sys-freebsd/freebsd-libexec/files/walld.xinetd
new file mode 100644
index 0000000..800b84f
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/walld.xinetd
@@ -0,0 +1,11 @@
+service walld
+{
+ type = rpc
+ socket_type = dgram
+ protocol = udp
+ wait = yes
+ user = root
+ server = /usr/libexec/rpc.rwalld
+ rpc_version = 1
+ disabled = yes
+}
diff --git a/sys-freebsd/freebsd-libexec/freebsd-libexec-11.0.ebuild b/sys-freebsd/freebsd-libexec/freebsd-libexec-11.0.ebuild
new file mode 100644
index 0000000..26851c8
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/freebsd-libexec-11.0.ebuild
@@ -0,0 +1,112 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit bsdmk freebsd pam multilib multibuild multilib-build toolchain-funcs
+
+DESCRIPTION="FreeBSD libexec things"
+SLOT="0"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ libexec/
+ usr.bin/
+ bin/
+ contrib/hyperv/
+ lib/
+ etc/
+ usr.sbin/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ >=sys-freebsd/freebsd-lib-9.1-r11[${MULTILIB_USEDEP}]
+ pam? ( virtual/pam )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+RDEPEND="${RDEPEND}
+ xinetd? ( sys-apps/xinetd )"
+
+S="${WORKDIR}/libexec"
+
+# Remove sendmail, tcp_wrapper and other useless stuff
+REMOVE_SUBDIRS="smrsh mail.local tcpd telnetd rshd rlogind ftpd"
+
+IUSE="pam ssl kerberos ipv6 nis xinetd"
+
+PATCHES=( "${FILESDIR}/${PN}-9.2-no_ld32.patch"
+ "${FILESDIR}/${PN}-10.2-atf-check.patch" )
+
+pkg_setup() {
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use pam || mymakeopts="${mymakeopts} WITHOUT_PAM_SUPPORT= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+
+ mymakeopts="${mymakeopts} WITHOUT_SENDMAIL= WITHOUT_PF= WITHOUT_RCMDS= "
+}
+
+src_prepare() {
+ # gcc-5.0 or later, Workaround for critical issue. bug 573358.
+ [[ "$(gcc-major-version)" -ge 5 ]] && replace-flags -O? -O1
+
+ if [[ ! -e "${WORKDIR}/include" ]]; then
+ ln -s /usr/include "${WORKDIR}/include" || die "Symlinking /usr/include.."
+ fi
+ # allow upgrade directly from 9.x to 10.2.
+ if has_version "<sys-freebsd/freebsd-lib-${RV}"; then
+ # taken from sys/sys/elf_common.h
+ echo "#define DF_1_INTERPOSE 0x00000400" >> "${S}"/rtld-elf/rtld.h
+ echo "#define STT_GNU_IFUNC 10" >> "${S}"/rtld-elf/rtld.h
+ echo "#define R_386_IRELATIVE 42" >> "${S}"/rtld-elf/rtld.h
+ echo "#define PT_GNU_RELRO 0x6474e552" >> "${S}"/rtld-elf/rtld.h
+ echo "#define DF_1_NODEFLIB 0x00000800" >> "${S}"/rtld-elf/rtld.h
+ # taken from sys/sys/fcntl.h
+ echo "#define F_DUPFD_CLOEXEC 17" >> "${S}"/rtld-elf/rtld.h
+ # taken from sys/sys/cdefs.h
+ echo '#define __compiler_membar() __asm __volatile(" " : : : "memory")' >> "${S}"/rtld-elf/rtld.h
+ # taken from sys/sys/mman.h
+ echo '#define MAP_ALIGNED(n) ((n) << MAP_ALIGNMENT_SHIFT)' >> "${S}"/rtld-elf/rtld.h
+ echo '#define MAP_ALIGNMENT_SHIFT 24' >> "${S}"/rtld-elf/rtld.h
+ echo '#define MAP_ALIGNMENT_MASK MAP_ALIGNED(0xff)' >> "${S}"/rtld-elf/rtld.h
+ echo '#define MAP_ALIGNED_SUPER MAP_ALIGNED(1)' >> "${S}"/rtld-elf/rtld.h
+ fi
+}
+
+setup_multilib_vars() {
+ if ! multilib_is_native_abi ; then
+ cd "${WORKDIR}/libexec/rtld-elf" || die
+ export mymakeopts="${mymakeopts} PROG=ld-elf32.so.1"
+ else
+ cd "${S}" || die
+ fi
+ "$@"
+}
+
+src_compile() {
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_compile
+}
+
+src_install() {
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_install
+
+ insinto /etc
+ doins "${WORKDIR}/etc/gettytab"
+ newinitd "${FILESDIR}/bootpd.initd" bootpd
+ newconfd "${FILESDIR}/bootpd.confd" bootpd
+
+ if use xinetd; then
+ for rpcd in rstatd rusersd walld rquotad sprayd; do
+ insinto /etc/xinetd.d
+ newins "${FILESDIR}/${rpcd}.xinetd" ${rpcd}
+ done
+ fi
+}
diff --git a/sys-freebsd/freebsd-libexec/metadata.xml b/sys-freebsd/freebsd-libexec/metadata.xml
new file mode 100644
index 0000000..a00f3ae
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+</maintainer>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.2-gnu.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.2-gnu.patch
new file mode 100644
index 0000000..b88fde2
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.2-gnu.patch
@@ -0,0 +1,63 @@
+diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
+index 80549d8..fd2aac5 100644
+--- a/share/mk/bsd.lib.mk
++++ b/share/mk/bsd.lib.mk
+@@ -173,7 +173,7 @@ _LIBS= lib${LIB}.a
+ lib${LIB}.a: ${OBJS} ${STATICOBJS}
+ @${ECHO} building static ${LIB} library
+ @rm -f ${.TARGET}
+- @${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
++ @${AR} ${ARFLAGS} ${.TARGET} ${OBJS} ${STATICOBJS} ${ARADD}
+ ${RANLIB} ${RANLIBFLAGS} ${.TARGET}
+ .endif
+
+@@ -186,7 +186,7 @@ POBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=.po}
+ lib${LIB}_p.a: ${POBJS}
+ @${ECHO} building profiled ${LIB} library
+ @rm -f ${.TARGET}
+- @${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' lorder ${POBJS} | tsort -q` ${ARADD}
++ @${AR} ${ARFLAGS} ${.TARGET} {POBJS} ${ARADD}
+ ${RANLIB} ${RANLIBFLAGS} ${.TARGET}
+ .endif
+
+@@ -215,7 +215,7 @@ ${SHLIB_NAME_FULL}: ${SOBJS}
+ .endif
+ ${_LD} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
+ -o ${.TARGET} -Wl,-soname,${SONAME} \
+- `NM='${NM}' lorder ${SOBJS} | tsort -q` ${LDADD}
++ `echo ${SOBJS} | xargs -n 1 echo | sort -u` ${LDADD}
+ .if ${MK_CTF} != "no"
+ ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}
+ .endif
+@@ -273,13 +273,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 19ad99f..46c4b09 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-10.3-gentoo.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.3-gentoo.patch
new file mode 100644
index 0000000..cdc244d
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.3-gentoo.patch
@@ -0,0 +1,337 @@
+diff --git a/share/mk/bsd.doc.mk b/share/mk/bsd.doc.mk
+index a8aa595..476b33b 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:
+ .if ${PRINTERDEVICE:Mhtml}
+ cd ${SRCDIR}; \
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}; \
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DOC}*.html ${DESTDIR}${BINDIR}/${VOLUME}
+ .endif
+ .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 183cb1c..5b57594 100644
+--- a/share/mk/bsd.files.mk
++++ b/share/mk/bsd.files.mk
+@@ -40,6 +40,7 @@ ${group}NAME_${file:T}?= ${file:T}
+ .endif
+ installfiles-${group}: _${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} \
+@@ -52,10 +53,12 @@ _${group}FILES+= ${file}
+ installfiles-${group}: _${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 b938221..6b98e72 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 6275ce3..8d32289 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 c753afe..14f74aa 100644
+--- a/share/mk/bsd.lib.mk
++++ b/share/mk/bsd.lib.mk
+@@ -46,8 +46,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) && \
+@@ -296,14 +294,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}
+@@ -357,10 +358,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 c097c77..c2994d8 100644
+--- a/share/mk/bsd.libnames.mk
++++ b/share/mk/bsd.libnames.mk
+@@ -51,7 +51,7 @@ LIBELF?= ${DESTDIR}${LIBDIR}/libelf.a
+ LIBEXECINFO?= ${DESTDIR}${LIBDIR}/libexecinfo.a
+ LIBFETCH?= ${DESTDIR}${LIBDIR}/libfetch.a
+ LIBFIGPAR?= ${DESTDIR}${LIBDIR}/libfigpar.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
+@@ -81,7 +81,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 574f0f5..b63b117 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 0212d3a..6435936 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 28255ea..2bc6546 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 73de02d..c6c30ca 100644
+--- a/share/mk/bsd.own.mk
++++ b/share/mk/bsd.own.mk
+@@ -206,9 +206,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 d6d0fa5..93a9046 100644
+--- a/share/mk/bsd.prog.mk
++++ b/share/mk/bsd.prog.mk
+@@ -42,10 +42,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
+@@ -200,6 +196,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"
+@@ -233,6 +230,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 fee6ccc..c2fe39a 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
+@@ -102,10 +98,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 c270260..68491ce 100644
+--- a/share/mk/sys.mk
++++ b/share/mk/sys.mk
+@@ -327,12 +327,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-8.0-gentoo.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gentoo.patch
new file mode 100644
index 0000000..f17f6c4
--- /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 0000000..41c4de4
--- /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 0000000..598d0b9
--- /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 0000000..f986ed9
--- /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 0000000..8eb80c3
--- /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-11.0.ebuild b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-11.0.ebuild
new file mode 100644
index 0000000..571e0f8
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-11.0.ebuild
@@ -0,0 +1,42 @@
+# Copyright 1999-2016 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.3-gentoo.patch"
+ epatch "${FILESDIR}/${PN}-add-nossp-cflags.patch"
+ use userland_GNU && epatch "${FILESDIR}/${PN}-10.2-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 0000000..a00f3ae
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+</maintainer>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-pam-modules/files/README.pamd b/sys-freebsd/freebsd-pam-modules/files/README.pamd
new file mode 100644
index 0000000..10da6cc
--- /dev/null
+++ b/sys-freebsd/freebsd-pam-modules/files/README.pamd
@@ -0,0 +1,63 @@
+/etc/pam.d
+
+This directory contains configuration files for the Pluggable
+Authentication Modules (PAM) library.
+
+Each file details the module chain for a single service, and must be
+named after that service. If no configuration file is found for a
+particular service, the /etc/pam.d/other is used instead. If that
+file does not exist, /etc/pam.conf is searched for entries matching
+the specified service or, failing that, the "other" service.
+
+See the pam(8) manual page for an explanation of the workings of the
+PAM library and descriptions of the various files and modules. Below
+is a summary of the format for the pam.conf and /etc/pam.d/* files.
+
+Configuration lines take the following form:
+
+module-type control-flag module-path arguments
+
+Comments are introduced with a hash mark ('#'). Blank lines and lines
+consisting entirely of comments are ignored.
+
+The meanings of the different fields are as follows:
+
+ module-type:
+ auth: prompt for a password to authenticate that the user is
+ who they say they are, and set any credentials.
+ account: non-authentication based authorization, based on time,
+ resources, etc.
+ session: housekeeping before and/or after login.
+ password: update authentication tokens.
+
+ control-flag: How libpam handles success or failure of the module.
+ required: success is required; on failure all remaining
+ modules are run, but the request will be denied.
+ requisite: success is required, and on failure no remaining
+ modules are run.
+ sufficient: success is sufficient, and if no previous required
+ module failed, no remaining modules are run.
+ binding: success is sufficient; on failure all remaining
+ modules are run, but the request will be denied.
+ optional: ignored unless the other modules return PAM_IGNORE.
+
+ arguments: Module-specific options, plus some generic ones:
+ debug: syslog debug info.
+ no_warn: return no warning messages to the application.
+ Remove this to feed back to the user the
+ reason(s) they are being rejected.
+ use_first_pass: try authentication using password from the
+ preceding auth module.
+ try_first_pass: first try authentication using password from
+ the preceding auth module, and if that fails
+ prompt for a new password.
+ use_mapped_pass: convert cleartext password to a crypto key.
+ expose_account: allow printing more info about the user when
+ prompting.
+
+Note that having a "sufficient" module as the last entry for a
+particular service and module type may result in surprising behaviour.
+To get the intended semantics, add a "required" entry listing the
+pam_deny module at the end of the chain.
+
+$Id$
diff --git a/sys-freebsd/freebsd-pam-modules/files/freebsd-pam-modules-6.0-gentoo.patch b/sys-freebsd/freebsd-pam-modules/files/freebsd-pam-modules-6.0-gentoo.patch
new file mode 100644
index 0000000..ce1a7fb
--- /dev/null
+++ b/sys-freebsd/freebsd-pam-modules/files/freebsd-pam-modules-6.0-gentoo.patch
@@ -0,0 +1,24 @@
+Index: fbsd-6.0/lib/libpam/modules/Makefile.inc
+===================================================================
+--- fbsd-6.0.orig/lib/libpam/modules/Makefile.inc
++++ fbsd-6.0/lib/libpam/modules/Makefile.inc
+@@ -5,18 +5,10 @@ PAMDIR= ${.CURDIR}/../../../../contrib/
+ NO_INSTALLLIB=
+ NO_PROFILE=
+
+-CFLAGS+= -I${PAMDIR}/include -I${.CURDIR}/../../libpam
++CFLAGS+= -I${.CURDIR}/../../libpam
+ WARNS?= 4
+
+-# This is nasty.
+-# For the static case, libpam.a depends on the modules.
+-# For the dynamic case, the modules depend on libpam.so.N
+-.if defined(_NO_LIBPAM_SO_YET)
+-NO_PIC=
+-.else
+ SHLIB_NAME?= ${LIB}.so.${SHLIB_MAJOR}
+-DPADD+= ${LIBPAM}
+ LDADD+= -lpam
+-.endif
+
+ .include "../Makefile.inc"
diff --git a/sys-freebsd/freebsd-pam-modules/files/freebsd-pam-modules-9.0-gentoo.patch b/sys-freebsd/freebsd-pam-modules/files/freebsd-pam-modules-9.0-gentoo.patch
new file mode 100644
index 0000000..aa08d40
--- /dev/null
+++ b/sys-freebsd/freebsd-pam-modules/files/freebsd-pam-modules-9.0-gentoo.patch
@@ -0,0 +1,22 @@
+--- lib/libpam/modules/Makefile.inc.old 2011-11-02 20:46:56.000000000 +0000
++++ lib/libpam/modules/Makefile.inc 2011-11-02 20:47:16.000000000 +0000
+@@ -5,18 +5,10 @@
+ NO_INSTALLLIB=
+ NO_PROFILE=
+
+-CFLAGS+= -I${PAMDIR}/include -I${.CURDIR}/../../libpam
++CFLAGS+= -I${.CURDIR}/../../libpam
+
+-# This is nasty.
+-# For the static case, libpam.a depends on the modules.
+-# For the dynamic case, the modules depend on libpam.so.N
+-.if defined(_NO_LIBPAM_SO_YET)
+-NO_PIC=
+-.else
+ SHLIB_NAME?= ${LIB}.so.${SHLIB_MAJOR}
+-DPADD+= ${LIBPAM}
+ LDADD+= -lpam
+-.endif
+
+ .c.o:
+ ${CC} ${CFLAGS} -DOPENPAM_STATIC_MODULES -c ${.IMPSRC}
diff --git a/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-11.0.ebuild b/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-11.0.ebuild
new file mode 100644
index 0000000..62a7b3e
--- /dev/null
+++ b/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-11.0.ebuild
@@ -0,0 +1,48 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit bsdmk freebsd multilib pam
+
+DESCRIPTION="FreeBSD's PAM authentication modules"
+SLOT="0"
+
+IUSE="kerberos nis"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="lib/"
+
+RDEPEND=">=sys-auth/openpam-20050201-r1
+ kerberos? ( dev-libs/openssl:0=
+ virtual/krb5 )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+
+S=${WORKDIR}/lib/libpam/modules
+
+PATCHES=( "${FILESDIR}"/${PN}-9.0-gentoo.patch )
+
+pkg_setup() {
+ # Avoid installing pam_ssh as that has its own ebuild.
+ mymakeopts="${mymakeopts} WITHOUT_OPENSSH= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+}
+
+src_prepare() {
+ for module in pam_deny pam_passwdqc pam_permit pam_krb5; do
+ sed -i -e "s:${module}::" "${S}"/modules.inc || die
+ done
+}
+
+src_install() {
+ mkinstall "LIBDIR=/$(get_libdir)/security" || die "install failed"
+
+ dodoc "${FILESDIR}/README.pamd"
+}
diff --git a/sys-freebsd/freebsd-pam-modules/metadata.xml b/sys-freebsd/freebsd-pam-modules/metadata.xml
new file mode 100644
index 0000000..a00f3ae
--- /dev/null
+++ b/sys-freebsd/freebsd-pam-modules/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+</maintainer>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-10.0-libevent.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-10.0-libevent.patch
new file mode 100644
index 0000000..57474ea
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-10.0-libevent.patch
@@ -0,0 +1,16 @@
+diff --git a/usr.sbin/ftp-proxy/ftp-proxy/Makefile b/usr.sbin/ftp-proxy/ftp-proxy/Makefile
+index de49888..2ab32fb 100644
+--- a/usr.sbin/ftp-proxy/ftp-proxy/Makefile
++++ b/usr.sbin/ftp-proxy/ftp-proxy/Makefile
+@@ -7,10 +7,7 @@ MAN= ftp-proxy.8
+
+ SRCS= ftp-proxy.c filter.c
+
+-CFLAGS+= -I${.CURDIR}/../../../contrib/pf/libevent
+-
+-LDADD+= ${LIBEVENT}
+-DPADD+= ${LIBEVENT}
++LDADD+= -levent
+
+ WARNS?= 3
+
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-10.0-pflogd.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-10.0-pflogd.patch
new file mode 100644
index 0000000..1316d3b
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-10.0-pflogd.patch
@@ -0,0 +1,15 @@
+diff --git a/sbin/pflogd/Makefile b/sbin/pflogd/Makefile
+index fcff8eb..0da383d 100644
+--- a/sbin/pflogd/Makefile
++++ b/sbin/pflogd/Makefile
+@@ -6,10 +6,7 @@ PROG= pflogd
+ SRCS= pflogd.c pidfile.c privsep.c privsep_fdpass.c
+ MAN= pflogd.8
+
+-CFLAGS+=-include ${.CURDIR}/../../lib/libpcap/config.h
+-
+ LDADD= -lpcap
+-DPADD= ${LIBPCAP}
+
+ WARNS?= 2
+
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-7.0-libevent.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-7.0-libevent.patch
new file mode 100644
index 0000000..1425db2
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-7.0-libevent.patch
@@ -0,0 +1,12 @@
+--- usr.sbin/ftp-proxy/ftp-proxy/Makefile.orig 2008-06-14 00:01:52 -0300
++++ usr.sbin/ftp-proxy/ftp-proxy/Makefile 2008-06-14 00:03:19 -0300
+@@ -10,8 +10,7 @@
+ CFLAGS+= -I${.CURDIR}/../../../contrib/pf/libevent
+ CFLAGS+= -I${.CURDIR}/../../../sys/contrib/pf
+
+-DPADD= ${LIBEVENT}
+-LDADD= ${LIBEVENT}
++LDADD= -levent
+
+ WARNS?= 2
+
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-7.0-pcap_pollution.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-7.0-pcap_pollution.patch
new file mode 100644
index 0000000..4a7c2e9
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-7.0-pcap_pollution.patch
@@ -0,0 +1,18 @@
+--- contrib/pf/pflogd/privsep.c.orig 2007-07-03 09:30:02 -0300
++++ contrib/pf/pflogd/privsep.c 2008-06-13 23:55:39 -0300
+@@ -31,13 +31,14 @@
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <limits.h>
++#include <stdio.h>
++#define HAVE_SNPRINTF
+ #ifndef __FreeBSD__
+ #include <pcap.h>
+ #include <pcap-int.h>
+ #endif
+ #include <pwd.h>
+ #include <signal.h>
+-#include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #ifdef __FreeBSD__
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-bpf.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-bpf.patch
new file mode 100644
index 0000000..fb3c701
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-bpf.patch
@@ -0,0 +1,10 @@
+--- contrib/pf/pflogd/pflogd.c.old 2011-11-02 21:12:57.000000000 +0000
++++ contrib/pf/pflogd/pflogd.c 2011-11-02 21:13:11.000000000 +0000
+@@ -39,6 +39,7 @@
+ #include <sys/stat.h>
+ #include <sys/socket.h>
+ #include <net/if.h>
++#include <net/bpf.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-getline.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-getline.patch
new file mode 100644
index 0000000..6679d32
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-getline.patch
@@ -0,0 +1,38 @@
+--- contrib/pf/ftp-proxy/ftp-proxy.c.old 2011-11-02 21:18:19.000000000 +0000
++++ contrib/pf/ftp-proxy/ftp-proxy.c 2011-11-02 21:18:36.000000000 +0000
+@@ -103,7 +103,7 @@
+ int drop_privs(void);
+ void end_session(struct session *);
+ void exit_daemon(void);
+-int getline(char *, size_t *);
++int ftpgetline(char *, size_t *);
+ void handle_connection(const int, short, void *);
+ void handle_signal(int, short, void *);
+ struct session * init_session(void);
+@@ -249,7 +249,7 @@
+ buf_avail);
+ s->cbuf_valid += clientread;
+
+- while ((n = getline(s->cbuf, &s->cbuf_valid)) > 0) {
++ while ((n = ftpgetline(s->cbuf, &s->cbuf_valid)) > 0) {
+ logmsg(LOG_DEBUG, "#%d client: %s", s->id, linebuf);
+ if (!client_parse(s)) {
+ end_session(s);
+@@ -343,7 +343,7 @@
+ }
+
+ int
+-getline(char *buf, size_t *valid)
++ftpgetline(char *buf, size_t *valid)
+ {
+ size_t i;
+
+@@ -1087,7 +1087,7 @@
+ buf_avail);
+ s->sbuf_valid += srvread;
+
+- while ((n = getline(s->sbuf, &s->sbuf_valid)) > 0) {
++ while ((n = ftpgetline(s->sbuf, &s->sbuf_valid)) > 0) {
+ logmsg(LOG_DEBUG, "#%d server: %s", s->id, linebuf);
+ if (!server_parse(s)) {
+ end_session(s);
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-libevent.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-libevent.patch
new file mode 100644
index 0000000..e488423
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-libevent.patch
@@ -0,0 +1,15 @@
+--- usr.sbin/ftp-proxy/ftp-proxy/Makefile.old 2011-11-02 20:57:03.000000000 +0000
++++ usr.sbin/ftp-proxy/ftp-proxy/Makefile 2011-11-02 20:57:21.000000000 +0000
+@@ -7,11 +7,9 @@
+
+ SRCS= ftp-proxy.c filter.c
+
+-CFLAGS+= -I${.CURDIR}/../../../contrib/pf/libevent
+ CFLAGS+= -I${.CURDIR}/../../../sys/contrib/pf
+
+-LDADD+= ${LIBEVENT}
+-DPADD+= ${LIBEVENT}
++LDADD+= -levent
+
+ WARNS?= 3
+
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-pcap_pollution.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-pcap_pollution.patch
new file mode 100644
index 0000000..184ab6f
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-pcap_pollution.patch
@@ -0,0 +1,17 @@
+--- contrib/pf/pflogd/privsep.c.old 2011-11-02 21:04:01.000000000 +0000
++++ contrib/pf/pflogd/privsep.c 2011-11-02 21:04:27.000000000 +0000
+@@ -32,11 +32,13 @@
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <limits.h>
++#include <stdio.h>
++#define HAVE_SNPRINTF
++#define HAVE_STRLCPY
+ #include <pcap.h>
+ #include <pcap-int.h>
+ #include <pwd.h>
+ #include <signal.h>
+-#include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <syslog.h>
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-pflogd.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-pflogd.patch
new file mode 100644
index 0000000..d5a65ea
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-pflogd.patch
@@ -0,0 +1,13 @@
+--- sbin/pflogd/Makefile.old 2011-11-02 21:08:46.000000000 +0000
++++ sbin/pflogd/Makefile 2011-11-02 21:08:53.000000000 +0000
+@@ -6,10 +6,7 @@
+ SRCS= pflogd.c pidfile.c privsep.c privsep_fdpass.c
+ MAN= pflogd.8
+
+-CFLAGS+=-include ${.CURDIR}/../../lib/libpcap/config.h
+-
+ LDADD= -lpcap
+-DPADD= ${LIBPCAP} ${LIBUTIL}
+
+ WARNS?= 2
+
diff --git a/sys-freebsd/freebsd-pf/files/pf.confd b/sys-freebsd/freebsd-pf/files/pf.confd
new file mode 100644
index 0000000..87c21b2
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/pf.confd
@@ -0,0 +1,9 @@
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# Defines where the rules file is found, by default /etc/pf.conf
+# pf_conf=/etc/pf.conf
+
+# Extra options to pass to pfctl when loading the rules
+# See pfctl(8)
+# pf_args=
diff --git a/sys-freebsd/freebsd-pf/files/pf.initd b/sys-freebsd/freebsd-pf/files/pf.initd
new file mode 100644
index 0000000..38ee4ea
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/pf.initd
@@ -0,0 +1,50 @@
+#!/sbin/openrc-run
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+depend() {
+ need net
+}
+
+checkconfig() {
+ if ! [ -c /dev/pf ]; then
+ ewarn "Pseudo-device /dev/pf not found."
+
+ ebegin "Loading pf module"
+ if ! kldload pf; then
+ eerror "Unable to load pf module."
+ eend 1
+ return 1
+ fi
+ eend $?
+
+ if ! [ -c /dev/pf ]; then
+ eerror "Pseudo-device /dev/pf still not found."
+ return 1
+ fi
+ fi
+
+ return 0
+}
+
+start() {
+ checkconfig || return 1
+
+ einfo "Starting firewall"
+
+ if [ -r "${PF_RULES_FILE}" ]; then
+ einfo "Loading firewall rules"
+ /sbin/pfctl -qe -f ${PF_RULES_FILE:-/etc/pf.conf} ${PF_OPTS}
+ else
+ /sbin/pfctl -qe ${PF_OPTS}
+ fi
+
+ eend $?
+}
+
+stop() {
+ einfo "Stopping firewall"
+ /sbin/pfctl -qd || retval=1
+ eend $?
+}
diff --git a/sys-freebsd/freebsd-pf/freebsd-pf-11.0.ebuild b/sys-freebsd/freebsd-pf/freebsd-pf-11.0.ebuild
new file mode 100644
index 0000000..14efdcb
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/freebsd-pf-11.0.ebuild
@@ -0,0 +1,73 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit bsdmk freebsd user
+
+DESCRIPTION="FreeBSD's base system libraries"
+SLOT="0"
+
+IUSE=""
+
+# Crypto is needed to have an internal OpenSSL header
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ usr.sbin/
+ sbin/
+ contrib/pf/
+ etc/
+"
+
+RDEPEND="net-libs/libpcap"
+DEPEND="${RDEPEND}
+ dev-libs/libevent
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+
+S="${WORKDIR}"
+
+SUBDIRS="usr.sbin/authpf sbin/pfctl sbin/pflogd usr.sbin/ftp-proxy/ftp-proxy"
+
+pkg_setup() {
+ enewgroup authpf 63
+ mymakeopts="${mymakeopts} NO_MANCOMPRESS= NO_INFOCOMPRESS= "
+}
+
+src_prepare() {
+ # pcap-int.h redefines snprintf as pcap_snprintf
+ epatch "${FILESDIR}/${PN}-9.0-pcap_pollution.patch"
+ # Use system's libevent
+ epatch "${FILESDIR}/${PN}-10.0-libevent.patch"
+ epatch "${FILESDIR}/${PN}-10.0-pflogd.patch"
+ epatch "${FILESDIR}/${PN}-9.0-bpf.patch"
+ epatch "${FILESDIR}/${PN}-9.0-getline.patch"
+ # Link in kernel sources
+ [[ ! -e "${WORKDIR}/sys" ]] && ln -s "/usr/src/sys" "${WORKDIR}/sys"
+}
+
+src_compile() {
+ for dir in ${SUBDIRS}; do
+ einfo "Starting make in ${dir}"
+ cd "${S}/${dir}" || die
+ mkmake || die "Make ${dir} failed"
+ done
+}
+
+src_install() {
+ for dir in ${SUBDIRS}; do
+ einfo "Starting install in ${dir}"
+ cd "${S}/${dir}" || die
+ mkinstall || die "Install ${dir} failed"
+ done
+
+ cd "${WORKDIR}"/etc
+ insinto /etc
+ doins pf.os
+ # pf.initd provided by openrc, but no pf.confd
+ newconfd "${FILESDIR}/pf.confd" pf
+}
diff --git a/sys-freebsd/freebsd-pf/metadata.xml b/sys-freebsd/freebsd-pf/metadata.xml
new file mode 100644
index 0000000..a00f3ae
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+</maintainer>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-rescue-10.0-zlib.patch b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-10.0-zlib.patch
new file mode 100644
index 0000000..42165c4
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-10.0-zlib.patch
@@ -0,0 +1,22 @@
+diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
+index 13c0d43..1f258f3 100644
+--- a/sbin/savecore/savecore.c
++++ b/sbin/savecore/savecore.c
+@@ -92,7 +92,7 @@ static int checkfor, compress, clear, force, keep, verbose; /* flags */
+ static int nfound, nsaved, nerr; /* statistics */
+ static int maxdumps;
+
+-extern FILE *zopen(const char *, const char *);
++extern FILE *gzopen(const char *, const char *);
+
+ static sig_atomic_t got_siginfo;
+ static void infohandler(int);
+@@ -626,7 +626,7 @@ DoFile(const char *savedir, const char *device)
+ if (compress) {
+ snprintf(corename, sizeof(corename), "%s.%d.gz",
+ istextdump ? "textdump.tar" : "vmcore", bounds);
+- fp = zopen(corename, "w");
++ fp = gzopen(corename, "w");
+ } else {
+ snprintf(corename, sizeof(corename), "%s.%d",
+ istextdump ? "textdump.tar" : "vmcore", bounds);
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-rescue-7.1-zlib.patch b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-7.1-zlib.patch
new file mode 100644
index 0000000..22fb2ec
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-7.1-zlib.patch
@@ -0,0 +1,21 @@
+diff -ur sbin/savecore/savecore.c sbin-zlib/savecore/savecore.c
+--- sbin/savecore/savecore.c 2005-02-26 01:21:50 +0000
++++ sbin-zlib/savecore/savecore.c 2005-05-06 12:00:06 +0000
+@@ -95,7 +95,7 @@
+ static int checkfor, compress, clear, force, keep, verbose; /* flags */
+ static int nfound, nsaved, nerr; /* statistics */
+
+-extern FILE *zopen(const char *, const char *);
++extern FILE *gzopen(const char *, const char *);
+
+ static void
+ printheader(FILE *f, const struct kerneldumpheader *h, const char *device,
+@@ -553,7 +553,7 @@
+ if (compress) {
+ sprintf(filename, "%s.%d.gz", istextdump ? "textdump.tar" :
+ "vmcore", bounds);
+- fp = zopen(filename, "w");
++ fp = gzopen(filename, "w");
+ } else {
+ sprintf(filename, "%s.%d", istextdump ? "textdump.tar" :
+ "vmcore", bounds);
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-rescue-8.0-pkgconfig_static_libarchive.patch b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-8.0-pkgconfig_static_libarchive.patch
new file mode 100644
index 0000000..7d12621
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-8.0-pkgconfig_static_libarchive.patch
@@ -0,0 +1,11 @@
+--- rescue/rescue/Makefile.old 2010-03-12 12:14:17 +0100
++++ rescue/rescue/Makefile 2010-03-12 12:14:47 +0100
+@@ -209,7 +209,7 @@
+ CRUNCH_LIBS+= -lbz2
+
+ CRUNCH_PROGS_usr.bin+= tar
+-CRUNCH_LIBS+= -larchive -lmd
++CRUNCH_LIBS+= `pkg-config --static --libs libarchive` -lmd
+ .if ${MK_OPENSSL} != "no"
+ CRUNCH_LIBS+= -lcrypto
+ .endif
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-rescue-8.2-libzcleverlink.patch b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-8.2-libzcleverlink.patch
new file mode 100644
index 0000000..3d44457
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-8.2-libzcleverlink.patch
@@ -0,0 +1,20 @@
+--- rescue/rescue/Makefile.old 2011-07-06 01:35:13.000000000 +0000
++++ rescue/rescue/Makefile 2011-07-06 01:35:54.000000000 +0000
+@@ -143,7 +143,7 @@
+ .if ${MK_ZFS} != "no"
+ CRUNCH_LIBS+= -lzfs -lnvpair -luutil -lavl
+ .endif
+-CRUNCH_LIBS+= -lgeom -lbsdxml -ljail -lkiconv -lmd -lreadline -lsbuf -lufs -lz
++CRUNCH_LIBS+= -lgeom -lbsdxml -ljail -lkiconv -lmd -lreadline -lsbuf -lufs
+
+ .if ${MACHINE_ARCH} == "i386"
+ CRUNCH_PROGS_sbin+= bsdlabel sconfig fdisk
+@@ -234,7 +234,7 @@
+ CRUNCH_PROGS_usr.sbin+= chown
+ CRUNCH_ALIAS_chown= chgrp
+ ##################################################################
+-CRUNCH_LIBS+= -lm
++CRUNCH_LIBS+= -lz -lm
+
+ ##################################################################
+ # The following is pretty nearly a generic crunchgen-handling makefile
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-rescue-9.1-bsdtar.patch b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-9.1-bsdtar.patch
new file mode 100644
index 0000000..d4d23d7
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-9.1-bsdtar.patch
@@ -0,0 +1,12 @@
+diff -Nur work.orig/contrib/libarchive/tar/bsdtar.c work/contrib/libarchive/tar/bsdtar.c
+--- work.orig/contrib/libarchive/tar/bsdtar.c 2012-07-12 13:44:29.000000000 +0900
++++ work/contrib/libarchive/tar/bsdtar.c 2012-07-29 00:57:25.000000000 +0900
+@@ -691,7 +691,7 @@
+ {
+ printf("bsdtar %s - %s\n",
+ BSDTAR_VERSION_STRING,
+- archive_version());
++ archive_version_string());
+ exit(0);
+ }
+
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-rescue-9.1-libcleverlink.patch b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-9.1-libcleverlink.patch
new file mode 100644
index 0000000..a194397
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-9.1-libcleverlink.patch
@@ -0,0 +1,21 @@
+diff -Nur work.orig/rescue/rescue/Makefile work/rescue/rescue/Makefile
+--- work.orig/rescue/rescue/Makefile 2012-07-29 00:50:20.000000000 +0900
++++ work/rescue/rescue/Makefile 2012-07-29 00:56:01.000000000 +0900
+@@ -125,7 +125,7 @@
+ .if ${MK_ZFS} != "no"
+ CRUNCH_LIBS+= -lavl -lnvpair -lpthread -lzfs -luutil -lumem
+ .endif
+-CRUNCH_LIBS+= -lgeom -lexpat -ljail -lkiconv -lmd -lreadline -lsbuf -lufs -lz
++CRUNCH_LIBS+= -lgeom -lexpat -ljail -lkiconv -lreadline -lsbuf -lufs
+
+ .if ${MACHINE_CPUARCH} == "i386"
+ CRUNCH_PROGS_sbin+= bsdlabel sconfig fdisk
+@@ -216,7 +216,7 @@
+ CRUNCH_PROGS_usr.sbin+= chown
+ CRUNCH_ALIAS_chown= chgrp
+ ##################################################################
+-CRUNCH_LIBS+= -lm
++CRUNCH_LIBS+= -lmd -lz -lm
+
+ .include <bsd.crunchgen.mk>
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-sbin-bsdxml2expat.patch b/sys-freebsd/freebsd-rescue/files/freebsd-sbin-bsdxml2expat.patch
new file mode 100644
index 0000000..bdda99b
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-sbin-bsdxml2expat.patch
@@ -0,0 +1,13 @@
+diff -uNr sbin/ifconfig.old/regdomain.c sbin/ifconfig/regdomain.c
+--- sbin/ifconfig.old/regdomain.c 2010-12-21 17:09:25.000000000 +0000
++++ sbin/ifconfig/regdomain.c 2011-07-10 15:56:27.000000000 +0000
+@@ -39,7 +39,7 @@
+ #include <err.h>
+ #include <unistd.h>
+
+-#include <bsdxml.h>
++#include <expat.h>
+
+ #include "regdomain.h"
+
+Los ficheros binarios sbin/ifconfig.old/regdomain.o y sbin/ifconfig/regdomain.o son distintos
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-ubin-10.2-bsdxml.patch b/sys-freebsd/freebsd-rescue/files/freebsd-ubin-10.2-bsdxml.patch
new file mode 100644
index 0000000..6064717
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-ubin-10.2-bsdxml.patch
@@ -0,0 +1,13 @@
+diff --git a/usr.bin/mt/mt.c b/usr.bin/mt/mt.c
+index af6562b..3121c81 100644
+--- a/usr.bin/mt/mt.c
++++ b/usr.bin/mt/mt.c
+@@ -92,7 +92,7 @@ __FBSDID("$FreeBSD: stable/10/usr.bin/mt/mt.c 280438 2015-03-24 14:36:10Z ken $"
+ #include <unistd.h>
+ #include <stdint.h>
+ #include <errno.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <mtlib.h>
+
+ #include <cam/cam.h>
diff --git a/sys-freebsd/freebsd-rescue/freebsd-rescue-11.0.ebuild b/sys-freebsd/freebsd-rescue/freebsd-rescue-11.0.ebuild
new file mode 100644
index 0000000..a0eb03f
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/freebsd-rescue-11.0.ebuild
@@ -0,0 +1,82 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit bsdmk freebsd toolchain-funcs
+
+DESCRIPTION="FreeBSD's rescue binaries"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+IUSE="atm netware nis zfs"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ usr.bin/
+ contrib/
+ lib/
+ bin/
+ sbin/
+ usr.sbin/
+ gnu/
+ sys/
+ libexec/
+ rescue/
+"
+
+RDEPEND=""
+DEPEND="sys-devel/flex
+ app-arch/xz-utils[static-libs]
+ sys-libs/ncurses[static-libs]
+ dev-libs/expat[static-libs]
+ app-arch/bzip2[static-libs]
+ dev-libs/libedit[static-libs]
+ dev-libs/libxml2:2[static-libs]
+ dev-libs/openssl:0=[static-libs]
+ sys-libs/zlib[static-libs]
+ sys-libs/readline[static-libs]
+ =sys-freebsd/freebsd-lib-${RV}*[atm?,netware?]
+ =sys-freebsd/freebsd-sources-${RV}*
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ zfs? ( =sys-freebsd/freebsd-cddl-${RV}* )"
+
+S="${WORKDIR}/rescue"
+
+pkg_setup() {
+ # Add the required source files.
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+ mymakeopts="${mymakeopts} NO_PIC= "
+}
+
+src_prepare() {
+ # As they are patches from ${WORKDIR} apply them by hand
+ cd "${WORKDIR}" || die
+ epatch "${FILESDIR}/${PN}"-10.0-zlib.patch
+ epatch "${FILESDIR}/freebsd-sbin-bsdxml2expat.patch"
+ epatch "${FILESDIR}/freebsd-ubin-10.2-bsdxml.patch"
+}
+
+src_compile() {
+ tc-export CC
+ # crunchgen is now checks env MAKE.
+ # Use to force BSD's make
+ export MAKE=/usr/bin/make
+
+ cd "${WORKDIR}/lib/libarchive" || die
+ echo "#include <expat.h>" > bsdxml.h
+ freebsd_src_compile
+ export CC="${CC} -L${WORKDIR}/lib/libarchive"
+
+ cd "${S}" || die
+ freebsd_src_compile
+}
diff --git a/sys-freebsd/freebsd-rescue/metadata.xml b/sys-freebsd/freebsd-rescue/metadata.xml
new file mode 100644
index 0000000..8703f7b
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/metadata.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+ </maintainer>
+ <use>
+ <flag name="zfs">Enable ZFS support.</flag>
+ <flag name="netware"> Build tools to work with NetWare protocols (IPX and NCP).</flag>
+ </use>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-sbin/files/adjkerntz-crontab b/sys-freebsd/freebsd-sbin/files/adjkerntz-crontab
new file mode 100644
index 0000000..5fc46f5
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/adjkerntz-crontab
@@ -0,0 +1,4 @@
+# Adjust the time zone if the CMOS clock keeps local time, as opposed to
+# UTC time. See adjkerntz(8) for details.
+1,31 0-5 * * * root /sbin/adjkerntz -a
+
diff --git a/sys-freebsd/freebsd-sbin/files/devd.conf b/sys-freebsd/freebsd-sbin/files/devd.conf
new file mode 100644
index 0000000..fd1e035
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/devd.conf
@@ -0,0 +1,153 @@
+# Refer to devd.conf(5) and devd(8) man pages for the details on how to
+# run and configure devd.
+#
+
+# NB: All regular expressions have an implicit ^$ around them.
+# NB: device-name is shorthand for 'match device-name'
+
+options {
+ # Each directory directive adds a directory the list of directories
+ # that we scan for files. Files are read-in in the order that they
+ # are returned from readdir(3). The rule-sets are combined to
+ # create a DFA that's used to match events to actions.
+ directory "/etc/devd";
+ directory "/usr/local/etc/devd";
+ pid-file "/var/run/devd.pid";
+
+ # Setup some shorthand for regex that we use later in the file.
+ #XXX Yes, these are gross -- imp
+ set scsi-controller-regex
+ "(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\
+ esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\
+ [0-9]+";
+};
+
+# Note that the attach/detach with the highest value wins, so that one can
+# override these general rules.
+
+#
+# For ethernet like devices start configuring the interface. Due to
+# a historical accident, this script is called pccard_ether.
+#
+attach 0 {
+ media-type "ethernet";
+ action "/etc/devd_queue add env IN_HOTPLUG=1 /etc/init.d/net.$device-name start";
+};
+
+detach 0 {
+ media-type "ethernet";
+ action "/etc/devd_queue add env IN_HOTPLUG=1 /etc/init.d/net.$device-name stop";
+};
+
+#
+# Try to start dhclient on Ethernet like interfaces when the link comes
+# up. Only devices that are configured to support DHCP will actually
+# run it. No link down rule exists because dhclient automaticly exits
+# when the link goes down.
+#
+notify 0 {
+ match "system" "IFNET";
+ match "type" "LINK_UP";
+ media-type "ethernet";
+ action "/etc/devd_queue add /etc/init.d/net.$subsystem start";
+};
+notify 0 {
+ match "system" "IFNET";
+ match "type" "LINK_DOWN";
+ media-type "ethernet";
+ action "/etc/devd_queue add /etc/init.d/net.$subsystem stop";
+};
+
+#
+# Like Ethernet devices, but separate because
+# they have a different media type. We may want
+# to exploit this later.
+#
+#detach 0 {
+# media-type "802.11";
+# action "env IN_HOTPLUG=1 /etc/init.d/net.$device-name stop";
+#};
+#attach 0 {
+# media-type "802.11";
+# action "env IN_HOTPLUG=1 /etc/init.d/net.$device-name start";
+#};
+
+# Not sure how to handle this in Gentoo yet
+# When a USB Bluetooth dongle appears activate it
+#attach 100 {
+# device-name "ubt[0-9]+";
+# action "/etc/rc.d/bluetooth start $device-name";
+#};
+#detach 100 {
+# device-name "ubt[0-9]+";
+# action "/etc/rc.d/bluetooth stop $device-name";
+#};
+
+# When a USB keyboard arrives, attach it as the console keyboard.
+attach 100 {
+ device-name "ukbd0";
+ action "kbdcontrol -k /dev/ukbd0 < /dev/console";
+};
+detach 100 {
+ device-name "ukbd0";
+ action "kbdcontrol -k /dev/kbd0 < /dev/console";
+};
+
+# The entry below starts and stops moused when a mouse is plugged in.
+attach 100 {
+ device-name "psm[0-9]+";
+ action "/etc/devd_queue add env IN_HOTPLUG=1 /etc/init.d/moused.$device-name start";
+};
+detach 100 {
+ device-name "psm[0-9]+";
+ action "/etc/devd_queue add env IN_HOTPLUG=1 /etc/init.d/moused.$device-name stop";
+};
+attach 100 {
+ device-name "ums[0-9]+";
+ action "/etc/devd_queue add env IN_HOTPLUG=1 /etc/init.d/moused.$device-name start";
+};
+detach 100 {
+ device-name "ums[0-9]+";
+ action "/etc/devd_queue add env IN_HOTPLUG=1 /etc/init.d/moused.$device-name stop";
+};
+
+# Notify all users before beginning emergency shutdown when we get
+# a _CRT or _HOT thermal event and we're going to power down the system
+# very soon.
+notify 10 {
+ match "system" "ACPI";
+ match "subsystem" "Thermal";
+ match "notify" "0xcc";
+ action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'";
+};
+
+/* EXAMPLES TO END OF FILE
+
+
+# Examples of notify hooks. A notify is a generic way for a kernel
+# subsystem to send event notification to userland.
+#
+# Here are some examples of ACPI notify handlers. ACPI subsystems that
+# generate notifies include the AC adapter, power/sleep buttons,
+# control method batteries, lid switch, and thermal zones.
+#
+# Information returned is not always the same as the ACPI notify
+# events. See the ACPI specification for more information about
+# notifies. Here is the information returned for each subsystem:
+#
+# ACAD: AC line state (0 is offline, 1 is online)
+# Button: Button pressed (0 for power, 1 for sleep)
+# CMBAT: ACPI battery events
+# Lid: Lid state (0 is closed, 1 is open)
+# Thermal: ACPI thermal zone events
+#
+# This example calls a script when the AC state changes, passing the
+# notify value as the first argument. If the state is 0x00, it might
+# call some sysctls to implement economy mode. If 0x01, it might set
+# the mode to performance.
+notify 10 {
+ match "system" "ACPI";
+ match "subsystem" "ACAD";
+ action "/etc/acpi_ac $notify";
+};
+*/
diff --git a/sys-freebsd/freebsd-sbin/files/devd.initd b/sys-freebsd/freebsd-sbin/files/devd.initd
new file mode 100644
index 0000000..6171258
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/devd.initd
@@ -0,0 +1,47 @@
+#!/sbin/openrc-run
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need localmount
+ after bootmisc hostname
+ before net
+}
+
+start() {
+ # Services may depend on us, so mark us as inactive
+ mark_service_inactive "${SVCNAME}"
+
+ # Create a queue so that if things went UP DOWN UP DOWN UP DOWN UP
+ # We just do an UP
+ # This is used by /etc/devd_queue
+ mkdir -p /var/run/devd
+
+ ebegin "Starting the Device State Change Daemon"
+ sysctl hw.bus.devctl_disable=0 >/dev/null
+ start-stop-daemon --start --exec /sbin/devd \
+ --pidfile /var/run/devd.pid
+ eend $? "Failed to start devd" \
+ || return $?
+
+ ebegin "Waiting for Device State Change Daemon to settle"
+ LC_ALL=C sleep "${DEVD_WAIT:-2}"
+ eend $?
+
+ # Now flush the queue
+ einfo "Flushing Device State Change Daemon queue"
+ /etc/devd_queue flush
+
+ mark_service_started "${SVCNAME}"
+ return 0
+}
+
+stop() {
+ ebegin "Stopping the Device State Change Daemon"
+ sysctl hw.bus.devctl_disable=1 >/dev/null
+ start-stop-daemon --stop --exec /sbin/devd \
+ --pidfile /var/run/devd.pid
+ eend $? "Failed to stop devd"
+}
+
+# vim: ts=4 :
diff --git a/sys-freebsd/freebsd-sbin/files/devd_queue b/sys-freebsd/freebsd-sbin/files/devd_queue
new file mode 100644
index 0000000..d42cb83
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/devd_queue
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# Notify the rc system that we're in the background
+export IN_BACKGROUND=true
+
+arg1="$1"
+if [ -z "$arg1" ] ; then
+ echo "Command required" > /dev/stderr
+ exit 1
+fi
+shift
+
+case "$arg1" in
+ add)
+ if [ -z "$1" ] ; then
+ echo "Command missing!" > /dev/stderr
+ exit 1
+ fi
+
+ # If we don't have a queue then just run
+ if [ ! -d /var/run/devd ] ; then
+ "$@"
+ exit $?
+ fi
+
+ cmd="$1"
+ args="$*"
+ if [ "$cmd" = "env" ] ; then
+ shift
+ while echo "$1" | grep -q "="; do
+ shift
+ [ "$1" = "--" ] && shift && break
+ done
+ cmd="$1"
+ fi
+ echo "$args" > /var/run/devd/$(basename "$cmd")
+ ;;
+ flush)
+ while ! rmdir /var/run/devd 2>/dev/null ; do
+ for cmd in $(cd /var/run/devd; ls) ; do
+ args=$(cat /var/run/devd/$cmd)
+ rm -f /var/run/devd/$cmd
+ $args
+ done
+ done
+ ;;
+ *)
+ echo "Unknown command $arg1"
+ ;;
+esac
diff --git a/sys-freebsd/freebsd-sbin/files/freebsd-sbin-10.0-zlib.patch b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-10.0-zlib.patch
new file mode 100644
index 0000000..c0a2bf9
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-10.0-zlib.patch
@@ -0,0 +1,22 @@
+diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
+index bdbf7e3..a4c67ec 100644
+--- a/sbin/savecore/savecore.c
++++ b/sbin/savecore/savecore.c
+@@ -92,7 +92,7 @@ static int checkfor, compress, clear, force, keep, verbose; /* flags */
+ static int nfound, nsaved, nerr; /* statistics */
+ static int maxdumps;
+
+-extern FILE *zopen(const char *, const char *);
++extern FILE *gzopen(const char *, const char *);
+
+ static sig_atomic_t got_siginfo;
+ static void infohandler(int);
+@@ -626,7 +626,7 @@ DoFile(const char *savedir, const char *device)
+ if (compress) {
+ snprintf(corename, sizeof(corename), "%s.%d.gz",
+ istextdump ? "textdump.tar" : "vmcore", bounds);
+- fp = zopen(corename, "w");
++ fp = gzopen(corename, "w");
+ } else {
+ snprintf(corename, sizeof(corename), "%s.%d",
+ istextdump ? "textdump.tar" : "vmcore", bounds);
diff --git a/sys-freebsd/freebsd-sbin/files/freebsd-sbin-6.1-pr102701.patch b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-6.1-pr102701.patch
new file mode 100644
index 0000000..7b9578c
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-6.1-pr102701.patch
@@ -0,0 +1,17 @@
+Solves the issue reported in Problem Report bin/102701.
+
+Can't delete an inet6 alias address from an interface.
+
+Index: fbsd-6.1/sbin/ifconfig/af_inet6.c
+===================================================================
+--- fbsd-6.1.orig/sbin/ifconfig/af_inet6.c
++++ fbsd-6.1/sbin/ifconfig/af_inet6.c
+@@ -515,7 +515,7 @@ static struct afswtch af_inet6 = {
+ .af_settunnel = in6_set_tunnel,
+ .af_difaddr = SIOCDIFADDR_IN6,
+ .af_aifaddr = SIOCAIFADDR_IN6,
+- .af_ridreq = &in6_addreq,
++ .af_ridreq = &in6_ridreq,
+ .af_addreq = &in6_addreq,
+ };
+
diff --git a/sys-freebsd/freebsd-sbin/files/freebsd-sbin-6.2-ldconfig.patch b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-6.2-ldconfig.patch
new file mode 100644
index 0000000..81ad024
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-6.2-ldconfig.patch
@@ -0,0 +1,13 @@
+diff -ur sbin.orig/ldconfig/elfhints.c sbin/ldconfig/elfhints.c
+--- sbin.orig/ldconfig/elfhints.c 2001-05-03 00:56:18 +0100
++++ sbin/ldconfig/elfhints.c 2007-08-06 10:16:24 +0100
+@@ -245,6 +245,9 @@
+ else
+ add_dir(hintsfile, argv[i], 0);
+ }
++ /* Always add our system dirs */
++ add_dir (hintsfile, "/lib", 1);
++ add_dir (hintsfile, "/usr/lib", 1);
+ write_elf_hints(hintsfile);
+ }
+
diff --git a/sys-freebsd/freebsd-sbin/files/freebsd-sbin-7.1-zlib.patch b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-7.1-zlib.patch
new file mode 100644
index 0000000..22fb2ec
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-7.1-zlib.patch
@@ -0,0 +1,21 @@
+diff -ur sbin/savecore/savecore.c sbin-zlib/savecore/savecore.c
+--- sbin/savecore/savecore.c 2005-02-26 01:21:50 +0000
++++ sbin-zlib/savecore/savecore.c 2005-05-06 12:00:06 +0000
+@@ -95,7 +95,7 @@
+ static int checkfor, compress, clear, force, keep, verbose; /* flags */
+ static int nfound, nsaved, nerr; /* statistics */
+
+-extern FILE *zopen(const char *, const char *);
++extern FILE *gzopen(const char *, const char *);
+
+ static void
+ printheader(FILE *f, const struct kerneldumpheader *h, const char *device,
+@@ -553,7 +553,7 @@
+ if (compress) {
+ sprintf(filename, "%s.%d.gz", istextdump ? "textdump.tar" :
+ "vmcore", bounds);
+- fp = zopen(filename, "w");
++ fp = gzopen(filename, "w");
+ } else {
+ sprintf(filename, "%s.%d", istextdump ? "textdump.tar" :
+ "vmcore", bounds);
diff --git a/sys-freebsd/freebsd-sbin/files/freebsd-sbin-bsdxml2expat.patch b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-bsdxml2expat.patch
new file mode 100644
index 0000000..bdda99b
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-bsdxml2expat.patch
@@ -0,0 +1,13 @@
+diff -uNr sbin/ifconfig.old/regdomain.c sbin/ifconfig/regdomain.c
+--- sbin/ifconfig.old/regdomain.c 2010-12-21 17:09:25.000000000 +0000
++++ sbin/ifconfig/regdomain.c 2011-07-10 15:56:27.000000000 +0000
+@@ -39,7 +39,7 @@
+ #include <err.h>
+ #include <unistd.h>
+
+-#include <bsdxml.h>
++#include <expat.h>
+
+ #include "regdomain.h"
+
+Los ficheros binarios sbin/ifconfig.old/regdomain.o y sbin/ifconfig/regdomain.o son distintos
diff --git a/sys-freebsd/freebsd-sbin/files/freebsd-sbin-setXid.patch b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-setXid.patch
new file mode 100644
index 0000000..c8cbebc
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-setXid.patch
@@ -0,0 +1,20 @@
+diff -ur sbin.orig/ping/Makefile sbin.setXid/ping/Makefile
+--- sbin.orig/ping/Makefile Thu Apr 7 20:27:57 2005
++++ sbin.setXid/ping/Makefile Thu Apr 7 20:42:02 2005
+@@ -18,4 +18,6 @@
+ LDADD+= -lipsec
+ .endif
+
++LDFLAGS+= -Wl,-z,now
++
+ .include <bsd.prog.mk>
+diff -ur sbin.orig/shutdown/Makefile sbin.setXid/shutdown/Makefile
+--- sbin.orig/shutdown/Makefile Thu Apr 7 20:27:57 2005
++++ sbin.setXid/shutdown/Makefile Thu Apr 7 20:42:17 2005
+@@ -7,4 +7,6 @@
+ BINGRP= operator
+ BINMODE=4550
+
++LDFLAGS+= -Wl,-z,now
++
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-sbin/files/idmapd.initd b/sys-freebsd/freebsd-sbin/files/idmapd.initd
new file mode 100644
index 0000000..60a0bb8
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/idmapd.initd
@@ -0,0 +1,20 @@
+#!/sbin/openrc-run
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need rpcbind
+}
+
+start() {
+ ebegin "Starting NFS idmapd"
+ start-stop-daemon --start --quiet --exec \
+ /sbin/idmapd -- $idmapdopts
+ eend $? "Error starting NFS idmapd"
+}
+
+stop() {
+ ebegin "Stopping NFS idmapd"
+ start-stop-daemon --stop --quiet --exec /sbin/idmapd
+ eend $? "Error stopping NFS idmapd"
+}
diff --git a/sys-freebsd/freebsd-sbin/files/ipfw.confd b/sys-freebsd/freebsd-sbin/files/ipfw.confd
new file mode 100644
index 0000000..687f92d
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/ipfw.confd
@@ -0,0 +1,10 @@
+# ipfw provides a stateful firewall.
+# This means we allow everything out, and if we have a connection we allow it
+# back in. This is very flexable and quite secure.
+
+# For ease of use, we allow auth and ssh ports through as well.
+# To override the list of allowed ports
+#PORTS_IN="auth ssh"
+
+# You may want to enable logging of denied connections
+#LOG_DENY="yes"
diff --git a/sys-freebsd/freebsd-sbin/files/ipfw.initd b/sys-freebsd/freebsd-sbin/files/ipfw.initd
new file mode 100644
index 0000000..13cdaee
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/ipfw.initd
@@ -0,0 +1,110 @@
+#!/sbin/openrc-run
+# Copyright 2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# This is a nice client firewall script which should suit most desktop users.
+# We allow auth and ssh in by default.
+
+PORTS_IN=${PORTS_IN-auth ssh}
+
+opts="panic showstatus"
+
+depend() {
+ before net
+ provide firewall
+}
+
+ipfw() {
+ /sbin/ipfw -f -q "$@"
+}
+
+init() {
+ # Load the kernel module
+ if ! sysctl net.inet.ip.fw.enable=1 >/dev/null 2>/dev/null ; then
+ if ! kldload ipfw ; then
+ eend 1 "Unable to load firewall module"
+ return 1
+ fi
+ fi
+
+ ipfw flush
+
+ ipfw add allow all from any to any via lo0
+ ipfw add allow all from any to 127.0.0.0/8
+ ipfw add deny ip from 127.0.0.0/8 to any
+
+ ipfw add allow ipv6-icmp from :: to ff02::/16
+ ipfw add allow ipv6-icmp from fe80::/10 to fe80::/10
+ ipfw add allow ipv6-icmp from fe80::/10 to ff02::/16
+}
+
+start() {
+ local x= log=
+ ebegin "Starting firewall rules"
+ if ! init ; then
+ eend 1 "Failed to flush firewall ruleset"
+ return 1
+ fi
+
+ [ "${LOG_DENY}" = "yes" ] && log="log"
+
+ # Use a statefull firewall
+ ipfw add check-state
+
+ # Open our configured ports
+ if [ -n "${PORTS_IN}" ] ; then
+ local pin=
+ for x in ${PORTS_IN} ; do
+ pin="${pin}${pin:+,}${x}"
+ done
+ ipfw add allow tcp from any to me ${pin} established keep-state
+ ipfw add allow tcp from any to me6 ${pin} established keep-state
+ ipfw add allow tcp from any to me ${pin} setup keep-state
+ ipfw add allow tcp from any to me6 ${pin} setup keep-state
+ ipfw add allow udp from any to me ${pin} established
+ ipfw add allow udp from any to me ${pin} keep-state
+ ipfw add allow udp from any to me6 ${pin} established
+ ipfw add allow udp from any to me6 ${pin} keep-state
+ fi
+
+ # Nice flexable rules that disallow incoming except for stuff we
+ # have asked for, and allow all outgoing.
+ ipfw add allow tcp from me to any established keep-state
+ ipfw add allow tcp from me to any setup keep-state
+ ipfw add allow tcp from me6 to any established keep-state
+ ipfw add allow tcp from me6 to any setup keep-state
+ ipfw add deny ${log} tcp from any to any
+ ipfw add allow udp from me to any established
+ ipfw add allow udp from me to any keep-state
+ ipfw add allow udp from me6 to any established
+ ipfw add allow udp from me6 to any keep-state
+ ipfw add deny ${log} udp from any to any
+
+ # Be a good firewall and allow some ICMP traffic.
+ # Remove 8 if you really want to disallow ping.
+ ipfw add allow icmp from any to any icmptypes 0,3,8,11,12
+ ipfw add allow ip6 from any to any proto ipv6-icmp
+
+ eend 0
+}
+
+stop() {
+ ebegin "Stopping firewall rules"
+ # We don't unload the kernel module as that action
+ # can cause memory leaks as of FreeBSD 6.x
+ sysctl net.inet.ip.fw.enable=0 >/dev/null
+ eend $?
+}
+
+panic() {
+ ebegin "Stopping firewall rules - hard"
+ if ! init ; then
+ eend 1 "Failed to flush firewall ruleset"
+ return 1
+ fi
+ eend 0
+}
+
+showstatus() {
+ ipfw show
+}
diff --git a/sys-freebsd/freebsd-sbin/files/sysctl.initd b/sys-freebsd/freebsd-sbin/files/sysctl.initd
new file mode 100644
index 0000000..9b8aaf8
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/sysctl.initd
@@ -0,0 +1,28 @@
+#!/sbin/openrc-run
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+depend() {
+ after checkroot root
+}
+
+start() {
+ ebegin "Configuring kernel parameters"
+
+ if [ ! -f /etc/sysctl.conf ]; then
+ eend 1 "/etc/sysctl.conf" "not found"
+ return 1
+ fi
+
+ local retval=0 var= comments=
+ while read var comments ; do
+ case "${var}" in
+ ""|"#"*) continue;;
+ esac
+ sysctl "${var}" >/dev/null || retval=1
+ done < /etc/sysctl.conf
+ eend ${retval} "Some errors were encountered"
+}
+
+# vim: set ts=4 :
diff --git a/sys-freebsd/freebsd-sbin/freebsd-sbin-11.0.ebuild b/sys-freebsd/freebsd-sbin/freebsd-sbin-11.0.ebuild
new file mode 100644
index 0000000..738e7a1
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/freebsd-sbin-11.0.ebuild
@@ -0,0 +1,101 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit bsdmk freebsd multilib
+
+DESCRIPTION="FreeBSD sbin utils"
+SLOT="0"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ sbin/
+ contrib/
+ lib/
+ libexec/
+ usr.sbin/
+ etc/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[ipv6?,atm?,netware?]
+ =sys-freebsd/freebsd-libexec-${RV}*
+ >=dev-libs/expat-2.0.1
+ ssl? ( dev-libs/openssl:0= )
+ >=dev-libs/libedit-20120311.3.0-r1
+ sys-libs/readline:0=
+ || (
+ sys-process/cronie
+ sys-process/vixie-cron
+ )
+ atm? ( net-analyzer/bsnmp )"
+DEPEND="${RDEPEND}
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+S="${WORKDIR}/sbin"
+
+IUSE="atm ipfilter +pf ipv6 build ssl +cxx netware"
+
+pkg_setup() {
+ # Add the required source files.
+ use build && EXTRACTONLY+="sys/ "
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use cxx || mymakeopts="${mymakeopts} WITHOUT_CXX="
+ use ipfilter || mymakeopts="${mymakeopts} WITHOUT_IPFILTER= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT="
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use pf || mymakeopts="${mymakeopts} WITHOUT_PF= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL="
+}
+
+REMOVE_SUBDIRS="dhclient pfctl pflogd rcorder resolvconf"
+
+PATCHES=( "${FILESDIR}/${PN}-setXid.patch"
+ "${FILESDIR}/${PN}-10.0-zlib.patch"
+ "${FILESDIR}/${PN}-6.2-ldconfig.patch"
+ "${FILESDIR}/${PN}-6.1-pr102701.patch"
+ "${FILESDIR}/${PN}-bsdxml2expat.patch" )
+
+src_prepare() {
+ if [[ ! -e "${WORKDIR}/sys" ]]; then
+ use build || ln -s "/usr/src/sys" "${WORKDIR}/sys"
+ fi
+}
+
+src_install() {
+ mymakeopts="${mymakeopts} GEOM_CLASS_DIR=/$(get_libdir)/geom "
+ freebsd_src_install
+ keepdir /var/log
+ # Needed by ldconfig:
+ keepdir /var/run
+
+ # Maybe ship our own sysctl.conf so things like radvd work out of the box.
+ # New wireless config method requires regdomain.xml in /etc
+ cd "${WORKDIR}/etc/" || die
+ insinto /etc
+ doins minfree sysctl.conf regdomain.xml || die
+
+ # Install a crontab for adjkerntz
+ insinto /etc/cron.d
+ newins "${FILESDIR}/adjkerntz-crontab" adjkerntz
+
+ # Install the periodic stuff (needs probably to be ported in a more
+ # gentooish way)
+ cd "${WORKDIR}/etc/periodic" || die
+
+ doperiodic security \
+ security/*.ipfwlimit \
+ security/*.ipfwdenied || die
+
+ use ipfilter && { doperiodic security \
+ security/*.ipfdenied || die ; }
+
+ use pf && { doperiodic security \
+ security/*.pfdenied || die ; }
+}
diff --git a/sys-freebsd/freebsd-sbin/metadata.xml b/sys-freebsd/freebsd-sbin/metadata.xml
new file mode 100644
index 0000000..dccfe68
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/metadata.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+ </maintainer>
+ <use>
+ <flag name="ipfilter">
+ Build tools to administer the ipfilter firewall.
+ </flag>
+ <flag name="pf">
+ Build tools to administer the PF firewall.
+ </flag>
+ <flag name="netware">
+ Build libraries and tools to work with NetWare protocols (IPX
+ and NCP).
+ </flag>
+ </use>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-share/files/freebsd-share-10.0-gentoo-eapi3.patch b/sys-freebsd/freebsd-share/files/freebsd-share-10.0-gentoo-eapi3.patch
new file mode 100644
index 0000000..1d0a53e
--- /dev/null
+++ b/sys-freebsd/freebsd-share/files/freebsd-share-10.0-gentoo-eapi3.patch
@@ -0,0 +1,17 @@
+diff --git a/share/i18n/esdb/Makefile.part b/share/i18n/esdb/Makefile.part
+index 9ca8577..329e9fb 100644
+--- a/share/i18n/esdb/Makefile.part
++++ b/share/i18n/esdb/Makefile.part
+@@ -13,10 +13,10 @@ PART!= sed '/^\#/d;/^ *$$/d' ${PARTFILE}
+ .endif
+ .if !defined(NO_EPREFIX)
+ CODESETS?= ${PART:C/^/${CODE}${SEP}/}
+-EPREFIX?= ${CODE}${SEP}
++EPREFIX= ${CODE}${SEP}
+ .else
+ CODESETS?= ${PART}
+-EPREFIX?=
++EPREFIX=
+ .endif
+ ESUBDIR?= ${CODE}
+ ESDB?= ${CODESETS:C/$/.esdb/:S/:/@/}
diff --git a/sys-freebsd/freebsd-share/files/freebsd-share-10.2-gnu-miscfiles.patch b/sys-freebsd/freebsd-share/files/freebsd-share-10.2-gnu-miscfiles.patch
new file mode 100644
index 0000000..1dc8488
--- /dev/null
+++ b/sys-freebsd/freebsd-share/files/freebsd-share-10.2-gnu-miscfiles.patch
@@ -0,0 +1,30 @@
+diff --git a/share/dict/Makefile b/share/dict/Makefile
+index 3e2a0df..5395077 100644
+--- a/share/dict/Makefile
++++ b/share/dict/Makefile
+@@ -4,8 +4,7 @@
+ NO_OBJ=
+
+ # XXX MISSING: connectives words
+-FILES= README propernames web2 web2a freebsd
++FILES= README freebsd
+ FILESDIR= ${BINDIR}/dict
+-SYMLINKS= web2 ${FILESDIR}/words
+
+ .include <bsd.prog.mk>
+diff --git a/share/misc/Makefile b/share/misc/Makefile
+index ffd42d8..7eb90bb 100644
+--- a/share/misc/Makefile
++++ b/share/misc/Makefile
+@@ -5,9 +5,9 @@
+
+ .PATH: ${.CURDIR}/../../sys/dev/usb
+
+-FILES= ascii birthtoken bsd-family-tree committers-doc.dot committers-ports.dot \
++FILES= bsd-family-tree committers-doc.dot committers-ports.dot \
+ committers-src.dot eqnchar flowers init.ee \
+- iso3166 iso639 latin1 man.template mdoc.template operator pci_vendors \
++ iso3166 iso639 man.template mdoc.template pci_vendors \
+ scsi_modes \
+ organization.dot
+
diff --git a/sys-freebsd/freebsd-share/files/freebsd-share-10.3-gentoo-skel.patch b/sys-freebsd/freebsd-share/files/freebsd-share-10.3-gentoo-skel.patch
new file mode 100644
index 0000000..79e29e9
--- /dev/null
+++ b/sys-freebsd/freebsd-share/files/freebsd-share-10.3-gentoo-skel.patch
@@ -0,0 +1,20 @@
+diff --git a/share/skel/Makefile b/share/skel/Makefile
+index 024985c..6f6e563 100644
+--- a/share/skel/Makefile
++++ b/share/skel/Makefile
+@@ -2,11 +2,11 @@
+ # $FreeBSD: stable/10/share/skel/Makefile 291794 2015-12-04 18:21:05Z bdrewery $
+
+ FILESGROUPS= FILES1 FILES2
+-FILES1= dot.cshrc dot.login dot.login_conf dot.mailrc dot.profile \
++FILES1= dot.login_conf dot.mailrc \
+ dot.shrc
+-FILES2= dot.mail_aliases dot.rhosts
+-FILES1DIR= ${SHAREDIR}/skel
+-FILES2DIR= ${SHAREDIR}/skel
++FILES2= dot.mail_aliases
++FILES1DIR= /etc/skel
++FILES2DIR= /etc/skel
+ FILES1MODE= 0644
+ FILES2MODE= 0600
+ NO_OBJ=
diff --git a/sys-freebsd/freebsd-share/files/freebsd-share-5.3-doc-locations.patch b/sys-freebsd/freebsd-share/files/freebsd-share-5.3-doc-locations.patch
new file mode 100644
index 0000000..c0798d3
--- /dev/null
+++ b/sys-freebsd/freebsd-share/files/freebsd-share-5.3-doc-locations.patch
@@ -0,0 +1,20 @@
+--- examples/smbfs/Makefile.orig Tue Mar 22 15:20:20 2005
++++ examples/smbfs/Makefile Tue Mar 22 15:20:46 2005
+@@ -2,6 +2,7 @@
+
+ NOOBJ=
+ BINDIR= /usr/share/examples/smbfs
++FILESDIR= ${DOCDIR}/smbfs
+ FILES= dot.nsmbrc
+
+ .PATH: ${.CURDIR}/../../../contrib/smbfs/examples
+--- examples/smbfs/print/Makefile.orig Tue Mar 22 15:22:17 2005
++++ examples/smbfs/print/Makefile Tue Mar 22 15:22:35 2005
+@@ -2,6 +2,7 @@
+
+ NOOBJ=
+ BINDIR= /usr/share/examples/smbfs/print
++FILESDIR= ${DOCDIR}/smbfs/print
+ FILES= lj6l ljspool printcap.sample tolj
+
+ .PATH: ${.CURDIR}/../../../../contrib/smbfs/examples/print
diff --git a/sys-freebsd/freebsd-share/files/freebsd-share-5.4-gentoo-skel.patch b/sys-freebsd/freebsd-share/files/freebsd-share-5.4-gentoo-skel.patch
new file mode 100644
index 0000000..f668d04
--- /dev/null
+++ b/sys-freebsd/freebsd-share/files/freebsd-share-5.4-gentoo-skel.patch
@@ -0,0 +1,20 @@
+Index: fbsd/share/skel/Makefile
+===================================================================
+--- fbsd.orig/share/skel/Makefile
++++ fbsd/share/skel/Makefile
+@@ -2,11 +2,11 @@
+ # $FreeBSD: src/share/skel/Makefile,v 1.9.2.1 2005/02/13 07:23:30 obrien Exp $
+
+ FILESGROUPS= FILES1 FILES2
+-FILES1= dot.cshrc dot.login dot.login_conf dot.mailrc dot.profile \
++FILES1= dot.login_conf dot.mailrc \
+ dot.shrc
+-FILES2= dot.mail_aliases dot.rhosts
+-FILES1DIR= /usr/share/skel
+-FILES2DIR= /usr/share/skel
++FILES2= dot.mail_aliases
++FILES1DIR= /etc/skel
++FILES2DIR= /etc/skel
+ FILES1MODE= 0644
+ FILES2MODE= 0600
+ NOOBJ=
diff --git a/sys-freebsd/freebsd-share/files/freebsd-share-8.0-gnu-miscfiles.patch b/sys-freebsd/freebsd-share/files/freebsd-share-8.0-gnu-miscfiles.patch
new file mode 100644
index 0000000..19167a6
--- /dev/null
+++ b/sys-freebsd/freebsd-share/files/freebsd-share-8.0-gnu-miscfiles.patch
@@ -0,0 +1,26 @@
+--- share/misc/Makefile.old 2010-03-12 01:32:39 +0100
++++ share/misc/Makefile 2010-03-12 01:33:25 +0100
+@@ -3,9 +3,9 @@
+
+ .PATH: ${.CURDIR}/../../sys/dev/usb
+
+-FILES= ascii birthtoken bsd-family-tree committers-doc.dot committers-ports.dot \
++FILES= bsd-family-tree committers-doc.dot committers-ports.dot \
+ committers-src.dot eqnchar flowers init.ee \
+- iso3166 iso639 latin1 man.template mdoc.template operator pci_vendors \
++ iso3166 iso639 man.template mdoc.template pci_vendors \
+ scsi_modes usb_hid_usages usbdevs
+
+ NO_OBJ=
+--- share/dict/Makefile.old 2010-03-12 01:33:53 +0100
++++ share/dict/Makefile 2010-03-12 01:34:18 +0100
+@@ -4,8 +4,7 @@
+ NO_OBJ=
+
+ # XXX MISSING: connectives words
+-FILES= README propernames web2 web2a freebsd
++FILES= README freebsd
+ FILESDIR= ${BINDIR}/dict
+-SYMLINKS= web2 ${FILESDIR}/words
+
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-share/files/freebsd-share-9.2-gnu-miscfiles.patch b/sys-freebsd/freebsd-share/files/freebsd-share-9.2-gnu-miscfiles.patch
new file mode 100644
index 0000000..af84dc3
--- /dev/null
+++ b/sys-freebsd/freebsd-share/files/freebsd-share-9.2-gnu-miscfiles.patch
@@ -0,0 +1,28 @@
+diff -Nur share.orig/dict/Makefile share/dict/Makefile
+--- share.orig/dict/Makefile 2012-12-31 18:00:00.000000000 +0900
++++ share/dict/Makefile 2012-12-31 18:03:15.000000000 +0900
+@@ -4,8 +4,7 @@
+ NO_OBJ=
+
+ # XXX MISSING: connectives words
+-FILES= README propernames web2 web2a freebsd
++FILES= README freebsd
+ FILESDIR= ${BINDIR}/dict
+-SYMLINKS= web2 ${FILESDIR}/words
+
+ .include <bsd.prog.mk>
+diff -Nur share.orig/misc/Makefile share/misc/Makefile
+--- share.orig/misc/Makefile 2012-12-31 18:00:00.000000000 +0900
++++ share/misc/Makefile 2012-12-31 18:04:22.000000000 +0900
+@@ -3,9 +3,9 @@
+
+ .PATH: ${.CURDIR}/../../sys/dev/usb
+
+-FILES= ascii birthtoken bsd-family-tree committers-doc.dot committers-ports.dot \
++FILES= bsd-family-tree committers-doc.dot committers-ports.dot \
+ committers-src.dot eqnchar flowers init.ee \
+- iso3166 iso639 latin1 man.template mdoc.template operator pci_vendors \
++ iso3166 iso639 man.template mdoc.template pci_vendors \
+ scsi_modes usb_hid_usages usbdevs \
+ organization.dot
+
diff --git a/sys-freebsd/freebsd-share/freebsd-share-11.0.ebuild b/sys-freebsd/freebsd-share/freebsd-share-11.0.ebuild
new file mode 100644
index 0000000..8ab449e
--- /dev/null
+++ b/sys-freebsd/freebsd-share/freebsd-share-11.0.ebuild
@@ -0,0 +1,113 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit bsdmk freebsd
+
+DESCRIPTION="FreeBSD shared tools/files"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+IUSE="doc usb zfs"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ share/
+ contrib/
+ gnu/
+ usr.bin/
+ usr.sbin/
+ sbin/
+ bin/
+ lib/
+ etc/
+"
+
+DEPEND="=sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+RDEPEND="sys-apps/miscfiles"
+
+RESTRICT="strip"
+
+S="${WORKDIR}/share"
+
+pkg_setup() {
+ # Add the required source files.
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ use doc || mymakeopts="${mymakeopts} NO_SHAREDOCS= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+ [[ ! -e /usr/bin/vtfontcvt ]] && mymakeopts="${mymakeopts} WITHOUT_VT= "
+
+ mymakeopts="${mymakeopts} NO_SENDMAIL= NO_MANCOMPRESS= NO_INFOCOMPRESS= WITHOUT_CLANG= "
+}
+
+REMOVE_SUBDIRS="mk termcap zoneinfo tabset"
+
+PATCHES=( "${FILESDIR}/${PN}-10.3-gentoo-skel.patch"
+ "${FILESDIR}/${PN}-10.0-gentoo-eapi3.patch"
+ "${FILESDIR}/${PN}-10.2-gnu-miscfiles.patch" )
+
+src_prepare() {
+ # Remove make.conf manpage as it describes bsdmk's make.conf.
+ sed -i -e 's:make.conf.5::' "${S}/man/man5/Makefile"
+ # Remove rc.conf manpage as it describes bsd's rc.conf.
+ sed -i -e 's:\brc.conf.5::' "${S}/man/man5/Makefile"
+ sed -i -e 's:\brc.conf.local.5::' "${S}/man/man5/Makefile"
+ # Remove mailer.conf manpage
+ sed -i -e 's:mailer.conf.5::' "${S}/man/man5/Makefile"
+ # Remove pbm and moduli(ssh) manpages
+ sed -i -e 's:pbm.5::' -e 's:moduli.5::' "${S}/man/man5/Makefile"
+ # Remove builtins manpage
+ sed -i -e '/builtins\.1/d' "${S}/man/man1/Makefile"
+ # Remove rc manpages
+ sed -i -e '/rc.8/d' "${S}/man/man8/Makefile"
+ # Remove hv_kvp_daemon.8 manpage. It's provided by freebsd-usbin.
+ sed -i -e '/hv_kvp_daemon.8/d' "${S}/man/man8/Makefile"
+
+ # Don't install the arch-specific directories in subdirectories
+ sed -i -e '/MANSUBDIR/d' "${S}"/man/man4/man4.{i386,sparc64}/Makefile
+
+ # Remove them so that they can't be included by error
+ rm -rf "${S}"/mk/*.mk
+
+ # Make proper symlinks by defining the full target.
+ local sdir
+ for sdir in colldef mklocale monetdef msgdef numericdef timedef
+ do
+ sed -e 's:\${enc2}$:\${enc2}/\${FILESNAME}:g' -i \
+ "${S}/${sdir}/Makefile" || \
+ die "Error fixing ${sdir}/Makefile"
+ done
+ if [[ ! -e "${WORKDIR}/sys" ]]; then
+ ln -s "/usr/src/sys" "${WORKDIR}/sys" || die "failed to set sys symlink"
+ fi
+}
+
+src_compile() {
+ export ESED="/usr/bin/sed"
+
+ # libiconv support.
+ # i18n/csmapper/APPLE requires mkcsmapper_static
+ # i18n/esdb/APPLE requires mkesdb_static
+ for pkg in mkcsmapper_static mkesdb_static
+ do
+ cd "${WORKDIR}"/usr.bin/${pkg} || die
+ freebsd_src_compile
+ done
+
+ # This is a groff problem and not a -shared problem.
+ cd "${S}" || die
+ export GROFF_TMAC_PATH="/usr/share/tmac/:/usr/share/groff/1.22.2/tmac/"
+ freebsd_src_compile -j1 || die "emake failed"
+}
+
+src_install() {
+ mkmake -j1 DESTDIR="${D}" DOCDIR=/usr/share/doc/${PF} install || die "Install failed"
+}
diff --git a/sys-freebsd/freebsd-share/metadata.xml b/sys-freebsd/freebsd-share/metadata.xml
new file mode 100644
index 0000000..9a9053f
--- /dev/null
+++ b/sys-freebsd/freebsd-share/metadata.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+ </maintainer>
+ <use>
+ <flag name="isdn">Enable ISDN support</flag>
+ <flag name="zfs">Enable ZFS support.</flag>
+ </use>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-sources/files/config-GENTOO b/sys-freebsd/freebsd-sources/files/config-GENTOO
new file mode 100644
index 0000000..7c7eb26
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/config-GENTOO
@@ -0,0 +1,4 @@
+# Kernel configuration for Gentoo/FreeBSD.
+include GENERIC
+ident GENTOO
+
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-10.0-gentoo.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-10.0-gentoo.patch
new file mode 100644
index 0000000..c7e12bd
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-10.0-gentoo.patch
@@ -0,0 +1,22 @@
+diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk
+index 2939a59..124ef6f 100644
+--- a/sys/conf/kern.mk
++++ b/sys/conf/kern.mk
+@@ -5,7 +5,7 @@
+ #
+ CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
+ -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \
+- -Wundef -Wno-pointer-sign ${FORMAT_EXTENSIONS} \
++ -Wundef -Wno-pointer-sign \
+ -Wmissing-include-dirs -fdiagnostics-show-option \
+ ${CWARNEXTRA}
+ #
+@@ -61,7 +61,7 @@ FORMAT_EXTENSIONS= -fformat-extensions
+ #
+ .if ${MACHINE_CPUARCH} == "i386"
+ .if ${COMPILER_TYPE} != "clang"
+-CFLAGS+= -mno-align-long-strings -mpreferred-stack-boundary=2
++CFLAGS+= -mpreferred-stack-boundary=2
+ .else
+ CFLAGS+= -mno-aes -mno-avx
+ .endif
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-10.1-gcc48.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-10.1-gcc48.patch
new file mode 100644
index 0000000..5cb4cf8
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-10.1-gcc48.patch
@@ -0,0 +1,18 @@
+https://svnweb.freebsd.org/base?view=revision&revision=281606
+
+diff --git a/sys/crypto/aesni/aesencdec.h b/sys/crypto/aesni/aesencdec.h
+index d4ed8b3..79847ee 100644
+--- a/sys/crypto/aesni/aesencdec.h
++++ b/sys/crypto/aesni/aesencdec.h
+@@ -27,6 +27,11 @@
+ *
+ */
+
++#if defined(__GNUC__) && defined(_KERNEL)
++/* Suppress inclusion of gcc's mm_malloc.h header */
++#define _MM_MALLOC_H_INCLUDED 1
++#endif
++
+ #include <wmmintrin.h>
+
+ static inline void
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-6.0-flex-2.5.31.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-6.0-flex-2.5.31.patch
new file mode 100644
index 0000000..88710cf
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-6.0-flex-2.5.31.patch
@@ -0,0 +1,22 @@
+Index: fbsd-6/sys/dev/aic7xxx/aicasm/aicasm_scan.l
+===================================================================
+--- fbsd-6.orig/sys/dev/aic7xxx/aicasm/aicasm_scan.l
++++ fbsd-6/sys/dev/aic7xxx/aicasm/aicasm_scan.l
+@@ -528,7 +528,7 @@ expand_macro(struct symbol *macro_symbol
+
+ /* Put back everything up until the replacement. */
+ while (body_pos > next_match)
+- unput(*--body_pos);
++ yyunput(*--body_pos, body_head);
+
+ /* Perform the replacement. */
+ if (match_marg != NULL) {
+@@ -537,7 +537,7 @@ expand_macro(struct symbol *macro_symbol
+ next_match = match_marg->replacement_text;
+ strp = next_match + strlen(next_match);
+ while (strp > next_match)
+- unput(*--strp);
++ yyunput(*--strp, next_match);
+
+ /* Skip past the unexpanded macro arg. */
+ body_pos -= match.rm_eo - match.rm_so;
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-6.1-ntfs.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-6.1-ntfs.patch
new file mode 100644
index 0000000..e74fcd3
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-6.1-ntfs.patch
@@ -0,0 +1,32 @@
+--- sys/fs/ntfs/ntfs_vnops.c.orig 2006-10-17 17:31:36 -0300
++++ sys/fs/ntfs/ntfs_vnops.c 2006-10-17 17:30:24 -0300
+@@ -507,8 +507,12 @@
+
+ /* Simulate . in every dir except ROOT */
+ if( ip->i_number != NTFS_ROOTINO ) {
+- struct dirent dot = { NTFS_ROOTINO,
+- sizeof(struct dirent), DT_DIR, 1, "." };
++ struct dirent dot;
++ dot.d_fileno = NTFS_ROOTINO;
++ dot.d_reclen = sizeof(struct dirent);
++ dot.d_type = DT_DIR;
++ dot.d_namlen = 1;
++ bcopy(".", dot.d_name, 1);
+
+ if( uio->uio_offset < sizeof(struct dirent) ) {
+ dot.d_fileno = ip->i_number;
+@@ -522,8 +526,12 @@
+
+ /* Simulate .. in every dir including ROOT */
+ if( uio->uio_offset < 2 * sizeof(struct dirent) ) {
+- struct dirent dotdot = { NTFS_ROOTINO,
+- sizeof(struct dirent), DT_DIR, 2, ".." };
++ struct dirent dotdot;
++ dotdot.d_fileno = NTFS_ROOTINO;
++ dotdot.d_reclen = sizeof(struct dirent);
++ dotdot.d_type = DT_DIR;
++ dotdot.d_namlen = 2;
++ bcopy("..", dotdot.d_name, 2);
+
+ error = uiomove((char *)&dotdot,sizeof(struct dirent),uio);
+ if(error)
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-7.0-tmpfs_whiteout_stub.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.0-tmpfs_whiteout_stub.patch
new file mode 100644
index 0000000..13524ef
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.0-tmpfs_whiteout_stub.patch
@@ -0,0 +1,44 @@
+diff -ur sys/fs/tmpfs.orig/tmpfs_vnops.c sys/fs/tmpfs/tmpfs_vnops.c
+--- sys/fs/tmpfs.orig/tmpfs_vnops.c 2008-06-22 12:17:48 -0300
++++ sys/fs/tmpfs/tmpfs_vnops.c 2008-06-28 12:05:10 -0300
+@@ -1459,6 +1459,30 @@
+ return (0);
+ }
+
++
++/* --------------------------------------------------------------------- */
++/* This does absolutely nothing */
++#ifdef GENTOO_LIVECD
++static int
++tmpfs_whiteout(struct vop_whiteout_args *ap)
++{
++ switch (ap->a_flags) {
++ case LOOKUP:
++ return (0);
++ break;
++ case CREATE:
++ return(EOPNOTSUPP);
++ break;
++ case DELETE:
++ return (0);
++ break;
++ default:
++ return(EOPNOTSUPP);
++ }
++ return(0);
++}
++#endif
++
+ /* --------------------------------------------------------------------- */
+
+ /*
+@@ -1484,6 +1508,9 @@
+ .vop_mkdir = tmpfs_mkdir,
+ .vop_rmdir = tmpfs_rmdir,
+ .vop_symlink = tmpfs_symlink,
++#ifdef GENTOO_LIVECD
++ .vop_whiteout = tmpfs_whiteout,
++#endif
+ .vop_readdir = tmpfs_readdir,
+ .vop_readlink = tmpfs_readlink,
+ .vop_inactive = tmpfs_inactive,
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-binutils_link.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-binutils_link.patch
new file mode 100644
index 0000000..43d01ba
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-binutils_link.patch
@@ -0,0 +1,37 @@
+diff -ruN sys.orig/conf/kern.post.mk sys/conf/kern.post.mk
+--- sys.orig/conf/kern.post.mk 2007-03-23 18:55:59 -0300
++++ sys/conf/kern.post.mk 2008-06-18 19:51:13 -0300
+@@ -85,7 +85,9 @@
+ ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
+ @rm -f ${.TARGET}
+ @echo linking ${.TARGET}
+- ${SYSTEM_LD}
++ ${SYSTEM_LD} -o ${.TARGET}.tmp
++ @sh $S/tools/gen-ld-u-options ${.TARGET}.tmp > ${.TARGET}.lopt
++ ${SYSTEM_LD} "@${.TARGET}.lopt"
+ .if defined(CTFMERGE)
+ ${SYSTEM_CTFMERGE}
+ .endif
+diff -ruN sys.orig/conf/kmod.mk sys/conf/kmod.mk
+--- sys.orig/conf/kmod.mk 2008-06-18 09:11:53 -0300
++++ sys/conf/kmod.mk 2008-06-18 19:50:01 -0300
+@@ -176,7 +176,8 @@
+
+ .if ${MACHINE_ARCH} != amd64
+ ${FULLPROG}: ${KMOD}.kld
+- ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld
++ sh ./@/tools/gen-ld-u-options ${KMOD}.kld > ${KMOD}.lopt
++ ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld "@${KMOD}.lopt"
+ .if !defined(DEBUG_FLAGS)
+ ${OBJCOPY} --strip-debug ${.TARGET}
+ .endif
+diff -ruN sys.orig/tools/gen-ld-u-options sys/tools/gen-ld-u-options
+--- sys.orig/tools/gen-ld-u-options 1969-12-31 21:00:00 -0300
++++ sys/tools/gen-ld-u-options 2008-06-18 19:47:56 -0300
+@@ -0,0 +1,6 @@
++#!/bin/sh
++
++for i in `objdump -h -w $1 | grep set_ | cut -c5- | cut -f1 -d " "`
++do
++ echo -n " -u __start_$i -u __stop_$i "
++done
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-includes.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-includes.patch
new file mode 100644
index 0000000..3db46fa
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-includes.patch
@@ -0,0 +1,13 @@
+Make headers usable alone, include the headers they need.
+There are probably much more missing.
+
+--- sys/net/if.h.old 2009-05-15 10:51:50 +0000
++++ sys/net/if.h 2009-05-15 10:52:05 +0000
+@@ -34,6 +34,7 @@
+ #define _NET_IF_H_
+
+ #include <sys/cdefs.h>
++#include <sys/socket.h>
+
+ #ifdef _KERNEL
+ #include <sys/queue.h>
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-types.h-fix.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-types.h-fix.patch
new file mode 100644
index 0000000..8de5df2
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-types.h-fix.patch
@@ -0,0 +1,15 @@
+Fixes a compile error if XOPEN_SOURCE 600 is defined.
+
+See: http://www.mailinglistarchive.com/freebsd-current@freebsd.org/msg15011.html
+
+--- sys/sys/types.h.orig
++++ sys/sys/types.h
+@@ -46,7 +46,7 @@
+
+ #include <sys/_pthreadtypes.h>
+
+-#if __BSD_VISIBLE
++#ifndef _POSIX_SOURCE
+ typedef unsigned char u_char;
+ typedef unsigned short u_short;
+ typedef unsigned int u_int;
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-7.2-debug-O2.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.2-debug-O2.patch
new file mode 100644
index 0000000..4fa3565
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.2-debug-O2.patch
@@ -0,0 +1,27 @@
+My UltraSPARC U5 panics on boot about a memory alignment error when compiled
+with gcc4 and -O. Compiling with -O2 fixes this, and it should not adversly
+affect debugging.
+
+NOTE: This does not fix the memory alignment panic when loading kernel modules.
+
+Roy Marples (uberlord@gentoo.org)
+
+--- sys/conf/kern.pre.mk.old 2009-05-22 10:09:46 +0000
++++ sys/conf/kern.pre.mk 2009-05-22 10:10:27 +0000
+@@ -22,15 +22,13 @@
+ COPTFLAGS?= -O
+ .else
+ . if defined(DEBUG)
+-_MINUS_O= -O
+ CTFFLAGS+= -g
+ . else
+-_MINUS_O= -O2
+ . endif
+ . if ${MACHINE_ARCH} == "amd64"
+ COPTFLAGS?=-O2 -frename-registers -pipe
+ . else
+-COPTFLAGS?=${_MINUS_O} -pipe
++COPTFLAGS?=-O2 -pipe
+ . endif
+ . if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
+ COPTFLAGS+= -fno-strict-aliasing
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-8.0-gentoo.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-8.0-gentoo.patch
new file mode 100644
index 0000000..0f8d070
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-8.0-gentoo.patch
@@ -0,0 +1,33 @@
+--- sys/conf/kern.mk.old 2007-05-24 23:53:42.000000000 +0200
++++ sys/conf/kern.mk 2008-03-14 14:37:47.216420518 +0100
+@@ -12,7 +12,7 @@
+ .else
+ CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
+ -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \
+- ${_wundef} ${_Wno_pointer_sign} -fformat-extensions
++ ${_wundef} ${_Wno_pointer_sign}
+ .if !defined(WITH_GCC3)
+ _Wno_pointer_sign=-Wno-pointer-sign
+ .endif
+@@ -36,7 +36,7 @@
+ # reserved for user applications.
+ #
+ .if ${MACHINE_ARCH} == "i386" && ${CC} != "icc"
+-CFLAGS+= -mno-align-long-strings -mpreferred-stack-boundary=2 \
++CFLAGS+= -mpreferred-stack-boundary=2 \
+ -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3
+ INLINE_LIMIT?= 8000
+ .endif
+Only in ./sys/conf: kern.mk.rej
+Only in ./sys/conf: kern.mk~
+--- sys/dev/aic7xxx/aicasm/Makefile.old 2010-03-10 14:01:50 +0100
++++ sys/dev/aic7xxx/aicasm/Makefile 2010-03-10 14:01:56 +0100
+@@ -14,7 +14,7 @@
+ SRCS= ${GENHDRS} ${CSRCS} ${YSRCS} ${LSRCS}
+ CLEANFILES+= ${GENHDRS} ${YSRCS:R:C/(.*)/\1.output/g}
+ DPADD= ${LIBL}
+-LDADD= -ll
++LDADD= -lfl
+ WARNS?= 6
+
+ # Correct path for kernel builds
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-8.0-subnet-route-pr40133.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-8.0-subnet-route-pr40133.patch
new file mode 100644
index 0000000..a7335f6
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-8.0-subnet-route-pr40133.patch
@@ -0,0 +1,21 @@
+Fixes changing the default subnet route after removing an ip address.
+
+See: http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=40133
+and http://mail-index.netbsd.org/tech-net/2008/12/03/msg000896.html
+
+Thanks to Roy Marples.
+--- sys/netinet/in.c.orig
++++ sys/netinet/in.c
+@@ -858,6 +858,12 @@
+ error = rtinit(&target->ia_ifa, (int)RTM_ADD, flags);
+ if (!error)
+ target->ia_flags |= IFA_ROUTE;
++ else if (error == EEXIST) {
++ /*
++ * the fact that the route already exists is not an error.
++ */
++ error = 0;
++ }
+ return (error);
+ }
+
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-8.2-unix2.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-8.2-unix2.patch
new file mode 100644
index 0000000..50dacd0
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-8.2-unix2.patch
@@ -0,0 +1,55 @@
+Index: sys/kern/uipc_usrreq.c
+===================================================================
+--- sys/kern/uipc_usrreq.c (revision 225745)
++++ sys/kern/uipc_usrreq.c (working copy)
+@@ -462,6 +462,8 @@
+ unp = sotounpcb(so);
+ KASSERT(unp != NULL, ("uipc_bind: unp == NULL"));
+
++ if (soun->sun_len > sizeof(struct sockaddr_un))
++ return (EINVAL);
+ namelen = soun->sun_len - offsetof(struct sockaddr_un, sun_path);
+ if (namelen <= 0)
+ return (EINVAL);
+@@ -1252,6 +1254,8 @@
+ unp = sotounpcb(so);
+ KASSERT(unp != NULL, ("unp_connect: unp == NULL"));
+
++ if (nam->sa_len > sizeof(struct sockaddr_un))
++ return (EINVAL);
+ len = nam->sa_len - offsetof(struct sockaddr_un, sun_path);
+ if (len <= 0)
+ return (EINVAL);
+Index: sys/compat/linux/linux_socket.c
+===================================================================
+--- sys/compat/linux/linux_socket.c (revision 225919)
++++ sys/compat/linux/linux_socket.c (working copy)
+@@ -104,6 +104,7 @@
+ int oldv6size;
+ struct sockaddr_in6 *sin6;
+ #endif
++ int namelen;
+
+ if (*osalen < 2 || *osalen > UCHAR_MAX || !osa)
+ return (EINVAL);
+@@ -166,6 +167,20 @@
+ }
+ }
+
++ if ((bdom == AF_LOCAL) && (*osalen > sizeof(struct sockaddr_un))) {
++ for (namelen = 0;
++ namelen < *osalen - offsetof(struct sockaddr_un, sun_path);
++ namelen++)
++ if (!((struct sockaddr_un *)kosa)->sun_path[namelen])
++ break;
++ if (namelen + offsetof(struct sockaddr_un, sun_path) >
++ sizeof(struct sockaddr_un)) {
++ error = EINVAL;
++ goto out;
++ }
++ alloclen = sizeof(struct sockaddr_un);
++ }
++
+ sa = (struct sockaddr *) kosa;
+ sa->sa_family = bdom;
+ sa->sa_len = alloclen;
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-disable-optimization.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-disable-optimization.patch
new file mode 100644
index 0000000..4824ff6
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-disable-optimization.patch
@@ -0,0 +1,32 @@
+Taken from debian GNU/kFreeBSD.
+
+Regretably, with GCC 4.4 or later this is the only flag combination
+I could find that doesn't cause kernel panics CPU triple-faults or
+other kind of severe breakage. This is Gentoo Bug #410945.
+
+Clang can use -O2, so we do not force -O1 on it
+
+--- a/sys/conf/kern.pre.mk
++++ b/sys/conf/kern.pre.mk
+@@ -41,6 +41,9 @@
+ .if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
+ COPTFLAGS+= -fno-strict-aliasing
+ .endif
++.if ${CC:T:Mclang} != "clang" && !empty(COPTFLAGS:M-O[23s])
++COPTFLAGS+= -O1
++.endif
+ .if !defined(NO_CPU_COPTFLAGS)
+ COPTFLAGS+= ${_CPUCFLAGS}
+ .endif
+--- a/sys/conf/kmod.mk
++++ b/sys/conf/kmod.mk
+@@ -91,6 +91,9 @@
+ .if !empty(CFLAGS:M-O[23s]) && empty(CFLAGS:M-fno-strict-aliasing)
+ CFLAGS+= -fno-strict-aliasing
+ .endif
++.if ${CC:T:Mclang} != "clang" && !empty(CFLAGS:M-O[23s])
++CFLAGS+= -O1
++.endif
+ WERROR?= -Werror
+ CFLAGS+= ${WERROR}
+ CFLAGS+= -D_KERNEL
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-ipv6refcount.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-ipv6refcount.patch
new file mode 100644
index 0000000..f0984f6
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-ipv6refcount.patch
@@ -0,0 +1,128 @@
+Index: sys/netinet6/in6.c
+===================================================================
+--- sys/netinet6/in6.c.orig
++++ sys/netinet6/in6.c
+@@ -1369,6 +1369,8 @@ in6_purgeaddr(struct ifaddr *ifa)
+ }
+
+ cleanup:
++ if (ifa0 != NULL)
++ ifa_free(ifa0);
+
+ plen = in6_mask2len(&ia->ia_prefixmask.sin6_addr, NULL); /* XXX */
+ if ((ia->ia_flags & IFA_ROUTE) && plen == 128) {
+@@ -1393,8 +1395,6 @@ cleanup:
+ return;
+ ia->ia_flags &= ~IFA_ROUTE;
+ }
+- if (ifa0 != NULL)
+- ifa_free(ifa0);
+
+ in6_unlink_ifa(ia, ifp);
+ }
+@@ -1667,14 +1667,19 @@ in6_lifaddr_ioctl(struct socket *so, u_long cmd, c
+ hostid = IFA_IN6(ifa);
+
+ /* prefixlen must be <= 64. */
+- if (64 < iflr->prefixlen)
++ if (64 < iflr->prefixlen) {
++ if (ifa != NULL)
++ ifa_free(ifa);
+ return EINVAL;
++ }
+ prefixlen = iflr->prefixlen;
+
+ /* hostid part must be zero. */
+ sin6 = (struct sockaddr_in6 *)&iflr->addr;
+ if (sin6->sin6_addr.s6_addr32[2] != 0 ||
+ sin6->sin6_addr.s6_addr32[3] != 0) {
++ if (ifa != NULL)
++ ifa_free(ifa);
+ return EINVAL;
+ }
+ } else
+@@ -2265,14 +2265,20 @@ in6_ifawithifp(struct ifnet *ifp, struct in6_addr
+ IN6_IFADDR_RUNLOCK();
+ return (struct in6_ifaddr *)ifa;
+ }
+- IN6_IFADDR_RUNLOCK();
+
+ /* use the last-resort values, that are, deprecated addresses */
+- if (dep[0])
++ if (dep[0]) {
++ ifa_ref((struct ifaddr *)dep[0]);
++ IN6_IFADDR_RUNLOCK();
+ return dep[0];
+- if (dep[1])
++ }
++ if (dep[1]) {
++ ifa_ref((struct ifaddr *)dep[1]);
++ IN6_IFADDR_RUNLOCK();
+ return dep[1];
++ }
+
++ IN6_IFADDR_RUNLOCK();
+ return NULL;
+ }
+
+Index: sys/netinet6/ip6_input.c
+===================================================================
+--- sys/netinet6/ip6_input.c.orig
++++ sys/netinet6/ip6_input.c
+@@ -879,19 +879,23 @@ passin:
+ * as our interface address (e.g. multicast addresses, addresses
+ * within FAITH prefixes and such).
+ */
+- if (deliverifp && !ip6_getdstifaddr(m)) {
++ if (deliverifp) {
+ struct in6_ifaddr *ia6;
+
+- ia6 = in6_ifawithifp(deliverifp, &ip6->ip6_dst);
+- if (ia6) {
+- if (!ip6_setdstifaddr(m, ia6)) {
+- /*
+- * XXX maybe we should drop the packet here,
+- * as we could not provide enough information
+- * to the upper layers.
+- */
++ if ((ia6 = ip6_getdstifaddr(m)) != NULL) {
++ ifa_free(&ia6->ia_ifa);
++ } else {
++ ia6 = in6_ifawithifp(deliverifp, &ip6->ip6_dst);
++ if (ia6) {
++ if (!ip6_setdstifaddr(m, ia6)) {
++ /*
++ * XXX maybe we should drop the packet here,
++ * as we could not provide enough information
++ * to the upper layers.
++ */
++ }
++ ifa_free(&ia6->ia_ifa);
+ }
+- ifa_free(&ia6->ia_ifa);
+ }
+ }
+
+Index: sys/netinet/tcp_input.c
+===================================================================
+--- sys/netinet/tcp_input.c.orig
++++ sys/netinet/tcp_input.c
+@@ -512,6 +512,8 @@ tcp6_input(struct mbuf **mp, int *offp, int proto)
+ (caddr_t)&ip6->ip6_dst - (caddr_t)ip6);
+ return IPPROTO_DONE;
+ }
++ if (ia6)
++ ifa_free(&ia6->ia_ifa);
+
+ tcp_input(m, *offp);
+ return IPPROTO_DONE;
+@@ -1240,7 +1242,8 @@ relocked:
+ rstreason = BANDLIM_RST_OPENPORT;
+ goto dropwithreset;
+ }
+- ifa_free(&ia6->ia_ifa);
++ if (ia6)
++ ifa_free(&ia6->ia_ifa);
+ }
+ #endif /* INET6 */
+ /*
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-sysctluint.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-sysctluint.patch
new file mode 100644
index 0000000..751a77c
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-sysctluint.patch
@@ -0,0 +1,13 @@
+u_int is defined in sys/types.h
+makes header usable alone.
+
+--- sys/sys/sysctl.h.old 2012-05-25 11:08:53.000000000 -0400
++++ sys/sys/sysctl.h 2012-05-25 11:09:16.000000000 -0400
+@@ -788,6 +788,7 @@
+ struct sysctl_req *);
+ #else /* !_KERNEL */
+ #include <sys/cdefs.h>
++#include <sys/types.h> /* for u_int */
+
+ __BEGIN_DECLS
+ int sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-ciss.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-ciss.patch
new file mode 100644
index 0000000..697984b
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-ciss.patch
@@ -0,0 +1,65 @@
+Index: sys/dev/ciss/ciss.c
+===================================================================
+--- sys/dev/ciss/ciss.c (revision 264510)
++++ sys/dev/ciss/ciss.c (revision 264511)
+@@ -180,8 +180,6 @@
+ static void ciss_cam_poll(struct cam_sim *sim);
+ static void ciss_cam_complete(struct ciss_request *cr);
+ static void ciss_cam_complete_fixup(struct ciss_softc *sc, struct ccb_scsiio *csio);
+-static struct cam_periph *ciss_find_periph(struct ciss_softc *sc,
+- int bus, int target);
+ static int ciss_name_device(struct ciss_softc *sc, int bus, int target);
+
+ /* periodic status monitoring */
+@@ -3398,27 +3396,6 @@
+
+
+ /********************************************************************************
+- * Find a peripheral attached at (target)
+- */
+-static struct cam_periph *
+-ciss_find_periph(struct ciss_softc *sc, int bus, int target)
+-{
+- struct cam_periph *periph;
+- struct cam_path *path;
+- int status;
+-
+- status = xpt_create_path(&path, NULL, cam_sim_path(sc->ciss_cam_sim[bus]),
+- target, 0);
+- if (status == CAM_REQ_CMP) {
+- periph = cam_periph_find(path, NULL);
+- xpt_free_path(path);
+- } else {
+- periph = NULL;
+- }
+- return(periph);
+-}
+-
+-/********************************************************************************
+ * Name the device at (target)
+ *
+ * XXX is this strictly correct?
+@@ -3427,12 +3404,22 @@
+ ciss_name_device(struct ciss_softc *sc, int bus, int target)
+ {
+ struct cam_periph *periph;
++ struct cam_path *path;
++ int status;
+
+ if (CISS_IS_PHYSICAL(bus))
+ return (0);
+- if ((periph = ciss_find_periph(sc, bus, target)) != NULL) {
++
++ status = xpt_create_path(&path, NULL, cam_sim_path(sc->ciss_cam_sim[bus]),
++ target, 0);
++
++ if (status == CAM_REQ_CMP) {
++ mtx_lock(&sc->ciss_mtx);
++ periph = cam_periph_find(path, NULL);
+ sprintf(sc->ciss_logical[bus][target].cl_name, "%s%d",
+ periph->periph_name, periph->unit_number);
++ mtx_unlock(&sc->ciss_mtx);
++ xpt_free_path(path);
+ return(0);
+ }
+ sc->ciss_logical[bus][target].cl_name[0] = 0;
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-3077.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-3077.patch
new file mode 100644
index 0000000..23f68ed
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-3077.patch
@@ -0,0 +1,26 @@
+Index: sys/netinet/in_mcast.c
+===================================================================
+--- sys/netinet/in_mcast.c (revision 254252)
++++ sys/netinet/in_mcast.c (working copy)
+@@ -1648,6 +1648,8 @@
+ * has asked for, but we always tell userland how big the
+ * buffer really needs to be.
+ */
++ if (msfr.msfr_nsrcs > in_mcast_maxsocksrc)
++ msfr.msfr_nsrcs = in_mcast_maxsocksrc;
+ tss = NULL;
+ if (msfr.msfr_srcs != NULL && msfr.msfr_nsrcs > 0) {
+ tss = malloc(sizeof(struct sockaddr_storage) * msfr.msfr_nsrcs,
+Index: sys/netinet6/in6_mcast.c
+===================================================================
+--- sys/netinet6/in6_mcast.c (revision 254252)
++++ sys/netinet6/in6_mcast.c (working copy)
+@@ -1625,6 +1625,8 @@
+ * has asked for, but we always tell userland how big the
+ * buffer really needs to be.
+ */
++ if (msfr.msfr_nsrcs > in6_mcast_maxsocksrc)
++ msfr.msfr_nsrcs = in6_mcast_maxsocksrc;
+ tss = NULL;
+ if (msfr.msfr_srcs != NULL && msfr.msfr_nsrcs > 0) {
+ tss = malloc(sizeof(struct sockaddr_storage) * msfr.msfr_nsrcs,
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-3266.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-3266.patch
new file mode 100644
index 0000000..0d1a894
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-3266.patch
@@ -0,0 +1,13 @@
+Index: sys/fs/nfsserver/nfs_nfsdport.c
+===================================================================
+--- sys/fs/nfsserver/nfs_nfsdport.c (revision 249651)
++++ sys/fs/nfsserver/nfs_nfsdport.c (working copy)
+@@ -1568,6 +1568,8 @@ nfsrvd_readdir(struct nfsrv_descript *nd, int isdg
+ nd->nd_repstat = NFSERR_BAD_COOKIE;
+ #endif
+ }
++ if (!nd->nd_repstat && vp->v_type != VDIR)
++ nd->nd_repstat = NFSERR_NOTDIR;
+ if (nd->nd_repstat == 0 && cnt == 0) {
+ if (nd->nd_flag & ND_NFSV2)
+ /* NFSv2 does not have NFSERR_TOOSMALL */
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5209.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5209.patch
new file mode 100644
index 0000000..e6710e3
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5209.patch
@@ -0,0 +1,19 @@
+Index: sys/netinet/sctp_output.c
+===================================================================
+--- sys/netinet/sctp_output.c (revision 254337)
++++ sys/netinet/sctp_output.c (revision 254338)
+@@ -5406,6 +5406,14 @@
+ }
+ SCTP_BUF_LEN(m) = sizeof(struct sctp_init_chunk);
+
++ /*
++ * We might not overwrite the identification[] completely and on
++ * some platforms time_entered will contain some padding. Therefore
++ * zero out the cookie to avoid putting uninitialized memory on the
++ * wire.
++ */
++ memset(&stc, 0, sizeof(struct sctp_state_cookie));
++
+ /* the time I built cookie */
+ (void)SCTP_GETTIME_TIMEVAL(&stc.time_entered);
+
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5691.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5691.patch
new file mode 100644
index 0000000..9aef150
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5691.patch
@@ -0,0 +1,89 @@
+Index: sys/net/if.c
+===================================================================
+--- sys/net/if.c (revision 254941)
++++ sys/net/if.c (working copy)
+@@ -2553,11 +2553,23 @@
+ CURVNET_RESTORE();
+ return (EOPNOTSUPP);
+ }
++
++ /*
++ * Pass the request on to the socket control method, and if the
++ * latter returns EOPNOTSUPP, directly to the interface.
++ *
++ * Make an exception for the legacy SIOCSIF* requests. Drivers
++ * trust SIOCSIFADDR et al to come from an already privileged
++ * layer, and do not perform any credentials checks or input
++ * validation.
++ */
+ #ifndef COMPAT_43
+ error = ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd,
+ data,
+ ifp, td));
+- if (error == EOPNOTSUPP && ifp != NULL && ifp->if_ioctl != NULL)
++ if (error == EOPNOTSUPP && ifp != NULL && ifp->if_ioctl != NULL &&
++ cmd != SIOCSIFADDR && cmd != SIOCSIFBRDADDR &&
++ cmd != SIOCSIFDSTADDR && cmd != SIOCSIFNETMASK)
+ error = (*ifp->if_ioctl)(ifp, cmd, data);
+ #else
+ {
+@@ -2601,7 +2613,9 @@
+ data,
+ ifp, td));
+ if (error == EOPNOTSUPP && ifp != NULL &&
+- ifp->if_ioctl != NULL)
++ ifp->if_ioctl != NULL &&
++ cmd != SIOCSIFADDR && cmd != SIOCSIFBRDADDR &&
++ cmd != SIOCSIFDSTADDR && cmd != SIOCSIFNETMASK)
+ error = (*ifp->if_ioctl)(ifp, cmd, data);
+ switch (ocmd) {
+
+Index: sys/netinet6/in6.c
+===================================================================
+--- sys/netinet6/in6.c (revision 254941)
++++ sys/netinet6/in6.c (working copy)
+@@ -431,6 +431,18 @@
+ case SIOCGIFSTAT_ICMP6:
+ sa6 = &ifr->ifr_addr;
+ break;
++ case SIOCSIFADDR:
++ case SIOCSIFBRDADDR:
++ case SIOCSIFDSTADDR:
++ case SIOCSIFNETMASK:
++ /*
++ * Although we should pass any non-INET6 ioctl requests
++ * down to driver, we filter some legacy INET requests.
++ * Drivers trust SIOCSIFADDR et al to come from an already
++ * privileged layer, and do not perform any credentials
++ * checks or input validation.
++ */
++ return (EINVAL);
+ default:
+ sa6 = NULL;
+ break;
+Index: sys/netnatm/natm.c
+===================================================================
+--- sys/netnatm/natm.c (revision 254941)
++++ sys/netnatm/natm.c (working copy)
+@@ -339,6 +339,21 @@
+ npcb = (struct natmpcb *)so->so_pcb;
+ KASSERT(npcb != NULL, ("natm_usr_control: npcb == NULL"));
+
++ switch (cmd) {
++ case SIOCSIFADDR:
++ case SIOCSIFBRDADDR:
++ case SIOCSIFDSTADDR:
++ case SIOCSIFNETMASK:
++ /*
++ * Although we should pass any non-ATM ioctl requests
++ * down to driver, we filter some legacy INET requests.
++ * Drivers trust SIOCSIFADDR et al to come from an already
++ * privileged layer, and do not perform any credentials
++ * checks or input validation.
++ */
++ return (EINVAL);
++ }
++
+ if (ifp == NULL || ifp->if_ioctl == NULL)
+ return (EOPNOTSUPP);
+ return ((*ifp->if_ioctl)(ifp, cmd, arg));
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5710.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5710.patch
new file mode 100644
index 0000000..83f30e8
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5710.patch
@@ -0,0 +1,28 @@
+Index: sys/fs/nullfs/null_vnops.c
+===================================================================
+--- sys/fs/nullfs/null_vnops.c (revision 254941)
++++ sys/fs/nullfs/null_vnops.c (working copy)
+@@ -858,6 +858,15 @@
+ return (error);
+ }
+
++static int
++null_link(struct vop_link_args *ap)
++{
++
++ if (ap->a_tdvp->v_mount != ap->a_vp->v_mount)
++ return (EXDEV);
++ return (null_bypass((struct vop_generic_args *)ap));
++}
++
+ /*
+ * Global vfs data structures
+ */
+@@ -871,6 +880,7 @@
+ .vop_getwritemount = null_getwritemount,
+ .vop_inactive = null_inactive,
+ .vop_islocked = vop_stdislocked,
++ .vop_link = null_link,
+ .vop_lock1 = null_lock,
+ .vop_lookup = null_lookup,
+ .vop_open = null_open,
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2014-1453.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2014-1453.patch
new file mode 100644
index 0000000..fe9e97e
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2014-1453.patch
@@ -0,0 +1,70 @@
+Index: sys/fs/nfsserver/nfs_nfsdserv.c
+===================================================================
+--- sys/fs/nfsserver/nfs_nfsdserv.c (revision 264251)
++++ sys/fs/nfsserver/nfs_nfsdserv.c (working copy)
+@@ -1457,10 +1457,23 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgr
+ nfsvno_relpathbuf(&fromnd);
+ goto out;
+ }
++ /*
++ * Unlock dp in this code section, so it is unlocked before
++ * tdp gets locked. This avoids a potential LOR if tdp is the
++ * parent directory of dp.
++ */
+ if (nd->nd_flag & ND_NFSV4) {
+ tdp = todp;
+ tnes = *toexp;
+- tdirfor_ret = nfsvno_getattr(tdp, &tdirfor, nd->nd_cred, p, 0);
++ if (dp != tdp) {
++ NFSVOPUNLOCK(dp, 0);
++ tdirfor_ret = nfsvno_getattr(tdp, &tdirfor, nd->nd_cred,
++ p, 0); /* Might lock tdp. */
++ } else {
++ tdirfor_ret = nfsvno_getattr(tdp, &tdirfor, nd->nd_cred,
++ p, 1);
++ NFSVOPUNLOCK(dp, 0);
++ }
+ } else {
+ tfh.nfsrvfh_len = 0;
+ error = nfsrv_mtofh(nd, &tfh);
+@@ -1481,10 +1494,12 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgr
+ tnes = *exp;
+ tdirfor_ret = nfsvno_getattr(tdp, &tdirfor, nd->nd_cred,
+ p, 1);
++ NFSVOPUNLOCK(dp, 0);
+ } else {
++ NFSVOPUNLOCK(dp, 0);
+ nd->nd_cred->cr_uid = nd->nd_saveduid;
+ nfsd_fhtovp(nd, &tfh, LK_EXCLUSIVE, &tdp, &tnes, NULL,
+- 0, p);
++ 0, p); /* Locks tdp. */
+ if (tdp) {
+ tdirfor_ret = nfsvno_getattr(tdp, &tdirfor,
+ nd->nd_cred, p, 1);
+@@ -1499,7 +1514,7 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgr
+ if (error) {
+ if (tdp)
+ vrele(tdp);
+- vput(dp);
++ vrele(dp);
+ nfsvno_relpathbuf(&fromnd);
+ nfsvno_relpathbuf(&tond);
+ goto out;
+@@ -1514,7 +1529,7 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgr
+ }
+ if (tdp)
+ vrele(tdp);
+- vput(dp);
++ vrele(dp);
+ nfsvno_relpathbuf(&fromnd);
+ nfsvno_relpathbuf(&tond);
+ goto out;
+@@ -1523,7 +1538,7 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgr
+ /*
+ * Done parsing, now down to business.
+ */
+- nd->nd_repstat = nfsvno_namei(nd, &fromnd, dp, 1, exp, p, &fdirp);
++ nd->nd_repstat = nfsvno_namei(nd, &fromnd, dp, 0, exp, p, &fdirp);
+ if (nd->nd_repstat) {
+ if (nd->nd_flag & ND_NFSV3) {
+ nfsrv_wcc(nd, fdirfor_ret, &fdirfor, fdiraft_ret,
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-exec.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-exec.patch
new file mode 100644
index 0000000..c36bed5
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-exec.patch
@@ -0,0 +1,66 @@
+Index: sys/kern/kern_exec.c
+===================================================================
+--- sys/kern/kern_exec.c (revision 266979)
++++ sys/kern/kern_exec.c (working copy)
+@@ -280,6 +280,7 @@ kern_execve(td, args, mac_p)
+ struct mac *mac_p;
+ {
+ struct proc *p = td->td_proc;
++ struct vmspace *oldvmspace;
+ int error;
+
+ AUDIT_ARG_ARGV(args->begin_argv, args->argc,
+@@ -296,6 +297,8 @@ kern_execve(td, args, mac_p)
+ PROC_UNLOCK(p);
+ }
+
++ KASSERT((td->td_pflags & TDP_EXECVMSPC) == 0, ("nested execve"));
++ oldvmspace = td->td_proc->p_vmspace;
+ error = do_execve(td, args, mac_p);
+
+ if (p->p_flag & P_HADTHREADS) {
+@@ -310,6 +313,12 @@ kern_execve(td, args, mac_p)
+ thread_single_end();
+ PROC_UNLOCK(p);
+ }
++ if ((td->td_pflags & TDP_EXECVMSPC) != 0) {
++ KASSERT(td->td_proc->p_vmspace != oldvmspace,
++ ("oldvmspace still used"));
++ vmspace_free(oldvmspace);
++ td->td_pflags &= ~TDP_EXECVMSPC;
++ }
+
+ return (error);
+ }
+Index: sys/sys/proc.h
+===================================================================
+--- sys/sys/proc.h (revision 266979)
++++ sys/sys/proc.h (working copy)
+@@ -968,4 +968,5 @@ curthread_pflags_restore(int save)
+
+ #endif /* _KERNEL */
+
++#define TDP_EXECVMSPC 0x40000000 /* Execve destroyed old vmspace */
+ #endif /* !_SYS_PROC_H_ */
+Index: sys/vm/vm_map.c
+===================================================================
+--- sys/vm/vm_map.c (revision 266979)
++++ sys/vm/vm_map.c (working copy)
+@@ -3631,6 +3631,8 @@ vmspace_exec(struct proc *p, vm_offset_t minuser,
+ struct vmspace *oldvmspace = p->p_vmspace;
+ struct vmspace *newvmspace;
+
++ KASSERT((curthread->td_pflags & TDP_EXECVMSPC) == 0,
++ ("vmspace_exec recursed"));
+ newvmspace = vmspace_alloc(minuser, maxuser);
+ if (newvmspace == NULL)
+ return (ENOMEM);
+@@ -3647,7 +3649,7 @@ vmspace_exec(struct proc *p, vm_offset_t minuser,
+ PROC_VMSPACE_UNLOCK(p);
+ if (p == curthread->td_proc)
+ pmap_activate(curthread);
+- vmspace_free(oldvmspace);
++ curthread->td_pflags |= TDP_EXECVMSPC;
+ return (0);
+ }
+
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-gentoo.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-gentoo.patch
new file mode 100644
index 0000000..b02d8b6
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-gentoo.patch
@@ -0,0 +1,21 @@
+diff -Nur sys.orig/conf/kern.mk sys/conf/kern.mk
+--- sys.orig/conf/kern.mk 2012-07-12 13:26:37.000000000 +0900
++++ sys/conf/kern.mk 2012-07-16 02:32:19.000000000 +0900
+@@ -5,7 +5,7 @@
+ #
+ CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
+ -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \
+- -Wundef -Wno-pointer-sign -fformat-extensions \
++ -Wundef -Wno-pointer-sign \
+ -Wmissing-include-dirs -fdiagnostics-show-option \
+ ${CWARNEXTRA}
+ #
+@@ -52,7 +52,7 @@
+ #
+ .if ${MACHINE_CPUARCH} == "i386"
+ .if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang"
+-CFLAGS+= -mno-align-long-strings -mpreferred-stack-boundary=2
++CFLAGS+= -mpreferred-stack-boundary=2
+ .else
+ CFLAGS+= -mno-aes -mno-avx
+ .endif
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-ktrace.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-ktrace.patch
new file mode 100644
index 0000000..0fb6df7
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-ktrace.patch
@@ -0,0 +1,12 @@
+Index: sys/kern/kern_ktrace.c
+===================================================================
+--- sys/kern/kern_ktrace.c (revision 266771)
++++ sys/kern/kern_ktrace.c (working copy)
+@@ -119,6 +119,7 @@ static int data_lengths[] = {
+ 0, /* KTR_SYSCTL */
+ sizeof(struct ktr_proc_ctor), /* KTR_PROCCTOR */
+ 0, /* KTR_PROCDTOR */
++ 0, /* unused */
+ sizeof(struct ktr_fault), /* KTR_FAULT */
+ sizeof(struct ktr_faultend), /* KTR_FAULTEND */
+ };
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-mmap-2014.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-mmap-2014.patch
new file mode 100644
index 0000000..fd4040a
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-mmap-2014.patch
@@ -0,0 +1,20 @@
+Index: sys/vm/vm_map.c
+===================================================================
+--- sys/vm/vm_map.c (revision 259950)
++++ sys/vm/vm_map.c (revision 259951)
+@@ -1207,6 +1207,7 @@ charged:
+ }
+ else if ((prev_entry != &map->header) &&
+ (prev_entry->eflags == protoeflags) &&
++ (cow & (MAP_ENTRY_GROWS_DOWN | MAP_ENTRY_GROWS_UP)) == 0 &&
+ (prev_entry->end == start) &&
+ (prev_entry->wired_count == 0) &&
+ (prev_entry->cred == cred ||
+@@ -3339,7 +3340,6 @@ vm_map_stack(vm_map_t map, vm_offset_t addrbos, vm
+ * NOTE: We explicitly allow bi-directional stacks.
+ */
+ orient = cow & (MAP_STACK_GROWS_DOWN|MAP_STACK_GROWS_UP);
+- cow &= ~orient;
+ KASSERT(orient != 0, ("No stack grow direction"));
+
+ if (addrbos < vm_map_min(map) ||
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-mmap.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-mmap.patch
new file mode 100644
index 0000000..ef2d0a7
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-mmap.patch
@@ -0,0 +1,20 @@
+http://www.freebsd.org/security/advisories/FreeBSD-SA-13:06.mmap.asc
+https://bugs.gentoo.org/show_bug.cgi?id=473688
+
+Index: sys/vm/vm_map.c
+===================================================================
+--- sys/vm/vm_map.c (revision 251636)
++++ sys/vm/vm_map.c (working copy)
+@@ -3761,6 +3761,12 @@ RetryLookup:;
+ vm_map_unlock_read(map);
+ return (KERN_PROTECTION_FAILURE);
+ }
++ if ((fault_typea & VM_PROT_COPY) != 0 &&
++ (entry->max_protection & VM_PROT_WRITE) == 0 &&
++ (entry->eflags & MAP_ENTRY_COW) == 0) {
++ vm_map_unlock_read(map);
++ return (KERN_PROTECTION_FAILURE);
++ }
+
+ /*
+ * If this page is not pageable, we have to get it for all possible
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-nfsserver.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-nfsserver.patch
new file mode 100644
index 0000000..767588f
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-nfsserver.patch
@@ -0,0 +1,16 @@
+http://www.freebsd.org/security/advisories/FreeBSD-SA-13:08.nfsserver.asc
+https://bugs.gentoo.org/show_bug.cgi?id=478314
+
+Index: sys/kern/vfs_export.c
+===================================================================
+--- sys/kern/vfs_export.c (revision 253367)
++++ sys/kern/vfs_export.c (working copy)
+@@ -208,7 +208,7 @@
+ np->netc_anon = crget();
+ np->netc_anon->cr_uid = argp->ex_anon.cr_uid;
+ crsetgroups(np->netc_anon, argp->ex_anon.cr_ngroups,
+- np->netc_anon->cr_groups);
++ argp->ex_anon.cr_groups);
+ np->netc_anon->cr_prison = &prison0;
+ prison_hold(np->netc_anon->cr_prison);
+ np->netc_numsecflavors = argp->ex_numsecflavors;
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-random.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-random.patch
new file mode 100644
index 0000000..bb3caba
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-random.patch
@@ -0,0 +1,27 @@
+Index: sys/dev/random/probe.c
+===================================================================
+--- sys/dev/random/probe.c (revision 260523)
++++ sys/dev/random/probe.c (working copy)
+@@ -30,6 +30,8 @@ __FBSDID("$FreeBSD$");
+
+ #include <sys/types.h>
+ #include <sys/param.h>
++#include <sys/systm.h>
++#include <sys/kernel.h>
+ #include <sys/malloc.h>
+ #include <sys/random.h>
+ #include <sys/selinfo.h>
+@@ -57,7 +59,12 @@ random_ident_hardware(struct random_systat *systat
+ /* Then go looking for hardware */
+ #if defined(__amd64__) || (defined(__i386__) && !defined(PC98))
+ if (via_feature_rng & VIA_HAS_RNG) {
+- *systat = random_nehemiah;
++ int enable;
++
++ enable = 0;
++ TUNABLE_INT_FETCH("hw.nehemiah_rng_enable", &enable);
++ if (enable)
++ *systat = random_nehemiah;
+ }
+ #endif
+ }
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-tcp.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-tcp.patch
new file mode 100644
index 0000000..2f82a5f
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-tcp.patch
@@ -0,0 +1,32 @@
+Index: sys/netinet/tcp_reass.c
+===================================================================
+--- sys/netinet/tcp_reass.c (revision 264836)
++++ sys/netinet/tcp_reass.c (working copy)
+@@ -211,7 +211,7 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int
+ * Investigate why and re-evaluate the below limit after the behaviour
+ * is understood.
+ */
+- if (th->th_seq != tp->rcv_nxt &&
++ if ((th->th_seq != tp->rcv_nxt || !TCPS_HAVEESTABLISHED(tp->t_state)) &&
+ tp->t_segqlen >= (so->so_rcv.sb_hiwat / tp->t_maxseg) + 1) {
+ V_tcp_reass_overflows++;
+ TCPSTAT_INC(tcps_rcvmemdrop);
+@@ -234,7 +234,7 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int
+ */
+ te = uma_zalloc(V_tcp_reass_zone, M_NOWAIT);
+ if (te == NULL) {
+- if (th->th_seq != tp->rcv_nxt) {
++ if (th->th_seq != tp->rcv_nxt || !TCPS_HAVEESTABLISHED(tp->t_state)) {
+ TCPSTAT_INC(tcps_rcvmemdrop);
+ m_freem(m);
+ *tlenp = 0;
+@@ -282,7 +282,8 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int
+ TCPSTAT_INC(tcps_rcvduppack);
+ TCPSTAT_ADD(tcps_rcvdupbyte, *tlenp);
+ m_freem(m);
+- uma_zfree(V_tcp_reass_zone, te);
++ if (te != &tqs)
++ uma_zfree(V_tcp_reass_zone, te);
+ tp->t_segqlen--;
+ /*
+ * Try to present any queued data
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.2-gentoo-gcc.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.2-gentoo-gcc.patch
new file mode 100644
index 0000000..9076fd2
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.2-gentoo-gcc.patch
@@ -0,0 +1,13 @@
+diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh
+index e504f75..7aa63df 100644
+--- a/sys/conf/newvers.sh
++++ b/sys/conf/newvers.sh
+@@ -86,7 +86,7 @@ fi
+ touch version
+ v=`cat version` u=${USER:-root} d=`pwd` h=${HOSTNAME:-`hostname`} t=`date`
+ i=`${MAKE:-make} -V KERN_IDENT`
+-compiler_v=$($(${MAKE:-make} -V CC) -v 2>&1 | grep 'version')
++compiler_v=$($(${MAKE:-make} -V CC) -v 2>&1 | grep 'version' | tail -n 1)
+
+ for dir in /bin /usr/bin /usr/local/bin; do
+ if [ -x "${dir}/svnversion" ] ; then
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-cve-2012-0217.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-cve-2012-0217.patch
new file mode 100644
index 0000000..0bf1b61
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-cve-2012-0217.patch
@@ -0,0 +1,26 @@
+Index: sys/amd64/amd64/trap.c
+===================================================================
+--- sys/amd64/amd64/trap.c.orig
++++ sys/amd64/amd64/trap.c (working copy)
+@@ -972,4 +972,21 @@
+ syscallname(td->td_proc, sa.code)));
+
+ syscallret(td, error, &sa);
++
++ /*
++ * If the user-supplied value of %rip is not a canonical
++ * address, then some CPUs will trigger a ring 0 #GP during
++ * the sysret instruction. However, the fault handler would
++ * execute with the user's %gs and %rsp in ring 0 which would
++ * not be safe. Instead, preemptively kill the thread with a
++ * SIGBUS.
++ */
++ if (td->td_frame->tf_rip >= VM_MAXUSER_ADDRESS) {
++ ksiginfo_init_trap(&ksi);
++ ksi.ksi_signo = SIGBUS;
++ ksi.ksi_code = BUS_OBJERR;
++ ksi.ksi_trapno = T_PROTFLT;
++ ksi.ksi_addr = (void *)td->td_frame->tf_rip;
++ trapsignal(td, &ksi);
++ }
+ }
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-ubin-10.3-bmake-workaround.patch b/sys-freebsd/freebsd-sources/files/freebsd-ubin-10.3-bmake-workaround.patch
new file mode 100644
index 0000000..c0ca444
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-ubin-10.3-bmake-workaround.patch
@@ -0,0 +1,13 @@
+diff --git a/usr.bin/bmake/Makefile b/usr.bin/bmake/Makefile
+index 6c6d8c2..22fec7a 100644
+--- a/usr.bin/bmake/Makefile
++++ b/usr.bin/bmake/Makefile
+@@ -5,7 +5,7 @@
+
+ .sinclude "Makefile.inc"
+
+-SRCTOP?= ${.CURDIR:H:H}
++SRCTOP= ${.CURDIR:H:H}
+
+ # look here first for config.h
+ CFLAGS+= -I${.CURDIR}
diff --git a/sys-freebsd/freebsd-sources/freebsd-sources-11.0.ebuild b/sys-freebsd/freebsd-sources/freebsd-sources-11.0.ebuild
new file mode 100644
index 0000000..e01278e
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/freebsd-sources-11.0.ebuild
@@ -0,0 +1,174 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic toolchain-funcs
+
+DESCRIPTION="FreeBSD kernel sources"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+IUSE="+build-kernel debug dtrace zfs"
+
+# Security Advisory and Errata patches.
+UPSTREAM_PATCHES=( "SA-16:18/atkbd.patch"
+ "SA-16:19/sendmsg.patch"
+ "SA-16:20/linux.patch"
+ "SA-16:21/stat.patch"
+ "EN-16:07/ipi.patch"
+ "EN-16:08/zfs.patch"
+ "EN-16:11/vmbus.patch"
+ "EN-16:12/hv_storvsc.patch"
+ "EN-16:13/vmbus.patch"
+ "EN-16:14/hv_storvsc.patch"
+ "EN-16:15/vmbus.patch"
+ "EN-16:16/hv_storvsc.patch" )
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ sys/
+ contrib/bmake/
+ usr.bin/bmake/
+"
+
+RDEPEND="dtrace? ( >=sys-freebsd/freebsd-cddl-9.2_rc1 )
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ !sys-freebsd/virtio-kmod
+ !sys-fs/fuse4bsd
+ !<sys-freebsd/freebsd-sources-9.2_beta1"
+DEPEND="build-kernel? (
+ dtrace? ( >=sys-freebsd/freebsd-cddl-9.2_rc1 )
+ >=sys-freebsd/freebsd-usbin-9.1
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ )"
+
+RESTRICT="strip binchecks"
+
+S="${WORKDIR}/sys"
+
+KERN_BUILD=GENTOO
+
+PATCHES=( "${FILESDIR}/${PN}-9.0-disable-optimization.patch"
+ "${FILESDIR}/${PN}-10.0-gentoo.patch"
+ "${FILESDIR}/${PN}-6.0-flex-2.5.31.patch"
+ "${FILESDIR}/${PN}-8.0-subnet-route-pr40133.patch"
+ "${FILESDIR}/${PN}-7.1-includes.patch"
+ "${FILESDIR}/${PN}-9.0-sysctluint.patch"
+ "${FILESDIR}/${PN}-9.2-gentoo-gcc.patch"
+ "${FILESDIR}/${PN}-10.1-gcc48.patch" )
+
+pkg_setup() {
+ # Add the required source files.
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ # WITHOUT_SSP= is required to boot kernel that compiled with newer gcc, bug #477914
+ [[ $(tc-getCC) == *gcc* ]] && mymakeopts="${mymakeopts} WITHOUT_SSP="
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL="
+}
+
+src_prepare() {
+ local conf="${S}/$(tc-arch-kernel)/conf/${KERN_BUILD}"
+
+ cd "${WORKDIR}" || die
+ epatch "${FILESDIR}/freebsd-ubin-10.3-bmake-workaround.patch"
+ cd "${S}" || die
+
+ # This replaces the gentoover patch, it doesn't need reapply every time.
+ sed -i -e 's:^REVISION=.*:REVISION="'${PVR}'":' \
+ -e 's:^BRANCH=.*:BRANCH="Gentoo":' \
+ -e 's:^VERSION=.*:VERSION="${TYPE} ${BRANCH} ${REVISION}":' \
+ "${S}/conf/newvers.sh"
+
+ # __FreeBSD_cc_version comes from FreeBSD's gcc.
+ # on 10.0-RELEASE it's 1000001.
+ # FYI, can get it from gnu/usr.bin/cc/cc_tools/freebsd-native.h.
+ sed -e "s:-D_KERNEL:-D_KERNEL -D__FreeBSD_cc_version=1000001:g" \
+ -i "${S}/conf/kern.pre.mk" \
+ -i "${S}/conf/kmod.mk" || die "Couldn't set __FreeBSD_cc_version"
+
+ # Remove -Werror
+ sed -e "s:-Werror:-Wno-error:g" \
+ -i "${S}/conf/kern.pre.mk" \
+ -i "${S}/conf/kmod.mk" || die
+
+ # Set the kernel configuration using USE flags.
+ cp -f "${FILESDIR}/config-GENTOO" "${conf}" || die
+ use debug || echo 'nomakeoptions DEBUG' >> "${conf}"
+ use dtrace || echo 'nomakeoptions WITH_CTF' >> "${conf}"
+
+ # Only used with USE=build-kernel, let the kernel build with its own flags, its safer.
+ unset LDFLAGS CFLAGS CXXFLAGS ASFLAGS KERNEL
+}
+
+src_configure() {
+ if use build-kernel ; then
+ tc-export CC
+ cd "${S}/$(tc-arch-kernel)/conf" || die
+ config ${KERN_BUILD} || die
+ fi
+}
+
+src_compile() {
+ if use build-kernel ; then
+ if has_version "<sys-freebsd/freebsd-ubin-10.0"; then
+ cd "${WORKDIR}"/usr.bin/bmake || die
+ CC=${CHOST}-gcc freebsd_src_compile
+ export BMAKE="${WORKDIR}/usr.bin/bmake/make"
+ fi
+ cd "${S}/$(tc-arch-kernel)/compile/${KERN_BUILD}" || die
+ freebsd_src_compile depend
+ freebsd_src_compile
+ else
+ einfo "Nothing to compile.."
+ fi
+}
+
+src_install() {
+ if use build-kernel ; then
+ cd "${S}/$(tc-arch-kernel)/compile/${KERN_BUILD}" || die
+ freebsd_src_install
+ rm -rf "${S}/$(tc-arch-kernel)/compile/${KERN_BUILD}"
+ cd "${S}"
+ fi
+
+ insinto "/usr/src/sys"
+ doins -r "${S}/".
+ if use zfs ; then
+ insinto "/usr/src/cddl"
+ doins -r "${WORKDIR}/cddl/".
+ fi
+}
+
+pkg_preinst() {
+ if [[ -L "${ROOT}/usr/src/sys" ]]; then
+ einfo "/usr/src/sys is a symlink, removing it..."
+ rm -f "${ROOT}/usr/src/sys"
+ fi
+
+ if use sparc-fbsd ; then
+ ewarn "WARNING: kldload currently causes kernel panics"
+ ewarn "on sparc64. This is probably a gcc-4.1 issue, but"
+ ewarn "we need gcc-4.1 to compile the kernel correctly :/"
+ ewarn "Please compile all modules you need into the kernel"
+ fi
+
+ ewarn "If you want manual compile (not recommended), please don't forget the following step."
+ if ! use sparc-fbsd ; then
+ ewarn "export CC=clang"
+ ewarn "export CXX=clang++"
+ fi
+ if ! use zfs ; then
+ ewarn "export WITHOUT_CDDL="
+ ewarn "Note, Please set USE=zfs if you want to enable modules of CDDL license."
+ fi
+ if ! use dtrace && ! has_version '>=sys-freebsd/freebsd-cddl-9.2_beta1' ; then
+ ewarn "GENERIC config require sys-freebsd/freebsd-cddl. Please emerge it."
+ fi
+}
diff --git a/sys-freebsd/freebsd-sources/metadata.xml b/sys-freebsd/freebsd-sources/metadata.xml
new file mode 100644
index 0000000..3860e80
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/metadata.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+ </maintainer>
+ <use>
+ <flag name="build-kernel">Build and install a kernel (recommended).</flag>
+ <flag name="dtrace">Enable DTrace support.</flag>
+ <flag name="zfs">Enable ZFS support.</flag>
+ </use>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-atf.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-atf.patch
new file mode 100644
index 0000000..d758c48
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-atf.patch
@@ -0,0 +1,15 @@
+diff --git a/usr.bin/atf/atf-sh/Makefile b/usr.bin/atf/atf-sh/Makefile
+index 4ebdc33..37ff8fa 100644
+--- a/usr.bin/atf/atf-sh/Makefile
++++ b/usr.bin/atf/atf-sh/Makefile
+@@ -33,8 +33,8 @@ PROG_CXX= atf-sh
+ SRCS= atf-sh.cpp
+ MAN= atf-sh.1 atf-sh-api.3
+
+-CFLAGS+= -DHAVE_CONFIG_H
+-CFLAGS+= -I${ATF}
++CXXFLAGS+= -DHAVE_CONFIG_H
++CXXFLAGS+= -I${ATF}
+
+ DPADD+= ${LIBATF_C} ${LIBATF_CXX}
+ LDADD+= -latf-c++ -latf-c
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-dtc-gcc46.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-dtc-gcc46.patch
new file mode 100644
index 0000000..1125238
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-dtc-gcc46.patch
@@ -0,0 +1,25 @@
+diff --git a/usr.bin/dtc/string.hh b/usr.bin/dtc/string.hh
+index 45bc4fd..6eaf8e4 100644
+--- a/usr.bin/dtc/string.hh
++++ b/usr.bin/dtc/string.hh
+@@ -32,6 +32,8 @@
+
+ #ifndef _STRING_HH_
+ #define _STRING_HH_
++#include <cstdio>
++#include <cstring>
+ #include "input_buffer.hh"
+
+ namespace dtc
+diff --git a/usr.bin/dtc/util.hh b/usr.bin/dtc/util.hh
+index 7f2ec67..8e13b1c 100644
+--- a/usr.bin/dtc/util.hh
++++ b/usr.bin/dtc/util.hh
+@@ -33,6 +33,7 @@
+ #ifndef _UTIL_HH_
+ #define _UTIL_HH_
+
++#include <stdint.h>
+ #include <vector>
+
+ // If we aren't using C++11, then just ignore static asserts.
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-kdump-ioctl.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-kdump-ioctl.patch
new file mode 100644
index 0000000..e106852
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-kdump-ioctl.patch
@@ -0,0 +1,26 @@
+diff --git a/usr.bin/kdump/Makefile b/usr.bin/kdump/Makefile
+index 38e9df6..5e831c6 100644
+--- a/usr.bin/kdump/Makefile
++++ b/usr.bin/kdump/Makefile
+@@ -22,7 +22,7 @@ CLEANFILES= ioctl.c kdump_subr.c kdump_subr.h linux_syscalls.c
+
+ ioctl.c: mkioctls
+ env MACHINE=${MACHINE} CPP="${CPP}" \
+- sh ${.CURDIR}/mkioctls print ${DESTDIR}/usr/include > ${.TARGET}
++ sh ${.CURDIR}/mkioctls print ${.CURDIR}/../../include > ${.TARGET}
+
+ kdump_subr.h: mksubr
+ sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include | \
+diff --git a/usr.bin/truss/Makefile b/usr.bin/truss/Makefile
+index 7a49497..bc8b61f 100644
+--- a/usr.bin/truss/Makefile
++++ b/usr.bin/truss/Makefile
+@@ -24,7 +24,7 @@ syscalls.h: syscalls.master
+
+ ioctl.c: ${.CURDIR}/../kdump/mkioctls
+ env MACHINE=${MACHINE} CPP="${CPP}" \
+- /bin/sh ${.CURDIR}/../kdump/mkioctls return ${DESTDIR}/usr/include > ${.TARGET}
++ /bin/sh ${.CURDIR}/../kdump/mkioctls return ${.CURDIR}/../../include > ${.TARGET}
+
+ .if ${MACHINE_CPUARCH} == "i386"
+ SRCS+= i386-linux.c linux_syscalls.h
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-mandoc.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-mandoc.patch
new file mode 100644
index 0000000..c5f7706
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-mandoc.patch
@@ -0,0 +1,13 @@
+diff --git a/usr.bin/mandoc/Makefile b/usr.bin/mandoc/Makefile
+index 0995534..1bcb3e0 100644
+--- a/usr.bin/mandoc/Makefile
++++ b/usr.bin/mandoc/Makefile
+@@ -1,7 +1,7 @@
+ # $FreeBSD$
+
+ MDOCMLDIR= ${.CURDIR}/../../contrib/mdocml
+-LIBMANDOC= ${.OBJDIR}/../../lib/libmandoc/libmandoc.a
++LIBMANDOC= ${.CURDIR}/../../lib/libmandoc/libmandoc.a
+ .PATH: ${MDOCMLDIR}
+
+ PROG= mandoc
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.1-kdump-workaround.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.1-kdump-workaround.patch
new file mode 100644
index 0000000..064647c
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.1-kdump-workaround.patch
@@ -0,0 +1,13 @@
+diff --git a/usr.bin/kdump/Makefile b/usr.bin/kdump/Makefile
+index cbf31d0..fa0d04d 100644
+--- a/usr.bin/kdump/Makefile
++++ b/usr.bin/kdump/Makefile
+@@ -8,7 +8,7 @@ SFX= 32
+ .PATH: ${.CURDIR}/../ktrace
+
+ PROG= kdump
+-SRCS= kdump_subr.c kdump.c ioctl.c subr.c
++SRCS= kdump_subr.h kdump_subr.c kdump.c ioctl.c subr.c
+ DPSRCS= kdump_subr.h
+ CFLAGS+= -I${.CURDIR}/../ktrace -I${.CURDIR} -I${.CURDIR}/../.. -I.
+
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.2-bsdxml.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.2-bsdxml.patch
new file mode 100644
index 0000000..6064717
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.2-bsdxml.patch
@@ -0,0 +1,13 @@
+diff --git a/usr.bin/mt/mt.c b/usr.bin/mt/mt.c
+index af6562b..3121c81 100644
+--- a/usr.bin/mt/mt.c
++++ b/usr.bin/mt/mt.c
+@@ -92,7 +92,7 @@ __FBSDID("$FreeBSD: stable/10/usr.bin/mt/mt.c 280438 2015-03-24 14:36:10Z ken $"
+ #include <unistd.h>
+ #include <stdint.h>
+ #include <errno.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <mtlib.h>
+
+ #include <cam/cam.h>
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.2-talk-workaround.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.2-talk-workaround.patch
new file mode 100644
index 0000000..3a65b37
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.2-talk-workaround.patch
@@ -0,0 +1,12 @@
+diff --git a/usr.bin/talk/io.c b/usr.bin/talk/io.c
+index 4daad7a..1fb9105 100644
+--- a/usr.bin/talk/io.c
++++ b/usr.bin/talk/io.c
+@@ -50,6 +50,7 @@ static const char sccsid[] = "@(#)io.c 8.1 (Berkeley) 6/6/93";
+ #include <stdlib.h>
+ #include <string.h>
+ #include <unistd.h>
++#include <wctype.h>
+ #define _XOPEN_SOURCE_EXTENDED
+ #include <curses.h>
+
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.3-bmake-workaround.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.3-bmake-workaround.patch
new file mode 100644
index 0000000..c0ca444
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.3-bmake-workaround.patch
@@ -0,0 +1,13 @@
+diff --git a/usr.bin/bmake/Makefile b/usr.bin/bmake/Makefile
+index 6c6d8c2..22fec7a 100644
+--- a/usr.bin/bmake/Makefile
++++ b/usr.bin/bmake/Makefile
+@@ -5,7 +5,7 @@
+
+ .sinclude "Makefile.inc"
+
+-SRCTOP?= ${.CURDIR:H:H}
++SRCTOP= ${.CURDIR:H:H}
+
+ # look here first for config.h
+ CFLAGS+= -I${.CURDIR}
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-bsdcmp.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-bsdcmp.patch
new file mode 100644
index 0000000..1a85529
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-bsdcmp.patch
@@ -0,0 +1,13 @@
+Index: fbsd-6.0/usr.bin/cmp/Makefile
+===================================================================
+--- fbsd-6.0.orig/usr.bin/cmp/Makefile
++++ fbsd-6.0/usr.bin/cmp/Makefile
+@@ -1,7 +1,7 @@
+ # @(#)Makefile 8.1 (Berkeley) 6/6/93
+ # $FreeBSD: src/usr.bin/cmp/Makefile,v 1.6.14.1 2005/09/17 11:33:41 brian Exp $
+
+-PROG= cmp
++PROG= bsdcmp
+ SRCS= cmp.c link.c misc.c regular.c special.c
+
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-fixmakefiles.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-fixmakefiles.patch
new file mode 100644
index 0000000..b135a82
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-fixmakefiles.patch
@@ -0,0 +1,35 @@
+Index: usr.bin/calendar/Makefile
+===================================================================
+--- usr.bin/calendar/Makefile.orig
++++ usr.bin/calendar/Makefile
+@@ -10,6 +10,7 @@ FR_LINKS= fr_FR.ISO8859-15
+ TEXTMODE?= 444
+
+ beforeinstall:
++ ${INSTALL} -d ${DESTDIR}${SHAREDIR}/calendar
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${TEXTMODE} \
+ ${.CURDIR}/calendars/calendar.* ${DESTDIR}${SHAREDIR}/calendar
+ .for lang in ${INTER}
+Index: usr.bin/ee/Makefile
+===================================================================
+--- usr.bin/ee/Makefile.orig
++++ usr.bin/ee/Makefile
+@@ -12,12 +12,12 @@ LDADD= -lncurses
+ NLS= en_US.US-ASCII fr_FR.ISO8859-1 de_DE.ISO8859-1 pl_PL.ISO8859-2 \
+ uk_UA.KOI8-U ru_RU.KOI8-R
+
+-NLSLINKS_en_US.US-ASCII= en_US.ISO8859-1 en_US.ISO8859-15
+-NLSLINKS_fr_FR.ISO8859-1= fr_BE.ISO8859-1 fr_BE.ISO8859-15 \
+- fr_CA.ISO8859-1 fr_CA.ISO8859-15 fr_CH.ISO8859-1 fr_CH.ISO8859-15 \
+- fr_FR.ISO8859-15
+-NLSLINKS_de_DE.ISO8859-1= de_AT.ISO8859-1 de_AT.ISO8859-15 de_CH.ISO8859-1 \
+- de_CH.ISO8859-15 de_DE.ISO8859-15
++#NLSLINKS_en_US.US-ASCII= en_US.ISO8859-1 en_US.ISO8859-15
++#NLSLINKS_fr_FR.ISO8859-1= fr_BE.ISO8859-1 fr_BE.ISO8859-15 \
++# fr_CA.ISO8859-1 fr_CA.ISO8859-15 fr_CH.ISO8859-1 fr_CH.ISO8859-15 \
++# fr_FR.ISO8859-15
++#NLSLINKS_de_DE.ISO8859-1= de_AT.ISO8859-1 de_AT.ISO8859-15 de_CH.ISO8859-1 \
++# de_CH.ISO8859-15 de_DE.ISO8859-15
+
+ NLSSRCFILES=ee.msg
+ .for lang in ${NLS}
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-kdump-ioctl.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-kdump-ioctl.patch
new file mode 100644
index 0000000..a89cf52
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-kdump-ioctl.patch
@@ -0,0 +1,28 @@
+By default the mkioctl program that generates code for kdump does look for
+ioctls in the whole /usr/include tree, but this does break when xorg is merged.
+This patch allows to look for include files only in the source tree.
+
+Index: fbsd-6/usr.bin/kdump/Makefile
+===================================================================
+--- fbsd-6.orig/usr.bin/kdump/Makefile
++++ fbsd-6/usr.bin/kdump/Makefile
+@@ -10,6 +10,6 @@ CFLAGS+= -I${.CURDIR}/../ktrace -I${.CUR
+ CLEANFILES= ioctl.c
+
+ ioctl.c: mkioctls
+- sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include > ${.TARGET}
++ sh ${.CURDIR}/mkioctls ${.CURDIR}/../../include > ${.TARGET}
+
+ .include <bsd.prog.mk>
+Index: fbsd-6/usr.bin/truss/Makefile
+===================================================================
+--- fbsd-6.orig/usr.bin/truss/Makefile
++++ fbsd-6/usr.bin/truss/Makefile
+@@ -29,6 +29,6 @@ syscalls.h: syscalls.master
+ ${.CURDIR}/i386.conf
+
+ ioctl.c: ${.CURDIR}/../kdump/mkioctls
+- sh ${.CURDIR}/../kdump/mkioctls ${DESTDIR}/usr/include > ${.TARGET}
++ sh ${.CURDIR}/../kdump/mkioctls ${.CURDIR}/../../include > ${.TARGET}
+
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.0-bsdar.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.0-bsdar.patch
new file mode 100644
index 0000000..c966b9b
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.0-bsdar.patch
@@ -0,0 +1,21 @@
+--- usr.bin/ar/Makefile.old 2010-03-12 14:50:30 +0100
++++ usr.bin/ar/Makefile 2010-03-12 14:50:53 +0100
+@@ -1,6 +1,6 @@
+ # $FreeBSD: src/usr.bin/ar/Makefile,v 1.22.2.1.2.1 2009/10/25 01:10:29 kensmith Exp $
+
+-PROG= ar
++PROG= freebsd-ar
+ SRCS= ar.c acplex.l acpyacc.y read.c util.c write.c y.tab.h
+
+ WARNS?= 5
+@@ -10,8 +10,7 @@
+
+ CFLAGS+=-I. -I${.CURDIR}
+
+-NO_SHARED?= yes
+-LINKS= ${BINDIR}/ar ${BINDIR}/ranlib
+-MLINKS= ar.1 ranlib.1
++LINKS= ${BINDIR}/freebsd-ar ${BINDIR}/freebsd-ranlib
++MLINKS= freebsd-ar.1 freebsd-ranlib.1
+
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.0-xinstall.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.0-xinstall.patch
new file mode 100644
index 0000000..e8f978a
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.0-xinstall.patch
@@ -0,0 +1,26 @@
+Parallel make installs often cause 2 concurrent install -d to fail
+while they are creating the path to the target dirs.
+This patch changes the failure to a warning so that a make -j6 install doesn't
+fails as often as it does on Gentoo/FreeBSD, if it uses /usr/bin/install.
+
+--- usr.bin/xinstall/xinstall.c.orig
++++ usr.bin/xinstall/xinstall.c
+@@ -748,9 +748,17 @@
+ ch = *p;
+ *p = '\0';
+ if (stat(path, &sb)) {
+- if (errno != ENOENT || mkdir(path, 0755) < 0) {
++ if (errno != ENOENT) {
+ err(EX_OSERR, "mkdir %s", path);
+ /* NOTREACHED */
++ } else if (mkdir(path, 0755) < 0) {
++ /* Previous errno from stat() says that the directory didn't exist (ENOENT)
++ * But if errno is now EEXIST, then we just hit a parallel make bug.
++ */
++ if (errno == EEXIST)
++ warn("mkdir: %s now exists!", path); /* let me know when this happens */
++ else
++ err(EX_OSERR, "mkdir %s", path);
+ } else if (verbose)
+ (void)printf("install: mkdir %s\n",
+ path);
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.2-compress.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.2-compress.patch
new file mode 100644
index 0000000..5bd1d55
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.2-compress.patch
@@ -0,0 +1,55 @@
+Index: usr.bin/compress/zopen.c
+===================================================================
+--- usr.bin/compress/zopen.c (revision 225020)
++++ usr.bin/compress/zopen.c (working copy)
+@@ -486,7 +486,7 @@ zread(void *cookie, char *rbp, int num)
+ block_compress = maxbits & BLOCK_MASK;
+ maxbits &= BIT_MASK;
+ maxmaxcode = 1L << maxbits;
+- if (maxbits > BITS) {
++ if (maxbits > BITS || maxbits < 12) {
+ errno = EFTYPE;
+ return (-1);
+ }
+@@ -513,17 +513,28 @@ zread(void *cookie, char *rbp, int num)
+ for (code = 255; code >= 0; code--)
+ tab_prefixof(code) = 0;
+ clear_flg = 1;
+- free_ent = FIRST - 1;
+- if ((code = getcode(zs)) == -1) /* O, untimely death! */
+- break;
++ free_ent = FIRST;
++ oldcode = -1;
++ continue;
+ }
+ incode = code;
+
+- /* Special case for KwKwK string. */
++ /* Special case for kWkWk string. */
+ if (code >= free_ent) {
++ if (code > free_ent || oldcode == -1) {
++ /* Bad stream. */
++ errno = EINVAL;
++ return (-1);
++ }
+ *stackp++ = finchar;
+ code = oldcode;
+ }
++ /*
++ * The above condition ensures that code < free_ent.
++ * The construction of tab_prefixof in turn guarantees that
++ * each iteration decreases code and therefore stack usage is
++ * bound by 1 << BITS - 256.
++ */
+
+ /* Generate output characters in reverse order. */
+ while (code >= 256) {
+@@ -540,7 +551,7 @@ middle: do {
+ } while (stackp > de_stack);
+
+ /* Generate the new entry. */
+- if ((code = free_ent) < maxmaxcode) {
++ if ((code = free_ent) < maxmaxcode && oldcode != -1) {
+ tab_prefixof(code) = (u_short) oldcode;
+ tab_suffixof(code) = finchar;
+ free_ent = code + 1;
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.0-fixmakefiles.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.0-fixmakefiles.patch
new file mode 100644
index 0000000..d34eb9e
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.0-fixmakefiles.patch
@@ -0,0 +1,11 @@
+diff -uNr usr.bin.old/calendar/Makefile usr.bin/calendar/Makefile
+--- usr.bin.old/calendar/Makefile 2011-11-02 18:22:09.000000000 +0000
++++ usr.bin/calendar/Makefile 2011-11-02 18:22:48.000000000 +0000
+@@ -15,6 +15,7 @@
+ WARNS?= 7
+
+ beforeinstall:
++ ${INSTALL} -d ${DESTDIR}${SHAREDIR}/calendar
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${TEXTMODE} \
+ ${.CURDIR}/calendars/calendar.* ${DESTDIR}${SHAREDIR}/calendar
+ .for lang in ${INTER}
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-ar-libarchive3.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-ar-libarchive3.patch
new file mode 100644
index 0000000..d4d89e1
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-ar-libarchive3.patch
@@ -0,0 +1,19 @@
+diff -Nur usr.bin.orig/ar/ar.c usr.bin/ar/ar.c
+--- usr.bin.orig/ar/ar.c 2012-01-03 12:23:45.000000000 +0900
++++ usr.bin/ar/ar.c 2012-12-25 20:50:29.000000000 +0900
+@@ -386,13 +386,13 @@
+ static void
+ bsdar_version(void)
+ {
+- (void)printf("BSD ar %s - %s\n", BSDAR_VERSION, archive_version());
++ (void)printf("BSD ar %s - %s\n", BSDAR_VERSION, archive_version_string());
+ exit(EX_OK);
+ }
+
+ static void
+ ranlib_version(void)
+ {
+- (void)printf("ranlib %s - %s\n", BSDAR_VERSION, archive_version());
++ (void)printf("ranlib %s - %s\n", BSDAR_VERSION, archive_version_string());
+ exit(EX_OK);
+ }
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-bsdar.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-bsdar.patch
new file mode 100644
index 0000000..a65185f
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-bsdar.patch
@@ -0,0 +1,25 @@
+diff -Nur work.orig/usr.bin/ar/Makefile work/usr.bin/ar/Makefile
+--- work.orig/usr.bin/ar/Makefile 2012-07-16 03:59:48.000000000 +0900
++++ work/usr.bin/ar/Makefile 2012-07-16 04:02:38.000000000 +0900
+@@ -2,7 +2,7 @@
+
+ .include <bsd.own.mk>
+
+-PROG= ar
++PROG= freebsd-ar
+ SRCS= ar.c acplex.l acpyacc.y read.c util.c write.c y.tab.h
+
+ DPADD= ${LIBARCHIVE} ${LIBELF}
+@@ -10,10 +10,7 @@
+
+ CFLAGS+=-I. -I${.CURDIR}
+
+-.if ${MK_SHARED_TOOLCHAIN} == "no"
+-NO_SHARED?= yes
+-.endif
+-LINKS= ${BINDIR}/ar ${BINDIR}/ranlib
+-MLINKS= ar.1 ranlib.1
++LINKS= ${BINDIR}/freebsd-ar ${BINDIR}/freebsd-ranlib
++MLINKS= freebsd-ar.1 freebsd-ranlib.1
+
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-grep.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-grep.patch
new file mode 100644
index 0000000..06cc5d2
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-grep.patch
@@ -0,0 +1,17 @@
+diff -Nur work.orig/usr.bin/grep/Makefile work/usr.bin/grep/Makefile
+--- work.orig/usr.bin/grep/Makefile 2012-07-16 04:59:01.000000000 +0900
++++ work/usr.bin/grep/Makefile 2012-07-16 05:00:15.000000000 +0900
+@@ -40,13 +40,6 @@
+ grep.1 lzfgrep.1
+ .endif
+
+-LINKS+= ${BINDIR}/${PROG} ${BINDIR}/xzgrep \
+- ${BINDIR}/${PROG} ${BINDIR}/xzegrep \
+- ${BINDIR}/${PROG} ${BINDIR}/xzfgrep \
+- ${BINDIR}/${PROG} ${BINDIR}/lzgrep \
+- ${BINDIR}/${PROG} ${BINDIR}/lzegrep \
+- ${BINDIR}/${PROG} ${BINDIR}/lzfgrep
+-
+ LDADD= -lz -llzma
+ DPADD= ${LIBZ} ${LIBLZMA}
+
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-kdump-ioctl.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-kdump-ioctl.patch
new file mode 100644
index 0000000..d98e599
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-kdump-ioctl.patch
@@ -0,0 +1,24 @@
+diff -Nur work.orig/usr.bin/kdump/Makefile work/usr.bin/kdump/Makefile
+--- work.orig/usr.bin/kdump/Makefile 2012-07-12 13:24:01.000000000 +0900
++++ work/usr.bin/kdump/Makefile 2012-07-16 03:54:14.000000000 +0900
+@@ -21,7 +21,7 @@
+
+ ioctl.c: mkioctls
+ env CPP="${CPP}" \
+- sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include > ${.TARGET}
++ sh ${.CURDIR}/mkioctls ${.CURDIR}/../../include > ${.TARGET}
+
+ kdump_subr.c: mksubr
+ sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include > ${.TARGET}
+diff -Nur work.orig/usr.bin/truss/Makefile work/usr.bin/truss/Makefile
+--- work.orig/usr.bin/truss/Makefile 2012-07-12 13:24:03.000000000 +0900
++++ work/usr.bin/truss/Makefile 2012-07-16 03:54:40.000000000 +0900
+@@ -24,7 +24,7 @@
+
+ ioctl.c: ${.CURDIR}/../kdump/mkioctls
+ env CPP="${CPP}" \
+- sh ${.CURDIR}/../kdump/mkioctls ${DESTDIR}/usr/include > ${.TARGET}
++ sh ${.CURDIR}/../kdump/mkioctls ${.CURDIR}/../../include > ${.TARGET}
+
+ .if ${MACHINE_CPUARCH} == "i386"
+ SRCS+= i386-linux.c linux_syscalls.h
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-minigzip.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-minigzip.patch
new file mode 100644
index 0000000..a9c0622
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-minigzip.patch
@@ -0,0 +1,10 @@
+diff -Nur work.orig/usr.bin/minigzip/Makefile work/usr.bin/minigzip/Makefile
+--- work.orig/usr.bin/minigzip/Makefile 2012-07-16 04:39:31.000000000 +0900
++++ work/usr.bin/minigzip/Makefile 2012-07-16 04:45:30.000000000 +0900
+@@ -10,4 +10,6 @@
+ DPADD= ${LIBZ}
+ LDADD= -lz
+
++CFLAGS+= -I${.CURDIR}/../../lib/libz
++
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-lint-stdarg.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-lint-stdarg.patch
new file mode 100644
index 0000000..9774724
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-lint-stdarg.patch
@@ -0,0 +1,24 @@
+diff -ur usr.bin.orig/xlint/llib/llib-lposix usr.bin/xlint/llib/llib-lposix
+--- usr.bin.orig/xlint/llib/llib-lposix 2005-04-29 17:30:03 +0000
++++ usr.bin/xlint/llib/llib-lposix 2005-05-03 14:12:26 +0000
+@@ -42,7 +42,7 @@
+ #include <sys/utsname.h>
+ #include <sys/times.h>
+ #include <stdio.h>
+-#include <stdarg.h>
++#include <machine/stdarg.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+ #include <math.h>
+diff -ur usr.bin.orig/xlint/llib/llib-lstdc usr.bin/xlint/llib/llib-lstdc
+--- usr.bin.orig/xlint/llib/llib-lstdc 2005-04-29 17:30:03 +0000
++++ usr.bin/xlint/llib/llib-lstdc 2005-05-03 14:12:35 +0000
+@@ -44,7 +44,7 @@
+ #include <math.h>
+ #include <setjmp.h>
+ #include <signal.h>
+-#include <stdarg.h>
++#include <machine/stdarg.h>
+ #include <stddef.h>
+ #include <stdio.h>
+ #include <stdlib.h>
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-setXid.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-setXid.patch
new file mode 100644
index 0000000..631ee4f
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-setXid.patch
@@ -0,0 +1,129 @@
+diff -ur usr.bin.orig/at/Makefile usr.bin.setXid/at/Makefile
+--- usr.bin.orig/at/Makefile Thu Apr 7 20:52:57 2005
++++ usr.bin.setXid/at/Makefile Thu Apr 7 21:21:02 2005
+@@ -15,6 +15,8 @@
+ BINMODE= 4555
+ CLEANFILES+= at.1
+
++LDFLAGS+=-Wl,-z,now
++
+ at.1: at.man
+ @${ECHO} Making ${.TARGET:T} from ${.ALLSRC:T}; \
+ sed -e \
+diff -ur usr.bin.orig/chpass/Makefile usr.bin.setXid/chpass/Makefile
+--- usr.bin.orig/chpass/Makefile Thu Apr 7 20:52:57 2005
++++ usr.bin.setXid/chpass/Makefile Thu Apr 7 21:22:40 2005
+@@ -15,6 +15,8 @@
+ #CFLAGS+=-DRESTRICT_FULLNAME_CHANGE
+ CFLAGS+=-I${.CURDIR}/../../usr.sbin/pwd_mkdb -I${.CURDIR}/../../lib/libc/gen -I.
+
++LDFLAGS+=-Wl,-z,now
++
+ DPADD= ${LIBCRYPT} ${LIBUTIL}
+ LDADD= -lcrypt -lutil
+ .if !defined(NO_NIS)
+diff -ur usr.bin.orig/fstat/Makefile usr.bin.setXid/fstat/Makefile
+--- usr.bin.orig/fstat/Makefile Thu Apr 7 20:52:57 2005
++++ usr.bin.setXid/fstat/Makefile Thu Apr 7 21:24:35 2005
+@@ -9,4 +9,6 @@
+ BINMODE=2555
+ WARNS?= 6
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
+diff -ur usr.bin.orig/lock/Makefile usr.bin.setXid/lock/Makefile
+--- usr.bin.orig/lock/Makefile Thu Apr 7 20:52:57 2005
++++ usr.bin.setXid/lock/Makefile Thu Apr 7 21:24:45 2005
+@@ -7,4 +7,6 @@
+ DPADD= ${LIBCRYPT}
+ LDADD= -lcrypt
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
+diff -ur usr.bin.orig/login/Makefile usr.bin.setXid/login/Makefile
+--- usr.bin.orig/login/Makefile Thu Apr 7 20:52:57 2005
++++ usr.bin.setXid/login/Makefile Thu Apr 7 21:24:55 2005
+@@ -13,4 +13,6 @@
+ INSTALLFLAGS=-fschg
+ .endif
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
+diff -ur usr.bin.orig/netstat/Makefile usr.bin.setXid/netstat/Makefile
+--- usr.bin.orig/netstat/Makefile Thu Apr 7 20:52:58 2005
++++ usr.bin.setXid/netstat/Makefile Thu Apr 7 21:25:08 2005
+@@ -14,4 +14,6 @@
+ DPADD= ${LIBKVM} ${LIBIPX} ${LIBNETGRAPH} ${LIBUTIL}
+ LDADD= -lkvm -lipx -lnetgraph -lutil
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
+diff -ur usr.bin.orig/opieinfo/Makefile usr.bin.setXid/opieinfo/Makefile
+--- usr.bin.orig/opieinfo/Makefile Thu Apr 7 20:52:58 2005
++++ usr.bin.setXid/opieinfo/Makefile Thu Apr 7 21:25:20 2005
+@@ -11,6 +11,8 @@
+ DPADD= ${LIBOPIE} ${LIBMD}
+ LDADD= -lopie -lmd
+
++LDFLAGS+=-Wl,-z,now
++
+ BINOWN= root
+ BINMODE=4555
+ INSTALLFLAGS=-fschg
+diff -ur usr.bin.orig/opiepasswd/Makefile usr.bin.setXid/opiepasswd/Makefile
+--- usr.bin.orig/opiepasswd/Makefile Thu Apr 7 20:52:58 2005
++++ usr.bin.setXid/opiepasswd/Makefile Thu Apr 7 21:25:29 2005
+@@ -11,6 +11,8 @@
+ DPADD= ${LIBOPIE} ${LIBMD}
+ LDADD= -lopie -lmd
+
++LDFLAGS+=-Wl,-z,now
++
+ BINOWN= root
+ BINMODE=4555
+ INSTALLFLAGS=-fschg
+diff -ur usr.bin.orig/passwd/Makefile usr.bin.setXid/passwd/Makefile
+--- usr.bin.orig/passwd/Makefile Thu Apr 7 20:52:58 2005
++++ usr.bin.setXid/passwd/Makefile Thu Apr 7 21:25:37 2005
+@@ -10,6 +10,8 @@
+ MLINKS = passwd.1 yppasswd.1
+ WARNS ?= 4
+
++LDFLAGS+=-Wl,-z,now
++
+ beforeinstall:
+ .for i in passwd yppasswd
+ [ ! -e ${DESTDIR}${BINDIR}/$i ] || \
+--- usr.bin.orig/su/Makefile Thu Apr 7 20:52:58 2005
++++ usr.bin.setXid/su/Makefile Thu Apr 7 21:26:00 2005
+@@ -10,4 +10,6 @@
+ BINMODE=4555
+ INSTALLFLAGS=-fschg
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
+diff -ur usr.bin.orig/wall/Makefile usr.bin.setXid/wall/Makefile
+--- usr.bin.orig/wall/Makefile Thu Apr 7 20:52:59 2005
++++ usr.bin.setXid/wall/Makefile Thu Apr 7 21:26:07 2005
+@@ -5,4 +5,6 @@
+ BINGRP= tty
+ BINMODE=2555
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
+diff -ur usr.bin.orig/write/Makefile usr.bin.setXid/write/Makefile
+--- usr.bin.orig/write/Makefile Thu Apr 7 20:52:59 2005
++++ usr.bin.setXid/write/Makefile Thu Apr 7 21:26:13 2005
+@@ -4,4 +4,6 @@
+ BINMODE=2555
+ BINGRP= tty
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-ubin/files/locate-updatedb-cron b/sys-freebsd/freebsd-ubin/files/locate-updatedb-cron
new file mode 100644
index 0000000..323f455
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/locate-updatedb-cron
@@ -0,0 +1,6 @@
+#! /bin/sh
+
+if [ -x /usr/libexec/locate.updatedb ]
+then
+ echo /usr/libexec/locate.updatedb | nice -n 5 su -fm nobody
+fi
diff --git a/sys-freebsd/freebsd-ubin/files/login.1.pamd b/sys-freebsd/freebsd-ubin/files/login.1.pamd
new file mode 100644
index 0000000..2c09584
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/login.1.pamd
@@ -0,0 +1,4 @@
+auth include system-local-login
+account include system-local-login
+session include system-local-login
+password include system-local-login
diff --git a/sys-freebsd/freebsd-ubin/files/login.pamd b/sys-freebsd/freebsd-ubin/files/login.pamd
new file mode 100644
index 0000000..db1c74f
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/login.pamd
@@ -0,0 +1,20 @@
+#
+# $Id$
+#
+# PAM configuration for the "login" service
+#
+
+# auth
+auth required pam_nologin.so no_warn
+auth sufficient pam_self.so no_warn
+auth include system
+
+# account
+account requisite pam_securetty.so
+account include system
+
+# session
+session include system
+
+# password
+password include system
diff --git a/sys-freebsd/freebsd-ubin/files/passwd.1.pamd b/sys-freebsd/freebsd-ubin/files/passwd.1.pamd
new file mode 100644
index 0000000..bab2eea
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/passwd.1.pamd
@@ -0,0 +1,9 @@
+#
+# $Id$
+#
+# PAM configuration for the "passwd" service
+#
+
+# passwd(1) does not use the auth, account or session services.
+
+password include system-auth
diff --git a/sys-freebsd/freebsd-ubin/files/passwd.pamd b/sys-freebsd/freebsd-ubin/files/passwd.pamd
new file mode 100644
index 0000000..44b7e71
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/passwd.pamd
@@ -0,0 +1,11 @@
+#
+# $Id$
+#
+# PAM configuration for the "passwd" service
+#
+
+# passwd(1) does not use the auth, account or session services.
+
+# password
+#password requisite pam_passwdqc.so enforce=users
+password required pam_unix.so no_warn try_first_pass nullok
diff --git a/sys-freebsd/freebsd-ubin/files/su.1.pamd b/sys-freebsd/freebsd-ubin/files/su.1.pamd
new file mode 100644
index 0000000..72e2bd1
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/su.1.pamd
@@ -0,0 +1,17 @@
+#
+# $Id$
+#
+# PAM configuration for the "su" service
+#
+
+# auth
+auth sufficient pam_rootok.so no_warn
+auth sufficient pam_self.so no_warn
+auth requisite pam_group.so no_warn group=wheel root_only fail_safe
+auth include system-auth
+
+# account
+account include system-auth
+
+# session
+session required pam_permit.so
diff --git a/sys-freebsd/freebsd-ubin/files/su.pamd b/sys-freebsd/freebsd-ubin/files/su.pamd
new file mode 100644
index 0000000..57019c5
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/su.pamd
@@ -0,0 +1,17 @@
+#
+# $Id$
+#
+# PAM configuration for the "su" service
+#
+
+# auth
+auth sufficient pam_rootok.so no_warn
+auth sufficient pam_self.so no_warn
+auth requisite pam_group.so no_warn group=wheel root_only fail_safe
+auth include system
+
+# account
+account include system
+
+# session
+session required pam_permit.so
diff --git a/sys-freebsd/freebsd-ubin/freebsd-ubin-11.0.ebuild b/sys-freebsd/freebsd-ubin/freebsd-ubin-11.0.ebuild
new file mode 100644
index 0000000..3cdde79
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/freebsd-ubin-11.0.ebuild
@@ -0,0 +1,210 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic pam multilib multibuild multilib-build
+
+DESCRIPTION="FreeBSD's base system source for /usr/bin"
+SLOT="0"
+IUSE="ar atm audit bluetooth ipv6 kerberos netware nis ssl usb build zfs"
+LICENSE="BSD zfs? ( CDDL )"
+
+# Security Advisory and Errata patches.
+UPSTREAM_PATCHES=( "SA-16:25/bspatch.patch" )
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ usr.bin/
+ contrib/
+ lib/
+ etc/
+ bin/
+ include/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[usb?,bluetooth?,${MULTILIB_USEDEP}]
+ ssl? ( dev-libs/openssl:0= )
+ kerberos? ( virtual/krb5 )
+ ar? ( >=app-arch/libarchive-3 )
+ virtual/pam
+ sys-libs/zlib
+ >=sys-libs/ncurses-5.9:0=
+ !sys-process/fuser-bsd
+ !dev-util/csup
+ !dev-libs/libiconv
+ !sys-freebsd/freebsd-contrib"
+
+DEPEND="${RDEPEND}
+ sys-devel/flex
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ =sys-freebsd/freebsd-sbin-${RV}*
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+RDEPEND="${RDEPEND}
+ >=sys-auth/pambase-20080219.1
+ sys-process/cronbase"
+
+S="${WORKDIR}/usr.bin"
+
+PATCHES=( "${FILESDIR}/${PN}-6.0-bsdcmp.patch"
+ "${FILESDIR}/${PN}-9.0-fixmakefiles.patch"
+ "${FILESDIR}/${PN}-setXid.patch"
+ "${FILESDIR}/${PN}-lint-stdarg.patch"
+ "${FILESDIR}/${PN}-8.0-xinstall.patch"
+ "${FILESDIR}/${PN}-9.1-bsdar.patch"
+ "${FILESDIR}/${PN}-9.1-minigzip.patch"
+ "${FILESDIR}/${PN}-10.0-atf.patch"
+ "${FILESDIR}/${PN}-10.0-dtc-gcc46.patch"
+ "${FILESDIR}/${PN}-10.0-kdump-ioctl.patch"
+ "${FILESDIR}/${PN}-10.0-mandoc.patch"
+ "${FILESDIR}/${PN}-10.2-bsdxml.patch"
+ "${FILESDIR}/${PN}-10.2-talk-workaround.patch"
+ "${FILESDIR}/${PN}-10.3-bmake-workaround.patch" )
+
+# Here we remove some sources we don't need because they are already
+# provided by portage's packages or similar. In order:
+# - Archiving tools, provided by their own ebuilds
+# - ncurses stuff
+# - less stuff
+# - bind utils
+# - rsh stuff
+# - binutils gprof
+# - dc stuff
+# and the rest are misc utils we already provide somewhere else.
+REMOVE_SUBDIRS="bzip2 bzip2recover tar cpio
+ gzip gprof
+ lzmainfo xz xzdec
+ unzip
+ tput tset tabs
+ less lessecho lesskey
+ hesinfo host
+ rsh rlogin rusers rwho ruptime
+ compile_et lex vi smbutil file vacation nc ftp telnet
+ c99 c89
+ bc dc
+ whois tftp man"
+
+pkg_setup() {
+ # Add the required source files.
+ use zfs && EXTRACTONLY+="cddl/ "
+ use build && EXTRACTONLY+="sys/ "
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use audit || mymakeopts="${mymakeopts} WITHOUT_AUDIT= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+ mymakeopts="${mymakeopts} WITHOUT_CLANG= WITHOUT_LZMA_SUPPORT= WITHOUT_SVN= WITHOUT_SVNLITE= WITHOUT_OPENSSH= WITHOUT_LDNS_UTILS= "
+}
+
+pkg_preinst() {
+ # bison installs a /usr/bin/yacc symlink ...
+ # we need to remove it to avoid triggering
+ # collision-protect errors
+ if [[ -L ${ROOT}/usr/bin/yacc ]] ; then
+ rm -f "${ROOT}"/usr/bin/yacc
+ fi
+}
+
+src_prepare() {
+ if [[ ! -e "${WORKDIR}/sys" ]]; then
+ use build || ln -s "/usr/src/sys" "${WORKDIR}/sys"
+ fi
+
+ # Rename manpage for renamed cmp
+ mv "${S}"/cmp/cmp.1 "${S}"/cmp/bsdcmp.1 || die
+ # Rename manpage for renamed ar
+ mv "${S}"/ar/ar.1 "${S}"/ar/freebsd-ar.1 || die
+ # Fix whereis(1) manpath search.
+ sed -i -e 's:"manpath -q":"manpath":' "${S}/whereis/pathnames.h"
+
+ # Build a dynamic make
+ sed -i -e '/^NO_SHARED/ s/^/#/' "${S}"/make/Makefile || die
+
+ # Disable it here otherwise our patch wont apply
+ use ar || dummy_mk ar
+
+ # Preparing to build xlint
+ export LINT=xlint
+}
+
+setup_multilib_vars() {
+ if ! multilib_is_native_abi ; then
+ cd "${WORKDIR}/usr.bin/ldd" || die
+ export mymakeopts="${mymakeopts} PROG=ldd32 WITHOUT_MAN="
+ else
+ cd "${S}" || die
+ fi
+ "$@"
+}
+
+src_compile() {
+ # Preparing to build mandoc
+ cd "${WORKDIR}/lib/libmandoc" || die
+ freebsd_src_compile -j1
+
+ cd "${S}" || die
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_compile -j1
+}
+
+src_install() {
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_install
+
+ # baselayout requires these in /bin
+ dodir /bin
+ for bin in sed printf ; do
+ mv "${D}/usr/bin/${bin}" "${D}/bin/" || die "mv ${bin} failed"
+ dosym /bin/${bin} /usr/bin/${bin} || die "dosym ${bin} failed"
+ done
+
+ for pamdfile in login passwd su; do
+ newpamd "${FILESDIR}/${pamdfile}.1.pamd" ${pamdfile} || die
+ done
+
+ cd "${WORKDIR}/etc" || die
+ insinto /etc
+ doins remote phones opieaccess fbtab || die
+
+ exeinto /etc/cron.daily
+ newexe "${FILESDIR}/locate-updatedb-cron" locate.updatedb || die
+
+ # tip requires /var/spool/lock/, bug #200700
+ keepdir /var/spool/lock
+
+ # create locate database #472468
+ local f=/var/db/locate.database
+ mkdir "${ED}${f%/*}" || die
+ touch "${ED}${f}" || die
+ fowners nobody:nobody ${f}
+}
+
+pkg_postinst() {
+ # We need to ensure that login.conf.db is up-to-date.
+ if [[ -e "${ROOT}"etc/login.conf ]] ; then
+ einfo "Updating ${ROOT}etc/login.conf.db"
+ "${ROOT}"usr/bin/cap_mkdb -f "${ROOT}"etc/login.conf "${ROOT}"etc/login.conf
+ elog "Remember to run cap_mkdb /etc/login.conf after making changes to it"
+ fi
+}
+
+pkg_postrm() {
+ # and if we uninstall yacc but keep bison,
+ # lets restore the /usr/bin/yacc symlink
+ if [[ ! -e ${ROOT}/usr/bin/yacc ]] && [[ -e ${ROOT}/usr/bin/yacc.bison ]] ; then
+ ln -s yacc.bison "${ROOT}"/usr/bin/yacc
+ fi
+}
diff --git a/sys-freebsd/freebsd-ubin/metadata.xml b/sys-freebsd/freebsd-ubin/metadata.xml
new file mode 100644
index 0000000..a7fa78a
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/metadata.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+ </maintainer>
+ <use>
+ <flag name="audit">
+ Build auditing tools.
+ </flag>
+ <flag name="netware">
+ Build libraries and tools to work with NetWare protocols (IPX
+ and NCP).
+ </flag>
+ <flag name="ar">
+ Build FreeBSD's ar and ranlib replacements based on libarchive. The
+ toolchain will still use binutils' version but you can play with it.
+ They have been renamed to freebsd-ar and freebsd-ranlib not to collide
+ with binutils.
+ </flag>
+ <flag name="zfs">Enable ZFS support (for fstat actually).</flag>
+ </use>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-10.0-bsdxml2expat.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-10.0-bsdxml2expat.patch
new file mode 100644
index 0000000..a84f96d
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-10.0-bsdxml2expat.patch
@@ -0,0 +1,24 @@
+diff -Nur work.orig/usr.sbin/ctladm/ctladm.c work/usr.sbin/ctladm/ctladm.c
+--- work.orig/usr.sbin/ctladm/ctladm.c 2012-07-12 13:25:58.000000000 +0900
++++ work/usr.sbin/ctladm/ctladm.c 2012-07-16 05:37:14.000000000 +0900
+@@ -60,7 +60,7 @@
+ #include <errno.h>
+ #include <err.h>
+ #include <ctype.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <cam/scsi/scsi_all.h>
+ #include <cam/scsi/scsi_message.h>
+ #include <cam/ctl/ctl.h>
+diff -Nur work.orig/usr.sbin/ctld/kernel.c work/usr.sbin/ctld/kernel.c
+--- work.orig/usr.sbin/ctld/kernel.c 2013-09-20 21:55:45.000000000 +0900
++++ work/usr.sbin/ctld/kernel.c 2013-09-20 22:01:17.000000000 +0900
+@@ -45,7 +45,7 @@
+ #include <sys/sbuf.h>
+ #include <sys/capability.h>
+ #include <assert.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <ctype.h>
+ #include <errno.h>
+ #include <fcntl.h>
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-10.3-bsdxml2expat.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-10.3-bsdxml2expat.patch
new file mode 100644
index 0000000..207b6ab
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-10.3-bsdxml2expat.patch
@@ -0,0 +1,13 @@
+diff --git a/usr.sbin/camdd/camdd.c b/usr.sbin/camdd/camdd.c
+index 88c648e..edf9c8b 100644
+--- a/usr.sbin/camdd/camdd.c
++++ b/usr.sbin/camdd/camdd.c
+@@ -71,7 +71,7 @@ __FBSDID("$FreeBSD: stable/10/usr.sbin/camdd/camdd.c 293409 2016-01-08 02:56:21Z
+ #include <libutil.h>
+ #include <pthread.h>
+ #include <assert.h>
+-#include <bsdxml.h>
++#include <expat.h>
+
+ #include <cam/cam.h>
+ #include <cam/cam_debug.h>
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-7.0-nowrap.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-7.0-nowrap.patch
new file mode 100644
index 0000000..9b11104
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-7.0-nowrap.patch
@@ -0,0 +1,45 @@
+diff -ur usr.sbin.orig/rpcbind/Makefile usr.sbin/rpcbind/Makefile
+--- usr.sbin.orig/rpcbind/Makefile 2007-04-21 12:02:30 +0000
++++ usr.sbin/rpcbind/Makefile 2007-04-21 12:05:32 +0000
+@@ -8,13 +8,20 @@
+ SRCS= check_bound.c rpcb_stat.c rpcb_svc_4.c rpcbind.c pmap_svc.c \
+ rpcb_svc.c rpcb_svc_com.c security.c warmstart.c util.c
+
+-CFLAGS+= -DPORTMAP -DLIBWRAP
++CFLAGS+= -DPORTMAP
+
+ .if ${MK_INET6_SUPPORT} != "no"
+ CFLAGS+= -DINET6
+ .endif
+
+-DPADD= ${LIBWRAP} ${LIBUTIL}
+-LDADD= -lwrap -lutil
++DPADD= ${LIBUTIL}
++LDADD= -lutil
++
++.if !defined(NO_WRAP)
++CFLAGS+= -DLIBWRAP
++DPADD+= ${LIBWRAP}
++LDADD+= -lwrap
++.endif
++
+
+ .include <bsd.prog.mk>
+diff -ur usr.sbin.orig/ypserv/Makefile usr.sbin/ypserv/Makefile
+--- usr.sbin.orig/ypserv/Makefile 2007-04-21 12:02:31 +0000
++++ usr.sbin/ypserv/Makefile 2007-04-21 12:06:53 +0000
+@@ -8,10 +8,13 @@
+ SRCS= yp_svc.c yp_server.c yp_dblookup.c yp_dnslookup.c \
+ ypxfr_clnt.c yp.h yp_main.c yp_error.c yp_access.c yp_svc_udp.c
+
+-CFLAGS+= -DDB_CACHE -DTCP_WRAPPER -I.
++CFLAGS+= -DDB_CACHE -I.
+
++.if !defined(NO_WRAP)
++CFLAGS+= -DTCP_WRAPPER
+ DPADD= ${LIBWRAP}
+ LDADD= -lwrap
++.endif
+
+ CLEANFILES= yp_svc.c ypxfr_clnt.c yp.h
+
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-8.2-newsyslog.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-8.2-newsyslog.patch
new file mode 100644
index 0000000..a098391
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-8.2-newsyslog.patch
@@ -0,0 +1,10 @@
+--- usr.sbin/newsyslog/pathnames.h.orig 2001-07-30 18:17:17.000000000 +0300
++++ usr.sbin/newsyslog/pathnames.h 2009-09-11 08:32:57.508226240 +0300
+@@ -24,5 +24,5 @@
+
+ #define _PATH_CONF "/etc/newsyslog.conf"
+ #define _PATH_SYSLOGPID _PATH_VARRUN "syslog.pid"
+-#define _PATH_BZIP2 "/usr/bin/bzip2"
+-#define _PATH_GZIP "/usr/bin/gzip"
++#define _PATH_BZIP2 "/bin/bzip2"
++#define _PATH_GZIP "/bin/gzip"
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.0-libarchive.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.0-libarchive.patch
new file mode 100644
index 0000000..bfe4794
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.0-libarchive.patch
@@ -0,0 +1,12 @@
+--- usr.sbin/bsdinstall/distextract/distextract.c.old 2011-11-02 20:28:08.000000000 +0000
++++ usr.sbin/bsdinstall/distextract/distextract.c 2011-11-02 20:28:57.000000000 +0000
+@@ -32,6 +32,9 @@
+ #include <limits.h>
+ #include <archive.h>
+ #include <dialog.h>
++#ifndef archive_read_free
++#define archive_read_free(x) archive_read_finish(x)
++#endif
+
+ static int extract_files(int nfiles, const char **files);
+
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.0-newsyslog.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.0-newsyslog.patch
new file mode 100644
index 0000000..1d83865
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.0-newsyslog.patch
@@ -0,0 +1,12 @@
+diff -uNr usr.sbin/newsyslog.old/pathnames.h usr.sbin/newsyslog/pathnames.h
+--- usr.sbin/newsyslog.old/pathnames.h 2011-11-02 20:12:37.000000000 +0000
++++ usr.sbin/newsyslog/pathnames.h 2011-11-02 20:12:50.000000000 +0000
+@@ -24,6 +24,6 @@
+
+ #define _PATH_CONF "/etc/newsyslog.conf"
+ #define _PATH_SYSLOGPID _PATH_VARRUN "syslog.pid"
+-#define _PATH_BZIP2 "/usr/bin/bzip2"
+-#define _PATH_GZIP "/usr/bin/gzip"
++#define _PATH_BZIP2 "/bin/bzip2"
++#define _PATH_GZIP "/bin/gzip"
+ #define _PATH_XZ "/usr/bin/xz"
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.1-bsdxml2expat.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.1-bsdxml2expat.patch
new file mode 100644
index 0000000..bddc0c7
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.1-bsdxml2expat.patch
@@ -0,0 +1,12 @@
+diff -Nur work.orig/usr.sbin/ctladm/ctladm.c work/usr.sbin/ctladm/ctladm.c
+--- work.orig/usr.sbin/ctladm/ctladm.c 2012-07-12 13:25:58.000000000 +0900
++++ work/usr.sbin/ctladm/ctladm.c 2012-07-16 05:37:14.000000000 +0900
+@@ -60,7 +60,7 @@
+ #include <errno.h>
+ #include <err.h>
+ #include <ctype.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <cam/scsi/scsi_all.h>
+ #include <cam/scsi/scsi_message.h>
+ #include <cam/ctl/ctl.h>
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.1-kldxref.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.1-kldxref.patch
new file mode 100644
index 0000000..95bd665
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.1-kldxref.patch
@@ -0,0 +1,30 @@
+Index: usr.sbin/kldxref/kldxref.c
+===================================================================
+--- usr.sbin/kldxref/kldxref.c (revision 265111)
++++ usr.sbin/kldxref/kldxref.c (working copy)
+@@ -274,6 +274,16 @@ usage(void)
+ exit(1);
+ }
+
++static int
++compare(const FTSENT *const *a, const FTSENT *const *b)
++{
++ if ((*a)->fts_info == FTS_D && (*b)->fts_info != FTS_D)
++ return 1;
++ if ((*a)->fts_info != FTS_D && (*b)->fts_info == FTS_D)
++ return -1;
++ return strcmp((*a)->fts_name, (*b)->fts_name);
++}
++
+ int
+ main(int argc, char *argv[])
+ {
+@@ -315,7 +325,7 @@ main(int argc, char *argv[])
+ err(1, "%s", argv[0]);
+ }
+
+- ftsp = fts_open(argv, fts_options, 0);
++ ftsp = fts_open(argv, fts_options, compare);
+ if (ftsp == NULL)
+ exit(1);
+
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-adduser.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-adduser.patch
new file mode 100644
index 0000000..39177b4
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-adduser.patch
@@ -0,0 +1,20 @@
+--- usr.sbin/adduser/adduser.sh.old 2006-10-01 13:41:16 +0000
++++ usr.sbin/adduser/adduser.sh 2006-10-01 13:41:38 +0000
+@@ -809,7 +809,7 @@
+ NOHOME="/nonexistent"
+ NOLOGIN="nologin"
+ NOLOGIN_PATH="/usr/sbin/nologin"
+-GREPCMD="/usr/bin/grep"
++GREPCMD="/bin/grep"
+ DATECMD="/bin/date"
+
+ # Set default values
+@@ -823,7 +823,7 @@
+ uhome=
+ upass=
+ ushell=
+-udotdir=/usr/share/skel
++udotdir=/etc/skel
+ ugroups=
+ uexpire=
+ upwexpire=
diff --git a/sys-freebsd/freebsd-usbin/files/iscsid.initd b/sys-freebsd/freebsd-usbin/files/iscsid.initd
new file mode 100644
index 0000000..f16d00e
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/iscsid.initd
@@ -0,0 +1,20 @@
+#!/sbin/openrc-run
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting iscsid"
+ start-stop-daemon --start --quiet --exec \
+ /usr/sbin/iscsid -- $iscsidopts
+ eend $? "Error starting iscsid"
+}
+
+stop() {
+ ebegin "Stopping iscsid"
+ start-stop-daemon --stop --quiet --exec /usr/sbin/iscsid
+ eend $? "Error stopping iscsid"
+}
diff --git a/sys-freebsd/freebsd-usbin/files/mountd.patch b/sys-freebsd/freebsd-usbin/files/mountd.patch
new file mode 100644
index 0000000..3cb9f03
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/mountd.patch
@@ -0,0 +1,15 @@
+http://security.freebsd.org/advisories/FreeBSD-SA-11:01.mountd.asc
+
+Index: usr.sbin/mountd/mountd.c
+===================================================================
+--- usr.sbin/mountd/mountd.c 20 Dec 2010 09:28:28 -0000 1.107
++++ usr.sbin/mountd/mountd.c 1 Mar 2011 11:47:16 -0000 1.108
+@@ -2875,7 +2875,7 @@ makemask(struct sockaddr_storage *ssp, i
+
+ for (i = 0; i < len; i++) {
+ bits = (bitlen > CHAR_BIT) ? CHAR_BIT : bitlen;
+- *p++ = (1 << bits) - 1;
++ *p++ = (u_char)~0 << (CHAR_BIT - bits);
+ bitlen -= bits;
+ }
+ return 0;
diff --git a/sys-freebsd/freebsd-usbin/files/moused.confd b/sys-freebsd/freebsd-usbin/files/moused.confd
new file mode 100644
index 0000000..4d64933
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/moused.confd
@@ -0,0 +1,20 @@
+# $Id$
+
+# See the moused man page for available settings.
+
+# Set to your mouse device psm[0-9] for PS/2 ports, ums[0-9] for USB ports
+# Leave blank to try to autodetect it
+MOUSED_DEVICE=""
+
+# Any additional flags requires
+MOUSED_FLAGS=""
+
+# If 0xd0-0xd3 default range is occupied in your language code table, specify
+# alternative range start like MOUSECHAR_START="3", see vidcontrol(1)
+MOUSECHAR_START=""
+
+# You can also multiplex the init script for each device like so
+# ln -s moused /etc/init.d/moused.ums0
+# This enables you to have a config file per mouse (forces MOUSED_DEVICE
+# to ums0 in this case) and control each mouse.
+# devd can also start and stop these mice, which laptop users will find handy.
diff --git a/sys-freebsd/freebsd-usbin/files/moused.initd b/sys-freebsd/freebsd-usbin/files/moused.initd
new file mode 100644
index 0000000..d7ca8e0
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/moused.initd
@@ -0,0 +1,66 @@
+#!/sbin/openrc-run
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+MOUSED_NAME=${SVCNAME##*.}
+if [ -n "${MOUSED_NAME}" ] && [ ${MOUSED_NAME} != "moused" ] ; then
+ MOUSED_DEVICE=/dev/"${MOUSED_NAME}"
+ MOUSED_PIDFILE=/var/run/moused-"${MOUSED_NAME}".pid
+else
+ MOUSED_NAME=
+ MOUSED_PIDFILE=/var/run/moused.pid
+fi
+
+depend() {
+ need localmount
+}
+
+start() {
+ ebegin "Starting the Console Mouse Daemon" "${MOUSED_NAME}"
+
+ if [ -z ${MOUSED_DEVICE} ] ; then
+ for x in /dev/psm[0-9]* /dev/ums[0-9]* ; do
+ if [ -e "${x}" ] && \
+ [ ! -e /var/run/moused-$(basename "${x}").pid ] ; then
+ MOUSED_DEVICE=${x}
+ eindent
+ einfo "Using mouse on ${MOUSED_DEVICE}"
+ eoutdent
+ break
+ fi
+ done
+ fi
+
+ if [ -z "${MOUSED_DEVICE}" ] ; then
+ eend 1 "No device specified in" "/etc/conf.d/${SVCNAME}" \
+ "and no mouse detected"
+ return 1
+ fi
+
+ local opts="${MOUSED_FLAGS} -p ${MOUSED_DEVICE}"
+ start-stop-daemon --start --quiet --exec /usr/sbin/moused \
+ --pidfile "${MOUSED_PIDFILE}" \
+ -- ${opts} -I "${MOUSED_PIDFILE}"
+ local retval=$?
+
+ [ -n "${MOUSE_CHAR_START}" ] && MOUSE_CHAR_START="-M ${MOUSE_CHAR_START}"
+ local ttyv=
+ for ttyv in /dev/ttyv* ; do
+ vidcontrol < "${ttyv}" ${MOUSE_CHAR_START} -m on || retval=1
+ done
+
+ eend ${retval} "Failed to start moused"
+}
+
+stop() {
+ ebegin "Stopping the Console Mouse Daemon" "${MOUSED_NAME}"
+ # Don't specify the binary as >1 instance of moused may be running
+ # which is perfectly valid as we can be multiplexed.
+ start-stop-daemon --stop --exec /usr/sbin/moused \
+ --pidfile "${MOUSED_PIDFILE}"
+ eend $? "Failed to stop moused"
+}
+
+# vim: set ts=4 :
+
diff --git a/sys-freebsd/freebsd-usbin/files/nfs.confd b/sys-freebsd/freebsd-usbin/files/nfs.confd
new file mode 100644
index 0000000..844252f
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/nfs.confd
@@ -0,0 +1,10 @@
+# Config file for /etc/init.d/nfs
+# Options for nfsd (see man nfsd)
+# Example: 8 nfsd servers started:
+#nfsdopts="-n 8"
+
+# Options for mountd (see man mountd)
+# Example: allow non-root users to mount shares:
+#mountdopts="-n"
+# Specify t he exports file, this is the default:
+#exportsfile="/etc/exports"
diff --git a/sys-freebsd/freebsd-usbin/files/nfs.initd b/sys-freebsd/freebsd-usbin/files/nfs.initd
new file mode 100644
index 0000000..17974ca
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/nfs.initd
@@ -0,0 +1,54 @@
+#!/sbin/openrc-run
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+#---------------------------------------------------------------------------
+# This script starts/stops nfsd and mountd
+# Daemons rpc.rquotad, rpc.rstatd, rpc.rusersd, rpc.rwalld and rpc.sprayd
+# should be started from inetd on FreeBSD.
+#---------------------------------------------------------------------------
+
+extra_started_commands="reload"
+
+# The binary locations
+nfsd=/usr/sbin/nfsd
+mountd=/usr/sbin/mountd
+
+depend() {
+ use ypbind net rpc.lockd
+ need rpcbind
+ after quota
+}
+
+start() {
+ ebegin "Starting NFS daemon"
+ start-stop-daemon --start --quiet --exec \
+ $nfsd -- ${nfsdopts}
+ eend $? "Error starting NFS daemon"
+
+ # Start mountd
+ ebegin "Starting NFS mountd"
+ start-stop-daemon --start --quiet --exec \
+ $mountd -- ${mountdopts} ${exportsfile}
+ eend $? "Error starting NFS mountd"
+}
+
+stop() {
+ ebegin "Stopping NFS mountd"
+ start-stop-daemon --stop --quiet --exec $mountd \
+ --pidfile /var/run/mountd.pid
+ eend $? "Error stopping NFS mountd"
+
+ ebegin "Stopping NFS daemon"
+ start-stop-daemon --stop --signal USR1 --quiet \
+ --name nfsd --user root
+ eend $? "Error stopping NFS daemon"
+}
+
+reload() {
+ # Hangup signal to mountd reloads /etc/exports.
+ ebegin "Reloading /etc/exports"
+ start-stop-daemon --signal 1 --quiet --exec $mountd \
+ --pidfile /var/run/mountd.pid
+ eend $?
+}
diff --git a/sys-freebsd/freebsd-usbin/files/nfsmount.initd b/sys-freebsd/freebsd-usbin/files/nfsmount.initd
new file mode 100644
index 0000000..2fb4901
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/nfsmount.initd
@@ -0,0 +1,63 @@
+#!/sbin/openrc-run
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+depend() {
+ need net rpcbind
+ use ypbind
+}
+
+start_statd() {
+ # Don't start rpc.statd if already started by init.d/nfs
+ killall -0 rpc.statd 2>/dev/null && return 0
+ ebegin "Starting NFS statd"
+ rpc.statd
+ eend $? "Error starting NFS statd"
+}
+
+stop_statd() {
+ # Don't stop rpc.statd if it's in use by init.d/nfs
+ killall -0 nfsd 2>/dev/null && return 0
+ # Make sure it's actually running
+ killall -0 rpc.statd 2>/dev/null || return 0
+ # Okay, all tests passed, stop rpc.statd
+ ebegin "Stopping NFS statd"
+ killall rpc.statd
+ eend $? "Error stopping NFS statd"
+}
+
+start_lockd() {
+ # Don't start rpc.lockd if already started by init.d/nfs
+ killall -0 rpc.lockd 2>/dev/null && return 0
+ ebegin "Starting NFS lockd"
+ rpc.lockd
+ eend $? "Error starting NFS lockd"
+}
+
+stop_lockd() {
+ # Don't stop rpc.lockd if it's in use by init.d/nfs
+ killall -0 nfsd 2>/dev/null && return 0
+ # Make sure it's actually running
+ killall -0 rpc.lockd 2>/dev/null || return 0
+ # Okay, all tests passed, stop rpc.lockd
+ ebegin "Stopping NFS lockd"
+ killall rpc.lockd
+ eend $? "Error stopping NFS lockd"
+}
+
+start() {
+ start_statd
+ start_lockd
+ ebegin "Mounting NFS filesystems"
+ mount -a -t nfs
+ eend $? "Error mounting NFS filesystems"
+}
+
+stop() {
+ ebegin "Unmounting NFS filesystems"
+ umount -a -t nfs
+ eend $? "Error unmounting NFS filesystems"
+ stop_statd
+ stop_lockd
+}
diff --git a/sys-freebsd/freebsd-usbin/files/nfsuserd.confd b/sys-freebsd/freebsd-usbin/files/nfsuserd.confd
new file mode 100644
index 0000000..f8f3ea1
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/nfsuserd.confd
@@ -0,0 +1,5 @@
+# Config file for /etc/init.d/nfsuserd
+# Options for nfsuserd (see man nfsuserd)
+# Example: set domain example.com:
+#nfsuserdopts="-domain example.com"
+
diff --git a/sys-freebsd/freebsd-usbin/files/nfsuserd.initd b/sys-freebsd/freebsd-usbin/files/nfsuserd.initd
new file mode 100644
index 0000000..d690074
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/nfsuserd.initd
@@ -0,0 +1,20 @@
+#!/sbin/openrc-run
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net nfs
+}
+
+start() {
+ ebegin "Starting nfsuserd"
+ start-stop-daemon --start --quiet --exec \
+ /usr/sbin/nfsuserd -- $nfsuserdopts
+ eend $? "Error starting nfsuserd"
+}
+
+stop() {
+ ebegin "Stopping nfsuserd"
+ start-stop-daemon --stop --quiet --exec /usr/sbin/nfsuserd
+ eend $? "Error stopping nfsuserd"
+}
diff --git a/sys-freebsd/freebsd-usbin/files/powerd.confd b/sys-freebsd/freebsd-usbin/files/powerd.confd
new file mode 100644
index 0000000..e5db5a1
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/powerd.confd
@@ -0,0 +1,14 @@
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# Mode allowed: maximum, minimum, adaptive
+# Default unless specified is adaptive
+
+AC_MODE="maximum"
+
+#BATTERY_MODE="minimum"
+
+POWERD_OPTS=""
+
+
diff --git a/sys-freebsd/freebsd-usbin/files/powerd.initd b/sys-freebsd/freebsd-usbin/files/powerd.initd
new file mode 100644
index 0000000..ff79f63
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/powerd.initd
@@ -0,0 +1,27 @@
+#!/sbin/openrc-run
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+depend() {
+ need localmount
+}
+
+start() {
+ local args=
+ [ -n "${BATTERY_MODE}" ] && args="${args} -b ${BATTERY_MODE}"
+ [ -n "${AC_MODE}" ] && args="${args} -a ${AC_MODE}"
+
+ ebegin "Starting Power Control Daemon"
+ start-stop-daemon --start --exec /usr/sbin/powerd \
+ --pidfile /var/run/powerd.pid \
+ -- ${args} ${POWERD_OPTS}
+ eend $? "Failed to start powerd"
+}
+
+stop() {
+ ebegin "Stopping Power Control Daemon"
+ start-stop-daemon --stop --exec /usr/sbin/powerd \
+ --pidfile /var/run/powerd.pid
+ eend $? "Failed to stop powerd"
+}
diff --git a/sys-freebsd/freebsd-usbin/files/pw.conf b/sys-freebsd/freebsd-usbin/files/pw.conf
new file mode 100644
index 0000000..29a246f
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/pw.conf
@@ -0,0 +1,5 @@
+# Change this to Gentoo's Default, instead of FreeBSD's default of
+# /usr/share/skel, so that bash and other packages installs the files on the
+# right place.
+skeleton /etc/skel
+
diff --git a/sys-freebsd/freebsd-usbin/files/rarpd.confd b/sys-freebsd/freebsd-usbin/files/rarpd.confd
new file mode 100644
index 0000000..b56fdd5
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/rarpd.confd
@@ -0,0 +1,7 @@
+# $Id$
+
+# Configuration file for /etc/init.d/rarpd
+
+# To start rarpd only for a given interface, set the
+# following variable
+# RARPD_ONLY_INTERFACE="rl0"
diff --git a/sys-freebsd/freebsd-usbin/files/rarpd.initd b/sys-freebsd/freebsd-usbin/files/rarpd.initd
new file mode 100644
index 0000000..3c2a3ff
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/rarpd.initd
@@ -0,0 +1,35 @@
+#!/sbin/openrc-run
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+depend() {
+ if [ -z "${RARPD_ONLY_INTERFACE}" ]; then
+ need net
+ else
+ need net."${RARPD_ONLY_INTERFACE}"
+ fi
+}
+
+start() {
+ local rarpd_opts
+
+ if [ -z "${RARPD_ONLY_INTERFACE}" ]; then
+ rarpd_opts="${rarpd_opts} -a"
+ else
+ rarpd_opts="${rarpd_opts} ${RARPD_ONLY_INTERFACE}"
+ fi
+
+ ebegin "Starting reverse ARP daemon"
+ start-stop-daemon --start --background \
+ --pidfile /var/run/rarpd.pid --make-pidfile \
+ --exec /usr/sbin/rarpd -- -f ${rarpd_opts}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping reverse ARP daemon"
+ start-stop-daemon --stop --pidfile /var/run/rarpd.pid \
+ --exec /usr/sbin/rarpd -- ${rarpd_opts}
+ eend $?
+}
diff --git a/sys-freebsd/freebsd-usbin/files/rpc.lockd.initd b/sys-freebsd/freebsd-usbin/files/rpc.lockd.initd
new file mode 100644
index 0000000..dd2fdbe
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/rpc.lockd.initd
@@ -0,0 +1,20 @@
+#!/sbin/openrc-run
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net rpcbind rpc.statd
+}
+
+start() {
+ ebegin "Starting NFS lockd"
+ start-stop-daemon --start --quiet --exec \
+ /usr/sbin/rpc.lockd -- $rpclockdopts
+ eend $? "Error starting NFS lockd"
+}
+
+stop() {
+ ebegin "Stopping NFS lockd"
+ start-stop-daemon --stop --quiet --exec /usr/sbin/rpc.lockd
+ eend $? "Error stopping NFS lockd"
+}
diff --git a/sys-freebsd/freebsd-usbin/files/rpc.statd.initd b/sys-freebsd/freebsd-usbin/files/rpc.statd.initd
new file mode 100644
index 0000000..163af5a
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/rpc.statd.initd
@@ -0,0 +1,20 @@
+#!/sbin/openrc-run
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net rpcbind
+}
+
+start() {
+ ebegin "Starting NFS statd"
+ start-stop-daemon --start --quiet --exec \
+ /usr/sbin/rpc.statd -- $rpcstatdopts
+ eend $? "Error starting NFS statd"
+}
+
+stop() {
+ ebegin "Stopping NFS statd"
+ start-stop-daemon --stop --quiet --exec /usr/sbin/rpc.statd
+ eend $? "Error stopping NFS statd"
+}
diff --git a/sys-freebsd/freebsd-usbin/files/rpcbind.initd b/sys-freebsd/freebsd-usbin/files/rpcbind.initd
new file mode 100644
index 0000000..1ff98a5
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/rpcbind.initd
@@ -0,0 +1,30 @@
+#!/sbin/openrc-run
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+depend() {
+ need localmount
+ use net
+ before inetd
+ before xinetd
+}
+
+start() {
+ ebegin "Starting rpcbind"
+ start-stop-daemon --start --exec /usr/sbin/rpcbind
+ local ret=$?
+ eend ${ret}
+
+ # without, if a service depending on portmap is started too fast,
+ # connecting to portmap will fail -- azarah
+ # doing that for rpcbind, too -- flameeyes
+ sleep 1
+ return ${ret}
+}
+
+stop() {
+ ebegin "Stopping rpcbind"
+ start-stop-daemon --stop --exec /usr/sbin/rpcbind
+ eend $?
+}
diff --git a/sys-freebsd/freebsd-usbin/files/syscons.confd b/sys-freebsd/freebsd-usbin/files/syscons.confd
new file mode 100644
index 0000000..7ba81ff
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/syscons.confd
@@ -0,0 +1,14 @@
+# $Id$
+# Example syscons config file. This is the place to set things like keymap, etc.
+
+# Set the keymap to "uk.iso".
+#KEYMAP="uk.iso"
+
+# Set the keyboard rate to 250ms delay, and 34 repeat rate.
+#KEYRATE="250.34"
+
+# Change the behaviour of F-unction keys (see kbdcontrol(1)).
+#KEYCHANGE="10 'ssh myhost'"
+
+# See vidcontrol(1) -t
+#BLANKTIME="off"
diff --git a/sys-freebsd/freebsd-usbin/files/syscons.initd b/sys-freebsd/freebsd-usbin/files/syscons.initd
new file mode 100644
index 0000000..5ab3075
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/syscons.initd
@@ -0,0 +1,78 @@
+#!/sbin/openrc-run
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+depend() {
+ need localmount
+}
+
+start() {
+ ebegin "Configuring system console"
+
+ if [ -n "${MODE}" ] ; then
+ einfo "Setting mode to ${MODE}"
+ vidcontrol "${MODE}"
+ eend $?
+ fi
+
+ # XXX: This should handle serial consoles.
+
+ # Set the keymap.
+ if [ -n "${KEYMAP}" ]; then
+ einfo "Setting keymap to" "${KEYMAP}"
+ kbdcontrol -l ${KEYMAP} < /dev/console
+ fi
+
+ if [ -n "${KEYRATE}" ]; then
+ einfo "Setting keyrate to" "${KEYRATE}"
+ kbdcontrol -r ${KEYRATE} < /dev/console
+ fi
+
+ if [ -n "${KEYCHANGE}" ]; then
+ einfo "Changing function keys..."
+ eval set -- "${KEYCHANGE}"
+ eindent
+ while [ $# -gt 0 ] ; do
+ veinfo "F$1 -> \`$2'"
+ kbdcontrol -f "$1" "$2" < /dev/console
+ shift ; shift
+ done
+ eoutdent
+ fi
+
+ if [ -n "${CURSOR}" ]; then
+ einfo "Setting cursor"
+ vidcontrol -c ${CURSOR}
+ fi
+
+ einfo "Setting custom fonts..."
+ # Nothing to see here, move along...
+ for v in FONT8x16 FONT8x14 FONT8x8; do
+ f=$(eval \$"${v}")
+ if [ -n "${f}" ]; then
+ vidcontrol -f ${v##FONT} ${f}
+ fi
+ done
+
+ if [ -n "${BLANKTIME}" ]; then
+ einfo "Setting blanktime"
+ vidcontrol -t ${BLANKTIME}
+ fi
+
+ if [ -n "${SAVER}" ]; then
+ for i in `kldstat | awk '$5 ~ "^splash_.*$" { print $5 }'`; do
+ kldunload ${i}
+ done
+ kldstat -v | grep -q _saver || kldload ${SAVER}_saver
+ fi
+
+ if [ -n "${KBDFLAGS}" ]; then
+ einfo "Setting keyboard flags for all screens"
+ for ttyv in /dev/ttyv*; do
+ kbdcontrol ${KBDFLAGS} <${ttyv} >${ttyv} 2>&1
+ done
+ fi
+
+ eend 0
+}
diff --git a/sys-freebsd/freebsd-usbin/files/syslogd.initd b/sys-freebsd/freebsd-usbin/files/syslogd.initd
new file mode 100644
index 0000000..87c40cd
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/syslogd.initd
@@ -0,0 +1,25 @@
+#!/sbin/openrc-run
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+depend() {
+ provide logger
+ need localmount
+}
+
+start() {
+ ebegin "Starting System Logger"
+ start-stop-daemon --start --quiet --exec /usr/sbin/syslogd \
+ -- ${SYSLOGD_OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping System Logger"
+ start-stop-daemon --stop --quiet --pidfile /var/run/syslog.pid
+ eend $?
+}
+
+
+
diff --git a/sys-freebsd/freebsd-usbin/freebsd-usbin-11.0.ebuild b/sys-freebsd/freebsd-usbin/freebsd-usbin-11.0.ebuild
new file mode 100644
index 0000000..28374e5
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/freebsd-usbin-11.0.ebuild
@@ -0,0 +1,187 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic eutils
+
+DESCRIPTION="FreeBSD /usr/sbin tools"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ usr.sbin/
+ contrib/
+ usr.bin/
+ lib/
+ sbin/
+ etc/
+ gnu/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[usb?,bluetooth?,netware?]
+ =sys-freebsd/freebsd-libexec-${RV}*
+ build? ( sys-apps/baselayout )
+ ssl? ( dev-libs/openssl:0 )
+ >=app-arch/libarchive-3
+ sys-apps/tcp-wrappers
+ dev-util/dialog
+ >=dev-libs/libedit-20120311.3.0-r1
+ net-libs/libpcap
+ kerberos? ( app-crypt/heimdal )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-ubin-${RV}*
+ zfs? ( =sys-freebsd/freebsd-cddl-${RV}* )
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ sys-apps/texinfo
+ sys-devel/flex"
+
+S="${WORKDIR}/usr.sbin"
+
+IUSE="acpi atm audit bluetooth floppy ipv6 kerberos minimal netware nis pam ssl usb build zfs"
+
+pkg_setup() {
+ # Add the required source files.
+ use nis && EXTRACTONLY+="libexec/ "
+ use build && EXTRACTONLY+="sys/ include/ "
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ # Release crunch is something like minimal. It seems to remove everything
+ # which is not needed to work.
+ use minimal && mymakeopts="${mymakeopts} RELEASE_CRUNCH= "
+
+ use acpi || mymakeopts="${mymakeopts} WITHOUT_ACPI= "
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use audit || mymakeopts="${mymakeopts} WITHOUT_AUDIT= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use pam || mymakeopts="${mymakeopts} WITHOUT_PAM_SUPPORT= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use floppy || mymakeopts="${mymakeopts} WITHOUT_FLOPPY= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_GSSAPI= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+
+ mymakeopts="${mymakeopts} WITHOUT_PF= WITHOUT_LPR= WITHOUT_SENDMAIL= WITHOUT_AUTHPF= WITHOUT_MAILWRAPPER= WITHOUT_UNBOUND= "
+
+ append-flags $(test-flags -fno-strict-aliasing)
+}
+
+PATCHES=(
+ "${FILESDIR}/${PN}-adduser.patch"
+ "${FILESDIR}/${PN}-9.0-newsyslog.patch"
+ "${FILESDIR}/${PN}-10.0-bsdxml2expat.patch"
+ "${FILESDIR}/${PN}-10.3-bsdxml2expat.patch"
+ )
+
+REMOVE_SUBDIRS="
+ tcpdchk tcpdmatch
+ sendmail praliases editmap mailstats makemap
+ pc-sysinstall cron mailwrapper ntp bsnmpd
+ tcpdump ndp inetd
+ wpa/wpa_supplicant wpa/hostapd wpa/hostapd_cli wpa/wpa_cli wpa/wpa_passphrase
+ zic amd
+ pkg pkg_install freebsd-update service sysrc bsdinstall"
+
+src_prepare() {
+ if ! use build; then
+ [[ ! -e "${WORKDIR}/sys" ]] && ln -s "/usr/src/sys" "${WORKDIR}/sys"
+ [[ ! -e "${WORKDIR}/include" ]] && ln -s "/usr/include" "${WORKDIR}/include"
+ else
+ dummy_mk mount_smbfs
+ fi
+ # Don't install mtree format manpage
+ # it's installed by libarchive.
+ sed -e "s: mtree.5::g" -i "${S}"/mtree/Makefile
+}
+
+src_compile() {
+ # Preparing to build nmtree
+ cd "${WORKDIR}/lib/libnetbsd" || die
+ freebsd_src_compile
+
+ cd "${S}" || die
+ freebsd_src_compile
+}
+
+src_install() {
+ # By creating these directories we avoid having to do a
+ # more complex hack
+ dodir /usr/share/doc
+ dodir /sbin
+ dodir /usr/libexec
+ dodir /usr/bin
+
+ # FILESDIR is used by some makefiles which will install files
+ # in the wrong place, just put it in the doc directory.
+ mkinstall DOCDIR=/usr/share/doc/${PF} || die "Install failed"
+
+ # Most of these now come from openrc.
+ for util in iscsid nfs nfsuserd rpc.statd rpc.lockd; do
+ newinitd "${FILESDIR}/"${util}.initd ${util} || die
+ if [[ -e "${FILESDIR}"/${util}.confd ]]; then \
+ newconfd "${FILESDIR}"/${util}.confd ${util} || die
+ fi
+ done
+
+ for class in daily monthly weekly; do
+ cat - > "${T}/periodic.${class}" <<EOS
+#!/bin/sh
+/usr/sbin/periodic ${class}
+EOS
+ exeinto /etc/cron.${class}
+ newexe "${T}/periodic.${class}" periodic
+ done
+
+ # Install the pw.conf file to let pw use Gentoo's skel location
+ insinto /etc
+ doins "${FILESDIR}/pw.conf" || die
+
+ cd "${WORKDIR}/etc" || die
+ doins apmd.conf syslog.conf newsyslog.conf nscd.conf || die
+
+ insinto /etc/ppp
+ doins ppp/ppp.conf || die
+
+ if use bluetooth; then
+ insinto /etc/bluetooth
+ doins bluetooth/* || die
+ rm -f "${D}"/etc/bluetooth/Makefile
+ fi
+
+ # Install the periodic stuff (needs probably to be ported in a more
+ # gentooish way)
+ cd "${WORKDIR}/etc/periodic" || die
+
+ doperiodic daily daily/*.accounting
+ doperiodic monthly monthly/*.accounting
+}
+
+pkg_postinst() {
+ # We need to run pwd_mkdb if key files are not present
+ # If they are, then there is no need to run pwd_mkdb
+ if [[ ! -e "${ROOT}etc/passwd" || ! -e "${ROOT}etc/pwd.db" || ! -e "${ROOT}etc/spwd.db" ]] ; then
+ if [[ -e "${ROOT}etc/master.passwd" ]] ; then
+ einfo "Generating passwd files from ${ROOT}etc/master.passwd"
+ "${ROOT}"usr/sbin/pwd_mkdb -p -d "${ROOT}etc" "${ROOT}etc/master.passwd"
+ else
+ eerror "${ROOT}etc/master.passwd does not exist!"
+ eerror "You will no be able to log into your system!"
+ fi
+ fi
+
+ for logfile in messages security auth.log maillog lpd-errs xferlog cron \
+ debug.log slip.log ppp.log; do
+ [[ -f "${ROOT}/var/log/${logfile}" ]] || touch "${ROOT}/var/log/${logfile}"
+ done
+}
diff --git a/sys-freebsd/freebsd-usbin/metadata.xml b/sys-freebsd/freebsd-usbin/metadata.xml
new file mode 100644
index 0000000..45c930b
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/metadata.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+ </maintainer>
+ <use>
+ <flag name="floppy">Enable floppy disk utilities (fdcontrol, fdformat, fdread, fdwrite).</flag>
+ <flag name="audit">
+ Build auditing tools.
+ </flag>
+ <flag name="netware">
+ Build libraries and tools to work with NetWare protocols (IPX
+ and NCP).
+ </flag>
+ <flag name='zfs'>Enable ZFS support.</flag>
+ </use>
+</pkgmetadata>