1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: netsurf.eclass
6 # Michael Weber <xmw@gentoo.org>
7 # @BLURB: Handle buildsystem of www.netsurf-browser.org components
9 # Handle unpacking and usage of separate buildsystem tarball and manage
10 # multilib build, static-libs generation and debug building.
12 # Supports PATCHES and DOCS as in base.eclass
15 0|1|2|3|4) die "this eclass doesn't support EAPI<5" ;;
19 inherit eutils toolchain-funcs multilib-minimal
21 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_install
23 # @ECLASS-VARIABLE: NETSURF_BUILDSYSTEM
25 # Select version of buildsystem tarball to be used along the component
26 # defaults to buildsystem-1.0
27 NETSURF_BUILDSYSTEM="${NETSURF_BUILDSYSTEM:-buildsystem-1.0}"
29 # @ECLASS-VARIABLE: NETSURF_BUILDSYSTEM_SRC_URI
31 # Download link for NETSURF_BUILDSYSTEM, add to SRC_URI iff set explicitly.
32 NETSURF_BUILDSYSTEM_SRC_URI="http://download.netsurf-browser.org/libs/releases/${NETSURF_BUILDSYSTEM}.tar.gz -> netsurf-${NETSURF_BUILDSYSTEM}.tar.gz"
34 # @ECLASS-VARIABLE: NETSURF_COMPONENT_TYPE
36 # Passed to buildsystem as COMPONENT_TYPE, valid values are
37 # lib-shared, lib-static and binary. Defaults to "lib-static lib-shared"
38 NETSURF_COMPONENT_TYPE="${NETSURF_COMPONENT_TYPE:-lib-static lib-shared}"
40 # @ECLASS-VARIABLE: SRC_URI
42 # Defaults to http://download.netsurf-browser.org/libs/releases/${P}-src.tar.gz
43 # and NETSURF_BUILDSYSTEM_SRC_URI.
44 if [ -z "${SRC_URI}" ] ; then
45 SRC_URI="http://download.netsurf-browser.org/libs/releases/${P}-src.tar.gz
46 ${NETSURF_BUILDSYSTEM_SRC_URI}"
50 if has lib-static ${NETSURF_COMPONENT_TYPE} ; then
54 DEPEND="virtual/pkgconfig"
56 # @FUNCTION: netsurf_src_prepare
58 # Apply and PATCHES and multilib_copy_sources for in-source build.
59 netsurf_src_prepare() {
60 [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
61 debug-print "$FUNCNAME: applying user patches"
67 # @ECLASS-VARIABLE: netsurf_makeconf
69 # Configuration variable bash array to be passed to emake calls.
70 # Defined at netsurf_src_configure and can be altered afterwards.
72 # @FUNCTION: netsurf_src_configure
74 # Setup netsurf_makeconf and run multilib-minimal_src_configure.
75 # A default multilib_src_configure is provided by this eclass.
76 netsurf_src_configure() {
78 NSSHARED=${WORKDIR}/${NETSURF_BUILDSYSTEM}
86 BUILD=$(usex debug debug release)
90 multilib-minimal_src_configure
93 multilib_src_configure() {
94 sed -e "/^INSTALL_ITEMS/s: /lib: /$(get_libdir):g" \
96 if [ -f ${PN}.pc.in ] ; then
97 sed -e "/^libdir/s:/lib:/$(get_libdir):g" \
100 sed -e 's:/bin/which:which:' \
101 -i ../${NETSURF_BUILDSYSTEM}/makefiles/Makefile.tools || die
104 # @FUNCTION: netsurf_make
106 # Calls emake with netsurf_makeconf and toolchain CC/LD
107 # as arguments for every NETSURF_COMPONENT_TYPE if activated.
109 for COMPONENT_TYPE in ${NETSURF_COMPONENT_TYPE} ; do
110 if [ "${COMPONENT_TYPE}" == "lib-static" ] ; then
111 if ! use static-libs ; then
115 emake CC="$(tc-getCC)" LD="$(tc-getLD)" "${netsurf_makeconf[@]}" \
116 COMPONENT_TYPE=${COMPONENT_TYPE} LIBDIR="$(get_libdir)" "$@"
120 # @FUNCTION: netsurf_src_compile
122 # Calls multilib-minimal_src_compile and netsurf_make doc if USE=doc.
123 # A default multilib_src_compile is provided by this eclass.
124 netsurf_src_compile() {
125 local problems=$(egrep -Hn -- ' (-O.?|-g)( |$)' \
126 $(find . -type f -name 'Makefile*'))
127 if [ -n "${problems}" ] ; then
128 elog "found bad flags:
132 multilib-minimal_src_compile "$@"
134 if has doc ${USE} ; then
135 netsurf_make "$@" docs
139 multilib_src_compile() {
143 # @FUNCTION: netsurf_src_test
145 # Calls multilib-minimal_src_test.
146 # A default multilib_src_test is provided by this eclass.
148 multilib-minimal_src_test "$@"
151 multilib_src_test() {
152 netsurf_make test "$@"
155 # @FUNCTION: netsurf_src_install
157 # Calls multilib-minimal_src_install.
158 # A default multilib_src_test is provided by this eclass.
159 # A default multilib_src_install is provided by this eclass.
160 netsurf_src_install() {
161 multilib-minimal_src_install "$@"
164 multilib_src_install() {
165 #DEFAULT_ABI may not be the last.
166 #install to clean dir, rename binaries, move everything back
167 if [ "${ABI}" == "${DEFAULT_ABI}" ] ; then
168 netsurf_make DESTDIR="${D}" install "$@"
170 netsurf_make DESTDIR="${D}"${ABI} install "$@"
171 if [ "${ABI}" != "${DEFAULT_ABI}" ] ; then
172 find "${D}"${ABI}/usr/bin -type f -exec mv {} {}.${ABI} \;
174 mv "${D}"${ABI}/* "${D}" || die
175 rmdir "${D}"${ABI} || die