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

Contents of /eclass/freebsd.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.35 - (show annotations) (download)
Wed Aug 28 15:56:11 2013 UTC (13 months, 3 weeks ago) by aballier
Branch: MAIN
CVS Tags: HEAD
Changes since 1.34: +43 -3 lines
Add live build support. Bug #458570 by Yuta SATOH

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.34 2013/08/09 20:10:20 aballier 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 if [[ ${PN} != "freebsd-share" ]] && [[ ${PN} != freebsd-sources ]]; then
70 IUSE="profile"
71 fi
72
73 #unalias -a
74 alias install-info='/usr/bin/bsdinstall-info'
75
76 EXPORT_FUNCTIONS src_compile src_install src_unpack
77
78 # doperiodic <kind> <file> ...
79 doperiodic() {
80 local kind=$1
81 shift
82
83 ( # dont want to pollute calling env
84 insinto /etc/periodic/${kind}
85 insopts -m 0755
86 doins "$@"
87 )
88 }
89
90 freebsd_get_bmake() {
91 local bmake
92 bmake=$(get_bmake)
93 [[ ${CBUILD} == *-freebsd* ]] || bmake="${bmake} -m /usr/share/mk/freebsd"
94
95 echo "${bmake}"
96 }
97
98 freebsd_do_patches() {
99 if [[ ${#PATCHES[@]} -gt 1 ]] ; then
100 for x in "${PATCHES[@]}"; do
101 epatch "${x}"
102 done
103 else
104 for x in ${PATCHES} ; do
105 epatch "${x}"
106 done
107 fi
108 epatch_user
109 }
110
111 freebsd_rename_libraries() {
112 ebegin "Renaming libraries"
113 # We don't use libtermcap, we use libncurses
114 find "${S}" -name Makefile -print0 | xargs -0 \
115 sed -i -e 's:-ltermcap:-lncurses:g; s:{LIBTERMCAP}:{LIBNCURSES}:g'
116 # flex provides libfl, not libl
117 find "${S}" -name Makefile -print0 | xargs -0 \
118 sed -i -e 's:-ll$:-lfl:g; s:-ll :-lfl :g; s:{LIBL}:{LIBFL}:g'
119 # ncurses provides libncursesw not libcursesw
120 find "${S}" -name Makefile -print0 | xargs -0 \
121 sed -i -e 's:-lcursesw:-lncursesw:g'
122 # we use expat instead of bsdxml
123 find "${S}" -name Makefile -print0 | xargs -0 \
124 sed -i -e 's:-lbsdxml:-lexpat:g'
125
126 eend $?
127 }
128
129 freebsd_src_unpack() {
130 if [[ ${MY_PV} == *9999* ]]; then
131 S="${WORKDIR}" subversion_src_unpack
132 else
133 unpack ${A}
134 fi
135 cd "${S}"
136
137 dummy_mk ${REMOVE_SUBDIRS}
138
139 freebsd_do_patches
140 freebsd_rename_libraries
141
142 # Starting from FreeBSD 9.2, its install command supports the -l option and
143 # they now use it. Emulate it if we are on a system that does not have it.
144 if [[ ${RV} > 9.1 ]] && ! has_version '>=sys-freebsd/freebsd-ubin-9.2_beta1' ; then
145 export INSTALL_LINK="ln -f"
146 export INSTALL_SYMLINK="ln -fs"
147 fi
148 }
149
150 freebsd_src_compile() {
151 use profile && filter-flags "-fomit-frame-pointer"
152 use profile || mymakeopts="${mymakeopts} NO_PROFILE= "
153
154 mymakeopts="${mymakeopts} NO_MANCOMPRESS= NO_INFOCOMPRESS= NO_FSCHG="
155
156 # Make sure to use FreeBSD definitions while crosscompiling
157 [[ -z "${BMAKE}" ]] && BMAKE="$(freebsd_get_bmake)"
158
159 # Create objdir if MAKEOBJDIRPREFIX is defined, so that we can make out of
160 # tree builds easily.
161 if [[ -n "${MAKEOBJDIRPREFIX}" ]] ; then
162 mkmake obj || die
163 fi
164
165 bsdmk_src_compile "$@"
166 }
167
168 # Helper function to make a multilib build with FreeBSD Makefiles.
169 # Usage:
170 # MULTIBUILD_VARIANTS=( $(get_all_abis) )
171 # multibuild_foreach_variant freebsd_multilib_multibuild_wrapper my_function
172 #
173 # Important note: To use this function you _have_ to:
174 # - inherit multilib.eclass and multibuild.eclass
175 # - set MULTIBUILD_VARIANTS
176
177 freebsd_multilib_multibuild_wrapper() {
178 # Get the ABI from multibuild.eclass
179 # This assumes MULTIBUILD_VARIANTS contains only valid ABIs.
180 local ABI=${MULTIBUILD_VARIANT}
181
182 # First, save the variables: CFLAGS, CXXFLAGS, LDFLAGS, LDADD and mymakeopts.
183 for i in CFLAGS CXXFLAGS LDFLAGS LDADD mymakeopts ; do
184 export ${i}_SAVE="${!i}"
185 done
186
187 # Setup the variables specific to this ABI.
188 multilib_toolchain_setup "${ABI}"
189
190 local target="$(tc-arch-kernel ${CHOST})"
191 mymakeopts="${mymakeopts} TARGET=${target} MACHINE=${target} MACHINE_ARCH=${target} SHLIBDIR=/usr/$(get_libdir) LIBDIR=/usr/$(get_libdir)"
192 if [ "${ABI}" != "${DEFAULT_ABI}" ] ; then
193 mymakeopts="${mymakeopts} COMPAT_32BIT="
194 fi
195
196 einfo "Building for ABI=${ABI} and TARGET=${target}"
197
198 export MAKEOBJDIRPREFIX="${BUILD_DIR}"
199 if [ ! -d "${MAKEOBJDIRPREFIX}" ] ; then
200 mkdir "${MAKEOBJDIRPREFIX}" || die "Could not create ${MAKEOBJDIRPREFIX}."
201 fi
202
203 CTARGET="${CHOST}" "$@"
204
205 # Restore the variables now.
206 for i in CFLAGS CXXFLAGS LDFLAGS LDADD mymakeopts ; do
207 ii="${i}_SAVE"
208 export ${i}="${!ii}"
209 done
210 }
211
212 freebsd_src_install() {
213 use profile || mymakeopts="${mymakeopts} NO_PROFILE= "
214
215 mymakeopts="${mymakeopts} NO_MANCOMPRESS= NO_INFOCOMPRESS= NO_FSCHG="
216
217 [[ -z "${BMAKE}" ]] && BMAKE="$(freebsd_get_bmake)"
218
219 bsdmk_src_install
220 }

  ViewVC Help
Powered by ViewVC 1.1.20