1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: netsurf.eclass
6 # maintainer-needed@gentoo.org
7 # @SUPPORTED_EAPIS: 5 6 7
8 # @BLURB: Handle buildsystem of www.netsurf-browser.org components
10 # Handle unpacking and usage of separate buildsystem tarball and manage
11 # multilib build, static-libs generation and debug building.
13 # Supports PATCHES and DOCS as in base.eclass
16 0|1|2|3|4) die "this eclass doesn't support EAPI<5" ;;
20 inherit eutils toolchain-funcs multilib-minimal
22 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_install
24 # @ECLASS-VARIABLE: NETSURF_BUILDSYSTEM
26 # Select version of buildsystem tarball to be used along the component
27 # defaults to buildsystem-1.0
28 NETSURF_BUILDSYSTEM="${NETSURF_BUILDSYSTEM:-buildsystem-1.0}"
30 # @ECLASS-VARIABLE: NETSURF_BUILDSYSTEM_SRC_URI
32 # Download link for NETSURF_BUILDSYSTEM, add to SRC_URI iff set explicitly.
33 NETSURF_BUILDSYSTEM_SRC_URI="http://download.netsurf-browser.org/libs/releases/${NETSURF_BUILDSYSTEM}.tar.gz -> netsurf-${NETSURF_BUILDSYSTEM}.tar.gz"
35 # @ECLASS-VARIABLE: NETSURF_COMPONENT_TYPE
37 # Passed to buildsystem as COMPONENT_TYPE, valid values are
38 # lib-shared, lib-static and binary. Defaults to "lib-static lib-shared"
39 NETSURF_COMPONENT_TYPE="${NETSURF_COMPONENT_TYPE:-lib-static lib-shared}"
41 # @ECLASS-VARIABLE: SRC_URI
43 # Defaults to http://download.netsurf-browser.org/libs/releases/${P}-src.tar.gz
44 # and NETSURF_BUILDSYSTEM_SRC_URI.
45 if [ -z "${SRC_URI}" ] ; then
46 SRC_URI="http://download.netsurf-browser.org/libs/releases/${P}-src.tar.gz
47 ${NETSURF_BUILDSYSTEM_SRC_URI}"
51 if has lib-static ${NETSURF_COMPONENT_TYPE} ; then
55 DEPEND="virtual/pkgconfig"
57 # @FUNCTION: netsurf_src_prepare
59 # Apply and PATCHES and multilib_copy_sources for in-source build.
60 netsurf_src_prepare() {
61 [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
62 debug-print "$FUNCNAME: applying user patches"
68 # @ECLASS-VARIABLE: netsurf_makeconf
70 # Configuration variable bash array to be passed to emake calls.
71 # Defined at netsurf_src_configure and can be altered afterwards.
73 # @FUNCTION: netsurf_src_configure
75 # Setup netsurf_makeconf and run multilib-minimal_src_configure.
76 # A default multilib_src_configure is provided by this eclass.
77 netsurf_src_configure() {
79 NSSHARED=${WORKDIR}/${NETSURF_BUILDSYSTEM}
87 BUILD=$(usex debug debug release)
91 multilib-minimal_src_configure
94 multilib_src_configure() {
95 sed -e "/^INSTALL_ITEMS/s: /lib: /$(get_libdir):g" \
97 if [ -f ${PN}.pc.in ] ; then
98 sed -e "/^libdir/s:/lib:/$(get_libdir):g" \
101 sed -e 's:/bin/which:which:' \
102 -i ../${NETSURF_BUILDSYSTEM}/makefiles/Makefile.tools || die
105 # @FUNCTION: netsurf_make
107 # Calls emake with netsurf_makeconf and toolchain CC/LD
108 # as arguments for every NETSURF_COMPONENT_TYPE if activated.
110 for COMPONENT_TYPE in ${NETSURF_COMPONENT_TYPE} ; do
111 if [ "${COMPONENT_TYPE}" == "lib-static" ] ; then
112 if ! use static-libs ; then
116 emake CC="$(tc-getCC)" LD="$(tc-getLD)" "${netsurf_makeconf[@]}" \
117 COMPONENT_TYPE=${COMPONENT_TYPE} LIBDIR="$(get_libdir)" "$@"
121 # @FUNCTION: netsurf_src_compile
123 # Calls multilib-minimal_src_compile and netsurf_make doc if USE=doc.
124 # A default multilib_src_compile is provided by this eclass.
125 netsurf_src_compile() {
126 local problems=$(egrep -Hn -- ' (-O.?|-g)( |$)' \
127 $(find . -type f -name 'Makefile*'))
128 if [ -n "${problems}" ] ; then
129 elog "found bad flags:
133 multilib-minimal_src_compile "$@"
135 if has doc ${USE} ; then
136 netsurf_make "$@" docs
140 multilib_src_compile() {
144 # @FUNCTION: netsurf_src_test
146 # Calls multilib-minimal_src_test.
147 # A default multilib_src_test is provided by this eclass.
149 multilib-minimal_src_test "$@"
152 multilib_src_test() {
153 netsurf_make test "$@"
156 # @FUNCTION: netsurf_src_install
158 # Calls multilib-minimal_src_install.
159 # A default multilib_src_test is provided by this eclass.
160 # A default multilib_src_install is provided by this eclass.
161 netsurf_src_install() {
162 multilib-minimal_src_install "$@"
165 multilib_src_install() {
166 #DEFAULT_ABI may not be the last.
167 #install to clean dir, rename binaries, move everything back
168 if [ "${ABI}" == "${DEFAULT_ABI}" ] ; then
169 netsurf_make DESTDIR="${D}" install "$@"
171 netsurf_make DESTDIR="${D}"${ABI} install "$@"
172 if [ "${ABI}" != "${DEFAULT_ABI}" ] ; then
173 find "${D}"${ABI}/usr/bin -type f -exec mv {} {}.${ABI} \;
175 mv "${D}"${ABI}/* "${D}" || die
176 rmdir "${D}"${ABI} || die