summaryrefslogtreecommitdiff
path: root/bootstrap
blob: 8fc5fec8709720f11a5b0b9c4d6842f88dab510b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#! /bin/sh
#                                               -*- Bootstrap -*-
# Run this file to produce a configure script.

DEFAULT_BOOTSTRAPFLAGS="--force --install --autoreconf=auto"
DEFAULT_CONFIGUREFLAGS="--enable-maintainer-mode --enable-compile-warnings"

OLDDIR=`pwd`

# move to source dir
DIR=`echo $0 | sed 's,[^/]*$,,'`
test -n "$DIR" && cd "$DIR"

if test "$1" = --write-configure; then
	test -f configure && \
	((echo '#! /bin/sh
	        DIR=`echo $0 | sed "s,[^/]*\$,,"`
	        exec ${DIR}bootstrap --configure -- "$@"' > configure \
	  && chmod a+x configure) || \
	 echo Failed writing to configure >&2)

	exit $?
fi

# check if we are invoked as configure, or bootstrap
BASE=`echo $0 | sed 's,.*/,,'`
if test "$BASE" = "configure"; then
	CONFIG=--config
	EXTRA_CONFIGUREFLAGS=$@
else # bootstrap
	EXTRA_BOOTSTRAPFLAGS=$*
fi

for arg in $DEFAULT_BOOTSTRAPFLAGS $BOOTSTRAPFLAGS $EXTRA_BOOTSTRAPFLAGS
do
if test -n "$DASHDASHFLAGS"; then
	DASHDASHFLAGS="$DASHDASHFLAGS $arg"
else
	case $arg in
		-h|--h|--he|--hel|--help)
			HELP=--help ;;
		-V|--vers|--versi|--versio|--version)
			VERSION=--version ;;
		-v|--verb|--verbo|--verbos|--verbose)
			VERBOSE=--verbose ;;
		-d|--de|--deb|--debu|--debug)
			DEBUG=--debug ;;
		-W|--w|--wa|--war|--warn|--warni|--warnin|--warning|--warnings|--warnings=yes|--warnings=all)
			WARNS=--warnings=all ;;
		--no-w|--no-wa|--no-war|--no-warn|--no-warni|--no-warnin|--no-warning|--no-warnings|--warn=no|--warning=no|--warnings=no)
			WARNS=--warnings=none ;;
		--w=*|--wa=*|--war=*|--warn=*|--warni=*|--warnin=*|--warning=*|--warnings=*)
			WARNS=$arg ;;
		-f|--f|--fo|--for|--forc|--force|--forced|--force=yes|--force-missing)
			FORCE=--force ;;
		--no-f|--no-fo|--no-for|--no-forc|--no-force|--no-forced|--force=no)
			FORCE=--no-force ;;
		-i|--i|--in|--ins|--inst|--insta|--instal|--install|--install=yes|-a|--add-missing)
			INSTALL=--install ;;
		--no-i|--no-in|--no-ins|--no-inst|--no-insta|--no-instal|--no-install|--install=no)
			INSTALL= ;;
		-s|--s|--sy|--sym|--syml|--symli|--symlin|--symlink|--symlink=yes|--no-copy|--copy=no)
			SYMLINK=--symlink ;;
		--no-s|--no-sy|--no-sym|--no-syml|--no-symli|--no-symlin|--no-symlink|--symlink=no|--copy|--copy=yes)
			SYMLINK= ;;
		-m|--m|--ma|--mak|--make|--make=yes)
			MAKE=--make
			CONFIG=--configure ;;
		--no-m|--no-ma|--no-mak|--no-make|--make=no)
			MAKE= ;;
		-c|--c|--co|--con|--conf|--confi|--config|--configu|--configur|--configure|--configure=yes)
			CONFIG=--configure ;;
		--no-c|--no-co|--no-con|--no-conf|--no-confi|--no-config|--no-configu|--no-configur|--no-configure|--configure=no)
			CONFIG= ;;
		-n|--dr|--dry|--dry-|--dry-r|--dry-ru|--dry-run)
			DRYRUN=echo ;;
		--auto|--autoreconf=auto)
			AUTORECONF=auto ;;
		--autoreconf|--autoreconf=yes)
			AUTORECONF=yes ;;
		--no-autoreconf|--autoreconf=no)
			AUTORECONF= ;;
		--)
			DASHDASHFLAGS=" " ;;
		*)
			echo Ignoring unknown parameter $arg
	esac
fi
done

test -z "$SYMLINK" && COPY=--copy
test -n "$INSTALL" && ADDMISSING=--add-missing

# use autoreconf if possible, just check for version 2+
if test "$AUTORECONF" = auto; then
	case `autoreconf --version 2>/dev/null` in
		*"autoreconf (GNU Autoconf) 2."* )
			echo Usable autoreconf found, running
		;;
		*)
			AUTORECONF=
		;;
	esac
fi

if test -n "$AUTORECONF";  then
	$DRYRUN autoreconf $HELP $VERSION $VERBOSE $DEBUG $FORCE $INSTALL $SYMLINK $MAKE $WARNS $AUTORECONFFLAGS || exit $?
else

# add files 'config.guess', 'config.sub', 'ltconfig', 'ltmain.sh'
test -f Makefile.am && MY_LIBTOOLIZEFLAGS=--automake

if grep -q '^ *AC_PROG_LIBTOOL' configure.ac configure.in 2>/dev/null; then
	$DRYRUN libtoolize $HELP $VERSION $COPY $DEBUG $FORCE $MY_LIBTOOLIZEFLAGS $LIBTOOLIZEFLAGS || exit $?
fi

# generate 'aclocal.m4'
if test -f configure.ac -o configure.in; then
	$DRYRUN aclocal $HELP $VERSION $VERBOSE $FORCE $ACLOCALFLAGS || exit $?
fi

# generate 'config.h.in'
if test -f configure.ac -o configure.in; then
	$DRYRUN autoheader $HELP $VERSION $VERBOSE $DEBUG $FORCE $WARNS $AUTOHEADERFLAGS || exit $?
fi

#  generate Makefile.in's from Makefile.am's
if test -f Makefile.am; then
	$DRYRUN automake $HELP $VERSION $VERBOSE $ADDMISSING $COPY $FORCE $WARNS $AUTOMAKEFLAGS || exit $?
fi

# generate configure from configure.ac
if test -f configure.ac -o -f configure.in; then
	$DRYRUN autoconf $HELP $VERSION $VERBOSE $DEBUG $FORCE $WARNS $AUTOCONFFLAGS || exit $?
fi

fi # !AUTOCONF

# move to build dir
cd $OLDDIR

# configure
if test -n "$CONFIG"; then
	if test -f ${DIR}configure; then
		$DRYRUN ${DIR}configure $HELP $VERSION $DEFAULT_CONFIGUREFLAGS $CONFIGUREFLAGS $DASHDASHFLAGS $EXTRA_CONFIGUREFLAGS || exit $?
	fi
fi

# make
if test -n "$MAKE"; then
	if test -f Makefile; then
		$DRYRUN make $MAKEFLAGS || exit $?
	fi
fi