source: rtems/bootstrap @ cf2e6dde

Last change on this file since cf2e6dde 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
RevLine 
[22fb90e4]1#!/bin/sh
[9b8baa1]2#
[e619c28]3# helps bootstrapping, when checked out from CVS
4# requires GNU autoconf and GNU automake
[9b8baa1]5#
[e619c28]6# this is not meant to be exported outside the source tree
[65c6425]7#
[e619c28]8# NOTE: Inspired by libtool's autogen script
[65c6425]9#
[e619c28]10# to be run from the toplevel directory of RTEMS'
11# source tree
12
13progname=`basename $0`
[df49c60]14top_srcdir=`dirname $0`
15
[2afb22b]16LC_ALL=C
17export LC_ALL
18
[22fb90e4]19verbose=""
[e619c28]20quiet="false"
[fba17c9e]21mode="autoreconf"
[aa96f47]22force=0
[e619c28]23
24usage()
25{
[7e03d10]26  echo
[7b1a711]27  echo "usage: ${progname} [-c|-h|-H] [-q][-v]"
[7e03d10]28  echo
29  echo "options:"
[8cdb582]30  echo "        -c .. clean, remove all aclocal/autoconf/automake generated files"
[77fff592]31  echo "        -h .. display this message and exit"
[2afb22b]32  echo "        -H .. regenerate headers.am files"
[77fff592]33  echo "        -q .. quiet, don't display directories"
34  echo "        -v .. verbose, pass -v to autotools"
[7e03d10]35  echo
[22fb90e4]36  exit 1
[e619c28]37}
38
[76d527e]39if test ! -f $top_srcdir/aclocal/version.m4; then
[7e03d10]40  echo "${progname}:"
[76d527e]41  echo "        Installation problem: Can't find file aclocal/version.m4"
[22fb90e4]42  exit 1
[7e03d10]43fi
44
[e619c28]45while test $# -gt 0; do
46case $1 in
[7e03d10]47-h|--he|--hel|--help)
48  usage ;;
[e619c28]49-q|--qu|--qui|--quie|--quiet)
[22fb90e4]50  quiet="true"
[e619c28]51  shift;;
52-v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
[22fb90e4]53  verbose="-v"
[e619c28]54  shift;;
[8cdb582]55-c|--cl|--cle|--clea|--clean)
[22fb90e4]56  mode="clean"
[8cdb582]57  shift;;
[aa96f47]58-f|--fo|--for|--forc|--force)
59  force=`expr $force + 1`
60  shift;;
[2afb22b]61-H|--headers)
62  mode="headers"
[77fff592]63  shift;;
[3031e6c]64-r|--re|--rec|--reco|--recon|--reconf)
[22fb90e4]65  mode="autoreconf"
[3031e6c]66  shift;;
[fba17c9e]67-g|--ge|--gen|--gene|--gener|--genera|--generat|--generate)
[22fb90e4]68  mode="generate"
[fba17c9e]69  shift;;
[22fb90e4]70-*) echo "unknown option $1"
[e619c28]71  usage ;;
[22fb90e4]72*) echo "invalid parameter $1"
[e619c28]73  usage ;;
74esac
75done
76
[8cdb582]77case $mode in
[2afb22b]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"
[2548d14]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
[2afb22b]130  tmp="$base/headers.am.new"
[2548d14]131  for i in bsps/include bsps/*/include bsps/*/*/include ; do
[2afb22b]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"
[4dfeba3]162            printf "\ninclude%sdir = \$(includedir)/$dir\n" "$am_dir" >> "$tmp"
[2afb22b]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
[4dfeba3]171          echo "include_HEADERS += include/bspopts.h" >> "$tmp"
[2afb22b]172        fi
173      done
174    done
175    cd "$base"
176    diff -q "$tmp" "$i/${hdr}headers.am" || mv "$tmp" "$i/${hdr}headers.am"
[77fff592]177  done
[2afb22b]178  rm -f "$tmp"
[77fff592]179  ;;
180
[8cdb582]181generate)
[d854517]182  AUTOCONF=${AUTOCONF-autoconf}
[58fd5ab]183  if test -z "$AUTOCONF"; then
184    echo "You must have autoconf installed to run $program"
[0b22af6]185    exit 1
[58fd5ab]186  fi
[22fb90e4]187
[0b22af6]188  AUTOHEADER=${AUTOHEADER-autoheader}
189  if test -z "$AUTOHEADER"; then
190    echo "You must have autoconf installed to run $program"
191    exit 1
[58fd5ab]192  fi
[22fb90e4]193
[d854517]194  AUTOMAKE=${AUTOMAKE-automake}
[58fd5ab]195  if test -z "$AUTOMAKE"; then
196    echo "You must have automake installed to run $program"
[0b22af6]197    exit 1
[58fd5ab]198  fi
[22fb90e4]199
[0b22af6]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
[df49c60]206  case $top_srcdir in
[ec6968b]207  /* ) aclocal_dir=$top_srcdir
[df49c60]208    ;;
[ec6968b]209  *) aclocal_dir=`pwd`/$top_srcdir
[df49c60]210    ;;
211  esac
212
[e712997]213  confs=`find . \( -name 'configure.in' -o -name 'configure.ac' \) -print`
[8cdb582]214  for i in $confs; do
[22fb90e4]215  dir=`dirname $i`
216  configure=`basename $i`
217  ( test "$quiet" = "true" || echo "$dir"
218    cd $dir
[ec6968b]219    pat="s,\$(RTEMS_TOPdir),${aclocal_dir},g"
220    aclocal_args=`grep '^[ ]*ACLOCAL_AMFLAGS' Makefile.am | \
[22fb90e4]221      sed -e 's%.*ACLOCAL_AMFLAGS.*\=[ ]*%%g' -e $pat `
[0b22af6]222    test "$verbose" = "-v" && echo "${ACLOCAL} $aclocal_args"
[22fb90e4]223    ${ACLOCAL} $aclocal_args
[0b22af6]224    test -n "`grep CONFIG_HEADER ${configure}`" && ${AUTOHEADER} \
[22fb90e4]225      && test "$verbose" = "-v" && echo "${AUTOHEADER}"
[0b22af6]226    test -n "`grep RTEMS_BSP_CONFIGURE ${configure}`" && ${AUTOHEADER} \
[22fb90e4]227      && test "$verbose" = "-v" && echo "${AUTOHEADER}"
228    test -f Makefile.am && ${AUTOMAKE} -a -c $verbose
229    ${AUTOCONF}
[76ee648]230    test -f Makefile.am && test -n "`grep 'stamp-h\.in' Makefile.in`" \
231      && echo timestamp > stamp-h.in
[8cdb582]232  )
233  done
234  ;;
[df49c60]235
[3031e6c]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
[22fb90e4]245  dir=`dirname $i`
246  configure=`basename $i`
247  ( test "$quiet" = "true" || echo "$dir"
248    cd $dir
249    ${AUTORECONF} -i --no-recursive $verbose
[3031e6c]250    test -f Makefile.am && test -n "`grep 'stamp-h\.in' Makefile.in`" \
251      && echo timestamp > stamp-h.in
252  )
253  done
254  ;;
255
[8cdb582]256clean)
257  test "$quiet" = "true" || echo "removing automake generated Makefile.in files"
[22fb90e4]258  files=`find . -name 'Makefile.am' -print | sed -e 's%\.am%\.in%g'`
259  for i in $files; do
[aa96f47]260    if test -f $i; then
261      rm -f $i
[22fb90e4]262      test "$verbose" = "-v" && echo "$i"
263    fi
[aa96f47]264  done
[8cdb582]265
266  test "$quiet" = "true" || echo "removing configure files"
[22fb90e4]267  files=`find . -name 'configure' -print`
268  for i in $files; do
[aa96f47]269    if test -f $i; then
270      rm -f $i
271      test "$verbose" = "-v" && echo "$i"
[22fb90e4]272    fi
[aa96f47]273  done
[22fb90e4]274
[aa96f47]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`
[22fb90e4]292      for i in $files; do
[aa96f47]293        if test -f $i; then
294          rm -f $i
295          test "$verbose" = "-v" && echo "$i"
[22fb90e4]296        fi
[aa96f47]297      done
298    done
299  fi
300
[8cdb582]301  test "$quiet" = "true" || echo "removing aclocal.m4 files"
[22fb90e4]302  files=`find . -name 'aclocal.m4' -print`
303  test "$verbose" = "-v" && test -n "$files" && echo "$files"
304  for i in $files; do
[aa96f47]305    if test -f $i; then
306      rm -f $i
[22fb90e4]307      test "$verbose" = "-v" && echo "$i"
308    fi
[aa96f47]309  done
[8cdb582]310
311  find . -name '*~' -print | xargs rm -f
[a5a0db4]312  find . -name 'bspopts.h.in' -print | xargs rm -f
[8cdb582]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
[76ee648]317  find . -name 'config.cache' -print | xargs rm -f
[6693a68]318  find . -name 'Makefile' -print | xargs rm -f
[8cdb582]319  find . -name '.deps' -print | xargs rm -rf
[76ee648]320  find . -name '.libs' -print | xargs rm -rf
321  find . -name 'stamp-h.in' | xargs rm -rf
[282cb9c]322  find . -name 'autom4te*.cache' | xargs rm -rf
[8cdb582]323  ;;
324esac
[cf0ed46]325
326exit 0
Note: See TracBrowser for help on using the repository browser.