Merge pull request #3127 from alexrp/arm32-on-arm64
[mono-project.git] / mcs / build / gensources.sh
blob14a0a01db59d07b4503b9a5d1ae8882e25442524
1 #! /bin/sh
3 outfile=$1
4 incfile=$2
5 excfile=$3
6 extfile=$4
7 extexcfile=$5
9 process_includes_1() {
10 sed -e '/^[ \t]*$/d' -e '/^[ \t]*#/d' $1 > $2
11 if cmp -s $1 $2; then
12 false
13 else
14 sed -n 's,^[ \t]*#include ,,p' $1 |
15 while read inc; do
16 cat $inc >> $2
17 echo $outfile: $inc >> $outfile.makefrag
18 echo $inc: >> $outfile.makefrag
19 done
23 process_includes() {
24 i=$1; o=$2; t=${2}.tmp
25 while process_includes_1 $i $o; do
26 mv $o $t
27 i=$t
28 done
29 rm -f $t
32 rm -f $outfile.makefrag
34 process_includes $incfile $outfile.inc
36 if test x$extfile != x -a -f "$extfile"; then
37 process_includes $extfile $outfile.ext.inc
38 cat $outfile.ext.inc >> $outfile.inc
39 rm -f $outfile.ext.inc
42 sort -u $outfile.inc > $outfile.inc_s
43 rm -f $outfile.inc
46 if test -n "$excfile" -a -f "$excfile"; then
47 process_includes $excfile $outfile.exc
50 if test -n "$extexcfile"; then
51 process_includes $extexcfile $outfile.ext_exc
52 cat $outfile.ext_exc >> $outfile.exc
53 rm -f $outfile.ext_exc
56 if test -f $outfile.exc; then
57 # So what we're doing below with uniq -u is that we take
58 # lines that have not been duplicated. This computes the
59 # symmetric difference between the files. This is not
60 # what we want. If a file is in the excludes but not in
61 # the sources, we want that file not to show up. By duplicating the
62 # excludes, we ensure that we won't end up in this failure state.
63 sort -u $outfile.exc > $outfile.exc_s
65 # Duplicate excludes
66 cat $outfile.exc_s >> $outfile.exc_s_dup
67 cat $outfile.exc_s >> $outfile.exc_s_dup
69 rm -f $outfile.exc $outfile.exc_s
71 cat $outfile.inc_s $outfile.exc_s_dup | sort | uniq -u > $outfile
72 rm -f $outfile.inc_s $outfile.exc_s_dup
73 else
74 mv $outfile.inc_s $outfile