| 1 | # Copyright 1999-2005 Gentoo Foundation |
1 | # Copyright 1999-2005 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.38 2006/06/28 00:15:32 flameeyes Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.47 2006/10/02 22:52:08 flameeyes Exp $ |
| 4 | # |
4 | # |
| 5 | # Author: Diego Pettenò <flameeyes@gentoo.org> |
5 | # Author: Diego Pettenò <flameeyes@gentoo.org> |
| 6 | # Enhancements: Martin Schlemmer <azarah@gentoo.org> |
6 | # Enhancements: Martin Schlemmer <azarah@gentoo.org> |
| 7 | # |
7 | # |
| 8 | # This eclass is for handling autotooled software packages that |
8 | # This eclass is for handling autotooled software packages that |
| … | |
… | |
| 10 | # |
10 | # |
| 11 | # NB: If you add anything, please comment it! |
11 | # NB: If you add anything, please comment it! |
| 12 | |
12 | |
| 13 | inherit eutils libtool |
13 | inherit eutils libtool |
| 14 | |
14 | |
| 15 | DEPEND="sys-devel/automake |
15 | [[ ${WANT_AUTOMAKE} == "latest" ]] && export WANT_AUTOMAKE=1.9 |
| 16 | sys-devel/autoconf |
16 | [[ ${WANT_AUTOCONF} == "latest" ]] && export WANT_AUTOCONF=2.5 |
|
|
17 | |
|
|
18 | _automake_atom="sys-devel/automake" |
|
|
19 | _autoconf_atom="sys-devel/autoconf" |
|
|
20 | [[ -n ${WANT_AUTOMAKE} ]] && _automake_atom="=sys-devel/automake-${WANT_AUTOMAKE}*" |
|
|
21 | if [[ -n ${WANT_AUTOCONF} ]] ; then |
|
|
22 | case ${WANT_AUTOCONF} in |
|
|
23 | 2.1) _autoconf_atom="=sys-devel/autoconf-${WANT_AUTOCONF}*" ;; |
|
|
24 | 2.5) _autoconf_atom=">=sys-devel/autoconf-2.59" ;; |
|
|
25 | esac |
|
|
26 | fi |
|
|
27 | DEPEND="${_automake_atom} |
|
|
28 | ${_autoconf_atom} |
| 17 | sys-devel/libtool" |
29 | sys-devel/libtool" |
|
|
30 | RDEPEND="" |
|
|
31 | unset _automake_atom _autoconf_atom |
| 18 | |
32 | |
| 19 | # Variables: |
33 | # Variables: |
| 20 | # |
34 | # |
| 21 | # AT_M4DIR - Additional director(y|ies) aclocal should search |
35 | # AT_M4DIR - Additional director(y|ies) aclocal should search |
| 22 | # AM_OPTS - Additional options to pass to automake during |
36 | # AM_OPTS - Additional options to pass to automake during |
| … | |
… | |
| 45 | # eauto* functions to run the tools. It doesn't accept parameters, but |
59 | # eauto* functions to run the tools. It doesn't accept parameters, but |
| 46 | # the directory with include files can be specified with AT_M4DIR variable. |
60 | # the directory with include files can be specified with AT_M4DIR variable. |
| 47 | eautoreconf() { |
61 | eautoreconf() { |
| 48 | local pwd=$(pwd) x auxdir |
62 | local pwd=$(pwd) x auxdir |
| 49 | |
63 | |
|
|
64 | if [[ -z ${AT_NO_RECURSIVE} ]]; then |
| 50 | # Take care of subdirs |
65 | # Take care of subdirs |
| 51 | for x in $(autotools_get_subdirs); do |
66 | for x in $(autotools_get_subdirs); do |
| 52 | if [[ -d ${x} ]] ; then |
67 | if [[ -d ${x} ]] ; then |
| 53 | cd "${x}" |
68 | cd "${x}" |
| 54 | AT_NOELIBTOOLIZE="yes" eautoreconf |
69 | AT_NOELIBTOOLIZE="yes" eautoreconf |
| 55 | cd "${pwd}" |
70 | cd "${pwd}" |
| 56 | fi |
71 | fi |
| 57 | done |
72 | done |
|
|
73 | fi |
| 58 | |
74 | |
| 59 | auxdir=$(autotools_get_auxdir) |
75 | auxdir=$(autotools_get_auxdir) |
| 60 | |
76 | |
| 61 | einfo "Running eautoreconf in '$(pwd)' ..." |
77 | einfo "Running eautoreconf in '$(pwd)' ..." |
| 62 | [[ -n ${auxdir} ]] && mkdir -p ${auxdir} |
78 | [[ -n ${auxdir} ]] && mkdir -p ${auxdir} |
| … | |
… | |
| 94 | ;; |
110 | ;; |
| 95 | esac |
111 | esac |
| 96 | done |
112 | done |
| 97 | fi |
113 | fi |
| 98 | |
114 | |
|
|
115 | autotools_set_versions |
| 99 | [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \ |
116 | [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \ |
| 100 | autotools_run_tool aclocal "$@" ${aclocal_opts} |
117 | autotools_run_tool aclocal "$@" ${aclocal_opts} |
| 101 | } |
118 | } |
| 102 | |
119 | |
| 103 | _elibtoolize() { |
120 | _elibtoolize() { |
| … | |
… | |
| 119 | } |
136 | } |
| 120 | |
137 | |
| 121 | eautoheader() { |
138 | eautoheader() { |
| 122 | # Check if we should run autoheader |
139 | # Check if we should run autoheader |
| 123 | [[ -n $(autotools_check_macro "AC_CONFIG_HEADERS") ]] || return 0 |
140 | [[ -n $(autotools_check_macro "AC_CONFIG_HEADERS") ]] || return 0 |
|
|
141 | autotools_set_versions |
| 124 | autotools_run_tool autoheader "$@" |
142 | autotools_run_tool autoheader "$@" |
| 125 | } |
143 | } |
| 126 | |
144 | |
| 127 | eautoconf() { |
145 | eautoconf() { |
| 128 | if [[ ! -f configure.ac && ! -f configure.in ]] ; then |
146 | if [[ ! -f configure.ac && ! -f configure.in ]] ; then |
| … | |
… | |
| 130 | eerror "No configure.{ac,in} present in '$(pwd | sed -e 's:.*/::')'!" |
148 | eerror "No configure.{ac,in} present in '$(pwd | sed -e 's:.*/::')'!" |
| 131 | echo |
149 | echo |
| 132 | die "No configure.{ac,in} present!" |
150 | die "No configure.{ac,in} present!" |
| 133 | fi |
151 | fi |
| 134 | |
152 | |
|
|
153 | autotools_set_versions |
| 135 | autotools_run_tool autoconf "$@" |
154 | autotools_run_tool autoconf "$@" |
| 136 | } |
155 | } |
| 137 | |
156 | |
| 138 | eautomake() { |
157 | eautomake() { |
| 139 | local extra_opts |
158 | local extra_opts |
| 140 | |
159 | |
| 141 | [[ -f Makefile.am ]] || return 0 |
160 | [[ -f Makefile.am ]] || return 0 |
| 142 | |
161 | |
|
|
162 | autotools_set_versions |
| 143 | if [[ -z ${FROM_EAUTORECONF} && -f Makefile.in ]]; then |
163 | if [[ -z ${FROM_EAUTORECONF} && -f Makefile.in ]]; then |
| 144 | local used_automake |
164 | local used_automake |
| 145 | local installed_automake |
165 | local installed_automake |
| 146 | |
166 | |
| 147 | installed_automake=$(automake --version | head -n 1 | \ |
167 | installed_automake=$(automake --version | head -n 1 | \ |
| … | |
… | |
| 162 | |
182 | |
| 163 | # --force-missing seems not to be recognized by some flavours of automake |
183 | # --force-missing seems not to be recognized by some flavours of automake |
| 164 | autotools_run_tool automake --add-missing --copy ${extra_opts} "$@" |
184 | autotools_run_tool automake --add-missing --copy ${extra_opts} "$@" |
| 165 | } |
185 | } |
| 166 | |
186 | |
|
|
187 | autotools_set_versions() { |
|
|
188 | [[ -n ${autotools_version_sets} ]] && return 0 |
| 167 | |
189 | |
|
|
190 | if [[ -n ${WANT_AUTOCONF} ]]; then |
|
|
191 | export WANT_AUTOCONF |
|
|
192 | einfo "Requested autoconf ${WANT_AUTOCONF}" |
|
|
193 | einfo "Using $(autoconf --version 2>/dev/null | head -n 1)" |
|
|
194 | einfo "Using $(autoheader --version 2>/dev/null | head -n 1)" |
|
|
195 | fi |
|
|
196 | |
|
|
197 | if [[ -n ${WANT_AUTOMAKE} ]]; then |
|
|
198 | export WANT_AUTOMAKE |
|
|
199 | einfo "Requested automake ${WANT_AUTOMAKE}" |
|
|
200 | einfo "Using $(automake --version 2>/dev/null | head -n 1)" |
|
|
201 | einfo "Using $(aclocal --version 2>/dev/null | head -n 1)" |
|
|
202 | fi |
|
|
203 | |
|
|
204 | autotools_version_sets="yes" |
|
|
205 | } |
| 168 | |
206 | |
| 169 | # Internal function to run an autotools' tool |
207 | # Internal function to run an autotools' tool |
| 170 | autotools_run_tool() { |
208 | autotools_run_tool() { |
| 171 | local STDERR_TARGET="${T}/$$.out" |
209 | local STDERR_TARGET="${T}/$$.out" |
| 172 | local PATCH_TARGET="${T}/$$.patch" |
210 | local PATCH_TARGET="${T}/$$.patch" |