kde5.eclass: Cleanup obsolete blocker
[gentoo.git] / eclass / netsurf.eclass
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: netsurf.eclass
5 # @MAINTAINER:
6 # Michael Weber <xmw@gentoo.org>
7 # @BLURB: Handle buildsystem of www.netsurf-browser.org components
8 # @DESCRIPTION:
9 # Handle unpacking and usage of separate buildsystem tarball and manage
10 # multilib build, static-libs generation and debug building.
11 #
12 # Supports PATCHES and DOCS as in base.eclass
13
14 case ${EAPI:-0} in
15         0|1|2|3|4) die "this eclass doesn't support EAPI<5" ;;
16         *) ;;
17 esac
18
19 inherit eutils toolchain-funcs multilib-minimal
20
21 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_install
22
23 # @ECLASS-VARIABLE: NETSURF_BUILDSYSTEM
24 # @DESCRIPTION:
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}"
28
29 # @ECLASS-VARIABLE: NETSURF_BUILDSYSTEM_SRC_URI
30 # @DESCRIPTION:
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"
33
34 # @ECLASS-VARIABLE: NETSURF_COMPONENT_TYPE
35 # @DESCRIPTION:
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}"
39
40 # @ECLASS-VARIABLE: SRC_URI
41 # @DESCRIPTION:
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}"
47 fi
48
49 IUSE="debug"
50 if has lib-static ${NETSURF_COMPONENT_TYPE} ; then
51         IUSE+=" static-libs"
52 fi
53
54 DEPEND="virtual/pkgconfig"
55
56 # @FUNCTION: netsurf_src_prepare
57 # @DESCRIPTION:
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"
62         epatch_user
63
64         multilib_copy_sources
65 }
66
67 # @ECLASS-VARIABLE: netsurf_makeconf
68 # @DESCRIPTION:
69 # Configuration variable bash array to be passed to emake calls.
70 # Defined at netsurf_src_configure and can be altered afterwards.
71
72 # @FUNCTION: netsurf_src_configure
73 # @DESCRIPTION:
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() {
77         netsurf_makeconf=(
78                 NSSHARED=${WORKDIR}/${NETSURF_BUILDSYSTEM}
79                 Q=
80                 HOST_CC="\$(CC)"
81                 CCOPT=
82                 CCNOOPT=
83                 CCDBG=
84                 LDDBG=
85                 AR="$(tc-getAR)"
86                 BUILD=$(usex debug debug release)
87                 PREFIX="${EROOT}"usr
88         )
89
90         multilib-minimal_src_configure
91 }
92
93 multilib_src_configure() {
94         sed -e "/^INSTALL_ITEMS/s: /lib: /$(get_libdir):g" \
95                 -i Makefile || die
96         if [ -f ${PN}.pc.in ] ; then
97                 sed -e "/^libdir/s:/lib:/$(get_libdir):g" \
98                         -i ${PN}.pc.in || die
99         fi
100         sed -e 's:/bin/which:which:' \
101                 -i ../${NETSURF_BUILDSYSTEM}/makefiles/Makefile.tools || die
102 }
103
104 # @FUNCTION: netsurf_make
105 # @DESCRIPTION:
106 # Calls emake with netsurf_makeconf and toolchain CC/LD
107 # as arguments for every NETSURF_COMPONENT_TYPE if activated.
108 netsurf_make() {
109         for COMPONENT_TYPE in ${NETSURF_COMPONENT_TYPE} ; do
110                 if [ "${COMPONENT_TYPE}" == "lib-static" ] ; then
111                         if ! use static-libs ; then
112                                 continue
113                         fi
114                 fi
115                 emake CC="$(tc-getCC)" LD="$(tc-getLD)" "${netsurf_makeconf[@]}" \
116                         COMPONENT_TYPE=${COMPONENT_TYPE} LIBDIR="$(get_libdir)" "$@"
117         done
118 }
119
120 # @FUNCTION: netsurf_src_compile
121 # @DESCRIPTION:
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:
129 ${problems}"
130         fi
131
132         multilib-minimal_src_compile "$@"
133
134         if has doc ${USE} ; then
135                 netsurf_make "$@" docs
136         fi
137 }
138
139 multilib_src_compile() {
140         netsurf_make "$@"
141 }
142
143 # @FUNCTION: netsurf_src_test
144 # @DESCRIPTION:
145 # Calls multilib-minimal_src_test.
146 # A default multilib_src_test is provided by this eclass.
147 netsurf_src_test() {
148         multilib-minimal_src_test "$@"
149 }
150
151 multilib_src_test() {
152         netsurf_make test "$@"
153 }
154
155 # @FUNCTION: netsurf_src_install
156 # @DESCRIPTION:
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 "$@"
162 }
163
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 "$@"
169         else
170                 netsurf_make DESTDIR="${D}"${ABI} install "$@"
171                 if [ "${ABI}" != "${DEFAULT_ABI}" ] ; then
172                         find "${D}"${ABI}/usr/bin -type f -exec mv {} {}.${ABI} \;
173                 fi
174                 mv "${D}"${ABI}/* "${D}" || die
175                 rmdir "${D}"${ABI} || die
176         fi
177 }