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\.5[47] |
---|
16 | AUTOMAKE_VERS=1\.7\.2 |
---|
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 | generate_bspdir_acinclude() |
---|
40 | { |
---|
41 | cat << EOF > acinclude.m4~ |
---|
42 | # RTEMS_CHECK_BSPDIR(RTEMS_BSP) |
---|
43 | AC_DEFUN([RTEMS_CHECK_BSPDIR], |
---|
44 | [ |
---|
45 | RTEMS_BSP_ALIAS(ifelse([\$1],,[\${RTEMS_BSP}],[\$1]),bspdir) |
---|
46 | case "\$bspdir" in |
---|
47 | EOF |
---|
48 | |
---|
49 | for i in */bsp_specs; do |
---|
50 | d=`dirname $i` |
---|
51 | cat << EOF >> acinclude.m4~ |
---|
52 | $d ) |
---|
53 | AC_CONFIG_SUBDIRS([$d]);; |
---|
54 | EOF |
---|
55 | done |
---|
56 | cat << EOF >> acinclude.m4~ |
---|
57 | *) |
---|
58 | AC_MSG_ERROR([Invalid BSP]);; |
---|
59 | esac |
---|
60 | ]) |
---|
61 | EOF |
---|
62 | if cmp -s acinclude.m4 acinclude.m4~ 2>/dev/null; then |
---|
63 | echo "acinclude.m4 is unchanged"; |
---|
64 | else |
---|
65 | cp acinclude.m4~ acinclude.m4 |
---|
66 | fi |
---|
67 | rm -f acinclude.m4~ |
---|
68 | } |
---|
69 | |
---|
70 | if test ! -f $top_srcdir/aclocal/version.m4; then |
---|
71 | echo "${progname}:" |
---|
72 | echo " Installation problem: Can't find file aclocal/version.m4" |
---|
73 | exit 1; |
---|
74 | fi |
---|
75 | |
---|
76 | while test $# -gt 0; do |
---|
77 | case $1 in |
---|
78 | -h|--he|--hel|--help) |
---|
79 | usage ;; |
---|
80 | -q|--qu|--qui|--quie|--quiet) |
---|
81 | quiet="true"; |
---|
82 | shift;; |
---|
83 | -v|--ve|--ver|--verb|--verbo|--verbos|--verbose) |
---|
84 | verbose="-v"; |
---|
85 | shift;; |
---|
86 | -c|--cl|--cle|--clea|--clean) |
---|
87 | mode="clean"; |
---|
88 | shift;; |
---|
89 | -*) echo "unknown option $1" ; |
---|
90 | usage ;; |
---|
91 | *) echo "invalid parameter $1" ; |
---|
92 | usage ;; |
---|
93 | esac |
---|
94 | done |
---|
95 | |
---|
96 | case $mode in |
---|
97 | generate) |
---|
98 | AUTOCONF=${AUTOCONF-`which autoconf`} |
---|
99 | if test -z "$AUTOCONF"; then |
---|
100 | echo "You must have autoconf installed to run $program" |
---|
101 | fi |
---|
102 | if test -z "`$AUTOCONF --version 2>/dev/null | grep -e \" $AUTOCONF_VERS\"`"; then |
---|
103 | cat << EOF |
---|
104 | RTEMS requires autoconf version $AUTOCONF_VERS. |
---|
105 | |
---|
106 | You are trying to use $AUTOCONF which does not seem to be sufficient |
---|
107 | EOF |
---|
108 | exit 1 |
---|
109 | fi |
---|
110 | |
---|
111 | AUTOMAKE=${AUTOMAKE-`which automake`} |
---|
112 | if test -z "$AUTOMAKE"; then |
---|
113 | echo "You must have automake installed to run $program" |
---|
114 | fi |
---|
115 | if test -z "`$AUTOMAKE --version 2>/dev/null | grep -e \" $AUTOMAKE_VERS\"`"; then |
---|
116 | cat << EOF |
---|
117 | RTEMS requires automake version $AUTOMAKE_VERS. |
---|
118 | |
---|
119 | You are trying to use $AUTOMAKE which does not seem to be sufficient |
---|
120 | EOF |
---|
121 | exit 1 |
---|
122 | fi |
---|
123 | |
---|
124 | case $top_srcdir in |
---|
125 | /* ) aclocal_dir=$top_srcdir |
---|
126 | ;; |
---|
127 | *) aclocal_dir=`pwd`/$top_srcdir |
---|
128 | ;; |
---|
129 | esac |
---|
130 | |
---|
131 | confs=`find . \( -name 'configure.in' -o -name 'configure.ac' \) -print` |
---|
132 | for i in $confs; do |
---|
133 | dir=`dirname $i`; |
---|
134 | configure=`basename $i`; |
---|
135 | ( test "$quiet" = "true" || echo "$dir"; |
---|
136 | cd $dir; |
---|
137 | test -n "`grep RTEMS_CHECK_BSPDIR ${configure}`" && \ |
---|
138 | generate_bspdir_acinclude; |
---|
139 | pat="s,\$(RTEMS_TOPdir),${aclocal_dir},g" |
---|
140 | aclocal_args=`grep '^[ ]*ACLOCAL_AMFLAGS' Makefile.am | \ |
---|
141 | sed -e 's%.*ACLOCAL_AMFLAGS.*\=[ ]*%%g' -e $pat ` ; |
---|
142 | test "$verbose" = "-v" && echo "aclocal $aclocal_args" |
---|
143 | aclocal $aclocal_args; |
---|
144 | test -n "`grep CONFIG_HEADER ${configure}`" && autoheader \ |
---|
145 | && test "$verbose" = "-v" && echo "autoheader"; |
---|
146 | test -n "`grep RTEMS_BSP_CONFIGURE ${configure}`" && autoheader \ |
---|
147 | && test "$verbose" = "-v" && echo "autoheader"; |
---|
148 | test -f Makefile.am && automake -a -c $verbose ; |
---|
149 | autoconf; |
---|
150 | test -f Makefile.am && test -n "`grep 'stamp-h\.in' Makefile.in`" \ |
---|
151 | && echo timestamp > stamp-h.in |
---|
152 | ) |
---|
153 | done |
---|
154 | ;; |
---|
155 | |
---|
156 | clean) |
---|
157 | test "$quiet" = "true" || echo "removing automake generated Makefile.in files" |
---|
158 | files=`find . -name 'Makefile.am' -print | sed -e 's%\.am%\.in%g'` ; |
---|
159 | for i in $files; do if test -f $i; then |
---|
160 | rm -f $i |
---|
161 | test "$verbose" = "-v" && echo "$i" |
---|
162 | fi; done |
---|
163 | |
---|
164 | test "$quiet" = "true" || echo "removing configure files" |
---|
165 | files=`find . -name 'configure' -print` ; |
---|
166 | test "$verbose" = "-v" && test -n "$files" && echo "$files" ; |
---|
167 | for i in $files; do if test -f $i; then |
---|
168 | rm -f $i config.guess config.sub depcomp install-sh mdate-sh missing \ |
---|
169 | mkinstalldirs texinfo.tex |
---|
170 | test "$verbose" = "-v" && echo "$i" |
---|
171 | fi; done |
---|
172 | |
---|
173 | test "$quiet" = "true" || echo "removing aclocal.m4 files" |
---|
174 | files=`find . -name 'aclocal.m4' -print` ; |
---|
175 | test "$verbose" = "-v" && test -n "$files" && echo "$files" ; |
---|
176 | for i in $files; do if test -f $i; then |
---|
177 | rm -f $i |
---|
178 | test "$verbose" = "-v" && echo "$i" |
---|
179 | fi; done |
---|
180 | |
---|
181 | find . -name '*~' -print | xargs rm -f |
---|
182 | find . -name 'bspopts.h*' -print | xargs rm -f |
---|
183 | find . -name '*.orig' -print | xargs rm -f |
---|
184 | find . -name '*.rej' -print | xargs rm -f |
---|
185 | find . -name 'config.status' -print | xargs rm -f |
---|
186 | find . -name 'config.log' -print | xargs rm -f |
---|
187 | find . -name 'config.cache' -print | xargs rm -f |
---|
188 | find . -name 'Makefile' -print | xargs rm -f |
---|
189 | find . -name '.deps' -print | xargs rm -rf |
---|
190 | find . -name '.libs' -print | xargs rm -rf |
---|
191 | find . -name 'stamp-h.in' | xargs rm -rf |
---|
192 | find . -name 'autom4te*.cache' | xargs rm -rf |
---|
193 | ;; |
---|
194 | esac |
---|