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