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.
24 test ! "$chk_prg_org" && chk_prg_org
="$*"
25 test $# -eq 0 && { echo "lacking on of $chk_prg_org"; exit 1;}
31 if test "$prg" = ""; then
41 #default options (configure this for your package)
44 DEF_CFLAGS_DEBUG
='-O0 -g -W -Wall -Werror -std=gnu99'
45 DEF_CFLAGS_RELEASE
='-O3 -W -Wall -Werror -std=gnu99'
46 DEF_CONFIGUREFLAGS_DEBUG
=''
47 DEF_CONFIGUREFLAGS_RELEASE
='--enable-nobug=RELEASE'
48 DEF_CC
="nice $(chk_prg ccache "") $(chk_prg distcc "") $(chk_prg gcc-3.4 gcc cc)"
50 #default programs (probably no need for configuration)
51 AUTOCONFVERSION
='2.50'
52 AUTOMAKEVERSION
='-1.9'
54 MAKE
="$(chk_prg gmake make)"
55 AUTOSCAN
="$(chk_prg autoscan$AUTOCONFVERSION autoscan)"
56 ACLOCAL
="$(chk_prg aclocal$AUTOMAKEVERSION aclocal)"
57 AUTOCONF
="$(chk_prg autoconf$AUTOCONFVERSION autoconf)"
58 AUTOHEADER
="$(chk_prg autoheader$AUTOCONFVERSION autoheader)"
59 AUTOMAKE
="$(chk_prg automake$AUTOMAKEVERSION)"
62 #commandline parser (needs to be done better / options etc)
76 dir_opt
="$DEF_BUILDDIR"
99 configure_opt
=${i#configure}
120 dir_opt
="${dir_opt:-$DEF_BUILDDIR}"
155 echo "bootstrap a GNU-Autotools Project"
156 echo "usage: bootstrap options..."
157 echo " options can be one or more of:"
158 echo " mrproper - big-clean the project, try's to uninstall previous version"
159 echo " rebuild - mrproper and rebuild from scratch"
160 echo " nobootstrap - don't use autotools, use existing configure"
161 echo " intree - do a build within the sourcetree *BAD!*"
162 echo " cd* - build into a subdir default: ./=build{-release|-debug}"
163 echo " chelp - shows ./configure --help, interactively asks for configure options"
164 echo " configure* - bootstraps the project including ./configure"
165 echo " make* - does a 'make' as well"
166 echo " check - additionally runs tests"
167 echo " install - installs project if checks are passed"
168 echo " clean - cleans up after building"
169 echo " uninstall - try to uninstall allready installed version before proceeding"
170 echo " dist - builds a distribution if all is sane"
171 echo " release - uses 'release' configuration"
172 echo " default: debug for check, release for install"
173 echo " help - this sceen"
174 echo " cd, configure and make can be quoted and appended with options"
176 echo " bootstrap rebuild 'cd build' 'configure --with-x' 'make -j4' dist"
182 #set some vars to defaults
183 if test ! "$build_opt"; then
184 build_opt
="$DEF_BUILDOPT"
187 if test ! "$CONFIGUREFLAGS"; then
188 if test $do_release = true
; then
189 CONFIGUREFLAGS
="$DEF_CONFIGUREFLAGS_RELEASE $EXTRA_CONFIGUREFLAGS"
191 CONFIGUREFLAGS
="$DEF_CONFIGUREFLAGS_DEBUG $EXTRA_CONFIGUREFLAGS"
193 export CONFIGUREFLAGS
196 if test ! "$CFLAGS"; then
197 if test $do_release = true
; then
198 CFLAGS
="$DEF_CFLAGS_RELEASE $EXTRA_CFLAGS"
199 dir_opt
="${dir_opt}.release"
201 CFLAGS
="$DEF_CFLAGS_DEBUG $EXTRA_CFLAGS"
202 dir_opt
="${dir_opt}.debug"
206 if test ! "$CC"; then
213 #first of all we install ourself
214 if test ! -f "$base_dir/bootstrap.sh"; then
215 echo "installing ./bootstrap.sh .."
216 cp -a "$0" "$base_dir/bootstrap.sh"
219 if test $do_nobootstrap = false
; then
221 # old compatibilitry check?
222 configure_ac_name
='configure.ac'
223 if test -f 'configure.in'; then
224 echo "using obsolete configure.in.."
225 configure_ac_name
='configure.in'
228 #we need to go into the build dir for deinstalling and mrproper
229 if test $do_dir = true
; then
230 test -d $dir_opt && cd $dir_opt
233 # uninstall old version?
234 if test $do_uninstall = true
; then
235 if test -f 'Makefile'; then
236 echo "uninstalling.."
241 # check if we want a really clean mrproper
242 if test $do_mrproper = true
; then
244 if test -f 'Makefile'; then
245 $MAKE maintainer-clean
248 rm -f config.
* configure Makefile Makefile.
in
249 test -d "$dir_opt" && chmod -R u
+w
"$dir_opt" && rm -rf $dir_opt
250 test -f $configure_ac_name && touch $configure_ac_name
255 if test $do_stop = true
; then
260 # do we need to make configure.ac
261 if test ! -f $configure_ac_name; then
262 echo "generating configure.ac.."
264 echo "dnl Note from bootstrap:" >$configure_ac_name
265 echo "dnl this scan is not yet configured for automake" >>$configure_ac_name
266 echo "dnl add at least the following macros" >>$configure_ac_name
267 echo "dnl AM_INIT_AUTOMAKE( name , version )" >>$configure_ac_name
268 echo "dnl AM_CONFIG_HEADER([config.h])" >>$configure_ac_name
269 echo "dnl and don't forget to insert Makefile in AC_CONFIG_FILES()" >>$configure_ac_name
270 echo "dnl end_of_note" >>$configure_ac_name
271 cat configure.scan
>>$configure_ac_name
273 echo "Please edit $configure_ac_name hit Ctrl-D when finished"
275 if test ! -f $configure_ac_name; then
276 echo "can't continue"
281 # do we need to make Makefile.am
282 if test ! -f 'Makefile.am'; then
283 echo "## Makefile.am" >Makefile.am
284 echo "" >>Makefile.am
285 echo "##end" >>Makefile.am
286 echo "Please edit 'Makefile.am' hit Ctrl-D when finished"
288 if test ! -f 'Makefile.am'; then
289 echo "can't continue"
294 # generating aclocal.m4
295 if test $configure_ac_name -nt 'aclocal.m4'; then
301 if test $configure_ac_name -nt 'configure'; then
307 if grep '^AM_CONFIG_HEADER' $configure_ac_name >/dev
/null
&& test $configure_ac_name -nt 'config.h.in'; then
315 if test 'Makefile.am' -nt 'Makefile.in'; then
317 test -f NEWS ||
echo "write me" >NEWS
318 test -f README ||
echo "write me" >README
319 test -f AUTHORS ||
echo "write me" >AUTHORS
320 test -f ChangeLog ||
echo "write me" >ChangeLog
321 $AUTOMAKE -a -c --gnu
328 if test $do_dir = true
; then
329 test -d $dir_opt || mkdir
-p "$dir_opt"
334 if test $do_chelp = true
; then
335 echo "configure help.."
336 $base_dir/configure
--help
337 echo "Please enter configure options and hit [return]:"
339 configure_opt
="$configure_opt $configure_new"
340 touch $base_dir/configure
344 if test $do_configure = true
; then
345 if test "$base_dir/configure" -nt 'Makefile'; then
347 $base_dir/configure
$CONFIGUREFLAGS $configure_opt
352 if test $do_build = true
; then
358 if test $do_check = true
; then
360 $MAKE $build_opt check ||
{
362 echo ".. test failed!"
368 if test $do_install = true
; then
374 if test $do_clean = true
; then
380 if test $do_dist = true
; then
381 echo "make distribution.."
382 $MAKE distcheck
&& $MAKE distclean
&& $MAKE dist
388 echo ".. finished! $(date +%H:%M:%S)"
390 # arch-tag: 0b599c55-a968-4c54-bb41-c0ba6472f0df