-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkconfig.sh
More file actions
executable file
·53 lines (40 loc) · 782 Bytes
/
mkconfig.sh
File metadata and controls
executable file
·53 lines (40 loc) · 782 Bytes
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
#!/bin/sh
is_int_or_float()
{
local rval=0
echo $1 | grep "[^\.0-9]" > /dev/null 2>&1 && rval=1
echo $1 | grep "^.*\..*\..*$" > /dev/null 2>&1 && rval=1
return ${rval}
}
add_macro()
{
local line="#define $1"
if [ "$2" != "" ]; then
if is_int_or_float $2; then
line="$line $2"
else
line="$line \"$2\""
fi
fi
echo $line >> config.h
}
cat > config.h <<EOF
#ifndef __CONFIG_H_
#define __CONFIG_H_
EOF
while true ; do
[ "$1" = "" ] && break
value=${1#*=}
[ "$value" = "$1" ] && value=''
#macro=`expr substr ${1%=*} 3 999`
macro=${1%=*}
macro=${macro#--}
macro=`echo $macro | tr "a-z-" "A-Z_"`
macro="CONFIG_$macro"
add_macro $macro $value
shift
done
add_macro PROJECT_VERSION "`cat version`"
cat >> config.h << EOF
#endif /* __CONFIG_H_ */
EOF