gschem/po: Apply updated Dutch translations from Bert Timmerman
[geda-gaf/arnaud.git] / autogen.sh
blobb8502ec64c276886a901b08fe51ee12e607d1447
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #####################################################################
21 # Setup variables
22 #####################################################################
24 ac_script=configure.ac
25 am_version=1.6.0
26 aclocal_flags="$ACLOCAL_FLAGS -I m4"
27 tooldir=build-tools
28 podirs="libgeda/po gschem/po gattrib/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, it
107 # only recognizes the top level po directory -- which gEDA doesn't use
108 # at all. We therefore run autopoint to populate the top-level po
109 # directory, and then copy the files to the po directories that we
110 # actually use.
112 # N.b. when this function is called we've cd'd into $srcdir.
113 autopoint_fix() {
114 top_po="po"
116 # For safety, refuse to continue if the top level po dir exists.
117 if test -d top_po; then
118 echo "***Error*** $script_name: $top_po exists. Remove it and re-run $script_name"
119 ! : #false
120 elif run_tool $AUTOPOINT --force; then
122 for d in $podirs; do
123 echo "$script_name: copying gettext files to $d ..."
124 cp -p $top_po/* $d || break
125 done
126 } && rm -rf $top_po
127 else
128 exit $?
132 #####################################################################
133 # Do some checks for directories and tools
134 #####################################################################
136 check_dist_file $ac_script || die=1
137 check_dist_file $tooldir/desktop-i18n &&
138 DESKTOP_I18N=$tooldir/desktop-i18n || die=1
140 AUTOCONF=`check_tool autoconf "GNU autoconf" ftp://ftp.gnu.org/pub/gnu/` 2>&1 || die=1
142 AUTOHEADER=`check_tool autoheader "GNU autoconf" ftp://ftp.gnu.org/pub/gnu/` 2>&1 || die=1
144 AUTOMAKE=`check_tool automake "GNU automake" ftp://ftp.gnu.org/pub/gnu/` 2>&1 || die=1
146 ACLOCAL=`check_tool aclocal "GNU automake" ftp://ftp.gnu.org/pub/gnu/` 2>&1 || die=1
148 LIBTOOLIZE=`check_tool "libtoolize glibtoolize" "GNU libtool" "ftp://ftp.gnu.org/pub/gnu/"` 2>&1 || die=1
150 AUTOPOINT=`check_tool autopoint "GNU gettext" "http://www.gnu.org/software/gettext"` 2>&1 || die=1
152 #####################################################################
153 # Check automake version
154 #####################################################################
156 # Exit now if we don't have automake at all
157 if test "x$AUTOMAKE" = x ; then
158 echo "***Error*** $script_name: Some required tools could not be found."
159 exit $die
162 printf "checking for automake >= $am_version ... "
163 am_have_version=`$AUTOMAKE --version | sed -n -e 's:[^0-9]* \([0-9]*\.[0-9]*\.*[0-9]*\).*$:\1:p'`
164 echo $am_have_version
166 need_major=`echo $am_version | awk -F . '{print $1}'`
167 need_minor=`echo $am_version | awk -F . '{print $2}'`
168 need_point=`echo $am_version | awk -F . '{print $3}'`
170 have_major=`echo $am_have_version | awk -F . '{print $1}'`
171 have_minor=`echo $am_have_version | awk -F . '{print $2}'`
172 have_point=`echo $am_have_version | awk -F . '{print $3}'`
174 if test "x$have_point" = x; then have_point="0"; fi
176 if test $need_major -gt $have_major ||
177 test $need_major -eq $have_major -a $need_minor -gt $have_minor ||
178 test $need_major -eq $have_major -a $need_minor -eq $have_minor \
179 -a $need_point -gt $have_point; then
180 cat >&2 <<EOF
182 You have Automake $am_have_version installed, but Automake $am_version
183 or later is required.
185 If your operating system doesn't provide a package, you can download
186 it from ftp://ftp.gnu.org/pub/gnu/
189 die=1
192 #####################################################################
193 # Die if checks failed
194 #####################################################################
196 if test "x$die" != x ; then
197 echo "***Error*** $script_name: Some required tools could not be found."
198 exit $die
201 #####################################################################
202 # Run tools
203 #####################################################################
205 ( cd $srcdir &&
206 autopoint_fix &&
207 run_tool "$DESKTOP_I18N" --setup &&
208 run_tool "$LIBTOOLIZE" --force --copy &&
209 run_tool "$ACLOCAL" $aclocal_flags &&
210 run_tool "$AUTOHEADER" &&
211 run_tool "$AUTOMAKE" --copy --add-missing --gnu &&
212 run_tool "$AUTOCONF" )