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