check for nobug.h and llist.h
[acogc.git] / bootstrap.sh
blobbc739aef856c6b1ccbc9d1c489bd7d4bf4e72a38
1 #!/bin/sh
3 # GNU autotools driver
5 # Copyright (C) 2001, 2004, Christian Thaeter <chth@gmx.net>
7 # hint: install this somewhere in your PATH as 'autobootstrap'
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License version 2 as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, contact me.
22 function chk_prg()
24 test ! "$chk_prg_org" && chk_prg_org="$*"
25 test $# -eq 0 && { echo "lacking on of $chk_prg_org"; exit 1;}
26 if test ! "$1"; then
27 echo "";
28 else
29 local prg
30 prg=$(which "$1")
31 if test "$prg" = ""; then
32 shift;
33 chk_prg "$@"
34 else
35 chk_prg_org="";
36 echo "$prg"
41 #default options (configure this for your package)
42 DEF_BUILDDIR='=build'
43 DEF_BUILDOPT='-j 9'
44 DEF_CFLAGS_DEBUG='-O0 -g -W -Wall -Werror -std=gnu99 -DEBUG_ALPHA'
45 DEF_CFLAGS_RELEASE='-DNDEBUG -O3 -W -Wall -Werror -std=gnu99'
46 DEF_CC="nice $(chk_prg ccache "") $(chk_prg distcc "") $(chk_prg gcc-3.4 gcc cc)"
48 #default programs (probably no need for configuration)
49 AUTOCONFVERSION='2.50'
50 AUTOMAKEVERSION='-1.9'
52 MAKE="$(chk_prg gmake make)"
53 AUTOSCAN="$(chk_prg autoscan$AUTOCONFVERSION autoscan)"
54 ACLOCAL="$(chk_prg aclocal$AUTOMAKEVERSION aclocal)"
55 AUTOCONF="$(chk_prg autoconf$AUTOCONFVERSION autoconf)"
56 AUTOHEADER="$(chk_prg autoheader$AUTOCONFVERSION autoheader)"
57 AUTOMAKE="$(chk_prg automake$AUTOMAKEVERSION)"
60 #commandline parser (needs to be done better / options etc)
61 do_mrproper=false
62 do_release=false
63 do_nobootstrap=false
64 do_stop=false
65 do_configure=false
66 do_chelp=false
67 do_build=false
68 do_check=false
69 do_install=false
70 do_clean=false
71 do_uninstall=false
72 do_dist=false
73 do_dir=true
74 dir_opt="$DEF_BUILDDIR"
75 base_dir=`pwd`
77 for i in "$@"; do
78 case $i in
79 mrproper|distclean)
80 do_mrproper=true
81 do_uninstall=true
82 do_stop=true
84 rebuild)
85 do_mrproper=true
86 do_uninstall=true
87 do_stop=false
89 nobootstrap)
90 do_nobootstrap=true
92 chelp)
93 do_chelp=true
94 do_stop=false
96 configure*)
97 configure_opt=${i#configure}
98 do_configure=true
99 do_stop=false
101 make*)
102 build_opt=${i#make}
103 do_build=true
104 do_configure=true
105 do_stop=false
107 build*)
108 build_opt=${i#build}
109 do_build=true
110 do_configure=true
111 do_stop=false
113 nocd|intree)
114 do_dir=false
116 cd*)
117 dir_opt=${i#cd}
118 dir_opt="${dir_opt:-$DEF_BUILDDIR}"
119 do_dir=true
121 check|test)
122 do_check=true
123 do_configure=true
124 do_stop=false
126 install)
127 do_release=true
128 do_install=true
129 do_check=true
130 do_configure=true
131 do_uninstall=true
132 do_stop=false
134 clean)
135 do_clean=true
136 do_stop=false
138 uninstall)
139 do_uninstall=true
140 do_stop=false
142 dist)
143 do_release=true
144 do_dist=true
145 do_configure=true
146 do_clean=true
147 do_stop=false
149 release)
150 do_release=true
152 help*|-h*)
153 echo "bootstrap a GNU-Autotools Project"
154 echo "usage: bootstrap options..."
155 echo " options can be one or more of:"
156 echo " mrproper - big-clean the project, try's to uninstall previous version"
157 echo " rebuild - mrproper and rebuild from scratch"
158 echo " nobootstrap - don't use autotools, use existing configure"
159 echo " intree - do a build within the sourcetree *BAD!*"
160 echo " cd* - build into a subdir default: ./=build{-release|-debug}"
161 echo " chelp - shows ./configure --help, interactively asks for configure options"
162 echo " configure* - bootstraps the project including ./configure"
163 echo " make* - does a 'make' as well"
164 echo " check - additionally runs tests"
165 echo " install - installs project if checks are passed"
166 echo " clean - cleans up after building"
167 echo " uninstall - try to uninstall allready installed version before proceeding"
168 echo " dist - builds a distribution if all is sane"
169 echo " release - uses 'release' configuration"
170 echo " default: debug for check, release for install"
171 echo " help - this sceen"
172 echo " cd, configure and make can be quoted and appended with options"
173 echo " example:"
174 echo " bootstrap rebuild 'cd build' 'configure --with-x' 'make -j4' dist"
175 exit 0
177 esac
178 done
180 #set some vars to defaults
181 if test ! "$build_opt"; then
182 build_opt="$DEF_BUILDOPT"
185 if test ! "$CFLAGS"; then
186 if test $do_release = true; then
187 CFLAGS="$DEF_CFLAGS_RELEASE $EXTRA_CFLAGS"
188 dir_opt="${dir_opt}.release"
189 else
190 CFLAGS="$DEF_CFLAGS_DEBUG $EXTRA_CFLAGS"
191 dir_opt="${dir_opt}.debug"
193 export CFLAGS
195 if test ! "$CC"; then
196 CC="$DEF_CC"
197 export CC
200 # lets go
202 #first of all we install ourself
203 if test ! -f "$base_dir/bootstrap.sh"; then
204 echo "installing ./bootstrap.sh .."
205 cp -a "$0" "$base_dir/bootstrap.sh"
208 if test $do_nobootstrap = false; then
210 # old compatibilitry check?
211 configure_ac_name='configure.ac'
212 if test -f 'configure.in'; then
213 echo "using obsolete configure.in.."
214 configure_ac_name='configure.in'
217 #we need to go into the build dir for deinstalling and mrproper
218 if test $do_dir = true; then
219 test -d $dir_opt && cd $dir_opt
222 # uninstall old version?
223 if test $do_uninstall = true; then
224 if test -f 'Makefile'; then
225 echo "uninstalling.."
226 $MAKE uninstall
230 # check if we want a really clean mrproper
231 if test $do_mrproper = true; then
232 echo "mrproper.."
233 if test -f 'Makefile'; then
234 $MAKE maintainer-clean
236 cd $base_dir
237 rm -f config.* configure Makefile Makefile.in
238 test -d "$dir_opt" && chmod -R u+w "$dir_opt" && rm -rf $dir_opt
239 test -f $configure_ac_name && touch $configure_ac_name
241 cd $base_dir
243 # enough?
244 if test $do_stop = true; then
245 echo "..stopped"
246 exit 0
249 # do we need to make configure.ac
250 if test ! -f $configure_ac_name; then
251 echo "generating configure.ac.."
252 $AUTOSCAN
253 echo "dnl Note from bootstrap:" >$configure_ac_name
254 echo "dnl this scan is not yet configured for automake" >>$configure_ac_name
255 echo "dnl add at least the following macros" >>$configure_ac_name
256 echo "dnl AM_INIT_AUTOMAKE( name , version )" >>$configure_ac_name
257 echo "dnl AM_CONFIG_HEADER([config.h])" >>$configure_ac_name
258 echo "dnl and don't forget to insert Makefile in AC_CONFIG_FILES()" >>$configure_ac_name
259 echo "dnl end_of_note" >>$configure_ac_name
260 cat configure.scan >>$configure_ac_name
261 rm configure.scan
262 echo "Please edit $configure_ac_name hit Ctrl-D when finished"
264 if test ! -f $configure_ac_name; then
265 echo "can't continue"
266 exit 1
270 # do we need to make Makefile.am
271 if test ! -f 'Makefile.am'; then
272 echo "## Makefile.am" >Makefile.am
273 echo "" >>Makefile.am
274 echo "##end" >>Makefile.am
275 echo "Please edit 'Makefile.am' hit Ctrl-D when finished"
277 if test ! -f 'Makefile.am'; then
278 echo "can't continue"
279 exit 1
283 # generating aclocal.m4
284 if test $configure_ac_name -nt 'aclocal.m4'; then
285 echo "aclocal.."
286 $ACLOCAL
289 #run autoconf?
290 if test $configure_ac_name -nt 'configure'; then
291 echo "autoconf.."
292 $AUTOCONF
295 #run autoheader?
296 if grep '^AM_CONFIG_HEADER' $configure_ac_name >/dev/null && test $configure_ac_name -nt 'config.h.in'; then
297 echo "autoheader.."
298 $AUTOHEADER
299 touch config.h.in
303 #run automake?
304 if test 'Makefile.am' -nt 'Makefile.in'; then
305 echo "automake.."
306 test -f NEWS || echo "write me" >NEWS
307 test -f README || echo "write me" >README
308 test -f AUTHORS || echo "write me" >AUTHORS
309 test -f ChangeLog || echo "write me" >ChangeLog
310 $AUTOMAKE -a -c --gnu
313 #nobootstrap end
316 #cd?
317 if test $do_dir = true; then
318 test -d $dir_opt || mkdir -p "$dir_opt"
319 cd $dir_opt
322 #configure help?
323 if test $do_chelp = true; then
324 echo "configure help.."
325 $base_dir/configure --help
326 echo "Please enter configure options and hit [return]:"
327 read configure_new
328 configure_opt="$configure_opt $configure_new"
329 touch $base_dir/configure
332 #configure?
333 if test $do_configure = true; then
334 if test "$base_dir/configure" -nt 'Makefile'; then
335 echo "configure.."
336 $base_dir/configure $configure_opt
340 #build?
341 if test $do_build = true; then
342 echo "building.."
343 $MAKE $build_opt
346 #check?
347 if test $do_check = true; then
348 echo "testing.."
349 $MAKE $build_opt check || {
350 err=$?
351 echo ".. test failed!"
352 exit $err
356 #install?
357 if test $do_install = true; then
358 echo "installing.."
359 $MAKE install-strip
362 #clean?
363 if test $do_clean = true; then
364 echo "cleaning.."
365 $MAKE clean
368 #dist?
369 if test $do_dist = true; then
370 echo "make distribution.."
371 $MAKE distcheck && $MAKE distclean && $MAKE dist
374 #cd back
375 cd $base_dir
377 echo ".. finished! $(date +%H:%M:%S)"
379 # arch-tag: 0b599c55-a968-4c54-bb41-c0ba6472f0df
380 #end