findlinks, mklinks, mdw-setup: Spruce up style.
[cfd] / mdw-setup
1 #! /bin/sh
2 ### -*-sh-*-
3 ###
4 ### Create links to the repository
5 ###
6 ### (c) 1997 Mark Wooding
7 ###
8
9 ###----- Licensing notice ---------------------------------------------------
10 ###
11 ### This file is part of the Common Files Distribution (`common').
12 ###
13 ### `Common' is free software; you can redistribute it and/or modify
14 ### it under the terms of the GNU General Public License as published by
15 ### the Free Software Foundation; either version 2 of the License, or
16 ### (at your option) any later version.
17 ###
18 ### `Common' is distributed in the hope that it will be useful,
19 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ### GNU General Public License for more details.
22 ###
23 ### You should have received a copy of the GNU General Public License
24 ### along with `common'; if not, write to the Free Software Foundation,
25 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27 set -e
28
29 ###--------------------------------------------------------------------------
30 ### Basic setup stuff.
31
32 ego=$(echo "$0" | sed 's:^.*[/\\]::; s:\.*$::')
33 usage="Usage: $ego"
34
35 ###--------------------------------------------------------------------------
36 ### Parse command line arguments.
37
38 while [ $# -gt 0 ]; do
39 case "$1" in
40 --help | -h | --usage | -u)
41 echo "$usage"
42 exit
43 ;;
44 --)
45 shift
46 break
47 ;;
48 -*)
49 echo >&2 "$ego: unknown option \`$1'"
50 exit 1
51 ;;
52 esac
53 shift
54 done
55
56 if [ $# -ne 0 ]; then
57 echo >&2 "$usage"
58 exit 1
59 fi
60
61 ###--------------------------------------------------------------------------
62 ### Link any strange common files we need.
63
64 [ -f .links ] && mklinks
65
66 ###--------------------------------------------------------------------------
67 ### Do any initial local stuff.
68
69 [ -x build-setup ] && ./build-setup start
70
71 ###--------------------------------------------------------------------------
72 ### Grind through the Autoconf machinery.
73
74 configure=
75 for i in configure.ac configure.in; do
76 [ -f $i ] && configure=$i
77 done
78 if [ "$configure" ]; then
79 grep >/dev/null AM_PROG_LIBTOOL $configure && libtoolize
80 find . -name Makefile.m4 -print | while read m4; do
81 dir=$(echo $m4 | sed 's:/[^/]*$::')
82 (cd $dir &&
83 m4 Makefile.m4 >Makefile.am.new &&
84 mv Makefile.am.new Makefile.am)
85 done
86 aclocalargs=
87 for i in config m4; do [ -d $i ] && aclocalargs="$aclocalargs -I $i"; done
88 aclocal $aclocalargs
89 autoconf --force
90 if grep >/dev/null 'AC_CONFIG_AUX_DIR' $configure; then
91 auxdir=$(
92 sed -n 's:^.*AC_CONFIG_AUX_DIR(\[\?\([^])]*\)\]\?).*$:\1:p' $configure)
93 mkdir -p $auxdir
94 fi
95 grep >/dev/null 'A[MC]_CONFIG_HEADER' $configure && autoheader
96 [ -f Makefile.am ] && automake -a
97 fi
98
99 ###--------------------------------------------------------------------------
100 ### Do any final local stuff.
101
102 [ -x build-setup ] && ./build-setup end
103
104 ###------ That's all, folks -------------------------------------------------