build-sys: Ignore new build-tools installed by Automake 1.13.
[geda-gaf.git] / autogen.sh
blob037e860b2c77f7e6dc50dc8da976adea77dbf935
1 #!/bin/sh
2 # -*-Shell-script-*-
3 # Developer helper script for setting up gEDA build environment
4 # Copyright (C) 2009 Peter Brett <peter@peter-b.co.uk>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #####################################################################
21 # Setup variables
22 #####################################################################
24 ac_script=configure.ac
25 am_version=1.11.0
26 aclocal_flags="$ACLOCAL_FLAGS -I m4"
27 tooldir=build-tools
28 podirs="libgeda/po gaf/po gschem/po gattrib/po gaf/po gnetlist/po gsymcheck/po"
30 srcdir=`dirname $0`
31 if test "x$srcdir" = x ; then srcdir=.; fi
33 script_name=`echo $0 | sed -e's:.*/::'`
35 #####################################################################
36 # Define some functions
37 #####################################################################
39 # check_dist_file FILENAME
40 # ------------------------
41 # Check that a file that should be provided by the tarball or git
42 # checkout is present.
43 check_dist_file() {
44 printf "checking for $srcdir/$1 ... " >&2
45 if test -f "$srcdir/$1" ; then
46 echo yes >&2
47 else
48 echo no >&2
49 cat >&2 <<EOF
51 $script_name: $srcdir/$1 is missing. Check that your source tarball
52 or git checkout is intact.
54 EOF
55 ! :
59 # check_tool TOOLS PKG [URL]
60 # --------------------------
61 # Check that a build tool is present. TOOLS is a list of candidates to
62 # search for in the path, and PKG is the package which provides the
63 # tool. If URL is specified, recommend to the user that he get obtain
64 # the package there. Prints the location of the tool on standard
65 # output.
66 check_tool() {
67 for tool in $1; do
68 printf "checking for $tool ... " >&2
69 found_tool=`which $tool 2> /dev/null` && break
70 echo no >&2
71 done
72 if test "x$found_tool" != x ; then
73 echo $found_tool >&2
74 echo $found_tool
75 else
76 echo >&2
77 echo "$script_name: You must have $2 installed." >&2
78 if test "x$3" != x ; then
79 cat >&2 <<EOF
81 If your operating system distribution doesn't provide a package, you
82 can get download it from <$3>.
84 EOF
86 ! : # false
90 # run_tool TOOL [ARG]...
91 # ----------------------
92 # Run TOOL with the given ARGs.
93 run_tool() {
94 echo "$script_name: running $1 ..."
95 if "$@"; then
97 else
98 echo "***Error*** $script_name: $1 failed with exit status $?"
99 ! : # false
103 # autopoint_fix [PO_DIR]...
104 # ------------------------
105 # GNU gettext has a tool called autopoint which is used for copying
106 # the gettext build infrastructure into the package. Unfortunately,
107 # some versions of autopoint only recognize the top level po directory
108 # -- which gEDA doesn't use at all.
110 # To get around this, when we run autopoint we check if it's created
111 # the top-level po directory. If it has, we copy the files to po
112 # directories that we actually use.
114 # N.b. when this function is called we've cd'd into $srcdir.
115 autopoint_fix() {
116 top_po="po"
118 # For safety, refuse to continue if the top level po dir exists.
119 if test -d $top_po; then
120 echo "***Error*** $script_name: $top_po exists. Remove it and re-run $script_name"
121 ! : #false
122 elif run_tool $AUTOPOINT --force; then
123 if test -d $top_po; then
125 for d in $podirs; do
126 echo "$script_name: copying gettext files to $d ..."
127 cp -p $top_po/* $d || break
128 done
129 } && rm -rf $top_po
131 else
132 exit $?
136 #####################################################################
137 # Do some checks for directories and tools
138 #####################################################################
140 check_dist_file $ac_script || die=1
141 check_dist_file $tooldir/desktop-i18n &&
142 DESKTOP_I18N=$tooldir/desktop-i18n || die=1
144 AUTOCONF=`check_tool autoconf "GNU autoconf" ftp://ftp.gnu.org/pub/gnu/` 2>&1 || die=1
146 AUTOHEADER=`check_tool autoheader "GNU autoconf" ftp://ftp.gnu.org/pub/gnu/` 2>&1 || die=1
148 AUTOMAKE=`check_tool automake "GNU automake" ftp://ftp.gnu.org/pub/gnu/` 2>&1 || die=1
150 ACLOCAL=`check_tool aclocal "GNU automake" ftp://ftp.gnu.org/pub/gnu/` 2>&1 || die=1
152 LIBTOOLIZE=`check_tool "libtoolize glibtoolize" "GNU libtool" "ftp://ftp.gnu.org/pub/gnu/"` 2>&1 || die=1
154 AUTOPOINT=`check_tool autopoint "GNU gettext" "http://www.gnu.org/software/gettext"` 2>&1 || die=1
156 #####################################################################
157 # Check automake version
158 #####################################################################
160 # Exit now if we don't have automake at all
161 if test "x$AUTOMAKE" = x ; then
162 echo "***Error*** $script_name: Some required tools could not be found."
163 exit $die
166 printf "checking for automake >= $am_version ... "
167 am_have_version=`$AUTOMAKE --version | sed -n -e 's:[^0-9]* \([0-9]*\.[0-9]*\.*[0-9]*\).*$:\1:p'`
168 echo $am_have_version
170 need_major=`echo $am_version | awk -F . '{print $1}'`
171 need_minor=`echo $am_version | awk -F . '{print $2}'`
172 need_point=`echo $am_version | awk -F . '{print $3}'`
174 have_major=`echo $am_have_version | awk -F . '{print $1}'`
175 have_minor=`echo $am_have_version | awk -F . '{print $2}'`
176 have_point=`echo $am_have_version | awk -F . '{print $3}'`
178 if test "x$have_point" = x; then have_point="0"; fi
180 if test $need_major -gt $have_major ||
181 test $need_major -eq $have_major -a $need_minor -gt $have_minor ||
182 test $need_major -eq $have_major -a $need_minor -eq $have_minor \
183 -a $need_point -gt $have_point; then
184 cat >&2 <<EOF
186 You have Automake $am_have_version installed, but Automake $am_version
187 or later is required.
189 If your operating system doesn't provide a package, you can download
190 it from ftp://ftp.gnu.org/pub/gnu/
193 die=1
196 #####################################################################
197 # Die if checks failed
198 #####################################################################
200 if test "x$die" != x ; then
201 echo "***Error*** $script_name: Some required tools could not be found."
202 exit $die
205 #####################################################################
206 # Run tools
207 #####################################################################
209 ( cd $srcdir &&
210 autopoint_fix &&
211 run_tool "$DESKTOP_I18N" --setup &&
212 run_tool "$LIBTOOLIZE" --force --copy &&
213 run_tool "$ACLOCAL" $aclocal_flags &&
214 run_tool "$AUTOHEADER" &&
215 run_tool "$AUTOMAKE" -Wall --copy --add-missing --gnu &&
216 run_tool "$AUTOCONF" )