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

Contents of /eclass/freebsd.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.38 - (show annotations) (download)
Fri Jun 5 16:38:21 2015 UTC (3 years, 10 months ago) by mgorny
Branch: MAIN
CVS Tags: HEAD
Changes since 1.37: +28 -6 lines
Enable IUSE=profile globally. Use upstream tarball for FreeBSD > 10.0.

1 # Copyright 1999-2015 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.37 2015/05/24 08:43:02 mgorny Exp $
4 #
5 # Diego Pettenò <flameeyes@gentoo.org>
6
7 inherit versionator eutils flag-o-matic bsdmk
8
9 # Drop patch level from ${PV}
10 MY_PV=${PV/_p*}
11 PLEVEL=${PV##*_p}
12
13 LICENSE="BSD"
14 HOMEPAGE="http://www.freebsd.org/"
15
16 # Define global package names
17 LIB="freebsd-lib-${PV}"
18 BIN="freebsd-bin-${PV}"
19 CONTRIB="freebsd-contrib-${PV}"
20 SHARE="freebsd-share-${PV}"
21 UBIN="freebsd-ubin-${PV}"
22 USBIN="freebsd-usbin-${PV}"
23 CRYPTO="freebsd-crypto-${PV}"
24 LIBEXEC="freebsd-libexec-${PV}"
25 SBIN="freebsd-sbin-${PV}"
26 GNU="freebsd-gnu-${PV}"
27 ETC="freebsd-etc-${PV}"
28 SYS="freebsd-sys-${PV}"
29 INCLUDE="freebsd-include-${PV}"
30 RESCUE="freebsd-rescue-${PV}"
31 CDDL="freebsd-cddl-${PV}"
32 SECURE="freebsd-secure-${PV}"
33
34 # Release version (5.3, 5.4, 6.0, etc)
35 RV="$(get_version_component_range 1-2 ${MY_PV})"
36
37 # SVN ebuild support.
38 # 9.1.0.9999 --> release/9.1.0
39 # 9.1.9999 --> releng/9.1
40 # 9.9999 --> stable/9
41 # 9999 --> head
42 #
43 # svn revision can be specified by patch level:
44 # freebsd-lib-9.9999_p247000 --> set svn -r 247000
45
46 if [[ ${MY_PV} == *9999* ]]; then
47 inherit subversion
48
49 # Set SVN revision using patch level.
50 [[ ${PV} == *_p* ]] && ESVN_REVISION="${PLEVEL}"
51
52 case ${MY_PV%.9999} in
53 *.*.*) BRANCH="release";;
54 *.*) BRANCH="releng" ;;
55 9999) BRANCH="head" ;;
56 *) BRANCH="stable" ;;
57 esac
58
59 if [[ ${BRANCH} == head ]] ; then
60 SVN_SUB_URI="${BRANCH}"
61 else
62 SVN_SUB_URI="${BRANCH}/${MY_PV%.9999}"
63 fi
64
65 ESVN_REPO_URI="svn://svn.freebsd.org/base/${SVN_SUB_URI}"
66 ESVN_PROJECT="freebsd-${BRANCH}"
67 fi
68
69 # use the original source code.
70 if [[ ${MY_PV} != *9999* ]] && version_is_at_least 10.0 ${RV} ; then
71 DL_PV=${MY_PV/_rc/-RC}
72 DL_PV=${DL_PV/_beta/-BETA}
73 DL_PV=${DL_PV/_alpha/-ALPHA}
74 if [[ ${DL_PV} == ${MY_PV} ]]; then
75 DL_PV="${DL_PV}-RELEASE"
76 fi
77 SRC_URI="mirror://freebsd/releases/i386/${DL_PV}/src.txz -> freebsd-src-${MY_PV}.tar.xz"
78 fi
79
80 IUSE="profile"
81
82 #unalias -a
83 alias install-info='/usr/bin/bsdinstall-info'
84
85 EXPORT_FUNCTIONS src_compile src_install src_unpack
86
87 # doperiodic <kind> <file> ...
88 doperiodic() {
89 local kind=$1
90 shift
91
92 ( # dont want to pollute calling env
93 insinto /etc/periodic/${kind}
94 insopts -m 0755
95 doins "$@"
96 )
97 }
98
99 freebsd_get_bmake() {
100 local bmake
101 bmake=$(get_bmake)
102 [[ ${CBUILD} == *-freebsd* ]] || bmake="${bmake} -m /usr/share/mk/freebsd"
103
104 echo "${bmake}"
105 }
106
107 # Generates a patch SRC_URI or DISTDIR of upstream.
108 freebsd_upstream_patches() {
109 local opt=$1
110 [[ ${#UPSTREAM_PATCHES[@]} -eq 0 ]] && return 1
111 for x in "${UPSTREAM_PATCHES[@]}"
112 do
113 local out=${PN}-${x/\//-}
114 out=${out/:/}
115 if [[ ${opt} == -s ]] ; then
116 echo "${DISTDIR}/${out}"
117 else
118 echo "https://security.freebsd.org/patches/${x} -> ${out}"
119 fi
120 done
121 }
122
123 freebsd_do_patches() {
124 if [[ ${#PATCHES[@]} -gt 1 ]] ; then
125 for x in "${PATCHES[@]}"; do
126 epatch "${x}"
127 done
128 else
129 for x in ${PATCHES} ; do
130 epatch "${x}"
131 done
132 fi
133 [[ ${#UPSTREAM_PATCHES[@]} -gt 0 ]] && epatch $(freebsd_upstream_patches -s)
134 epatch_user
135 }
136
137 freebsd_rename_libraries() {
138 ebegin "Renaming libraries"
139 # We don't use libtermcap, we use libncurses
140 find "${S}" -name Makefile -print0 | xargs -0 \
141 sed -i -e 's:-ltermcap:-lncurses:g; s:{LIBTERMCAP}:{LIBNCURSES}:g'
142 # flex provides libfl, not libl
143 find "${S}" -name Makefile -print0 | xargs -0 \
144 sed -i -e 's:-ll$:-lfl:g; s:-ll :-lfl :g; s:{LIBL}:{LIBFL}:g'
145 # ncurses provides libncursesw not libcursesw
146 find "${S}" -name Makefile -print0 | xargs -0 \
147 sed -i -e 's:-lcursesw:-lncursesw:g'
148 # we use expat instead of bsdxml
149 find "${S}" -name Makefile -print0 | xargs -0 \
150 sed -i -e 's:-lbsdxml:-lexpat:g'
151
152 eend $?
153 }
154
155 freebsd_src_unpack() {
156 if [[ ${MY_PV} == *9999* ]]; then
157 S="${WORKDIR}" subversion_src_unpack
158
159 # When share/mk exists in ${WORKDIR}, it is used on FreeBSD 10.0
160 # Removed "${WORKDIR}"/share/mk/*.mk, use to force /usr/share/mk.
161 if [[ ${PN} != freebsd-mk-defs ]] ; then
162 [[ -e "${WORKDIR}"/share/mk ]] && rm -rf "${WORKDIR}"/share/mk/*.mk
163 fi
164 else
165 if version_is_at_least 10.0 ${RV} ; then
166 local tarball="freebsd-src-${MY_PV}.tar.xz"
167 local topdir="usr/src/"
168 local extractlist=()
169 for i in ${EXTRACTONLY} ; do
170 extractlist+=( ${topdir}${i} )
171 done
172 ebegin "Unpacking parts of ${tarball} to ${WORKDIR}"
173 cd "${WORKDIR}" || die
174 tar -xJpf "${DISTDIR}/${tarball}" --strip-components=2 "${extractlist[@]}" 2> /dev/null || die "tar extract command failed"
175 cd - || die
176 else
177 for f in ${A} ; do
178 [[ ${f} == *.tar.* ]] && unpack ${f}
179 done
180 fi
181 fi
182 cd "${S}"
183
184 dummy_mk ${REMOVE_SUBDIRS}
185
186 freebsd_do_patches
187 freebsd_rename_libraries
188
189 # Starting from FreeBSD 9.2, its install command supports the -l option and
190 # they now use it. Emulate it if we are on a system that does not have it.
191 if version_is_at_least 9.2 ${RV} && ! has_version '>=sys-freebsd/freebsd-ubin-9.2_beta1' ; then
192 export INSTALL_LINK="ln -f"
193 export INSTALL_SYMLINK="ln -fs"
194 fi
195 }
196
197 freebsd_src_compile() {
198 use profile && filter-flags "-fomit-frame-pointer"
199 use profile || mymakeopts="${mymakeopts} NO_PROFILE= "
200
201 mymakeopts="${mymakeopts} NO_MANCOMPRESS= NO_INFOCOMPRESS= NO_FSCHG="
202
203 # Make sure to use FreeBSD definitions while crosscompiling
204 [[ -z "${BMAKE}" ]] && BMAKE="$(freebsd_get_bmake)"
205
206 # Create objdir if MAKEOBJDIRPREFIX is defined, so that we can make out of
207 # tree builds easily.
208 if [[ -n "${MAKEOBJDIRPREFIX}" ]] ; then
209 mkmake obj || die
210 fi
211
212 bsdmk_src_compile "$@"
213 }
214
215 # Helper function to make a multilib build with FreeBSD Makefiles.
216 # Usage:
217 # MULTIBUILD_VARIANTS=( $(get_all_abis) )
218 # multibuild_foreach_variant freebsd_multilib_multibuild_wrapper my_function
219 #
220 # Important note: To use this function you _have_ to:
221 # - inherit multilib.eclass and multibuild.eclass
222 # - set MULTIBUILD_VARIANTS
223
224 freebsd_multilib_multibuild_wrapper() {
225 # Get the ABI from multibuild.eclass
226 # This assumes MULTIBUILD_VARIANTS contains only valid ABIs.
227 local ABI=${MULTIBUILD_VARIANT}
228
229 # First, save the variables: CFLAGS, CXXFLAGS, LDFLAGS, LDADD and mymakeopts.
230 for i in CFLAGS CXXFLAGS LDFLAGS LDADD mymakeopts ; do
231 export ${i}_SAVE="${!i}"
232 done
233
234 # Setup the variables specific to this ABI.
235 multilib_toolchain_setup "${ABI}"
236
237 local target="$(tc-arch-kernel ${CHOST})"
238 mymakeopts="${mymakeopts} TARGET=${target} MACHINE=${target} MACHINE_ARCH=${target} SHLIBDIR=/usr/$(get_libdir) LIBDIR=/usr/$(get_libdir)"
239 if [ "${ABI}" != "${DEFAULT_ABI}" ] ; then
240 mymakeopts="${mymakeopts} COMPAT_32BIT="
241 fi
242
243 einfo "Building for ABI=${ABI} and TARGET=${target}"
244
245 export MAKEOBJDIRPREFIX="${BUILD_DIR}"
246 if [ ! -d "${MAKEOBJDIRPREFIX}" ] ; then
247 mkdir "${MAKEOBJDIRPREFIX}" || die "Could not create ${MAKEOBJDIRPREFIX}."
248 fi
249
250 CTARGET="${CHOST}" "$@"
251
252 # Restore the variables now.
253 for i in CFLAGS CXXFLAGS LDFLAGS LDADD mymakeopts ; do
254 ii="${i}_SAVE"
255 export ${i}="${!ii}"
256 done
257 }
258
259 freebsd_src_install() {
260 use profile || mymakeopts="${mymakeopts} NO_PROFILE= "
261
262 mymakeopts="${mymakeopts} NO_MANCOMPRESS= NO_INFOCOMPRESS= NO_FSCHG="
263
264 [[ -z "${BMAKE}" ]] && BMAKE="$(freebsd_get_bmake)"
265
266 bsdmk_src_install
267 }

  ViewVC Help
Powered by ViewVC 1.1.20