Update wiki pages
[geda-gaf.git] / autogen.sh
blob7b82f04ce070664f8c1f1b2c3ddffd6da5542579
1 #!/bin/sh
2 # -*-Shell-script-*-
3 # Developer helper script for setting up gEDA build environment
4 # Copyright (C) 2009, 2016 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-legacy/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 # In newer versions of autopoint, there is a second bug whereby the
115 # "intl" embedded internationalization library installed by autopoint
116 # requires a "ChangeLog" file for "make dist", but doesn't actually
117 # provide one.
119 # N.b. when this function is called we've cd'd into $srcdir.
120 autopoint_fix() {
121 top_po="po"
123 # For safety, refuse to continue if the top level po dir exists.
124 if test -d $top_po; then
125 echo "***Error*** $script_name: $top_po exists. Remove it and re-run $script_name"
126 ! : #false
127 elif run_tool $AUTOPOINT --force; then
128 if test -d $top_po; then
130 for d in $podirs; do
131 echo "$script_name: copying gettext files to $d ..."
132 cp -p $top_po/* $d || break
133 done
134 } && rm -rf $top_po
137 cl="intl/ChangeLog"
138 if test -d "intl" -a ! -e "$cl"; then
139 echo "$script_name: creating file $cl"
140 touch "$cl"
142 else
143 exit $?
147 #####################################################################
148 # Do some checks for directories and tools
149 #####################################################################
151 check_dist_file $ac_script || die=1
152 check_dist_file $tooldir/desktop-i18n &&
153 DESKTOP_I18N=$tooldir/desktop-i18n || die=1
155 AUTOCONF=`check_tool autoconf "GNU autoconf" ftp://ftp.gnu.org/pub/gnu/` 2>&1 || die=1
157 AUTOHEADER=`check_tool autoheader "GNU autoconf" ftp://ftp.gnu.org/pub/gnu/` 2>&1 || die=1
159 AUTOMAKE=`check_tool automake "GNU automake" ftp://ftp.gnu.org/pub/gnu/` 2>&1 || die=1
161 ACLOCAL=`check_tool aclocal "GNU automake" ftp://ftp.gnu.org/pub/gnu/` 2>&1 || die=1
163 LIBTOOLIZE=`check_tool "libtoolize glibtoolize" "GNU libtool" "ftp://ftp.gnu.org/pub/gnu/"` 2>&1 || die=1
165 AUTOPOINT=`check_tool autopoint "GNU gettext" "http://www.gnu.org/software/gettext"` 2>&1 || die=1
167 #####################################################################
168 # Check automake version
169 #####################################################################
171 # Exit now if we don't have automake at all
172 if test "x$AUTOMAKE" = x ; then
173 echo "***Error*** $script_name: Some required tools could not be found."
174 exit $die
177 printf "checking for automake >= $am_version ... "
178 am_have_version=`$AUTOMAKE --version | sed -n -e 's:[^0-9]* \([0-9]*\.[0-9]*\.*[0-9]*\).*$:\1:p'`
179 echo $am_have_version
181 need_major=`echo $am_version | awk -F . '{print $1}'`
182 need_minor=`echo $am_version | awk -F . '{print $2}'`
183 need_point=`echo $am_version | awk -F . '{print $3}'`
185 have_major=`echo $am_have_version | awk -F . '{print $1}'`
186 have_minor=`echo $am_have_version | awk -F . '{print $2}'`
187 have_point=`echo $am_have_version | awk -F . '{print $3}'`
189 if test "x$have_point" = x; then have_point="0"; fi
191 if test $need_major -gt $have_major ||
192 test $need_major -eq $have_major -a $need_minor -gt $have_minor ||
193 test $need_major -eq $have_major -a $need_minor -eq $have_minor \
194 -a $need_point -gt $have_point; then
195 cat >&2 <<EOF
197 You have Automake $am_have_version installed, but Automake $am_version
198 or later is required.
200 If your operating system doesn't provide a package, you can download
201 it from ftp://ftp.gnu.org/pub/gnu/
204 die=1
207 #####################################################################
208 # Die if checks failed
209 #####################################################################
211 if test "x$die" != x ; then
212 echo "***Error*** $script_name: Some required tools could not be found."
213 exit $die
216 #####################################################################
217 # Run tools
218 #####################################################################
220 ( cd $srcdir &&
221 autopoint_fix &&
222 run_tool "$DESKTOP_I18N" --setup &&
223 run_tool "$LIBTOOLIZE" --force --copy &&
224 run_tool "$ACLOCAL" $aclocal_flags &&
225 run_tool "$AUTOHEADER" &&
226 run_tool "$AUTOMAKE" -Wall --copy --add-missing --gnu &&
227 run_tool "$AUTOCONF" &&
228 (cd xorn && autoreconf -if))