/[gentoo-x86]/eclass/freebsd.eclass
Gentoo

Contents of /eclass/freebsd.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.26 - (show annotations) (download)
Mon Jun 17 20:00:37 2013 UTC (10 months, 1 week ago) by aballier
Branch: MAIN
Changes since 1.25: +4 -4 lines
freebsd_multilib_multibuild_wrapper: save and restore LDADD too.

1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/freebsd.eclass,v 1.25 2013/06/17 17:31:30 aballier Exp $
4 #
5 # Diego Pettenò <flameeyes@gentoo.org>
6
7 inherit versionator eutils flag-o-matic bsdmk
8
9 LICENSE="BSD"
10 HOMEPAGE="http://www.freebsd.org/"
11
12 # Define global package names
13 LIB="freebsd-lib-${PV}"
14 BIN="freebsd-bin-${PV}"
15 CONTRIB="freebsd-contrib-${PV}"
16 SHARE="freebsd-share-${PV}"
17 UBIN="freebsd-ubin-${PV}"
18 USBIN="freebsd-usbin-${PV}"
19 CRYPTO="freebsd-crypto-${PV}"
20 LIBEXEC="freebsd-libexec-${PV}"
21 SBIN="freebsd-sbin-${PV}"
22 GNU="freebsd-gnu-${PV}"
23 ETC="freebsd-etc-${PV}"
24 SYS="freebsd-sys-${PV}"
25 INCLUDE="freebsd-include-${PV}"
26 RESCUE="freebsd-rescue-${PV}"
27 CDDL="freebsd-cddl-${PV}"
28
29 # Release version (5.3, 5.4, 6.0, etc)
30 RV="$(get_version_component_range 1-2)"
31
32 if [[ ${PN} != "freebsd-share" ]] && [[ ${PN} != freebsd-sources ]]; then
33 IUSE="profile"
34 fi
35
36 #unalias -a
37 alias install-info='/usr/bin/bsdinstall-info'
38
39 EXPORT_FUNCTIONS src_compile src_install src_unpack
40
41 # doperiodic <kind> <file> ...
42 doperiodic() {
43 local kind=$1
44 shift
45
46 ( # dont want to pollute calling env
47 insinto /etc/periodic/${kind}
48 insopts -m 0755
49 doins "$@"
50 )
51 }
52
53 freebsd_get_bmake() {
54 local bmake
55 bmake=$(get_bmake)
56 [[ ${CBUILD} == *-freebsd* ]] || bmake="${bmake} -m /usr/share/mk/freebsd"
57
58 echo "${bmake}"
59 }
60
61 freebsd_do_patches() {
62 if [[ ${#PATCHES[@]} -gt 1 ]] ; then
63 for x in "${PATCHES[@]}"; do
64 epatch "${x}"
65 done
66 else
67 for x in ${PATCHES} ; do
68 epatch "${x}"
69 done
70 fi
71 epatch_user
72 }
73
74 freebsd_rename_libraries() {
75 ebegin "Renaming libraries"
76 # We don't use libtermcap, we use libncurses
77 find "${S}" -name Makefile -print0 | xargs -0 \
78 sed -i -e 's:-ltermcap:-lncurses:g; s:{LIBTERMCAP}:{LIBNCURSES}:g'
79 # flex provides libfl, not libl
80 find "${S}" -name Makefile -print0 | xargs -0 \
81 sed -i -e 's:-ll$:-lfl:g; s:-ll :-lfl :g; s:{LIBL}:{LIBFL}:g'
82 # ncurses provides libncursesw not libcursesw
83 find "${S}" -name Makefile -print0 | xargs -0 \
84 sed -i -e 's:-lcursesw:-lncursesw:g'
85 # we use expat instead of bsdxml
86 find "${S}" -name Makefile -print0 | xargs -0 \
87 sed -i -e 's:-lbsdxml:-lexpat:g'
88
89 eend $?
90 }
91
92 freebsd_src_unpack() {
93 unpack ${A}
94 cd "${S}"
95
96 dummy_mk ${REMOVE_SUBDIRS}
97
98 freebsd_do_patches
99 freebsd_rename_libraries
100 }
101
102 freebsd_src_compile() {
103 use profile && filter-flags "-fomit-frame-pointer"
104 use profile || mymakeopts="${mymakeopts} NO_PROFILE= "
105
106 mymakeopts="${mymakeopts} NO_MANCOMPRESS= NO_INFOCOMPRESS= NO_FSCHG="
107
108 # Many things breaks when using ricer flags here
109 [[ -z "${NOFLAGSTRIP}" ]] && strip-flags
110
111 # Make sure to use FreeBSD definitions while crosscompiling
112 [[ -z "${BMAKE}" ]] && BMAKE="$(freebsd_get_bmake)"
113
114 # Create objdir if MAKEOBJDIRPREFIX is defined, so that we can make out of
115 # tree builds easily.
116 if [[ -n "${MAKEOBJDIRPREFIX}" ]] ; then
117 mkmake obj || die
118 fi
119
120 bsdmk_src_compile
121 }
122
123 # Helper function to make a multilib build with FreeBSD Makefiles.
124 # Usage:
125 # MULTIBUILD_VARIANTS=( $(get_all_abis) )
126 # multibuild_foreach_variant freebsd_multilib_multibuild_wrapper my_function
127 #
128 # Important note: To use this function you _have_ to:
129 # - inherit multilib.eclass and multibuild.eclass
130 # - set MULTILIB_VARIANTS
131 # - have a multilib useflag in IUSE
132
133 freebsd_multilib_multibuild_wrapper() {
134 # Get the ABI from multibuild.eclass
135 # This assumes MULTILIB_VARIANTS contains only valid ABIs.
136 local ABI=${MULTIBUILD_VARIANT}
137
138 # First, save the variables: CFLAGS, CXXFLAGS, LDFLAGS, LDADD and mymakeopts.
139 for i in CFLAGS CXXFLAGS LDFLAGS LDADD mymakeopts ; do
140 export ${i}_SAVE="${!i}"
141 done
142
143 # Setup the variables specific to this ABI.
144 multilib_toolchain_setup "${ABI}"
145
146 local target="$(tc-arch-kernel ${CHOST})"
147 mymakeopts="${mymakeopts} TARGET=${target} MACHINE=${target} MACHINE_ARCH=${target} SHLIBDIR=/usr/$(get_libdir) LIBDIR=/usr/$(get_libdir)"
148 if use multilib && [ "${ABI}" != "${DEFAULT_ABI}" ] ; then
149 mymakeopts="${mymakeopts} COMPAT_32BIT="
150 fi
151
152 einfo "Building for ABI=${ABI} and TARGET=${target}"
153
154 export MAKEOBJDIRPREFIX="${BUILD_DIR}"
155 if [ ! -d "${MAKEOBJDIRPREFIX}" ] ; then
156 mkdir "${MAKEOBJDIRPREFIX}" || die "Could not create ${MAKEOBJDIRPREFIX}."
157 fi
158
159 CTARGET="${CHOST}" "$@"
160
161 # Restore the variables now.
162 for i in CFLAGS CXXFLAGS LDFLAGS LDADD mymakeopts ; do
163 ii="${i}_SAVE"
164 export ${i}="${!ii}"
165 done
166 }
167
168 freebsd_src_install() {
169 use profile || mymakeopts="${mymakeopts} NO_PROFILE= "
170
171 mymakeopts="${mymakeopts} NO_MANCOMPRESS= NO_INFOCOMPRESS= NO_FSCHG="
172
173 [[ -z "${BMAKE}" ]] && BMAKE="$(freebsd_get_bmake)"
174
175 bsdmk_src_install
176 }

  ViewVC Help
Powered by ViewVC 1.1.20