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
='-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)
74 dir_opt
="$DEF_BUILDDIR"
97 configure_opt
=${i#configure}
112 dir_opt
="${dir_opt:-$DEF_BUILDDIR}"
147 echo "bootstrap a GNU-Autotools Project"
148 echo "usage: bootstrap options..."
149 echo " options can be one or more of:"
150 echo " mrproper - big-clean the project, try's to uninstall previous version"
151 echo " rebuild - mrproper and rebuild from scratch"
152 echo " nobootstrap - don't use autotools, use existing configure"
153 echo " intree - do a build within the sourcetree *BAD!*"
154 echo " cd* - build into a subdir default: ./=build{-release|-debug}"
155 echo " chelp - shows ./configure --help, interactively asks for configure options"
156 echo " configure* - bootstraps the project including ./configure"
157 echo " make* - does a 'make' as well"
158 echo " check - additionally runs tests"
159 echo " install - installs project if checks are passed"
160 echo " clean - cleans up after building"
161 echo " uninstall - try to uninstall allready installed version before proceeding"
162 echo " dist - builds a distribution if all is sane"
163 echo " release - uses 'release' configuration"
164 echo " default: debug for check, release for install"
165 echo " help - this sceen"
166 echo " cd, configure and make can be quoted and appended with options"
168 echo " bootstrap rebuild 'cd build' 'configure --with-x' 'make -j4' dist"
174 #set some vars to defaults
175 if test ! "$build_opt"; then
176 build_opt
="$DEF_BUILDOPT"
179 if test ! "$CFLAGS"; then
180 if test $do_release = true
; then
181 CFLAGS
="$DEF_CFLAGS_RELEASE $EXTRA_CFLAGS"
182 dir_opt
="${dir_opt}.release"
184 CFLAGS
="$DEF_CFLAGS_DEBUG $EXTRA_CFLAGS"
185 dir_opt
="${dir_opt}.debug"
189 if test ! "$CC"; then
196 #first of all we install ourself
197 if test ! -f "$base_dir/bootstrap.sh"; then
198 echo "installing ./bootstrap.sh .."
199 cp -a "$0" "$base_dir/bootstrap.sh"
202 if test $do_nobootstrap = false
; then
204 # old compatibilitry check?
205 configure_ac_name
='configure.ac'
206 if test -f 'configure.in'; then
207 echo "using obsolete configure.in.."
208 configure_ac_name
='configure.in'
211 #we need to go into the build dir for deinstalling and mrproper
212 if test $do_dir = true
; then
213 test -d $dir_opt && cd $dir_opt
216 # uninstall old version?
217 if test $do_uninstall = true
; then
218 if test -f 'Makefile'; then
219 echo "uninstalling.."
224 # check if we want a really clean mrproper
225 if test $do_mrproper = true
; then
227 if test -f 'Makefile'; then
228 $MAKE maintainer-clean
231 rm -f config.
* configure Makefile Makefile.
in
232 test -d "$dir_opt" && chmod -R u
+w
"$dir_opt" && rm -rf $dir_opt
233 test -f $configure_ac_name && touch $configure_ac_name
238 if test $do_stop = true
; then
243 # do we need to make configure.ac
244 if test ! -f $configure_ac_name; then
245 echo "generating configure.ac.."
247 echo "dnl Note from bootstrap:" >$configure_ac_name
248 echo "dnl this scan is not yet configured for automake" >>$configure_ac_name
249 echo "dnl add at least the following macros" >>$configure_ac_name
250 echo "dnl AM_INIT_AUTOMAKE( name , version )" >>$configure_ac_name
251 echo "dnl AM_CONFIG_HEADER([config.h])" >>$configure_ac_name
252 echo "dnl and don't forget to insert Makefile in AC_CONFIG_FILES()" >>$configure_ac_name
253 echo "dnl end_of_note" >>$configure_ac_name
254 cat configure.scan
>>$configure_ac_name
256 echo "Please edit $configure_ac_name hit Ctrl-D when finished"
258 if test ! -f $configure_ac_name; then
259 echo "can't continue"
264 # do we need to make Makefile.am
265 if test ! -f 'Makefile.am'; then
266 echo "## Makefile.am" >Makefile.am
267 echo "" >>Makefile.am
268 echo "##end" >>Makefile.am
269 echo "Please edit 'Makefile.am' hit Ctrl-D when finished"
271 if test ! -f 'Makefile.am'; then
272 echo "can't continue"
277 # generating aclocal.m4
278 if test $configure_ac_name -nt 'aclocal.m4'; then
284 if test $configure_ac_name -nt 'configure'; then
290 if grep '^AM_CONFIG_HEADER' $configure_ac_name >/dev
/null
&& test $configure_ac_name -nt 'config.h.in'; then
298 if test 'Makefile.am' -nt 'Makefile.in'; then
300 test -f NEWS ||
echo "write me" >NEWS
301 test -f README ||
echo "write me" >README
302 test -f AUTHORS ||
echo "write me" >AUTHORS
303 test -f ChangeLog ||
echo "write me" >ChangeLog
304 $AUTOMAKE -a -c --gnu
311 if test $do_dir = true
; then
312 test -d $dir_opt || mkdir
-p "$dir_opt"
317 if test $do_chelp = true
; then
318 echo "configure help.."
319 $base_dir/configure
--help
320 echo "Please enter configure options and hit [return]:"
322 configure_opt
="$configure_opt $configure_new"
323 touch $base_dir/configure
327 if test $do_configure = true
; then
328 if test "$base_dir/configure" -nt 'Makefile'; then
330 $base_dir/configure
$configure_opt
335 if test $do_build = true
; then
341 if test $do_check = true
; then
343 $MAKE $build_opt check ||
{
345 echo ".. test failed!"
351 if test $do_install = true
; then
357 if test $do_clean = true
; then
363 if test $do_dist = true
; then
364 echo "make distribution.."
365 $MAKE distcheck
&& $MAKE distclean
&& $MAKE dist
373 # arch-tag: 0b599c55-a968-4c54-bb41-c0ba6472f0df