freebsd-lib-10.3-r3.ebuild 19 KB

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