source: rtems/bootstrap @ 4f4ed2f0

Last change on this file since 4f4ed2f0 was 2548d14, checked in by Sebastian Huber <sebastian.huber@…>, on Sep 10, 2018 at 3:38:14 PM

build: Include header.am in cpukit/Makefile.am

Include all cpukit/*/header.am files in cpukit/Makefile.am. This gets
rid of all subtree Makefile.am and the sudirs hack.

  • Property mode set to 100755
File size: 8.5 KB
Line 
1#!/bin/sh
2#
3# helps bootstrapping, when checked out from CVS
4# requires GNU autoconf and GNU automake
5#
6# this is not meant to be exported outside the source tree
7#
8# NOTE: Inspired by libtool's autogen script
9#
10# to be run from the toplevel directory of RTEMS'
11# source tree
12
13progname=`basename $0`
14top_srcdir=`dirname $0`
15
16LC_ALL=C
17export LC_ALL
18
19verbose=""
20quiet="false"
21mode="autoreconf"
22force=0
23
24usage()
25{
26  echo
27  echo "usage: ${progname} [-c|-h|-H] [-q][-v]"
28  echo
29  echo "options:"
30  echo "        -c .. clean, remove all aclocal/autoconf/automake generated files"
31  echo "        -h .. display this message and exit"
32  echo "        -H .. regenerate headers.am files"
33  echo "        -q .. quiet, don't display directories"
34  echo "        -v .. verbose, pass -v to autotools"
35  echo
36  exit 1
37}
38
39if 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
43fi
44
45while test $# -gt 0; do
46case $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-f|--fo|--for|--forc|--force)
59  force=`expr $force + 1`
60  shift;;
61-H|--headers)
62  mode="headers"
63  shift;;
64-r|--re|--rec|--reco|--recon|--reconf)
65  mode="autoreconf"
66  shift;;
67-g|--ge|--gen|--gene|--gener|--genera|--generat|--generate)
68  mode="generate"
69  shift;;
70-*) echo "unknown option $1"
71  usage ;;
72*) echo "invalid parameter $1"
73  usage ;;
74esac
75done
76
77case $mode in
78headers)
79  if test "." != "$top_srcdir"; then
80    echo "To generate the headers.am you must call the script via \"./$progname -H\""
81    exit 1
82  fi
83  base="$PWD"
84
85  # Generate cpukit/header-dirs.am
86  tmp="$base/cpukit/header-dirs.am.new"
87  hdr_dirs=`for i in cpukit/include cpukit/libnetworking cpukit/score/cpu/*/include ; do
88    cd "$i"
89    find -mindepth 1 -type d
90    cd "$base"
91  done | sort -u | sed 's%^\./%%'`
92  echo '## This file was generated by "./boostrap -H".' > "$tmp"
93  echo 'include_HEADERS =' >> "$tmp"
94  for dir in $hdr_dirs ; do
95    am_dir=`echo $dir | sed 's%[/-]%_%g'`
96    echo "include_${am_dir}dir = \$(includedir)/$dir" >> "$tmp"
97    echo "include_${am_dir}_HEADERS =" >> "$tmp"
98  done
99  diff -q "$tmp" "cpukit/header-dirs.am" || mv "$tmp" "cpukit/header-dirs.am"
100  rm -f "$tmp"
101
102  # Generate cpukit/*/headers.am
103  tmp="$base/headers.am.new"
104  cpukit="$base/cpukit"
105  cd "$cpukit"
106  for inc in include score/cpu/*/include ; do
107    echo '## This file was generated by "./boostrap -H".' > "$tmp"
108    hdr=`dirname $inc`
109    am_dir=""
110    cd $inc
111    for b in `find -type d | sort` ; do
112      for j in `find $b -mindepth 1 -maxdepth 1 -name '*.h' | sed 's%^\.%%' | sed 's%^/%%' | sort` ; do
113        dir=`dirname $j`
114        if test x$dir != x. ; then
115          am_dir=`echo $dir | sed 's%[/-]%_%g'`
116          am_dir="_$am_dir"
117        else
118          am_dir=""
119        fi
120        echo "include${am_dir}_HEADERS += $inc/$j" >> "$tmp"
121      done
122    done
123    cd "$cpukit"
124    diff -q "$tmp" "${hdr}/headers.am" || mv "$tmp" "${hdr}/headers.am"
125  done
126  rm -f "$tmp"
127  cd "$base"
128
129  # Generate bsps/*/headers.am
130  tmp="$base/headers.am.new"
131  for i in bsps/include bsps/*/include bsps/*/*/include ; do
132    dir=""
133    am_dir=""
134    echo '## This file was generated by "./boostrap -H".' > "$tmp"
135    case $i in
136      bsps/*/*/include)
137        hdr="../"
138        inc="../../../../../../$i/"
139        ;;
140      bsps/*/include)
141        hdr="../"
142        inc="../../../../../$i/"
143        ;;
144      bsps/include)
145        hdr="../"
146        inc="../../$i/"
147        ;;
148      *)
149        hdr=""
150        inc=""
151        ;;
152    esac
153    cd $i
154    for b in `find -type d | sort` ; do
155      for j in `find $b -mindepth 1 -maxdepth 1 -name '*.h' -or -name '*.inc' | sed 's%^\.%%' | sed 's%^/%%' | sort` ; do
156        d=`dirname $j`
157        if test x$d != x$dir ; then
158          dir=$d
159          if test x$d != x. ; then
160            am_dir=`echo $dir | sed 's%[/-]%_%g'`
161            am_dir="_$am_dir"
162            printf "\ninclude%sdir = \$(includedir)/$dir\n" "$am_dir" >> "$tmp"
163          else
164            am_dir=""
165            echo "" >> "$tmp"
166          fi
167          echo "include${am_dir}_HEADERS =" >> "$tmp"
168        fi
169        echo "include${am_dir}_HEADERS += $inc$j" >> "$tmp"
170        if test $j = bsp.h ; then
171          echo "include_HEADERS += include/bspopts.h" >> "$tmp"
172        fi
173      done
174    done
175    cd "$base"
176    diff -q "$tmp" "$i/${hdr}headers.am" || mv "$tmp" "$i/${hdr}headers.am"
177  done
178  rm -f "$tmp"
179  ;;
180
181generate)
182  AUTOCONF=${AUTOCONF-autoconf}
183  if test -z "$AUTOCONF"; then
184    echo "You must have autoconf installed to run $program"
185    exit 1
186  fi
187
188  AUTOHEADER=${AUTOHEADER-autoheader}
189  if test -z "$AUTOHEADER"; then
190    echo "You must have autoconf installed to run $program"
191    exit 1
192  fi
193
194  AUTOMAKE=${AUTOMAKE-automake}
195  if test -z "$AUTOMAKE"; then
196    echo "You must have automake installed to run $program"
197    exit 1
198  fi
199
200  ACLOCAL=${ACLOCAL-aclocal}
201  if test -z "$ACLOCAL"; then
202    echo "You must have automake installed to run $program"
203    exit 1
204  fi
205
206  case $top_srcdir in
207  /* ) aclocal_dir=$top_srcdir
208    ;;
209  *) aclocal_dir=`pwd`/$top_srcdir
210    ;;
211  esac
212
213  confs=`find . \( -name 'configure.in' -o -name 'configure.ac' \) -print`
214  for i in $confs; do
215  dir=`dirname $i`
216  configure=`basename $i`
217  ( test "$quiet" = "true" || echo "$dir"
218    cd $dir
219    pat="s,\$(RTEMS_TOPdir),${aclocal_dir},g"
220    aclocal_args=`grep '^[ ]*ACLOCAL_AMFLAGS' Makefile.am | \
221      sed -e 's%.*ACLOCAL_AMFLAGS.*\=[ ]*%%g' -e $pat `
222    test "$verbose" = "-v" && echo "${ACLOCAL} $aclocal_args"
223    ${ACLOCAL} $aclocal_args
224    test -n "`grep CONFIG_HEADER ${configure}`" && ${AUTOHEADER} \
225      && test "$verbose" = "-v" && echo "${AUTOHEADER}"
226    test -n "`grep RTEMS_BSP_CONFIGURE ${configure}`" && ${AUTOHEADER} \
227      && test "$verbose" = "-v" && echo "${AUTOHEADER}"
228    test -f Makefile.am && ${AUTOMAKE} -a -c $verbose
229    ${AUTOCONF}
230    test -f Makefile.am && test -n "`grep 'stamp-h\.in' Makefile.in`" \
231      && echo timestamp > stamp-h.in
232  )
233  done
234  ;;
235
236autoreconf)
237  AUTORECONF=${AUTORECONF-autoreconf}
238  if test -z "$AUTORECONF"; then
239    echo "You must have autoreconf installed to run $program"
240    exit 1
241  fi
242
243  confs=`find . -name 'configure.ac' -print`
244  for i in $confs; do
245  dir=`dirname $i`
246  configure=`basename $i`
247  ( test "$quiet" = "true" || echo "$dir"
248    cd $dir
249    ${AUTORECONF} -i --no-recursive $verbose
250    test -f Makefile.am && test -n "`grep 'stamp-h\.in' Makefile.in`" \
251      && echo timestamp > stamp-h.in
252  )
253  done
254  ;;
255
256clean)
257  test "$quiet" = "true" || echo "removing automake generated Makefile.in files"
258  files=`find . -name 'Makefile.am' -print | sed -e 's%\.am%\.in%g'`
259  for i in $files; do
260    if test -f $i; then
261      rm -f $i
262      test "$verbose" = "-v" && echo "$i"
263    fi
264  done
265
266  test "$quiet" = "true" || echo "removing configure files"
267  files=`find . -name 'configure' -print`
268  for i in $files; do
269    if test -f $i; then
270      rm -f $i
271      test "$verbose" = "-v" && echo "$i"
272    fi
273  done
274
275  if test $force -gt 0; then
276    needles=""
277    if test $force -gt 1; then
278      # Manually maintained
279      needles="$needles config.sub"
280      needles="$needles config.guess"
281    fi
282    if test $force -gt 0; then
283      # Inherited from automake
284      needles="$needles compile"
285      needles="$needles depcomp"
286      needles="$needles install-sh"
287      needles="$needles missing"
288      needles="$needles mdate-sh"
289    fi
290    for j in $needles; do
291      files=`find . -name "$j" -print`
292      for i in $files; do
293        if test -f $i; then
294          rm -f $i
295          test "$verbose" = "-v" && echo "$i"
296        fi
297      done
298    done
299  fi
300
301  test "$quiet" = "true" || echo "removing aclocal.m4 files"
302  files=`find . -name 'aclocal.m4' -print`
303  test "$verbose" = "-v" && test -n "$files" && echo "$files"
304  for i in $files; do
305    if test -f $i; then
306      rm -f $i
307      test "$verbose" = "-v" && echo "$i"
308    fi
309  done
310
311  find . -name '*~' -print | xargs rm -f
312  find . -name 'bspopts.h.in' -print | xargs rm -f
313  find . -name '*.orig' -print | xargs rm -f
314  find . -name '*.rej' -print | xargs rm -f
315  find . -name 'config.status' -print | xargs rm -f
316  find . -name 'config.log' -print | xargs rm -f
317  find . -name 'config.cache' -print | xargs rm -f
318  find . -name 'Makefile' -print | xargs rm -f
319  find . -name '.deps' -print | xargs rm -rf
320  find . -name '.libs' -print | xargs rm -rf
321  find . -name 'stamp-h.in' | xargs rm -rf
322  find . -name 'autom4te*.cache' | xargs rm -rf
323  ;;
324esac
325
326exit 0
Note: See TracBrowser for help on using the repository browser.