[282cb9c] | 1 | #! /bin/sh |
---|
[9b8baa1] | 2 | # |
---|
[e619c28] | 3 | # helps bootstrapping, when checked out from CVS |
---|
| 4 | # requires GNU autoconf and GNU automake |
---|
[9b8baa1] | 5 | # |
---|
| 6 | # $Id$ |
---|
[e619c28] | 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` |
---|
[df49c60] | 16 | top_srcdir=`dirname $0` |
---|
| 17 | |
---|
[8cdb582] | 18 | verbose=""; |
---|
[e619c28] | 19 | quiet="false" |
---|
[8cdb582] | 20 | mode="generate" |
---|
[e619c28] | 21 | |
---|
| 22 | usage() |
---|
| 23 | { |
---|
[7e03d10] | 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" |
---|
[8cdb582] | 31 | echo " -c .. clean, remove all aclocal/autoconf/automake generated files" |
---|
[7e03d10] | 32 | echo |
---|
[e619c28] | 33 | exit 1; |
---|
| 34 | } |
---|
| 35 | |
---|
[282cb9c] | 36 | generate_bspdir_acinclude() |
---|
| 37 | { |
---|
| 38 | cat << EOF > acinclude.m4~ |
---|
| 39 | # RTEMS_CHECK_BSPDIR(RTEMS_BSP) |
---|
| 40 | AC_DEFUN([RTEMS_CHECK_BSPDIR], |
---|
| 41 | [ |
---|
[0affee3] | 42 | case "\$RTEMS_BSP_FAMILY" in |
---|
[282cb9c] | 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 | |
---|
[76d527ec] | 66 | if test ! -f $top_srcdir/aclocal/version.m4; then |
---|
[7e03d10] | 67 | echo "${progname}:" |
---|
[76d527ec] | 68 | echo " Installation problem: Can't find file aclocal/version.m4" |
---|
[7e03d10] | 69 | exit 1; |
---|
| 70 | fi |
---|
| 71 | |
---|
[e619c28] | 72 | while test $# -gt 0; do |
---|
| 73 | case $1 in |
---|
[7e03d10] | 74 | -h|--he|--hel|--help) |
---|
| 75 | usage ;; |
---|
[e619c28] | 76 | -q|--qu|--qui|--quie|--quiet) |
---|
| 77 | quiet="true"; |
---|
| 78 | shift;; |
---|
| 79 | -v|--ve|--ver|--verb|--verbo|--verbos|--verbose) |
---|
| 80 | verbose="-v"; |
---|
| 81 | shift;; |
---|
[8cdb582] | 82 | -c|--cl|--cle|--clea|--clean) |
---|
| 83 | mode="clean"; |
---|
| 84 | shift;; |
---|
[e619c28] | 85 | -*) echo "unknown option $1" ; |
---|
| 86 | usage ;; |
---|
| 87 | *) echo "invalid parameter $1" ; |
---|
| 88 | usage ;; |
---|
| 89 | esac |
---|
| 90 | done |
---|
| 91 | |
---|
[8cdb582] | 92 | case $mode in |
---|
| 93 | generate) |
---|
[d854517] | 94 | AUTOCONF=${AUTOCONF-autoconf} |
---|
[58fd5ab] | 95 | if test -z "$AUTOCONF"; then |
---|
| 96 | echo "You must have autoconf installed to run $program" |
---|
[0b22af6] | 97 | exit 1 |
---|
[58fd5ab] | 98 | fi |
---|
[0b22af6] | 99 | |
---|
| 100 | AUTOHEADER=${AUTOHEADER-autoheader} |
---|
| 101 | if test -z "$AUTOHEADER"; then |
---|
| 102 | echo "You must have autoconf installed to run $program" |
---|
| 103 | exit 1 |
---|
[58fd5ab] | 104 | fi |
---|
| 105 | |
---|
[d854517] | 106 | AUTOMAKE=${AUTOMAKE-automake} |
---|
[58fd5ab] | 107 | if test -z "$AUTOMAKE"; then |
---|
| 108 | echo "You must have automake installed to run $program" |
---|
[0b22af6] | 109 | exit 1 |
---|
[58fd5ab] | 110 | fi |
---|
| 111 | |
---|
[0b22af6] | 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 | |
---|
[df49c60] | 118 | case $top_srcdir in |
---|
[ec6968b] | 119 | /* ) aclocal_dir=$top_srcdir |
---|
[df49c60] | 120 | ;; |
---|
[ec6968b] | 121 | *) aclocal_dir=`pwd`/$top_srcdir |
---|
[df49c60] | 122 | ;; |
---|
| 123 | esac |
---|
| 124 | |
---|
[e712997] | 125 | confs=`find . \( -name 'configure.in' -o -name 'configure.ac' \) -print` |
---|
[8cdb582] | 126 | for i in $confs; do |
---|
| 127 | dir=`dirname $i`; |
---|
[e712997] | 128 | configure=`basename $i`; |
---|
[8cdb582] | 129 | ( test "$quiet" = "true" || echo "$dir"; |
---|
| 130 | cd $dir; |
---|
[282cb9c] | 131 | test -n "`grep RTEMS_CHECK_BSPDIR ${configure}`" && \ |
---|
| 132 | generate_bspdir_acinclude; |
---|
[ec6968b] | 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 ` ; |
---|
[0b22af6] | 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}; |
---|
[76ee648c] | 144 | test -f Makefile.am && test -n "`grep 'stamp-h\.in' Makefile.in`" \ |
---|
| 145 | && echo timestamp > stamp-h.in |
---|
[8cdb582] | 146 | ) |
---|
| 147 | done |
---|
| 148 | ;; |
---|
[df49c60] | 149 | |
---|
[8cdb582] | 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 |
---|
[23557f5] | 162 | rm -f $i config.sub config.guess depcomp install-sh mdate-sh missing \ |
---|
[d7aabb7c] | 163 | mkinstalldirs texinfo.tex |
---|
[8cdb582] | 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 |
---|
[d0d33f21] | 176 | find . -name 'bspopts.h*' -print | xargs rm -f |
---|
[8cdb582] | 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 |
---|
[76ee648c] | 181 | find . -name 'config.cache' -print | xargs rm -f |
---|
[6693a68] | 182 | find . -name 'Makefile' -print | xargs rm -f |
---|
[8cdb582] | 183 | find . -name '.deps' -print | xargs rm -rf |
---|
[76ee648c] | 184 | find . -name '.libs' -print | xargs rm -rf |
---|
| 185 | find . -name 'stamp-h.in' | xargs rm -rf |
---|
[282cb9c] | 186 | find . -name 'autom4te*.cache' | xargs rm -rf |
---|
[8cdb582] | 187 | ;; |
---|
| 188 | esac |
---|
[cf0ed46] | 189 | |
---|
| 190 | exit 0 |
---|