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