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 MAKE
="$(chk_prg gmake make)"
50 AUTOSCAN
="$(chk_prg autoscan)"
51 ACLOCAL
="$(chk_prg aclocal)"
52 AUTOCONF
="$(chk_prg autoconf)"
53 AUTOHEADER
="$(chk_prg autoheader)"
54 AUTOMAKE
="$(chk_prg automake)"
57 #commandline parser (needs to be done better / options etc)
71 dir_opt
="$DEF_BUILDDIR"
94 configure_opt
=${i#configure}
109 dir_opt
="${dir_opt:-$DEF_BUILDDIR}"
144 echo "bootstrap a GNU-Autotools Project"
145 echo "usage: bootstrap options..."
146 echo " options can be one or more of:"
147 echo " mrproper - big-clean the project, try's to uninstall previous version"
148 echo " rebuild - mrproper and rebuild from scratch"
149 echo " nobootstrap - don't use autotools, use existing configure"
150 echo " intree - do a build within the sourcetree *BAD!*"
151 echo " cd* - build into a subdir default: ./=build{-release|-debug}"
152 echo " chelp - shows ./configure --help, interactively asks for configure options"
153 echo " configure* - bootstraps the project including ./configure"
154 echo " make* - does a 'make' as well"
155 echo " check - additionally runs tests"
156 echo " install - installs project if checks are passed"
157 echo " clean - cleans up after building"
158 echo " uninstall - try to uninstall allready installed version before proceeding"
159 echo " dist - builds a distribution if all is sane"
160 echo " release - uses 'release' configuration"
161 echo " default: debug for check, release for install"
162 echo " help - this sceen"
163 echo " cd, configure and make can be quoted and appended with options"
165 echo " bootstrap rebuild 'cd build' 'configure --with-x' 'make -j4' dist"
171 #set some vars to defaults
172 if test ! "$build_opt"; then
173 build_opt
="$DEF_BUILDOPT"
176 if test ! "$CFLAGS"; then
177 if test $do_release = true
; then
178 CFLAGS
="$DEF_CFLAGS_RELEASE $EXTRA_CFLAGS"
179 dir_opt
="${dir_opt}.release"
181 CFLAGS
="$DEF_CFLAGS_DEBUG $EXTRA_CFLAGS"
182 dir_opt
="${dir_opt}.debug"
186 if test ! "$CC"; then
193 #first of all we install ourself
194 if test ! -f "$base_dir/bootstrap.sh"; then
195 echo "installing ./bootstrap.sh .."
196 cp -a "$0" "$base_dir/bootstrap.sh"
199 if test $do_nobootstrap = false
; then
201 # old compatibilitry check?
202 configure_ac_name
='configure.ac'
203 if test -f 'configure.in'; then
204 echo "using obsolete configure.in.."
205 configure_ac_name
='configure.in'
208 #we need to go into the build dir for deinstalling and mrproper
209 if test $do_dir = true
; then
210 test -d $dir_opt && cd $dir_opt
213 # uninstall old version?
214 if test $do_uninstall = true
; then
215 if test -f 'Makefile'; then
216 echo "uninstalling.."
221 # check if we want a really clean mrproper
222 if test $do_mrproper = true
; then
224 if test -f 'Makefile'; then
225 $MAKE maintainer-clean
228 rm -f config.
* configure Makefile Makefile.
in
229 test -d "$dir_opt" && chmod -R u
+w
"$dir_opt" && rm -rf $dir_opt
230 test -f $configure_ac_name && touch $configure_ac_name
235 if test $do_stop = true
; then
240 # do we need to make configure.ac
241 if test ! -f $configure_ac_name; then
242 echo "generating configure.ac.."
244 echo "dnl Note from bootstrap:" >$configure_ac_name
245 echo "dnl this scan is not yet configured for automake" >>$configure_ac_name
246 echo "dnl add at least the following macros" >>$configure_ac_name
247 echo "dnl AM_INIT_AUTOMAKE( name , version )" >>$configure_ac_name
248 echo "dnl AM_CONFIG_HEADER([config.h])" >>$configure_ac_name
249 echo "dnl and don't forget to insert Makefile in AC_CONFIG_FILES()" >>$configure_ac_name
250 echo "dnl end_of_note" >>$configure_ac_name
251 cat configure.scan
>>$configure_ac_name
253 echo "Please edit $configure_ac_name hit Ctrl-D when finished"
255 if test ! -f $configure_ac_name; then
256 echo "can't continue"
261 # do we need to make Makefile.am
262 if test ! -f 'Makefile.am'; then
263 echo "## Makefile.am" >Makefile.am
264 echo "" >>Makefile.am
265 echo "##end" >>Makefile.am
266 echo "Please edit 'Makefile.am' hit Ctrl-D when finished"
268 if test ! -f 'Makefile.am'; then
269 echo "can't continue"
274 # generating aclocal.m4
275 if test $configure_ac_name -nt 'aclocal.m4'; then
281 if test $configure_ac_name -nt 'configure'; then
287 if grep '^AM_CONFIG_HEADER' $configure_ac_name >/dev
/null
&& test $configure_ac_name -nt 'config.h.in'; then
295 if test 'Makefile.am' -nt 'Makefile.in'; then
297 test -f NEWS ||
echo "write me" >NEWS
298 test -f README ||
echo "write me" >README
299 test -f AUTHORS ||
echo "write me" >AUTHORS
300 test -f ChangeLog ||
echo "write me" >ChangeLog
301 $AUTOMAKE -a -c --gnu
308 if test $do_dir = true
; then
309 test -d $dir_opt || mkdir
-p "$dir_opt"
314 if test $do_chelp = true
; then
315 echo "configure help.."
316 $base_dir/configure
--help
317 echo "Please enter configure options and hit [return]:"
319 configure_opt
="$configure_opt $configure_new"
320 touch $base_dir/configure
324 if test $do_configure = true
; then
325 if test "$base_dir/configure" -nt 'Makefile'; then
327 $base_dir/configure
$configure_opt
332 if test $do_build = true
; then
338 if test $do_check = true
; then
340 $MAKE $build_opt check ||
{
342 echo ".. test failed!"
348 if test $do_install = true
; then
354 if test $do_clean = true
; then
360 if test $do_dist = true
; then
361 echo "make distribution.."
362 $MAKE distcheck
&& $MAKE distclean
&& $MAKE dist
370 # arch-tag: 0b599c55-a968-4c54-bb41-c0ba6472f0df