-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·133 lines (117 loc) · 2.23 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/sh
this_prog=`basename $0`
DEFAULT_DIST='.pps'
DIST=
usage()
{
cat <<HELP
Usage: $1 [-h|--help]
Options:
-h, --help : print this message
Parameters:
--dist=DIST : specify the distribution (defaults to '$DEFAULT_DIST')
HELP
}
version()
{
description=$(git describe --always HEAD)
version=$(echo $description | cut -d'-' -f1)
release=$(echo $description | cut -d'-' -f2)
if [ "$release" = "$version" ]; then
# We are either at a tag or we don't have any tag yet
# Check to see if $version has '.'
if [ ${version%%.*} = "$version" ]; then
# We don't have . in $version
echo "0.0-1"
else
# We are at a tag
echo "$version-1"
fi
else
release=$((release+1))
echo "${version}-$release"
fi
}
parse_args()
{
local prev
local optarg
local opt
for opt; do
if [ -n "$prev" ]; then
eval "$prev=\$opt"
prev=
continue
fi
optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
case "$opt" in
-h | --h | -help | --help)
usage $this_prog
exit ;;
-dist | --dist)
prev=DIST
;;
-dist=* | --dist=*)
DIST=$optarg
;;
-*)
cat <<EOF
Error: unrecognized option $opt
Try $this_prog --help for more information.
EOF
exit 2 ;;
esac
done
VERSION=$(version | cut -d'-' -f1)
RELEASE=$(version | cut -d'-' -f2)
[ -n "$DIST" ] || DIST=$DEFAULT_DIST
echo "VERSION=$VERSION"
echo "RELEASE=$RELEASE"
echo "DIST=$DIST"
}
replace()
{
local key
local prev
local opt
local optarg
local script="sed"
local input
for opt; do
if [ -n "$prev" ]; then
script="$script -e 's,@$prev@,$opt,g'"
prev=
continue
fi
optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
case "$opt" in
--*=*)
key=${opt#--}
key=${key%%=*}
script="$script -e 's,@$key@,$optarg,g'"
;;
*)
if [ -z "$input" ]; then
input=$opt
else
input="$input $opt"
fi
;;
esac
done
echo "input=$input"
if [ "$script" != "sed" ]; then
for f in $input; do
echo "Processing $f..."
cat $f | eval "$script" > ${f%.*}
done
else
echo "Nothing to be done for replace()"
fi
return 0
}
parse_args $@
replace --VERSION=$VERSION \
--RELEASE=$RELEASE \
--DIST=$DIST \
$(find . -type f -name '*.in')