Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / bin / g++dep
blob188f8ac0c08fd2448bae633817eee9097dc2b097
1 #! /bin/sh
2 # This utility is a lightly edited version of the freed Berkeley
3 # script `mkdep'. The current script is intended to work for GNU G++.
5 # Here is the original BSD header:
6 # @(#)mkdep.sh 1.7 (Berkeley) 10/13/87
9 if [ $# = 0 ] ; then
10 echo 'usage: g++dep [-p] [-f makefile] [flags] file ...'
11 exit 1
14 DO_ACE_MAKE_DEPEND=0
15 MAKE=GNUmakefile
16 STOPNOW=0
17 REL=""
19 while [ $STOPNOW -eq 0 ]
21 case $1 in
22 # -e for compatibility with depgen.pl
23 -e) shift; shift ;;
25 # -f allows you to select a makefile name
26 -f) MAKE=$2
27 shift; shift ;;
29 # the -p flag produces "program: program.c" style dependencies
30 # so .o's don't get produced
31 -p) SED='s;\.o;;'
32 shift ;;
34 # -A implies -r and fixes the .obj line, hate
35 -A) REL="ACE_ROOT TAO_ROOT "$REL
36 DO_ACE_MAKE_DEPEND=1
37 shift ;;
39 # -r allows the use of relative pathnames...
40 -r) REL="ACE_ROOT TAO_ROOT "$REL
41 shift ;;
43 # -R VARNAME allows you to specify a variable which should be used
44 # to generate relative paths if it's defined. You can use multiple
45 # -R options, but be careful if one of the values is a proper
46 # subset of a subsequent value, because I suspect that sed will
47 # substitute for the first value properly, but not for the
48 # second. You might be able to get around this by reordering and
49 # having the more specific values lead the less specific values.
50 -R) REL=$2" "$REL
51 shift; shift;;
52 *) STOPNOW=1
53 esac
54 done
56 if [ ! -w $MAKE ]; then
57 echo "g++dep: no writeable file \"$MAKE\""
58 exit 1
61 TMP=/tmp/g++dep$$
62 SCRIPT=${TMP}_script
64 trap 'rm -f $TMP $SCRIPT; exit 1' 1 2 3 13 15
66 cp $MAKE ${MAKE}.bak
68 sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP
70 cat << _EOF_ >> $TMP
71 # DO NOT DELETE THIS LINE -- g++dep uses it.
72 # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
74 _EOF_
76 # Local files may appear as './foo' change that to 'foo'
77 echo 's; \./; ;g' >$SCRIPT
79 # If the -p flag is set we want to change 'foo.o' to simply 'foo'
80 echo $SED >>$SCRIPT
82 # Dependencies on local files are better expressed like that, instead
83 # of using $(TAO_ROOT) or $(ACE_ROOT). This is specially important
84 # for IDL generated files.
85 echo "s;`pwd`/;;g" >>$SCRIPT
87 if [ -z "$TAO_ROOT" ]; then
88 TAO_ROOT=${ACE_ROOT}/TAO
91 # This is a long series of commands to change the actual value of
92 # $ACE_ROOT to '$(ACE_ROOT)', similar changes are done for TAO_ROOT
93 # and any number of "variables" defined via the -R option.
94 for varname in $REL; do
95 varvalue=$(eval echo \$${varname})
96 echo "s;"$varvalue";$""("$varname");g" >>$SCRIPT
97 done
99 if [ $DO_ACE_MAKE_DEPEND -eq 1 ]; then
100 # Append a series of commands to the sed script that help with the
101 # ACE build style (.obj subdirectories, plaform indenpendent
102 # dependencies, etc.)
104 # To avoid interpolation we build this string in pieces, the idea is
105 # to generate a rule that will convert
106 # foo.o:
107 # into
108 # .obj/foo.o .shobj/foo.o .obj/foo.so .shobj/foo.so:
110 # will be foo.o foo.
111 LONG_TARGET="$""(sort "
112 for i in VDIR VSHDIR; do
113 for j in OBJEXT SOEXT; do
114 LONG_TARGET=${LONG_TARGET}"$""("${i}")\1.$""("${j}") "
115 done
116 done
117 LONG_TARGET=${LONG_TARGET}")"
119 cat >>$SCRIPT <<EOF
121 # Change the actual plaform config.h file to a MAKE macro...
122 s;${ACE_PLATFORM_CONFIG};\$(ACE_PLATFORM_CONFIG);g
124 # Append a 'x' character to the config-all and config-lite names,
125 # because we are going to remove all the config-* names..
126 s/config-all/configx-all/
127 s/config-lite/configx-lite/
129 # Remove the config-* names
130 /config-.*\.h/d
132 # Restore configx-all and configx-lite to their original names
133 s/configx-all/config-all/
134 s/configx-lite/config-lite/
136 # Remove any absolute dependencies
137 s; /[-a-zA-Z0-9_./+]*\.h;;g
139 # Remove blanks followed by a backslash
140 s;[ \\t][ \\t]*\\\\; \\\\;g
142 # g++ generate dependencies for foo.o in the current directory, but we
143 # we need dependencies for foo.o and foo.so in the .obj and .shobj
144 # subdirectories. Actually .obj and .shobj are, respectively, the
145 # expansions of VDIR and VSHDIR, therefore it is better *NOT* to use
146 # the values of said variables, but generated dependencies that expand
147 # them.
148 s;\([-a-zA-Z0-9._+]*\)\.o:;\\${LONG_TARGET}:;
150 # An older implementation of the previous code, but using the actual
151 # value of VDIR and VSHDIR at time of dependency generation.
153 #s;\([-a-zA-Z0-9._+]*\)\.o:;\\${VDIR}\1.${OBJEXT} ${VDIR}\1.${SOEXT} ${VSHDIR}\1.${OBJEXT} ${VSHDIR}\1.${SOEXT}:;
159 g++ -MM -MG -DACE_LACKS_PRAGMA_ONCE $* |
160 sed -f $SCRIPT ${ACE_DEPEND_SED_CMD} >>$TMP
161 /bin/rm -f $SCRIPT
163 cat << _EOF_ >> $TMP
165 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
166 _EOF_
168 # copy to preserve permissions
169 cp $TMP $MAKE
170 rm -f ${MAKE}.bak $TMP
171 exit 0