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