* autogen.sh: Add options to build for coldfire and uClinux.
[gnupg.git] / scripts / autogen.sh
1 #!/bin/sh
2 # Run this to generate all the initial makefiles, etc.
3 #
4 # Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
5 #
6 # This file is free software; as a special exception the author gives
7 # unlimited permission to copy and/or distribute it, with or without
8 # modifications, as long as this notice is preserved.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
12 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14 PGM=GnuPG
15 lib_config_files=""
16 autoconf_vers=2.52
17 automake_vers=1.6
18 aclocal_vers=1.6
19
20 ACLOCAL=${ACLOCAL:-aclocal}
21 AUTOCONF=${AUTOCONF:-autoconf}
22 AUTOMAKE=${AUTOMAKE:-automake}
23 AUTOHEADER=${AUTOHEADER:-autoheader}
24 DIE=no
25
26 # Used to cross-compile GnuPG for Windows.
27 if test "$1" = "--build-w32"; then
28     tmp=`dirname $0`
29     tsdir=`cd "$tmp"; cd ..; pwd`
30     shift
31     host=i386--mingw32
32     if [ ! -f $tsdir/scripts/config.guess ]; then
33         echo "$tsdir/scripts/config.guess not found" >&2
34         exit 1
35     fi
36     build=`$tsdir/scripts/config.guess`
37         
38     if ! mingw32 --version >/dev/null; then
39         echo "We need at least version 0.3 of MingW32/CPD" >&2
40         exit 1
41     fi
42
43     if [ -f "$tsdir/config.log" ]; then
44         if ! head $tsdir/config.log | grep i386--mingw32 >/dev/null; then
45             echo "Pease run a 'make distclean' first" >&2
46             exit 1
47         fi
48     fi
49
50     crossbindir=`mingw32 --install-dir`/bin
51     CC=`mingw32 --get-path gcc`
52     CPP=`mingw32 --get-path cpp`
53     AR=`mingw32 --get-path ar`
54     RANLIB=`mingw32 --get-path ranlib`
55     export CC CPP AR RANLIB 
56
57     disable_foo_tests=""
58     if [ -n "$lib_config_files" ]; then
59         for i in $lib_config_files; do
60             j=`echo $i | tr '[a-z-]' '[A-Z_]'`
61             eval "$j=${crossbindir}/$i"
62             export $j
63             disable_foo_tests="$disable_foo_tests --disable-`echo $i| \
64                            sed 's,-config$,,'`-test"
65             if [ ! -f "${crossbindir}/$i" ]; then                   
66                 echo "$i not installed for MingW32" >&2
67                 DIE=yes
68             fi
69         done
70     fi
71     [ $DIE = yes ] && exit 1
72
73     $tsdir/configure --build=${build} --host=${host} \
74                 ${disable_foo_tests} $*
75     exit $?
76 fi
77
78
79 # This is the special case to build on a ColdFire platform under 
80 # the uClinux kernel.  Tested on a MCF4249C3 board.
81 if test "$1" = "--build-coldfire"; then
82     tmp=`dirname $0`
83     tsdir=`cd "$tmp"; cd ..; pwd`
84     shift
85     if [ $# -lt 1 ]; then
86       echo "usage: autogen.sh --build-coldfire <crossroot>" >&2
87       exit 1
88     fi
89     crossdir="$1"
90     shift
91
92     host=m68k-elf
93     crossprefix=${host}-
94     if [ ! -f $tsdir/scripts/config.guess ]; then
95         echo "$tsdir/scripts/config.guess not found" >&2
96         exit 1
97     fi
98     build=`$tsdir/scripts/config.guess`
99         
100     if [ -f "$tsdir/config.log" ]; then
101         if ! head $tsdir/config.log | grep m68k-elf >/dev/null; then
102             echo "Pease run a 'make distclean' first" >&2
103             exit 1
104         fi
105     fi
106
107     crossbindir=$crossdir/bin
108     CC=${crossbindir}/${crossprefix}gcc
109     CPP=${crossbindir}/cpp
110     AR=${crossbindir}/${crossprefix}ar
111     RANLIB=${crossbindir}/${crossprefix}ranlib
112
113     CFLAGS="-Os -g -fomit-frame-pointer"
114     CFLAGS="$CFLAGS -m5307 -DCONFIG_COLDFIRE"
115     CFLAGS="$CFLAGS -Dlinux -D__linux__ -Dunix -D__uClinux__ -DEMBED"
116     CFLAGS="$CFLAGS -fno-builtin -msep-data"
117     LDFLAGS="-Wl,-elf2flt -Wl,-move-rodata -nostartfiles"
118     LDFLAGS="$LDFLAGS ${crossdir}/m68k-elf/lib/crt0.o"
119     LIBS="-lc"
120
121     disable_foo_tests=""
122     if [ -n "$lib_config_files" ]; then
123         for i in $lib_config_files; do
124             j=`echo $i | tr '[a-z-]' '[A-Z_]'`
125             eval "$j=${crossbindir}/$i"
126             export $j
127             disable_foo_tests="$disable_foo_tests --disable-`echo $i| \
128                            sed 's,-config$,,'`-test"
129             if [ ! -f "${crossbindir}/$i" ]; then                   
130                 echo "$i not installed for ColdFire" >&2
131                 DIE=yes
132             fi
133         done
134     fi
135     [ $DIE = yes ] && exit 1
136
137     $tsdir/configure --build=${build} --host=${host} \
138                 ${disable_foo_tests} \
139                 --disable-dynload \
140                 --disable-exec \
141                 --disable-photo-viewers \
142                 --disable-keyserver-helpers \
143                 --disable-ldap \
144                 --disable-mailto \
145                 --disable-largefile \
146                 --disable-asm \
147                 --disable-nls $* \
148                 CC="$CC" CPP="$CPP" AR="$AR" RANLIB="$RANLIB" \
149                 CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" LIBS="$LIBS"
150     exit $?
151 fi
152
153
154 # This is the special case to build on a ColdFire platform under 
155 # the uClinux kernel with uClinux-dist.  Tested on a MCF4249C3 board.
156 if test "$1" = "--build-uclinux"; then
157     tmp=`dirname $0`
158     tsdir=`cd "$tmp"; cd ..; pwd`
159     shift
160
161     if [ ! -f $tsdir/scripts/config.guess ]; then
162         echo "$tsdir/scripts/config.guess not found" >&2
163         exit 1
164     fi
165     build=`$tsdir/scripts/config.guess`
166     host=m68k-elf
167         
168     if [ -f "$tsdir/config.log" ]; then
169         if ! head $tsdir/config.log | grep m68k-elf >/dev/null; then
170             echo "Please run a 'make distclean' first" >&2
171             exit 1
172         fi
173     fi
174
175     $tsdir/configure --build=${build} --host=${host} \
176                 ${disable_foo_tests} \
177                 --disable-dynload \
178                 --disable-exec \
179                 --disable-photo-viewers \
180                 --disable-keyserver-helpers \
181                 --disable-ldap \
182                 --disable-mailto \
183                 --disable-largefile \
184                 --disable-asm \
185                 --disable-nls $* \
186                 CC="$CC" CPP="$CPP" AR="$AR" RANLIB="$RANLIB" \
187                 CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" LIBS="$LDLIBS"
188     exit $?
189 fi
190
191
192
193 if ($AUTOCONF --version) < /dev/null > /dev/null 2>&1 ; then
194     if ($AUTOCONF --version | awk 'NR==1 { if( $3 >= '$autoconf_vers') \
195                                exit 1; exit 0; }');
196     then
197        echo "**Error**: "\`autoconf\'" is too old."
198        echo '           (version ' $autoconf_vers ' or newer is required)'
199        DIE="yes"
200     fi
201 else
202     echo
203     echo "**Error**: You must have "\`autoconf\'" installed to compile $PGM."
204     echo '           (version ' $autoconf_vers ' or newer is required)'
205     DIE="yes"
206 fi
207
208 if ($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 ; then
209   if ($AUTOMAKE --version | awk 'NR==1 { if( $4 >= '$automake_vers') \
210                              exit 1; exit 0; }');
211      then
212      echo "**Error**: "\`automake\'" is too old."
213      echo '           (version ' $automake_vers ' or newer is required)'
214      DIE="yes"
215   fi
216   if ($ACLOCAL --version) < /dev/null > /dev/null 2>&1; then
217     if ($ACLOCAL --version | awk 'NR==1 { if( $4 >= '$aclocal_vers' ) \
218                                                 exit 1; exit 0; }' );
219     then
220       echo "**Error**: "\`aclocal\'" is too old."
221       echo '           (version ' $aclocal_vers ' or newer is required)'
222       DIE="yes"
223     fi
224   else
225     echo
226     echo "**Error**: Missing "\`aclocal\'".  The version of "\`automake\'
227     echo "           installed doesn't appear recent enough."
228     DIE="yes"
229   fi
230 else
231     echo
232     echo "**Error**: You must have "\`automake\'" installed to compile $PGM."
233     echo '           (version ' $automake_vers ' or newer is required)'
234     DIE="yes"
235 fi
236
237
238 if (gettext --version </dev/null 2>/dev/null | awk 'NR==1 { split($4,A,"."); \
239     X=10000*A[1]+100*A[2]+A[3]; echo X; if( X >= 1038 ) exit 1; exit 0}')
240     then
241     echo "**Error**: You must have "\`gettext\'" installed to compile $PGM."
242     echo '           (version 0.10.38 or newer is required; get'
243     echo '            ftp://alpha.gnu.org/gnu/gettext/gettext-0.10.38.tar.gz'
244     echo '            or install the latest Debian package)'
245     DIE="yes"
246 fi
247
248
249 if test "$DIE" = "yes"; then
250     exit 1
251 fi
252
253 echo "Running aclocal..."
254 $ACLOCAL
255 echo "Running autoheader..."
256 $AUTOHEADER
257 echo "Running automake --gnu ..."
258 $AUTOMAKE --gnu;
259 echo "Running autoconf..."
260 $AUTOCONF
261
262 echo "You can now run \"./configure --enable-maintainer-mode\" and then \"make\"."
263