generate_dist_headers.sh 1.51 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#! /bin/sh

# Generate a list of distributed files w.r.t. a list of file which must
# be excluded.
# --------------------
# List all the headers in order to make them part of distribution.

# Use the C locale to have a deterministic sort.
export LC_ALL=C

if [ $# -ne 3 ]; then
  echo "$0 <scanned_dir> <output> <nodist-headers>"
  exit 1
fi

me=`basename $0`
scanned_dir=$1
output=$2
nodist_headers=$3
test -f "$nodist_headers" \
  || { echo "$me: Cannot find \`$nodist_headers' in `pwd`."; exit 1; }

echo "Generating $output..." >&2
rm -f "$output"
25
cat <<EOF > "$output"
26
27
28
29
30
31
32
33
34
35
## Generated by \`$me', do not edit by hand.

nobase_include_HEADERS = \\
EOF

find $scanned_dir -type f -a \( -name '*.hh' -o -name '*.hxx' \) \
  | sort						\
  | comm -23 - "$nodist_headers"			\
  | sed -e 's/$/ \\/g' >> $output

36

37
38
39
40
last_line=`tail -n 1 $output | sed -e 's/\\\//g'` # remove '\' in last line
sed '$d' < $output > $output.tmp # remove last line
mv $output.tmp $output
echo $last_line >> $output # put the cleaned last line back.
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59


# Add non distributed files to installed headers list.
#
# Non distributed headers will be installed if the installation
# process is launched from the repository copy.
cat <<EOF >> "$output"
#<<lrde
nobase_include_HEADERS += \\
EOF

cat $nodist_headers | sed -e 's/$/ \\/g' >> $output

last_line=`tail -n 1 $output | sed -e 's/\\\//g'` # remove '\' in last line
sed '$d' < $output > $output.tmp # remove last line
mv $output.tmp $output
echo $last_line >> $output # put the cleaned last line back.

echo "#>>" >> $output