meson.eclass: Don't mix host *FLAGS with build *FLAGS
[gentoo.git] / eclass / fox.eclass
1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: fox.eclass
5 # @MAINTAINER:
6 # maintainer-needed@gentoo.org
7 # @BLURB: Functionality required the FOX Toolkit and it's applications
8 # @DESCRIPTION:
9 # This eclass allows building SLOT-able FOX Toolkit installations
10 # (x11-libs/fox: headers, libs, and docs), which are by design
11 # parallel-installable, while installing only one version of the utils
12 # (dev-util/reswrap) and apps (app-editors/adie, sci-calculators/calculator,
13 # x11-misc/pathfinder, and x11-misc/shutterbug).
14 #
15 # Version numbering follows the kernel-style odd-even minor version
16 # designation.  Even-number minor versions are API stable, which patch
17 # releases aimed mostly at the library; apps generally won't need to be
18 # bumped for a patch release.
19 #
20 # Odd-number versions are development branches with their own SLOT and
21 # are API unstable; changes are made to the apps, and likely need to be
22 # bumped together with the library.
23 #
24 # Here are sample [R]DEPENDs for the fox apps
25 #       1.6: 'x11-libs/fox:1.6'
26 #       1.7: '~x11-libs/fox-${PV}'
27 #
28 # EAPI phase trickery borrowed from enlightenment.eclass
29
30 inherit autotools versionator
31
32
33 FOX_EXPF="src_unpack src_compile src_install pkg_postinst"
34 case "${EAPI:-0}" in
35         2|3|4|5) FOX_EXPF+=" src_prepare src_configure" ;;
36         *) ;;
37 esac
38 EXPORT_FUNCTIONS ${FOX_EXPF}
39
40 # @ECLASS-VARIABLE: FOX_PV
41 # @DESCRIPTION:
42 # The version of the FOX Toolkit provided or required by the package
43 : ${FOX_PV:=${PV}}
44
45 # @ECLASS-VARIABLE: FOXVER
46 # @INTERNAL
47 # @DESCRIPTION:
48 # The major.minor version of FOX_PV, usually acts as $SLOT and is used in
49 # building the applications
50 FOXVER=$(get_version_component_range 1-2 ${FOX_PV})
51
52 # @ECLASS-VARIABLE: FOX_APPS
53 # @INTERNAL
54 # @DESCRIPTION:
55 # The applications originally packaged in the FOX Toolkit
56 FOX_APPS="adie calculator pathfinder shutterbug"
57
58 # @ECLASS-VARIABLE: FOXCONF
59 # @DEFAULT_UNSET
60 # @DESCRIPTION:
61 # Set this to add additional configuration options during src_configure
62
63 DESCRIPTION="C++ Toolkit for developing Graphical User Interfaces easily and effectively"
64 HOMEPAGE="http://www.fox-toolkit.org/"
65 SRC_URI="ftp://ftp.fox-toolkit.org/pub/fox-${FOX_PV}.tar.gz"
66
67 IUSE="debug doc profile"
68
69 if [[ ${PN} != fox ]] ; then
70         FOX_COMPONENT="${FOX_COMPONENT:-${PN}}"
71 fi
72
73 if [[ -z ${FOX_COMPONENT} ]] ; then
74         DOXYGEN_DEP="doc? ( app-doc/doxygen )"
75 fi
76
77 if [[ ${PN} != reswrap ]] ; then
78         RESWRAP_DEP="dev-util/reswrap"
79 fi
80
81 DEPEND="${DOXYGEN_DEP}
82         ${RESWRAP_DEP}
83         >=sys-apps/sed-4"
84
85 S="${WORKDIR}/fox-${FOX_PV}"
86
87 fox_src_unpack() {
88         unpack ${A}
89         cd "${S}"
90
91         has src_prepare ${FOX_EXPF} || fox_src_prepare
92 }
93
94 fox_src_prepare() {
95         # fox changed from configure.in to configure.am in 1.6.38
96         local confFile="configure.ac"
97         [[ -r "configure.in" ]] && confFile="configure.in"
98
99         # Respect system CXXFLAGS
100         sed -i -e 's:CXXFLAGS=""::' $confFile || die "sed ${confFile} error"
101
102         # don't strip binaries
103         sed -i -e '/LDFLAGS="-s ${LDFLAGS}"/d' $confFile || die "sed ${confFile} error"
104
105         # don't build apps from top-level (i.e. x11-libs/fox)
106         # utils == reswrap
107         local d
108         for d in ${FOX_APPS} utils windows ; do
109                 sed -i -e "s:${d}::" Makefile.am || die "sed Makefile.am error"
110         done
111
112         # use the installed reswrap for everything else
113         for d in ${FOX_APPS} chart controlpanel tests ; do
114                 [[ -d ${d} ]] &&
115                 (sed -i -e 's:$(top_builddir)/utils/reswrap:reswrap:' \
116                         ${d}/Makefile.am || die "sed ${d}/Makefile.am error")
117         done
118
119         # use the installed headers and library for apps
120         for d in ${FOX_APPS} ; do
121                 sed -i \
122                         -e "s:-I\$(top_srcdir)/include -I\$(top_builddir)/include:-I\$(includedir)/fox-${FOXVER}:" \
123                         -e 's:$(top_builddir)/src/libFOX:-lFOX:' \
124                         -e 's:$(top_builddir)/lib/libFOX:-lFOX:' \
125                         -e 's:\.la::' \
126                         ${d}/Makefile.am || die "sed ${d}/Makefile.am error"
127         done
128
129         eautoreconf
130 }
131
132 fox_src_configure() {
133         use debug && FOXCONF+=" --enable-debug" \
134                   || FOXCONF+=" --enable-release"
135
136         econf ${FOXCONF} \
137                   $(use_with profile profiling)
138 }
139
140
141 fox_src_compile() {
142         has src_configure ${FOX_EXPF} || fox_src_configure
143
144         cd "${S}/${FOX_COMPONENT}"
145         emake || die "compile error"
146
147         # build class reference docs (FOXVER >= 1.2)
148         if use doc && [[ -z ${FOX_COMPONENT} ]] ; then
149                 emake -C "${S}"/doc docs  || die "doxygen error"
150         fi
151 }
152
153 fox_src_install() {
154         cd "${S}/${FOX_COMPONENT}"
155
156         emake install \
157                 DESTDIR="${D}" \
158                 htmldir=/usr/share/doc/${PF}/html \
159                 artdir=/usr/share/doc/${PF}/html/art \
160                 screenshotsdir=/usr/share/doc/${PF}/html/screenshots \
161                 || die "install error"
162
163         # create desktop menu items for apps
164         case ${FOX_COMPONENT} in
165                 adie)
166                         newicon big_gif.gif adie.gif
167                         make_desktop_entry adie "Adie Text Editor" adie.gif
168                         ;;
169                 calculator)
170                         newicon bigcalc.gif foxcalc.gif
171                         make_desktop_entry calculator "FOX Calculator" foxcalc.gif
172                         ;;
173                 pathfinder)
174                         newicon iconpath.gif pathfinder.gif
175                         make_desktop_entry PathFinder "PathFinder" pathfinder.gif "FileManager"
176                         ;;
177                 shutterbug)
178                         doicon shutterbug.gif
179                         make_desktop_entry shutterbug "ShutterBug" shutterbug.gif "Graphics"
180                         ;;
181         esac
182
183         for doc in ADDITIONS AUTHORS LICENSE_ADDENDUM README TRACING ; do
184                 [ -f $doc ] && dodoc $doc
185         done
186
187         # remove documentation if USE=-doc
188         use doc || rm -fr "${D}/usr/share/doc/${PF}/html"
189
190         # install class reference docs if USE=doc
191         if use doc && [[ -z ${FOX_COMPONENT} ]] ; then
192                 dohtml -r "${S}/doc/ref"
193         fi
194
195         # slot fox-config
196         if [[ -f ${D}/usr/bin/fox-config ]] ; then
197                 mv "${D}/usr/bin/fox-config" "${D}/usr/bin/fox-${FOXVER}-config" \
198                 || die "failed to install fox-config"
199         fi
200 }
201
202 fox_pkg_postinst() {
203         if [ -z "${FOX_COMPONENT}" ] ; then
204                 echo
205                 einfo "Multiple versions of the FOX Toolkit library may now be installed"
206                 einfo "in parallel SLOTs on the same system."
207                 einfo
208                 einfo "The reswrap utility and the applications included in the FOX Toolkit"
209                 einfo "(adie, calculator, pathfinder, shutterbug) are now available as"
210                 einfo "separate ebuilds."
211                 echo
212
213                 if version_is_at_least "1.7.25"; then
214                         einfo "Fox versions after 1.7.25 ships a pkg-config file called fox17.pc"
215                         einfo "instead of the previous fox-config tool."
216                         einfo "You now get all info via pkg-config:"
217                         einfo
218                         einfo "pkg-config fox17 --libs (etc.)"
219                 else
220                         einfo "The fox-config script has been installed as fox-${FOXVER}-config."
221                         einfo "The fox-wrapper package is used to direct calls to fox-config"
222                         einfo "to the correct versioned script, based on the WANT_FOX variable."
223                         einfo "For example:"
224                         einfo
225                         einfo "    WANT_FOX=\"${FOXVER}\" fox-config <options>"
226                 fi
227                 einfo
228         fi
229 }