freebsd-lib-11.0-r1.ebuild 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit bsdmk freebsd flag-o-matic multilib toolchain-funcs eutils multibuild multilib-build
  5. DESCRIPTION="FreeBSD's base system libraries"
  6. SLOT="0"
  7. LICENSE="BSD zfs? ( CDDL )"
  8. # Security Advisory and Errata patches.
  9. UPSTREAM_PATCHES=( "SA-16:37/libc.patch"
  10. "SA-16:38/bhyve.patch" )
  11. # Crypto is needed to have an internal OpenSSL header
  12. # sys is needed for libalias, probably we can just extract that instead of
  13. # extracting the whole tarball
  14. if [[ ${PV} != *9999* ]]; then
  15. KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
  16. SRC_URI="${SRC_URI}
  17. $(freebsd_upstream_patches)"
  18. fi
  19. EXTRACTONLY="
  20. lib/
  21. contrib/
  22. crypto/
  23. libexec/
  24. etc/
  25. include/
  26. usr.sbin/
  27. gnu/
  28. secure/
  29. "
  30. if [ "${CATEGORY#*cross-}" = "${CATEGORY}" ]; then
  31. RDEPEND="ssl? ( dev-libs/openssl:0= )
  32. hesiod? ( net-dns/hesiod )
  33. kerberos? ( app-crypt/heimdal )
  34. usb? ( !dev-libs/libusb )
  35. zfs? ( =sys-freebsd/freebsd-cddl-${RV}* )
  36. >=dev-libs/expat-2.0.1
  37. >=dev-util/dialog-1.2.20150225
  38. =sys-freebsd/freebsd-libexec-${RV}*
  39. !sys-libs/libutempter
  40. !dev-libs/libelf
  41. !dev-libs/libexecinfo
  42. !dev-libs/libiconv
  43. !sys-freebsd/freebsd-headers"
  44. DEPEND="${RDEPEND}
  45. >=sys-devel/flex-2.5.31-r2
  46. =sys-freebsd/freebsd-sources-${RV}*"
  47. RDEPEND="${RDEPEND}
  48. =sys-freebsd/freebsd-share-${RV}*
  49. >=virtual/libiconv-0-r2"
  50. else
  51. EXTRACTONLY+="sys/ "
  52. fi
  53. DEPEND="${DEPEND}
  54. userland_GNU? ( sys-apps/mtree )
  55. =sys-freebsd/freebsd-mk-defs-${RV}*"
  56. S="${WORKDIR}/lib"
  57. export CTARGET=${CTARGET:-${CHOST}}
  58. if [ "${CTARGET}" = "${CHOST}" -a "${CATEGORY#*cross-}" != "${CATEGORY}" ]; then
  59. export CTARGET=${CATEGORY/cross-}
  60. fi
  61. IUSE="atm bluetooth ssl hesiod ipv6 kerberos usb netware
  62. build crosscompile_opts_headers-only zfs
  63. userland_GNU userland_BSD"
  64. QA_DT_NEEDED="lib/libc.so.7 usr/lib32/libc.so.7"
  65. pkg_setup() {
  66. # Add the required source files.
  67. use build && EXTRACTONLY+="sys/ "
  68. use zfs && EXTRACTONLY+="cddl/ "
  69. [ -c /dev/zero ] || \
  70. die "You forgot to mount /dev; the compiled libc would break."
  71. if ! use ssl && use kerberos; then
  72. eerror "If you want kerberos support you need to enable ssl support, too."
  73. fi
  74. use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
  75. use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
  76. use hesiod || mymakeopts="${mymakeopts} WITHOUT_HESIOD= "
  77. use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6_SUPPORT= "
  78. use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= WITHOUT_GSSAPI= "
  79. use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
  80. use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
  81. use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
  82. use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
  83. mymakeopts="${mymakeopts} WITHOUT_SENDMAIL= WITHOUT_CLANG= WITHOUT_LIBCPLUSPLUS= WITHOUT_LDNS= WITHOUT_UNBOUND= "
  84. if [ "${CTARGET}" != "${CHOST}" ]; then
  85. mymakeopts="${mymakeopts} MACHINE=$(tc-arch-kernel ${CTARGET})"
  86. mymakeopts="${mymakeopts} MACHINE_ARCH=$(tc-arch-kernel ${CTARGET})"
  87. fi
  88. }
  89. PATCHES=(
  90. "${FILESDIR}/${PN}-6.0-pmc.patch"
  91. "${FILESDIR}/${PN}-10.0-atfcxx.patch"
  92. "${FILESDIR}/${PN}-9.0-bluetooth.patch"
  93. "${FILESDIR}/${PN}-11.0-workaround.patch"
  94. "${FILESDIR}/${PN}-11.0-bsdxml2expat.patch"
  95. "${FILESDIR}/${PN}-11.0-libsysdecode.patch"
  96. "${FILESDIR}/${PN}-11.0-libproc-libcxx.patch"
  97. "${FILESDIR}/${PN}-add-nossp-cflags.patch"
  98. )
  99. # Here we disable and remove source which we don't need or want
  100. # In order:
  101. # - ncurses stuff
  102. # - libexpat creates a bsdxml library which is the same as expat
  103. # - archiving libraries (have their own ebuild)
  104. # - sendmail libraries (they are installed by sendmail)
  105. # - SNMP library and dependency (have their own ebuilds)
  106. # - libstand: static library, 32bits on amd64 used for boot0, we build it from
  107. # boot0 instead.
  108. #
  109. # The rest are libraries we already have somewhere else because
  110. # they are contribution.
  111. REMOVE_SUBDIRS="ncurses \
  112. libexpat \
  113. libz libbz2 libarchive liblzma \
  114. libsm libsmdb libsmutil \
  115. libbegemot libbsnmp \
  116. libpam libpcap libwrap libmagic \
  117. libcom_err
  118. libedit
  119. libstand
  120. libgssapi"
  121. # Are we building a cross-compiler?
  122. is_crosscompile() {
  123. [ "${CATEGORY#*cross-}" != "${CATEGORY}" ]
  124. }
  125. src_prepare() {
  126. # gcc-5.0 or later, Workaround for critical issue. bug 573358.
  127. use x86-fbsd && [[ "$(gcc-major-version)" -ge 5 ]] && replace-flags -O? -O1
  128. sed -i.bak -e 's:-o/dev/stdout:-t:' "${S}/libc/net/Makefile.inc"
  129. # Upstream Display Managers default to using VT7
  130. # We should make FreeBSD allow this by default
  131. local x=
  132. for x in "${WORKDIR}"/etc/etc.*/ttys ; do
  133. sed -i.bak \
  134. -e '/ttyv5[[:space:]]/ a\
  135. # Display Managers default to VT7.\
  136. # If you use the xdm init script, keep ttyv6 commented out\
  137. # unless you force a different VT for the DM being used.' \
  138. -e '/^ttyv[678][[:space:]]/ s/^/# /' "${x}" \
  139. || die "Failed to sed ${x}"
  140. rm "${x}".bak
  141. done
  142. # This one is here because it also
  143. # patches "${WORKDIR}/include"
  144. cd "${WORKDIR}"
  145. epatch "${FILESDIR}/${PN}-includes.patch"
  146. # Don't install the hesiod man page or header
  147. rm "${WORKDIR}"/include/hesiod.h || die
  148. sed -i.bak -e 's:hesiod.h::' "${WORKDIR}"/include/Makefile || die
  149. sed -i.bak -e 's:hesiod.c::' -e 's:hesiod.3::' \
  150. "${WORKDIR}"/lib/libc/net/Makefile.inc || die
  151. # Fix the Makefiles of these few libraries that will overwrite our LDADD.
  152. cd "${S}"
  153. for dir in libradius libtacplus libcam libdevstat libfetch libgeom libmemstat libopie \
  154. libsmb libprocstat libulog; do sed -i.bak -e 's:LDADD=:LDADD+=:g' "${dir}/Makefile" || \
  155. die "Problem fixing \"${dir}/Makefile"
  156. done
  157. # Call LD with LDFLAGS, rename them to RAW_LDFLAGS
  158. sed -e 's/LDFLAGS/RAW_LDFLAGS/g' \
  159. -i "${S}/csu/i386/Makefile" || die
  160. if install --version 2> /dev/null | grep -q GNU; then
  161. sed -i.bak -e 's:${INSTALL} -C:${INSTALL}:' "${WORKDIR}/include/Makefile"
  162. fi
  163. # Try to fix sed calls for GNU sed. Do it only with GNU userland and force
  164. # BSD's sed on BSD.
  165. cd "${S}"
  166. if [[ ${CBUILD:-${CHOST}} != *bsd* ]]; then
  167. find . -name Makefile -exec sed -ibak 's/sed -i /sed -i/' {} \;
  168. sed -i -e 's/-i ""/-i""/' "${S}/csu/Makefile.inc" || die
  169. fi
  170. if use build; then
  171. cd "${WORKDIR}"
  172. # This patch has to be applied on ${WORKDIR}/sys, so we do it here since it
  173. # shouldn't be a symlink to /usr/src/sys (which should be already patched)
  174. epatch "${FILESDIR}"/freebsd-sources-9.0-sysctluint.patch
  175. return 0
  176. fi
  177. if ! is_crosscompile ; then
  178. if [[ ! -e "${WORKDIR}/sys" ]]; then
  179. ln -s "${SYSROOT}/usr/src/sys" "${WORKDIR}/sys" || die "Couldn't make sys symlink!"
  180. fi
  181. else
  182. sed -i.bak -e "s:/usr/include:/usr/${CTARGET}/usr/include:g" \
  183. "${S}/libc/rpc/Makefile.inc" \
  184. "${S}/libc/yp/Makefile.inc"
  185. fi
  186. }
  187. bootstrap_lib() {
  188. for i ; do
  189. cd "${WORKDIR}/${i}" || die "missing ${i}"
  190. freebsd_src_compile
  191. append-ldflags "-L${MAKEOBJDIRPREFIX}/${WORKDIR}/${i}"
  192. done
  193. }
  194. get_csudir() {
  195. if [ -d "${WORKDIR}/lib/csu/$1-elf" ]; then
  196. echo "lib/csu/$1-elf"
  197. else
  198. echo "lib/csu/$1"
  199. fi
  200. }
  201. bootstrap_csu() {
  202. local csudir="$(get_csudir $(tc-arch-kernel ${CTARGET}))"
  203. export RAW_LDFLAGS=$(raw-ldflags)
  204. bootstrap_lib "${csudir}"
  205. CFLAGS="${CFLAGS} -B ${MAKEOBJDIRPREFIX}/${WORKDIR}/${csudir}"
  206. append-ldflags "-B ${MAKEOBJDIRPREFIX}/${WORKDIR}/${csudir}"
  207. bootstrap_lib "gnu/lib/csu"
  208. cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
  209. for i in *.So ; do
  210. ln -s $i ${i%.So}S.o
  211. done
  212. CFLAGS="${CFLAGS} -B ${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
  213. append-ldflags "-B ${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
  214. }
  215. # Compile libssp_nonshared.a and add it's path to LDFLAGS.
  216. bootstrap_libssp_nonshared() {
  217. bootstrap_lib "gnu/lib/libssp/libssp_nonshared"
  218. }
  219. bootstrap_libgcc() {
  220. bootstrap_lib "lib/libcompiler_rt"
  221. cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libcompiler_rt" || die
  222. ln -s libcompiler_rt.a libgcc.a || die
  223. bootstrap_lib "lib/libc" "gnu/lib/libgcc"
  224. }
  225. bootstrap_libthr() {
  226. bootstrap_lib "lib/libthr"
  227. cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libthr" || die
  228. ln -s libthr.so libpthread.so
  229. }
  230. # What to build for a cross-compiler.
  231. # We also need the csu but this has to be handled separately.
  232. CROSS_SUBDIRS="lib/libc lib/msun gnu/lib/libssp/libssp_nonshared lib/libthr lib/libutil lib/librt lib/libc_nonshared"
  233. # What to build for non-default ABIs.
  234. 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"
  235. # Subdirs for a native build:
  236. NATIVE_SUBDIRS="lib gnu/lib/libssp/libssp_nonshared gnu/lib/libregex gnu/lib/csu gnu/lib/libgcc lib/libiconv_modules"
  237. # Is my $ABI native ?
  238. is_native_abi() {
  239. is_crosscompile && return 1
  240. multilib_is_native_abi
  241. }
  242. # Do we need to bootstrap the csu and libssp_nonshared?
  243. need_bootstrap() {
  244. 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}"
  245. }
  246. # Get the subdirs we are building.
  247. get_subdirs() {
  248. local ret=""
  249. if is_native_abi ; then
  250. # If we are building for the native ABI, build everything
  251. ret="${NATIVE_SUBDIRS}"
  252. elif is_crosscompile ; then
  253. # With a cross-compiler we only build the very core parts.
  254. ret="${CROSS_SUBDIRS}"
  255. if [ "${EBUILD_PHASE}" = "install" ]; then
  256. # Add the csu dir first when installing. We treat it separately for
  257. # compiling.
  258. ret="$(get_csudir $(tc-arch-kernel ${CTARGET})) ${ret}"
  259. fi
  260. else
  261. # For the non-native ABIs we only build the csu parts and very core
  262. # libraries for now.
  263. ret="${NON_NATIVE_SUBDIRS} $(get_csudir $(tc-arch-kernel ${CHOST}))"
  264. fi
  265. echo "${ret}"
  266. }
  267. # Bootstrap the core libraries and setup the flags so that the other parts can
  268. # build against it.
  269. do_bootstrap() {
  270. einfo "Bootstrapping on ${CHOST} for ${CTARGET}"
  271. if ! is_crosscompile ; then
  272. # Pre-install headers, but not when building a cross-compiler since we
  273. # assume they have been installed in the previous pass.
  274. einfo "Pre-installing includes in include_proper_${ABI}"
  275. mkdir "${WORKDIR}/include_proper_${ABI}" || die
  276. CTARGET="${CHOST}" install_includes "/include_proper_${ABI}"
  277. CFLAGS="${CFLAGS} -isystem ${WORKDIR}/include_proper_${ABI}"
  278. [[ $(tc-getCXX) = *clang++* ]] && CXXFLAGS="${CXXFLAGS} -isystem /usr/include/c++/v1"
  279. CXXFLAGS="${CXXFLAGS} -isystem ${WORKDIR}/include_proper_${ABI}"
  280. mymakeopts="${mymakeopts} RPCDIR=${WORKDIR}/include_proper_${ABI}/rpcsvc"
  281. fi
  282. bootstrap_csu
  283. bootstrap_libssp_nonshared
  284. is_crosscompile && bootstrap_lib "lib/libc"
  285. is_crosscompile || is_native_abi || bootstrap_libgcc
  286. is_native_abi || bootstrap_libthr
  287. }
  288. # Compile it. Assume we have the toolchain setup correctly.
  289. do_compile() {
  290. # Bootstrap if needed, otherwise assume the system headers are in
  291. # /usr/include.
  292. if need_bootstrap ; then
  293. do_bootstrap
  294. else
  295. CFLAGS="${CFLAGS} -isystem /usr/include"
  296. [[ $(tc-getCXX) = *clang++* ]] && CXXFLAGS="${CXXFLAGS} -isystem /usr/include/c++/v1"
  297. CXXFLAGS="${CXXFLAGS} -isystem /usr/include"
  298. fi
  299. export RAW_LDFLAGS=$(raw-ldflags)
  300. # Everything is now setup, build it!
  301. for i in $(get_subdirs) ; do
  302. einfo "Building in ${i}... with CC=${CC} and CFLAGS=${CFLAGS}"
  303. cd "${WORKDIR}/${i}/" || die "missing ${i}."
  304. freebsd_src_compile || die "make ${i} failed"
  305. done
  306. }
  307. src_compile() {
  308. # Does not work with GNU sed
  309. # Force BSD's sed on BSD.
  310. if [[ ${CBUILD:-${CHOST}} == *bsd* ]]; then
  311. export ESED=/usr/bin/sed
  312. unalias sed
  313. fi
  314. use usb && export NON_NATIVE_SUBDIRS="${NON_NATIVE_SUBDIRS} lib/libusb lib/libusbhid"
  315. cd "${WORKDIR}/include"
  316. $(freebsd_get_bmake) CC="$(tc-getCC)" SRCTOP="${WORKDIR}" || die "make include failed"
  317. use crosscompile_opts_headers-only && return 0
  318. # Bug #270098
  319. append-flags $(test-flags -fno-strict-aliasing)
  320. # Bug #324445
  321. append-flags $(test-flags -fno-strict-overflow)
  322. # strip flags and do not do it later, we only add safe, and in fact
  323. # needed flags after all
  324. strip-flags
  325. export NOFLAGSTRIP=yes
  326. if is_crosscompile ; then
  327. export YACC='yacc -by'
  328. CHOST=${CTARGET} tc-export CC LD CXX RANLIB
  329. mymakeopts="${mymakeopts} NLS="
  330. CFLAGS="${CFLAGS} -isystem /usr/${CTARGET}/usr/include"
  331. CXXFLAGS="${CXXFLAGS} -isystem /usr/${CTARGET}/usr/include"
  332. append-ldflags "-L${WORKDIR}/${CHOST}/${WORKDIR}/lib/libc"
  333. fi
  334. if is_crosscompile ; then
  335. do_compile
  336. else
  337. local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
  338. multibuild_foreach_variant freebsd_multilib_multibuild_wrapper do_compile
  339. fi
  340. }
  341. gen_libc_ldscript() {
  342. # Parameters:
  343. # $1 = target libdir
  344. # $2 = source libc dir
  345. # $3 = source libssp_nonshared dir
  346. # Clear the symlink.
  347. rm -f "${DESTDIR}/$2/libc.so" || die
  348. # Move the library if needed
  349. if [ "$1" != "$2" ] ; then
  350. mv "${DESTDIR}/$2/libc.so.7" "${DESTDIR}/$1/" || die
  351. fi
  352. # Generate libc.so ldscript for inclusion of libssp_nonshared.a when linking
  353. # this is done to avoid having to touch gcc spec file as it is currently
  354. # done on FreeBSD upstream, mostly because their binutils aren't able to
  355. # cope with linker scripts yet.
  356. # Taken from toolchain-funcs.eclass:
  357. local output_format
  358. output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p')
  359. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )"
  360. # iconv symbol provided by libc_nonshared.a.
  361. # http://svnweb.freebsd.org/base?view=revision&amp;revision=258283
  362. cat > "${DESTDIR}/$2/libc.so" <<-END_LDSCRIPT
  363. /* GNU ld script
  364. SSP (-fstack-protector) requires __stack_chk_fail_local to be local.
  365. GCC invokes this symbol in a non-PIC way, which results in TEXTRELs if
  366. this symbol was provided by a shared libc. So we link in
  367. libssp_nonshared.a from here.
  368. */
  369. ${output_format}
  370. GROUP ( /$1/libc.so.7 /$3/libc_nonshared.a /$3/libssp_nonshared.a )
  371. END_LDSCRIPT
  372. }
  373. header_list=""
  374. move_header() {
  375. local dirname=$(dirname ${1})
  376. local filename=$(basename ${1})
  377. if [ ! -d "${dirname}/${ABI}" ] ; then
  378. mkdir "${dirname}/${ABI}" || die
  379. fi
  380. mv "${1}" "${dirname}/${ABI}/" || die
  381. export header_list="${header_list} ${1}"
  382. }
  383. make_header_template() {
  384. cat <<-END_HEADER
  385. /*
  386. * Wrapped header for multilib support.
  387. * See the real headers included below.
  388. */
  389. #if defined(__x86_64__)
  390. @ABI_amd64_fbsd@
  391. #elif defined(__i386__)
  392. @ABI_x86_fbsd@
  393. #else
  394. @ABI_${DEFAULT_ABI}@
  395. #endif
  396. END_HEADER
  397. }
  398. wrap_header() {
  399. local dirname=$(dirname ${1})
  400. local filename=$(basename ${1})
  401. if [ -n "${dirname#.}" ] ; then
  402. dirname="${dirname}/${2}"
  403. else
  404. dirname="${2}"
  405. fi
  406. if [ -f "${dirname}/${filename}" ] ; then
  407. sed -e "s:@ABI_${2}@:#include <${dirname}/${filename}>:" ${1}
  408. else
  409. cat ${1}
  410. fi
  411. }
  412. wrap_header_end() {
  413. sed -e "s:@ABI_.*@:#error \"Sorry, no support for your ABI.\":" ${1}
  414. }
  415. do_install() {
  416. if is_crosscompile ; then
  417. INCLUDEDIR="/usr/${CTARGET}/usr/include"
  418. else
  419. INCLUDEDIR="/usr/include"
  420. fi
  421. dodir ${INCLUDEDIR}
  422. CTARGET="${CHOST}" \
  423. install_includes ${INCLUDEDIR}
  424. is_crosscompile && use crosscompile_opts_headers-only && return 0
  425. # Install a libusb.pc for better compat with Linux's libusb
  426. if use usb ; then
  427. dodir /usr/$(get_libdir)/pkgconfig
  428. sed -i.bkp "s:^libdir=.*:libdir=/usr/$(get_libdir):g" "${S}"/libusb/libusb-*.pc
  429. fi
  430. for i in $(get_subdirs) ; do
  431. if [[ ${i} != *libiconv_modules* ]] ; then
  432. einfo "Installing in ${i}..."
  433. cd "${WORKDIR}/${i}/" || die "missing ${i}."
  434. freebsd_src_install || die "Install ${i} failed"
  435. fi
  436. done
  437. if ! is_crosscompile; then
  438. local mymakeopts_save="${mymakeopts}"
  439. mymakeopts="${mymakeopts} SHLIBDIR=/usr/$(get_libdir)/i18n LIBDIR=/usr/$(get_libdir)/i18n"
  440. einfo "Installing in lib/libiconv_modules..."
  441. cd "${WORKDIR}/lib/libiconv_modules/" || die "missing libiconv_modules."
  442. freebsd_src_install || die "Install lib/libiconv_modules failed"
  443. mymakeopts="${mymakeopts_save}"
  444. fi
  445. if ! is_crosscompile ; then
  446. if ! multilib_is_native_abi ; then
  447. DESTDIR="${D}" gen_libc_ldscript "usr/$(get_libdir)" "usr/$(get_libdir)" "usr/$(get_libdir)"
  448. else
  449. dodir "$(get_libdir)"
  450. DESTDIR="${D}" gen_libc_ldscript "$(get_libdir)" "usr/$(get_libdir)" "usr/$(get_libdir)"
  451. fi
  452. else
  453. CHOST=${CTARGET} DESTDIR="${D}/usr/${CTARGET}/" gen_libc_ldscript "usr/lib" "usr/lib" "usr/lib"
  454. # We're done for the cross libc here.
  455. return 0
  456. fi
  457. # Generate ldscripts for core libraries that will go in /
  458. multilib_is_native_abi && \
  459. gen_usr_ldscript -a alias cam geom ipsec jail kiconv \
  460. kvm m md procstat sbuf thr ufs util elf
  461. if [[ ${#MULTIBUILD_VARIANTS[@]} -gt 1 ]] ; then
  462. cd "${D}/usr/include"
  463. for i in machine/*.h fenv.h ; do
  464. move_header ${i}
  465. done
  466. if multilib_is_native_abi ; then
  467. # Supposedly the last one!
  468. local uniq_headers="$(echo ${header_list} | tr ' ' '\n' | sort | uniq | tr '\n' ' ')"
  469. for j in ${uniq_headers} ; do
  470. make_header_template > ${j}
  471. for i in $(get_all_abis) ; do
  472. wrap_header ${j} ${i} > ${j}.new
  473. cp ${j}.new ${j}
  474. rm -f ${j}.new
  475. done
  476. wrap_header_end ${j} > ${j}.new
  477. cp ${j}.new ${j}
  478. rm -f ${j}.new
  479. done
  480. fi
  481. fi
  482. }
  483. src_install() {
  484. if is_crosscompile ; then
  485. einfo "Installing for ${CTARGET} in ${CHOST}.."
  486. # From this point we need to force: get stripped with the correct tools,
  487. # get tc-arch-kernel to return the right value, etc.
  488. export CHOST=${CTARGET}
  489. mymakeopts="${mymakeopts} WITHOUT_MAN= \
  490. INCLUDEDIR=/usr/${CTARGET}/usr/include \
  491. SHLIBDIR=/usr/${CTARGET}/usr/lib \
  492. LIBDIR=/usr/${CTARGET}/usr/lib"
  493. dosym "usr/include" "/usr/${CTARGET}/sys-include"
  494. do_install
  495. return 0
  496. else
  497. export STRIP_MASK="*/usr/lib*/*crt*.o"
  498. local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
  499. multibuild_foreach_variant freebsd_multilib_multibuild_wrapper do_install
  500. fi
  501. cd "${WORKDIR}/etc/"
  502. insinto /etc
  503. doins nls.alias mac.conf netconfig
  504. # Install ttys file
  505. local MACHINE="$(tc-arch-kernel)"
  506. doins "etc.${MACHINE}"/*
  507. }
  508. install_includes()
  509. {
  510. local INCLUDEDIR="$1"
  511. # The idea is to be called from either install or unpack.
  512. # During unpack it's required to install them as portage's user.
  513. if [[ "${EBUILD_PHASE}" == "install" ]]; then
  514. local DESTDIR="${D}"
  515. BINOWN="root"
  516. BINGRP="wheel"
  517. else
  518. local DESTDIR="${WORKDIR}"
  519. [[ -z "${USER}" ]] && USER="portage"
  520. BINOWN="${USER}"
  521. [[ -z "${GROUPS}" ]] && GROUPS="portage"
  522. BINGRP="${GROUPS}"
  523. fi
  524. # Must exist before we use it.
  525. [[ -d "${DESTDIR}${INCLUDEDIR}" ]] || die "dodir or mkdir ${INCLUDEDIR} before using install_includes."
  526. cd "${WORKDIR}/include"
  527. local MACHINE="$(tc-arch-kernel)"
  528. einfo "Installing includes into ${INCLUDEDIR} as ${BINOWN}:${BINGRP}..."
  529. $(freebsd_get_bmake) installincludes \
  530. MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE} \
  531. DESTDIR="${DESTDIR}" \
  532. INCLUDEDIR="${INCLUDEDIR}" BINOWN="${BINOWN}" \
  533. BINGRP="${BINGRP}" \
  534. WITHOUT_GSSAPI= \
  535. SRCTOP="${WORKDIR}"|| die "install_includes() failed"
  536. einfo "includes installed ok."
  537. EXTRA_INCLUDES="lib/librtld_db lib/libutil lib/msun gnu/lib/libregex lib/libcasper lib/libmp"
  538. for i in $EXTRA_INCLUDES; do
  539. einfo "Installing $i includes into ${INCLUDEDIR} as ${BINOWN}:${BINGRP}..."
  540. cd "${WORKDIR}/$i" || die
  541. $(freebsd_get_bmake) installincludes DESTDIR="${DESTDIR}" \
  542. MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE} \
  543. INCLUDEDIR="${INCLUDEDIR}" BINOWN="${BINOWN}" \
  544. BINGRP="${BINGRP}" \
  545. SRCTOP="${WORKDIR}" || die "problem installing $i includes."
  546. einfo "$i includes installed ok."
  547. done
  548. }