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}
118 dir_opt
="${dir_opt:-$DEF_BUILDDIR}"
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"
174 echo " bootstrap rebuild 'cd build' 'configure --with-x' 'make -j4' dist"
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"
190 CFLAGS
="$DEF_CFLAGS_DEBUG $EXTRA_CFLAGS"
191 dir_opt
="${dir_opt}.debug"
195 if test ! "$CC"; then
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.."
230 # check if we want a really clean mrproper
231 if test $do_mrproper = true
; then
233 if test -f 'Makefile'; then
234 $MAKE maintainer-clean
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
244 if test $do_stop = true
; then
249 # do we need to make configure.ac
250 if test ! -f $configure_ac_name; then
251 echo "generating configure.ac.."
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
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"
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"
283 # generating aclocal.m4
284 if test $configure_ac_name -nt 'aclocal.m4'; then
290 if test $configure_ac_name -nt 'configure'; then
296 if grep '^AM_CONFIG_HEADER' $configure_ac_name >/dev
/null
&& test $configure_ac_name -nt 'config.h.in'; then
304 if test 'Makefile.am' -nt 'Makefile.in'; then
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
317 if test $do_dir = true
; then
318 test -d $dir_opt || mkdir
-p "$dir_opt"
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]:"
328 configure_opt
="$configure_opt $configure_new"
329 touch $base_dir/configure
333 if test $do_configure = true
; then
334 if test "$base_dir/configure" -nt 'Makefile'; then
336 $base_dir/configure
$configure_opt
341 if test $do_build = true
; then
347 if test $do_check = true
; then
349 $MAKE $build_opt check ||
{
351 echo ".. test failed!"
357 if test $do_install = true
; then
363 if test $do_clean = true
; then
369 if test $do_dist = true
; then
370 echo "make distribution.."
371 $MAKE distcheck
&& $MAKE distclean
&& $MAKE dist
377 echo ".. finished! $(date +%H:%M:%S)"
379 # arch-tag: 0b599c55-a968-4c54-bb41-c0ba6472f0df