New test for log changes
[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     -D)
71         sh_cflags="-g -Wall -Werror -Wdeclaration-after-statement"
72         sh_cxxflags="-g -Wall -Werror"
73         enable_configure=true
74         enable_help=false
75         shift
76         ;;
77     -c)
78         sh_cflags=""
79         sh_cxxflags=""
80         enable_configure=true
81         enable_help=false
82         shift
83         ;;
84 esac
85
86 if $enable_configure; then
87     if [ -n "$sh_cflags" ]; then
88         if $has_libtool; then
89             CFLAGS="$sh_cflags" CXXFLAGS="$sh_cxxflags" ./configure \
90                 --disable-shared --enable-static --with-pic $*
91         else
92             CFLAGS="$sh_cflags" CXXFLAGS="$sh_cxxflags" ./configure $*
93         fi
94     else
95         ./configure $*
96     fi
97 fi
98 if $enable_help; then
99     cat <<EOF
100
101 Build the Makefiles with the configure command.
102   ./configure [--someoption=somevalue ...]
103
104 For help on options or configuring run
105   ./configure --help
106
107 Build and install binaries with the usual
108   make
109   make check
110   make install
111
112 Build distribution tarball with
113   make dist
114
115 Verify distribution tarball with
116   make distcheck
117
118 EOF
119     if [ -f /etc/debian_version ]; then
120         cat <<EOF
121 Or just build the Debian packages without configuring
122   dpkg-buildpackage -rfakeroot
123
124 When building from Git, you need these Debian packages:
125   autoconf automake libtool gcc bison tcl8.4
126   xsltproc docbook docbook-xml docbook-xsl
127   libxslt1-dev libgnutls-dev libreadline5-dev libwrap0-dev
128   pkg-config libicu-dev 
129
130 And if you want to make a Debian package: dpkg-dev fakeroot debhelper
131 (Then run "dpkg-buildpackage -rfakeroot" in this directory.)
132
133 EOF
134     fi
135     if [ "`uname -s`" = FreeBSD ]; then
136         cat <<EOF
137 When building from a Git, you need these FreeBSD Ports:
138   pkg_add -r autoconf268 automake111 libtool bison tcl84 \\
139              docbook-xsl libxml2 libxslt
140   pkg_add -r icu4
141 EOF
142     fi
143 fi