Attempt to fix 5709. Has not been able to reproduce before or after
[pazpar2-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=automake19
19     aclocal="aclocal19 -I /usr/local/share/aclocal"
20     autoconf=autoconf259
21     libtoolize=libtoolize15
22     autoheader=autoheader259
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="-O0 -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 --disable-shared --enable-static $*
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 tcl8.4
118   xsltproc docbook docbook-xml docbook-xsl
119   libxslt1-dev libgnutls-dev libreadline5-dev libicu-dev
120
121 And if you want to make a Debian package: dpkg-dev fakeroot debhelper
122 (Then run "dpkg-buildpackage -rfakeroot" in this directory.)
123
124 EOF
125     fi
126     if [ "`uname -s`" = FreeBSD ]; then
127         cat <<EOF
128 When building from a Git, you need these FreeBSD Ports:
129   autoconf259, automake19, libtool15, bison, tcl84,
130   docbook-xsl, libxml2, libxslt, g++-4.0, make
131 EOF
132     fi
133 fi