Version 4.2.23
[yaz-moved-to-github.git] / buildconf.sh
1 #!/bin/sh
2
3 automake=automake
4 aclocal=aclocal
5 autoconf=autoconf
6 libtoolize=libtoolize
7 autoheader=autoheader
8
9 test -d autom4te.cache && rm -r autom4te.cache
10 test -d config || mkdir config
11 if [ -d .git ]; then
12     git submodule init
13     git submodule update
14 fi
15 if [ "`uname -s`" = FreeBSD ]; then
16     # FreeBSD intalls the various auto* tools with version numbers
17     echo "Using special configuration for FreeBSD ..."
18     automake=automake
19     aclocal="aclocal -I /usr/local/share/aclocal"
20     autoconf=autoconf
21     libtoolize=libtoolize
22     autoheader=autoheader
23 fi
24
25 if [ "`uname -s`" = Darwin ]; then
26     echo "Using special configuration for Darwin/MacOS ..."
27     libtoolize=glibtoolize
28 fi
29
30 if $automake --version|head -1 |grep '1\.[4-7]'; then
31     echo "automake 1.4-1.7 is active. You should use automake 1.8 or later"
32     if [ -f /etc/debian_version ]; then
33         echo " sudo apt-get install automake1.9"
34         echo " sudo update-alternatives --config automake"
35     fi
36     exit 1
37 fi
38
39 set -x
40 $aclocal -I m4
41 if grep AC_CONFIG_HEADERS configure.ac >/dev/null; then
42     $autoheader
43 fi
44 if grep AM_PROG_LIBTOOL configure.ac >/dev/null; then
45     has_libtool=true
46 else
47     has_libtool=false
48 fi
49
50 $libtoolize --automake --force 
51 $automake --add-missing 
52 $autoconf
53 set -
54 if [ -f config.cache ]; then
55         rm config.cache
56 fi
57
58 enable_configure=false
59 enable_help=true
60 sh_flags=""
61 conf_flags=""
62 case $1 in
63     -d)
64         sh_cflags="-g -Wall -Wdeclaration-after-statement -Wstrict-prototypes"
65         sh_cxxflags="-g -Wall"
66         enable_configure=true
67         enable_help=false
68         shift
69         ;;
70     -c)
71         sh_cflags=""
72         sh_cxxflags=""
73         enable_configure=true
74         enable_help=false
75         shift
76         ;;
77 esac
78
79 if $enable_configure; then
80     if [ -n "$sh_cflags" ]; then
81         if $has_libtool; then
82             CFLAGS="$sh_cflags" CXXFLAGS="$sh_cxxflags" ./configure \
83                 --disable-shared --enable-static --with-pic $*
84         else
85             CFLAGS="$sh_cflags" CXXFLAGS="$sh_cxxflags" ./configure $*
86         fi
87     else
88         ./configure $*
89     fi
90 fi
91 if $enable_help; then
92     cat <<EOF
93
94 Build the Makefiles with the configure command.
95   ./configure [--someoption=somevalue ...]
96
97 For help on options or configuring run
98   ./configure --help
99
100 Build and install binaries with the usual
101   make
102   make check
103   make install
104
105 Build distribution tarball with
106   make dist
107
108 Verify distribution tarball with
109   make distcheck
110
111 EOF
112     if [ -f /etc/debian_version ]; then
113         cat <<EOF
114 Or just build the Debian packages without configuring
115   dpkg-buildpackage -rfakeroot
116
117 When building from Git, you need these Debian packages:
118   autoconf automake libtool gcc bison tcl8.4
119   xsltproc docbook docbook-xml docbook-xsl
120   libxslt1-dev libgnutls-dev libreadline5-dev libwrap0-dev
121   pkg-config libicu-dev 
122
123 And if you want to make a Debian package: dpkg-dev fakeroot debhelper
124 (Then run "dpkg-buildpackage -rfakeroot" in this directory.)
125
126 EOF
127     fi
128     if [ "`uname -s`" = FreeBSD ]; then
129         cat <<EOF
130 When building from a Git, you need these FreeBSD Ports:
131   pkg_add -r autoconf262 automake110 libtool bison tcl84 \\
132              docbook-xsl libxml2 libxslt
133   pkg_add -r icu4
134 EOF
135     fi
136 fi