Fixes to the libgcrypt switch. Basically works now.
[gnupg.git] / autogen.sh
1 #!/bin/sh
2 # Run this to generate all the initial makefiles, etc.
3 # It is only needed for the CVS version.
4
5 # have_version(prog, list of executables, required version) 
6 #
7 # Returns true and sets $prog to the first executable with the
8 # required minimum major.minor.
9 have_version ()
10 {
11   found=0
12
13   for prog in $2 :
14   do
15     ver=$($prog --version \
16           | gawk '{ if (match($0, /[0-9]+\.[0-9]+/))
17                       {
18                         print substr($0, RSTART, RLENGTH); ok=1; exit 0;
19                       }
20                   }
21   
22                   END {
23                         if (! ok)
24                           exit 1;
25                       }')
26   
27     if test $? = 0
28     then
29       if expr 0$ver '>=' 0$3 >/dev/null 2>&1
30       then
31         echo Using $prog
32         found=1
33         export $1="$prog"
34         break
35       fi
36     fi
37   done
38
39   if test 0$found = 01
40   then
41     true
42   else
43     echo "*** Error.  Could not find an appropriate executable for $1 with "
44     echo "at least version $3."
45     false
46   fi
47 }
48
49 PGM=NEWPG
50 lib_config_files=""
51 autoconf_vers=2.52
52 automake_vers=1.5
53 aclocal_vers=1.5
54 #libtool_vers=1.3
55
56 DIE=no
57 if test "$1" = "--build-w32"; then
58     shift
59     target=i386--mingw32
60     if [ ! -f ./config.guess ]; then
61         echo "./config.guess not found" >&2
62         exit 1
63     fi
64     host=`./config.guess`
65         
66     if ! mingw32 --version >/dev/null; then
67         echo "We need at least version 0.3 of MingW32/CPD" >&2
68         exit 1
69     fi
70
71     if [ -f config.h ]; then
72         if grep HAVE_DOSISH_SYSTEM config.h | grep undef >/dev/null; then
73             echo "Pease run a 'make distclean' first" >&2
74             exit 1
75         fi
76     fi
77
78     crossinstalldir=`mingw32 --install-dir`
79     crossbindir=`mingw32 --get-bindir 2>/dev/null` \
80                || crossbindir="$crossinstalldir/bin"
81     crossdatadir=`mingw32 --get-datadir 2>/dev/null` \
82                || crossdatadir="$crossinstalldir/share"
83     crosslibdir=`mingw32 --get-libdir 2>/dev/null` \
84                || crosslibdir="$crossinstalldir/i386--mingw32/lib"
85     crossincdir=`mingw32 --get-includedir 2>/dev/null` \
86                || crossincdir="$crossinstalldir/i386--mingw32/include"
87     CC=`mingw32 --get-path gcc`
88     CPP=`mingw32 --get-path cpp`
89     AR=`mingw32 --get-path ar`
90     RANLIB=`mingw32 --get-path ranlib`
91     export CC CPP AR RANLIB 
92
93     disable_foo_tests=""
94     if [ -n "$lib_config_files" ]; then
95         for i in $lib_config_files; do
96             j=`echo $i | tr '[a-z-]' '[A-Z_]'`
97             eval "$j=${crossbindir}/$i"
98             export $j
99             disable_foo_tests="$disable_foo_tests --disable-`echo $i| \
100                            sed 's,-config$,,'`-test"
101             if [ ! -f "${crossbindir}/$i" ]; then                   
102                 echo "$i not installed for MingW32" >&2
103                 DIE=yes
104             fi
105         done
106     fi
107     [ $DIE = yes ] && exit 1
108
109     ./configure --host=${host} --target=${target}  ${disable_foo_tests} \
110                 --bindir=${crossbindir} --libdir=${crosslibdir} \
111                 --datadir=${crossdatadir} --includedir=${crossincdir} \
112                 --enable-maintainer-mode $*
113     exit $?
114 fi
115
116 if ! have_version autoconf "$autoconf autoconf" $autoconf_vers
117 then
118   DIE="yes"
119 fi
120
121 if have_version automake "$automake automake automake-1.6" $automake_vers
122 then
123   if ! have_version aclocal "$aclocal aclocal aclocal-1.6" $aclocal_vers
124   then
125     DIE='yes'
126   fi
127 else
128     DIE='yes'
129 fi
130
131 #if (libtool --version) < /dev/null > /dev/null 2>&1 ; then
132 #    if (libtool --version | awk 'NR==1 { if( $4 >= '$libtool_vers') \
133 #                               exit 1; exit 0; }');
134 #    then
135 #       echo "**Error**: "\`libtool\'" is too old."
136 #       echo '           (version ' $libtool_vers ' or newer is required)'
137 #       DIE="yes"
138 #    fi
139 #else
140 #    echo
141 #    echo "**Error**: You must have "\`libtool\'" installed to compile $PGM."
142 #    echo '           (version ' $libtool_vers ' or newer is required)'
143 #    DIE="yes"
144 #fi
145
146 if test "$DIE" = "yes"; then
147     exit 1
148 fi
149
150 #echo "Running libtoolize...  Ignore non-fatal messages."
151 #echo "no" | libtoolize
152
153 echo "Running autopoint"
154 autopoint
155
156 echo "Running $aclocal -I m4"
157 $aclocal -I m4
158 echo "Running autoheader..."
159 autoheader
160 echo "Running $automake --gnu -a"
161 $automake --gnu -a
162 echo "Running $autoconf"
163 $autoconf