summaryrefslogtreecommitdiff
path: root/ace-diff-config.in
blob: 3ac2c46f33569e19f22913fc183e78ffc349a30e (plain)
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/bin/sh

# -------------------------------------------------------------------------
#       $Id$
# 
#       ace-diff-config script - use to compare ACE macro definitions in
#                                ACE configuration headers
# 
# -------------------------------------------------------------------------

#  Copyright (C) 1998  Ossama Othman
#
#  All Rights Reserved
#
# This library is free software; you can redistribute it and/or
# modify it under the current ACE distribution terms.
# 
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# This is a script that can be used to determine differences between two ACE
# configuration headers.  The file `ACE.ifnames' contains a list of all of the
# identifiers used in ACE's preprocessor conditionals (generated with
# GNU Autoconf's "ifnames" program).  The script will go through the list in
# ACE.ifnames and determine if the given macro was defined in only one of the
# two headers being headers being compared.
#
# The C++ pre-processor is used when comparing so that macros from "#included"
# headers will also be checked.

set -e

INCLUDES="@top_srcdir@"
CXXCPP="@CXXCPP@ -I. -I$INCLUDES"
MACRO_LIST_FILE="ACE.ifnames"
RESULTS_FILE=ace-diff-config.results
TEST_FILE="ace-diff-config.test.cpp"

usage()
{
    cat <<EOF
Usage: ace-diff-config HEADER1 HEADER2
       e.g.:  ./ace-diff-config ace/config-linux-lxpthreads.h ace/config.h

EOF

    exit $1
}

if test $# -eq 0; then
    usage 1
fi

if test -f $RESULTS_FILE; then
  mv $RESULTS_FILE $RESULTS_FILE.bak
fi

if test -f $1; then
  :
else
  echo "error: $1 does not exist"
  exit 1
fi

if test -f $2; then
  :
else
  echo "error: $2 does not exist"
  exit 1
fi

# Process the first header
echo ""
echo -n "Processing $1 "

echo "Macros that are defined in $1" >> $RESULTS_FILE
echo "but not in $2" >> $RESULTS_FILE
echo "-------------------------------------------------------" >> $RESULTS_FILE

list=`cat $MACRO_LIST_FILE`; for p in $list; do
  # Provide some output
  echo -n "."
  cat > $TEST_FILE <<EOF

#include "$1"

#ifdef $p
DEFINED
#endif

EOF

  if (eval "$CXXCPP $TEST_FILE") |
     egrep "DEFINED" >/dev/null; then
    defined=true
  else
    defined=false
  fi

  # now check if it is defined in header #2
  if test $defined = true; then
    cat > $TEST_FILE <<EOF

#include "$2"

#ifdef $p
DEFINED
#endif

EOF

    if (eval "$CXXCPP $TEST_FILE") |
       egrep "DEFINED" >/dev/null; then
      defined=true
    else
      defined=false
    fi

    # if "defined" is false then, the first header is the only header that
    # defines the macro.
    if test $defined = false; then
      echo $p >> $RESULTS_FILE
    fi
  fi

done


# Process the second header
echo ""
echo -n "Processing $2 "

echo "" >> $RESULTS_FILE
echo "Macros that are defined in $2" >> $RESULTS_FILE
echo "but not in $1" >> $RESULTS_FILE
echo "-------------------------------------------------------" >> $RESULTS_FILE

list=`cat $MACRO_LIST_FILE`; for p in $list; do
  # Provide some output
  echo -n "."

  cat > $TEST_FILE <<EOF

#include "$2"

#ifdef $p
DEFINED
#endif

EOF

  if (eval "$CXXCPP $TEST_FILE") |
     egrep "DEFINED" >/dev/null; then
    defined=true
  else
    defined=false
  fi

  # now check if it is defined in header #1
  if test $defined = true; then
    cat > $TEST_FILE <<EOF

#include "$1"

#ifdef $p
DEFINED
#endif

EOF

    if (eval "$CXXCPP $TEST_FILE") |
       egrep "DEFINED" >/dev/null; then
      defined=true
    else
      defined=false
    fi

    # if "defined" is false then, the second header is the only header that
    # defines the macro.
    if test $defined = false; then
      echo $p >> $RESULTS_FILE
    fi
  fi

done

rm $TEST_FILE

echo ""
echo "Results are in $RESULTS_FILE."
echo ""