/[gentoo-x86]/eclass/autotools.eclass
Gentoo

Diff of /eclass/autotools.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.4 Revision 1.15
1# Copyright 1999-2002 Gentoo Technologies, Inc. 1# Copyright 1999-2005 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License, v2 or later 2# Distributed under the terms of the GNU General Public License v2
3# Author: Martin Schlemmer <azarah@gentoo.org>
4# $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.4 2002/07/26 21:50:14 danarmak Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.15 2005/08/30 11:29:17 flameeyes Exp $
5# The autotools eclass enables building of the apps that needs the latest autconf/automake.
6# 4#
7# NOTES: 5# Author: Diego Pettenò <flameeyes@gentoo.org>
6# Enhancements: Martin Schlemmer <azarah@gentoo.org>
8# 7#
9# This eclass was made to bridge the incompadibility problem of autoconf-2.13, 8# This eclass is for handling autotooled software packages that
10# autoconf-2.5x and automake-1.4x, automake-1.5x. Most packages needs 9# needs to regenerate their build scripts.
11# autoconf-2.13 and automake-1.4x, but cannot work with the latest versions
12# of these packages due to incompadibility, thus when we have a package that
13# needs the latest versions of automake and autoconf, it begins to get a
14# problem.
15# 10#
11# NB: If you add anything, please comment it!
12
13inherit eutils gnuconfig
14
15#DEPEND="sys-devel/automake
16# sys-devel/autoconf
17# sys-devel/libtool"
16# 18#
17# Commented Example: 19# Ebuilds should rather depend on the proper version of the tool.
18# 20
19# The following is a commented template for how to use this eclass: 21# Internal function to run an autotools' tool
20# 22autotools_run_tool() {
21# #<cut here> 23 local STDERR_TARGET="${T}/$$.out"
22# # Copyright 1999-2002 Gentoo Technologies, Inc. 24 local PATCH_TARGET="${T}/$$.patch"
23# # Distributed under the terms of the GNU General Public License, v2 or later 25 local ris
24# # Maintainer: John Doe <john@foo.com> 26
25# # $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.4 2002/07/26 21:50:14 danarmak Exp $ 27 echo "***** $1 *****" > ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}
26# 28 echo >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}
27# # If you need to set the versions different from in here, it *must* 29
28# # be done before inherit.eclass is sourced 30 ebegin "Running $1"
29# #ACONFVER=2.52f 31 $@ >> ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/} 2>&1
30# #AMAKEVER=1.5b 32 ris=$?
31# 33 eend ${ris}
32# # Source inherit.eclass and inherit AutoTools 34
33# . /usr/portage/eclass/inherit.eclass 35 if [[ ${ris} != 0 ]]; then
34# inherit autotools 36 echo
35# 37 eerror "Failed Running $1 !"
36# # This is pretty standard. 38 eerror
37# S=${WORKDIR}/${P} 39 eerror "Include in your bugreport the contents of:"
38# DESCRIPTION="My Application" 40 eerror
39# 41 eerror " ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}"
40# # Here you *NEED* to have $SRC_URI as a source url to include the automake 42 echo
41# # and autoconf source tarballs 43 die "Failed Running $1 !"
42# SRC_URI="${SRC_URI} 44 fi
43# http://download.foo.com/files/${P}.tar.gz" 45}
44# 46
45# HOMEPAGE="http://www.foo.com/" 47# Internal function to check for support
46# 48autotools_check_macro() {
47# # Here you *NEED* to have "$DEPEND" as an depend to include the dependancies 49 [[ -f configure.ac || -f configure.in ]] && \
48# # of automake and autoconf. 50 autoconf --trace=$1 2>/dev/null
49# DEPEND="${DEPEND} 51 return 0
50# foo-libs/libfoo" 52}
51# 53
52# src_compile() { 54# Internal function to get additional subdirs to configure
53# 55autotools_get_subdirs() {
54# # This will install automake and autoconf in a tempory directory and 56 local subdirs_scan_out
55# # setup the environment. Do not forget!!!!!!! 57
56# install_autotools 58 subdirs_scan_out=$(autotools_check_macro "AC_CONFIG_SUBDIRS")
57# 59 [[ -n ${subdirs_scan_out} ]] || return 0
58# # Now like normal 60
59# ./configure --host=${CHOST} \ 61 echo "${subdirs_scan_out}" | gawk \
60# --prefix=/usr || die 62 '($0 !~ /^[[:space:]]*(#|dnl)/) {
61# emake || die 63 if (match($0, "AC_CONFIG_SUBDIRS\\(\\[?([^\\])]*)", res)) {
62# } 64 split(res[1], DIRS, /[\])]/)
63# 65 print DIRS[1]
64# src_install() { 66 }
65# 67 }' | uniq
66# # Still pretty standard to how you would normally do it 68
67# make DESTDIR=${D} install || die 69 return 0
68# dodoc AUTHORS COPYING ChangeLog INSTALL NEWS README TODO 70}
69# }
70# #<cut here>
71#
72 71
73 72
74ECLASS=autotools
75INHERITED="$INHERITED $ECLASS"
76 73
77#[ -z "$ACONFVER" ] && ACONFVER=2.52f 74# These functions runs the autotools using autotools_run_tool with the
78#[ -z "$AMAKEVER" ] && AMAKEVER=1.5b 75# specified parametes. The name of the tool run is the same of the function
79[ -z "$ACONFVER" ] && die "!!! You need to set \$ACONFVER *before* inheriting the eclass !!!" 76# without e prefix.
80[ -z "$AMAKEVER" ] && die "!!! You need to set \$AMAKEVER *before* inheriting the eclass !!!" 77# They also force installing the support files for safety.
78eaclocal() {
79 local aclocal_opts
81 80
82DESCRIPTION="Based on the $ECLASS eclass" 81 [[ -n ${M4DIR} ]] && aclocal_opts="-I ${M4DIR}"
83#ASRC_URI="ftp://ftp.gnu.org/gnu/autoconf/autoconf-${ACONFVER}.tar.bz2
84# ftp://alpha.gnu.org/gnu/autoconf/autoconf-${ACONFVER}.tar.bz2
85# ftp://ftp.gnu.org/gnu/automake/automake-${AMAKEVER}.tar.bz2
86# ftp://alpha.gnu.org/gnu/automake/automake-${AMAKEVER}.tar.bz2"
87SRC_URI="ftp://ftp.gnu.org/gnu/autoconf/autoconf-${ACONFVER}.tar.bz2
88 ftp://alpha.gnu.org/gnu/autoconf/autoconf-${ACONFVER}.tar.bz2
89 ftp://ftp.gnu.org/gnu/automake/automake-${AMAKEVER}.tar.bz2
90 ftp://alpha.gnu.org/gnu/automake/automake-${AMAKEVER}.tar.bz2"
91
92DEPEND="sys-devel/make
93 sys-devel/perl
94 >=sys-devel/m4-1.4o-r2"
95 82
96 83 [[ -f aclocal.m4 && -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \
97AUTO_S="${WORKDIR}" 84 autotools_run_tool aclocal "$@" ${aclocal_opts}
98AUTO_D="${T}/autotools"
99
100fetch_autotools() {
101
102 local y
103 for y in ${ASRC_URI}
104 do
105 if [ ! -e ${DISTDIR}/${y##*/} ]
106 then
107 echo ">>> Fetching ${y##*/}..."
108 echo
109 local x
110 local _SRC_URI
111 for x in ${GENTOO_MIRRORS}
112 do
113 _SRC_URI="${_SRC_URI} ${x}/distfiles/${y##*/}"
114 done
115 _SRC_URI="${_SRC_URI} `queryhost.sh "${SRC_URI}"`"
116 for x in ${_SRC_URI}
117 do
118 if [ ! -e ${DISTDIR}/${y##*/} ]
119 then
120 if [ "${y##*/}" = "${x##*/}" ]
121 then
122 echo ">>> Trying site ${x}..."
123 eval "${FETCHCOMMAND}"
124 fi
125 fi
126 done
127 if [ ! -e ${DISTDIR}/${y##*/} ]
128 then
129 echo '!!!'" Couldn't download ${y##*/} needed by autotools.eclass. Aborting."
130 exit 1
131 fi
132 echo
133 fi
134 done
135} 85}
136 86
137unpack_autotools() { 87_elibtoolize() {
88 # Check if we should run libtoolize
89 [[ -n $(autotools_check_macro "AC_PROG_LIBTOOL") ]] || return 0
90 use userland_Darwin && LIBTOOLIZE="glibtoolize"
91 autotools_run_tool ${LIBTOOLIZE:-libtoolize} "$@"
138 92
139 cd ${AUTO_S} 93 # Need to rerun aclocal
140 94 eaclocal
141 local x
142 for x in ${ASRC_URI}
143 do
144 unpack ${x##*/} || die "!!! Could not unpack ${x##*/} needed by autotools !!!"
145 done
146} 95}
147 96
148install_autoconf() { 97eautoheader() {
149 98 # Check if we should run autoheader
150 cd ${AUTO_S}/autoconf-${ACONFVER} || die "!!! Failed to build autoconf !!!" 99 [[ -n $(autotools_check_macro "AC_CONFIG_HEADERS") ]] || return 0
151 100 autotools_run_tool autoheader "$@"
152 ./configure --prefix=${AUTO_D} \
153 --infodir=${AUTO_D}/share/info \
154 --mandir=${AUTO_D}/share/man \
155 --target=${CHOST} || die "!!! Failed to configure autoconf !!!"
156
157 emake || die "!!! Failed to build autoconf !!!"
158
159 make install || die "!!! Failed to install autoconf !!!"
160} 101}
161 102
162install_automake() { 103eautoconf() {
104 if [[ ! -f configure.ac && ! -f configure.in ]] ; then
105 echo
106 eerror "No configure.{ac,in} present in '$(pwd | sed -e 's:.*/::')'!"
107 echo
108 die "No configure.{ac,in} present!"
109 fi
163 110
164 cd ${AUTO_S}/automake-${AMAKEVER} || die "!!! Failed to build automake !!!" 111 autotools_run_tool autoconf "$@"
165
166 ./configure --prefix=${AUTO_D} \
167 --infodir=${AUTO_D}/share/info \
168 --mandir=${AUTO_D}/share/man \
169 --target=${CHOST} || die "!!! Failed to configure automake !!!"
170
171 emake || die "!!! Failed to build automake !!!"
172
173 make install || die "!!! Failed to install automake !!!"
174} 112}
175 113
176install_autotools() { 114eautomake() {
177 115 [[ -f Makefile.am ]] || return 0
178 if [ "${SRC_URI/autoconf/}" = "$SRC_URI" ] || [ "${SRC_URI/automake/}" = "$SRC_URI" ] 116 # --force-missing seems not to be recognized by some flavours of automake
179 then 117 autotools_run_tool automake --add-missing --copy "$@"
180 echo "!!! \$SRC_URI was not set properly !!! It needs to include \${SRC_URI}"
181 exit 1
182 fi
183
184 if [ "${DEPEND/make/}" = "$DEPEND" ] || [ "${DEPEND/perl/}" = "$DEPEND" ] || \
185 [ "${DEPEND/m4/}" = "$DEPEND" ]
186 then
187 echo "!!! \$DEPEND was not set properly !!! It needs to include \${DEPEND}"
188 exit 1
189 fi
190
191 mkdir -p ${AUTO_S}
192 mkdir -p ${AUTO_D}/{bin,etc,lib,include,share} \
193 || die "!!! Could not create needed directories for autotools !!!"
194
195# fetch_autotools
196# unpack_autotools
197 install_autoconf
198 install_automake
199
200 export PATH=${AUTO_D}/bin:${PATH}
201 cd ${S}
202 ln -sf ${AUTO_D}/share/automake/depcomp ${S}/depcomp
203} 118}
204 119
120# This function mimes the behavior of autoreconf, but uses the different
121# eauto* functions to run the tools. It doesn't accept parameters, but
122# the directory with include files can be specified with M4DIR variable.
123#
124# Note: doesn't run autopoint right now, but runs gnuconfig_update.
125eautoreconf() {
126 local pwd=$(pwd) x
127
128 # Take care of subdirs
129 for x in $(autotools_get_subdirs); do
130 if [[ -d ${x} ]] ; then
131 cd "${x}"
132 eautoreconf
133 cd "${pwd}"
134 fi
135 done
136
137 eaclocal
138 _elibtoolize --copy --force
139 eautoconf
140 eautoheader
141 eautomake
142 gnuconfig_update
143}

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.20