1 | #!/bin/sh |
---|
2 | # |
---|
3 | # helps bootstrapping, when checked out from CVS |
---|
4 | # requires GNU autoconf and GNU automake |
---|
5 | # |
---|
6 | # $Id$ |
---|
7 | |
---|
8 | # this is not meant to be exported outside the source tree |
---|
9 | |
---|
10 | # NOTE: Inspired by libtool's autogen script |
---|
11 | |
---|
12 | # to be run from the toplevel directory of RTEMS' |
---|
13 | # source tree |
---|
14 | |
---|
15 | AUTOCONF_VERS=2.52 |
---|
16 | AUTOMAKE_VERS=1.6.[123] |
---|
17 | |
---|
18 | progname=`basename $0` |
---|
19 | top_srcdir=`dirname $0` |
---|
20 | |
---|
21 | verbose=""; |
---|
22 | quiet="false" |
---|
23 | mode="generate" |
---|
24 | |
---|
25 | usage() |
---|
26 | { |
---|
27 | echo |
---|
28 | echo "usage: ${progname} [-h|-q|-v]" |
---|
29 | echo |
---|
30 | echo "options:" |
---|
31 | echo " -h .. display this message and exit"; |
---|
32 | echo " -q .. quiet, don't display directories"; |
---|
33 | echo " -v .. verbose, pass -v to automake when invoking automake" |
---|
34 | echo " -c .. clean, remove all aclocal/autoconf/automake generated files" |
---|
35 | echo |
---|
36 | exit 1; |
---|
37 | } |
---|
38 | |
---|
39 | if test ! -f $top_srcdir/aclocal/version.m4; then |
---|
40 | echo "${progname}:" |
---|
41 | echo " Installation problem: Can't find file aclocal/version.m4" |
---|
42 | exit 1; |
---|
43 | fi |
---|
44 | |
---|
45 | while test $# -gt 0; do |
---|
46 | case $1 in |
---|
47 | -h|--he|--hel|--help) |
---|
48 | usage ;; |
---|
49 | -q|--qu|--qui|--quie|--quiet) |
---|
50 | quiet="true"; |
---|
51 | shift;; |
---|
52 | -v|--ve|--ver|--verb|--verbo|--verbos|--verbose) |
---|
53 | verbose="-v"; |
---|
54 | shift;; |
---|
55 | -c|--cl|--cle|--clea|--clean) |
---|
56 | mode="clean"; |
---|
57 | shift;; |
---|
58 | -*) echo "unknown option $1" ; |
---|
59 | usage ;; |
---|
60 | *) echo "invalid parameter $1" ; |
---|
61 | usage ;; |
---|
62 | esac |
---|
63 | done |
---|
64 | |
---|
65 | case $mode in |
---|
66 | generate) |
---|
67 | AUTOCONF=${AUTOCONF-`which autoconf`} |
---|
68 | if test -z "$AUTOCONF"; then |
---|
69 | echo "You must have autoconf installed to run $program" |
---|
70 | fi |
---|
71 | AUTOCONF_VER=`$AUTOCONF --version 2>/dev/null` |
---|
72 | if test -z "`echo $AUTOCONF_VER | grep \" $AUTOCONF_VERS\"`"; then |
---|
73 | cat << EOF |
---|
74 | RTEMS requires autoconf version $AUTOCONF_VERS. |
---|
75 | |
---|
76 | You are trying to use $AUTOCONF which does not seem to be sufficient |
---|
77 | EOF |
---|
78 | exit 1 |
---|
79 | fi |
---|
80 | |
---|
81 | AUTOMAKE=${AUTOMAKE-`which automake`} |
---|
82 | if test -z "$AUTOMAKE"; then |
---|
83 | echo "You must have automake installed to run $program" |
---|
84 | fi |
---|
85 | AUTOMAKE_VER=`$AUTOMAKE --version 2>/dev/null` |
---|
86 | if test -z "`echo $AUTOMAKE_VER | grep \" $AUTOMAKE_VERS\"`"; then |
---|
87 | cat << EOF |
---|
88 | RTEMS requires automake version $AUTOMAKE_VERS. |
---|
89 | |
---|
90 | You are trying to use $AUTOMAKE which does not seem to be sufficient |
---|
91 | EOF |
---|
92 | exit 1 |
---|
93 | fi |
---|
94 | |
---|
95 | case $top_srcdir in |
---|
96 | /* ) aclocal_dir=$top_srcdir |
---|
97 | ;; |
---|
98 | *) aclocal_dir=`pwd`/$top_srcdir |
---|
99 | ;; |
---|
100 | esac |
---|
101 | |
---|
102 | confs=`find . \( -name 'configure.in' -o -name 'configure.ac' \) -print` |
---|
103 | for i in $confs; do |
---|
104 | dir=`dirname $i`; |
---|
105 | configure=`basename $i`; |
---|
106 | ( test "$quiet" = "true" || echo "$dir"; |
---|
107 | cd $dir; |
---|
108 | pat="s,\$(RTEMS_TOPdir),${aclocal_dir},g" |
---|
109 | aclocal_args=`grep '^[ ]*ACLOCAL_AMFLAGS' Makefile.am | \ |
---|
110 | sed -e 's%.*ACLOCAL_AMFLAGS.*\=[ ]*%%g' -e $pat ` ; |
---|
111 | test "$verbose" = "-v" && echo "aclocal $aclocal_args" |
---|
112 | aclocal $aclocal_args; |
---|
113 | test -n "`grep CONFIG_HEADER ${configure}`" && autoheader \ |
---|
114 | && test "$verbose" = "-v" && echo "autoheader"; |
---|
115 | test -n "`grep RTEMS_BSP_CONFIGURE ${configure}`" && autoheader \ |
---|
116 | && test "$verbose" = "-v" && echo "autoheader"; |
---|
117 | test -f Makefile.am && automake -a -c $verbose ; |
---|
118 | autoconf; |
---|
119 | test -f Makefile.am && test -n "`grep 'stamp-h\.in' Makefile.in`" \ |
---|
120 | && echo timestamp > stamp-h.in |
---|
121 | ) |
---|
122 | done |
---|
123 | ;; |
---|
124 | |
---|
125 | clean) |
---|
126 | test "$quiet" = "true" || echo "removing automake generated Makefile.in files" |
---|
127 | files=`find . -name 'Makefile.am' -print | sed -e 's%\.am%\.in%g'` ; |
---|
128 | for i in $files; do if test -f $i; then |
---|
129 | rm -f $i |
---|
130 | test "$verbose" = "-v" && echo "$i" |
---|
131 | fi; done |
---|
132 | |
---|
133 | test "$quiet" = "true" || echo "removing configure files" |
---|
134 | files=`find . -name 'configure' -print` ; |
---|
135 | test "$verbose" = "-v" && test -n "$files" && echo "$files" ; |
---|
136 | for i in $files; do if test -f $i; then |
---|
137 | rm -f $i config.guess config.sub depcomp install-sh mdate-sh missing \ |
---|
138 | mkinstalldirs texinfo.tex |
---|
139 | test "$verbose" = "-v" && echo "$i" |
---|
140 | fi; done |
---|
141 | |
---|
142 | test "$quiet" = "true" || echo "removing aclocal.m4 files" |
---|
143 | files=`find . -name 'aclocal.m4' -print` ; |
---|
144 | test "$verbose" = "-v" && test -n "$files" && echo "$files" ; |
---|
145 | for i in $files; do if test -f $i; then |
---|
146 | rm -f $i |
---|
147 | test "$verbose" = "-v" && echo "$i" |
---|
148 | fi; done |
---|
149 | |
---|
150 | find . -name '*~' -print | xargs rm -f |
---|
151 | find . -name 'bspopts.h*' -print | xargs rm -f |
---|
152 | find . -name '*.orig' -print | xargs rm -f |
---|
153 | find . -name '*.rej' -print | xargs rm -f |
---|
154 | find . -name 'config.status' -print | xargs rm -f |
---|
155 | find . -name 'config.log' -print | xargs rm -f |
---|
156 | find . -name 'config.cache' -print | xargs rm -f |
---|
157 | find . -name 'Makefile' -print | xargs rm -f |
---|
158 | find . -name '.deps' -print | xargs rm -rf |
---|
159 | find . -name '.libs' -print | xargs rm -rf |
---|
160 | find . -name 'stamp-h.in' | xargs rm -rf |
---|
161 | ;; |
---|
162 | esac |
---|