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

Contents of /eclass/freebsd.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.29 - (show annotations) (download)
Mon Jul 8 02:08:44 2013 UTC (14 months, 1 week ago) by aballier
Branch: MAIN
Changes since 1.28: +1 -3 lines
stop adding cflags for multilib, it is now done in the profiles

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.28 2013/06/18 17:30:56 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 # Make sure to use FreeBSD definitions while crosscompiling
109 [[ -z "${BMAKE}" ]] && BMAKE="$(freebsd_get_bmake)"
110
111 # Create objdir if MAKEOBJDIRPREFIX is defined, so that we can make out of
112 # tree builds easily.
113 if [[ -n "${MAKEOBJDIRPREFIX}" ]] ; then
114 mkmake obj || die
115 fi
116
117 bsdmk_src_compile
118 }
119
120 # Helper function to make a multilib build with FreeBSD Makefiles.
121 # Usage:
122 # MULTIBUILD_VARIANTS=( $(get_all_abis) )
123 # multibuild_foreach_variant freebsd_multilib_multibuild_wrapper my_function
124 #
125 # Important note: To use this function you _have_ to:
126 # - inherit multilib.eclass and multibuild.eclass
127 # - set MULTILIB_VARIANTS
128 # - have a multilib useflag in IUSE
129
130 freebsd_multilib_multibuild_wrapper() {
131 # Get the ABI from multibuild.eclass
132 # This assumes MULTILIB_VARIANTS contains only valid ABIs.
133 local ABI=${MULTIBUILD_VARIANT}
134
135 # First, save the variables: CFLAGS, CXXFLAGS, LDFLAGS, LDADD and mymakeopts.
136 for i in CFLAGS CXXFLAGS LDFLAGS LDADD mymakeopts ; do
137 export ${i}_SAVE="${!i}"
138 done
139
140 # Setup the variables specific to this ABI.
141 multilib_toolchain_setup "${ABI}"
142
143 local target="$(tc-arch-kernel ${CHOST})"
144 mymakeopts="${mymakeopts} TARGET=${target} MACHINE=${target} MACHINE_ARCH=${target} SHLIBDIR=/usr/$(get_libdir) LIBDIR=/usr/$(get_libdir)"
145 if use multilib && [ "${ABI}" != "${DEFAULT_ABI}" ] ; then
146 mymakeopts="${mymakeopts} COMPAT_32BIT="
147 fi
148
149 einfo "Building for ABI=${ABI} and TARGET=${target}"
150
151 export MAKEOBJDIRPREFIX="${BUILD_DIR}"
152 if [ ! -d "${MAKEOBJDIRPREFIX}" ] ; then
153 mkdir "${MAKEOBJDIRPREFIX}" || die "Could not create ${MAKEOBJDIRPREFIX}."
154 fi
155
156 CTARGET="${CHOST}" "$@"
157
158 # Restore the variables now.
159 for i in CFLAGS CXXFLAGS LDFLAGS LDADD mymakeopts ; do
160 ii="${i}_SAVE"
161 export ${i}="${!ii}"
162 done
163 }
164
165 freebsd_src_install() {
166 use profile || mymakeopts="${mymakeopts} NO_PROFILE= "
167
168 mymakeopts="${mymakeopts} NO_MANCOMPRESS= NO_INFOCOMPRESS= NO_FSCHG="
169
170 [[ -z "${BMAKE}" ]] && BMAKE="$(freebsd_get_bmake)"
171
172 bsdmk_src_install
173 }

  ViewVC Help
Powered by ViewVC 1.1.20