Commit | Line | Data |
---|---|---|
c143ef62 MM |
1 | #! /bin/sh |
2 | ||
3 | # Helper script to turn --enable-sim-xxx switches into defines | |
4 | ||
5 | # Arg 1 -- header name | |
6 | # Arg 2 -- define name | |
7 | # Arg 3 -- --enable-sim switch spelling | |
8 | # Arg 4 -- --enable-sim switch value | |
9 | # the remaining switches are paired, with the first being the value to test arg 4 against | |
10 | # and the second is the value to put in the define if it matches | |
11 | ||
12 | hdr="$1" | |
13 | shift | |
14 | ||
15 | define="$1" | |
16 | shift | |
17 | ||
18 | switch="$1" | |
19 | shift | |
20 | ||
21 | value="$1" | |
22 | shift | |
23 | ||
24 | while test $# -gt 1; do | |
25 | test_value="$1" | |
26 | shift | |
27 | ||
28 | set_value="$1" | |
29 | shift | |
30 | ||
31 | if test x"$value" = x"$test_value" -o x"$test_value" = x"*"; then | |
32 | echo "Defining $define=$set_value" | |
33 | (echo "" | |
34 | if test x"$value" = x""; then | |
35 | echo "/* no $switch */" | |
36 | elif test x"$value" = x"yes"; then | |
37 | echo "/* $switch */" | |
38 | else | |
39 | echo "/* $switch=$value */" | |
40 | fi | |
41 | ||
42 | echo "#ifndef $define" | |
43 | echo "#define $define $set_value" | |
44 | echo "#endif") >> $hdr | |
45 | exit 0; | |
46 | fi | |
47 | done | |
48 | ||
49 | if test x"$value" != x"" -a x"$value" != x"no"; then | |
50 | echo "$switch=$value is not supported" 1>&2 | |
51 | exit 1 | |
52 | fi |