1 |
jmc |
1.5 |
#! /usr/bin/env bash |
2 |
adcroft |
1.1 |
# |
3 |
|
|
# Converts -Dmacro to #define macro |
4 |
jmc |
1.6 |
# and -Umacro to #undef macro |
5 |
adcroft |
1.1 |
# on standard output |
6 |
|
|
# |
7 |
|
|
# Any options that do not take the form -D* or -U* are placed as comments. |
8 |
|
|
# |
9 |
|
|
# usage: convert_cpp_cmd2defines [-Dmacro1|-Umacro1] [...] |
10 |
|
|
# |
11 |
jmc |
1.6 |
# $Header: /u/gcmpack/MITgcm/tools/convert_cpp_cmd2defines,v 1.5 2010/05/24 12:03:51 jmc Exp $ |
12 |
adcroft |
1.2 |
# $Name: $ |
13 |
adcroft |
1.1 |
|
14 |
|
|
cat << EOF |
15 |
|
|
/* |
16 |
jmc |
1.6 |
This file created by convert_cpp_cmd2defines with the following command line arguments: |
17 |
adcroft |
1.1 |
$@ |
18 |
|
|
*/ |
19 |
|
|
|
20 |
|
|
EOF |
21 |
|
|
|
22 |
adcroft |
1.2 |
BARRIER= |
23 |
|
|
|
24 |
adcroft |
1.3 |
# Process arguments |
25 |
jmc |
1.5 |
for arg in "$@" |
26 |
adcroft |
1.3 |
do |
27 |
|
|
case $arg in |
28 |
adcroft |
1.2 |
-b*) |
29 |
adcroft |
1.3 |
BARRIER=`echo $arg | sed 's/-b//'` |
30 |
|
|
echo "#ifndef ${BARRIER}" |
31 |
|
|
echo "#define ${BARRIER}" |
32 |
|
|
;; |
33 |
adcroft |
1.1 |
-D*) |
34 |
adcroft |
1.3 |
echo $arg | sed 's/-D/#define /' | sed 's/=/ /' |
35 |
|
|
;; |
36 |
adcroft |
1.1 |
-U*) |
37 |
adcroft |
1.3 |
echo $arg | sed 's/-U/#undef /' | sed 's/=/ /' |
38 |
|
|
;; |
39 |
adcroft |
1.1 |
*) |
40 |
adcroft |
1.3 |
echo "/* " $arg " */" |
41 |
|
|
;; |
42 |
adcroft |
1.1 |
esac |
43 |
|
|
done |
44 |
adcroft |
1.2 |
|
45 |
|
|
if test ! "x${BARRIER}" = x ; then |
46 |
|
|
echo "#endif /* ${BARRIER} */" |
47 |
|
|
fi |