mdw-setup: Fix for constructing Makefile.am from m4 source.
[cfd] / mdw-setup
CommitLineData
30a4312c
MW
1#! /bin/sh
2
3set -e
4
5### Basic setup stuff
6ego=$(echo "$0" | sed 's:^.*[/\\]::; s:\.*$::')
7usage="Usage: $ego [--debian]"
8
9### Parse options
10debian=no
11while [ $# -gt 0 ]; do
12 case "$1" in
13 --help | -h | --usage | -u)
14 echo "$usage"
15 exit
16 ;;
17 --debian)
18 debian=yes
19 ;;
20 --)
21 shift
22 break
23 ;;
24 -*)
25 echo >&2 "$ego: unknown option \`$1'"
26 exit 1
27 ;;
28 esac
29 shift
30done
31if [ $# -ne 0 ]; then
32 echo >&2 "$usage"
33 exit 1
34fi
35
36### Link any strange common files we need
37[ -f .links ] && mklinks
38
39### Grind through the Autoconf machinery
40configure=
41for i in configure.ac configure.in; do
42 [ -f $i ] && configure=$i
43done
44if [ "$configure" ]; then
45 grep >/dev/null AM_PROG_LIBTOOL $configure && libtoolize
46 find . -name Makefile.m4 -print | while read m4; do
3dc9c14b
MW
47 dir=$(echo $m4 | sed 's:/[^/]*$::')
48 (cd $dir &&
49 m4 Makefile.m4 >Makefile.am.new &&
50 mv Makefile.am.new Makefile.am)
30a4312c
MW
51 done
52 mkaclocal
53 autoconf
54 grep >/dev/null AM_CONFIG_HEADER $configure && autoheader
55 [ -f Makefile.am ] && automake -a
56fi
57
58### Maybe make a build directory
59[ $debian = no ] && [ ! -e build ] && mkdir build