| 1 |
#! /usr/bin/env bash |
| 2 |
# |
| 3 |
# Converts -Dmacro to #define macro |
| 4 |
# and -Umacro to #undef macro |
| 5 |
# 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 |
# $Header: /u/gcmpack/MITgcm/tools/convert_cpp_cmd2defines,v 1.6 2012/07/06 18:53:14 jmc Exp $ |
| 12 |
# $Name: $ |
| 13 |
|
| 14 |
cat << EOF |
| 15 |
/* Warning - this file is automatically generated - do NOT edit */ |
| 16 |
/* |
| 17 |
Created by convert_cpp_cmd2defines with the following command line arguments: |
| 18 |
$@ |
| 19 |
*/ |
| 20 |
|
| 21 |
EOF |
| 22 |
|
| 23 |
BARRIER= |
| 24 |
|
| 25 |
# Process arguments |
| 26 |
for arg in "$@" |
| 27 |
do |
| 28 |
case $arg in |
| 29 |
-b*) |
| 30 |
BARRIER=`echo $arg | sed 's/-b//'` |
| 31 |
echo "#ifndef ${BARRIER}" |
| 32 |
echo "#define ${BARRIER}" |
| 33 |
;; |
| 34 |
-D*) |
| 35 |
echo $arg | sed 's/-D/#define /' | sed 's/=/ /' |
| 36 |
;; |
| 37 |
-U*) |
| 38 |
echo $arg | sed 's/-U/#undef /' | sed 's/=/ /' |
| 39 |
;; |
| 40 |
*) |
| 41 |
echo "/* " $arg " */" |
| 42 |
;; |
| 43 |
esac |
| 44 |
done |
| 45 |
|
| 46 |
if test ! "x${BARRIER}" = x ; then |
| 47 |
echo "#endif /* ${BARRIER} */" |
| 48 |
fi |