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
10 echo 'usage: g++dep [-p] [-f makefile] [flags] file ...'
19 while [ $STOPNOW -eq 0 ]
22 # -e for compatibility with depgen.pl
25 # -f allows you to select a makefile name
29 # the -p flag produces "program: program.c" style dependencies
30 # so .o's don't get produced
34 # -A implies -r and fixes the .obj line, hate
35 -A) REL
="ACE_ROOT TAO_ROOT "$REL
39 # -r allows the use of relative pathnames...
40 -r) REL
="ACE_ROOT TAO_ROOT "$REL
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.
56 if [ ! -w $MAKE ]; then
57 echo "g++dep: no writeable file \"$MAKE\""
64 trap 'rm -f $TMP $SCRIPT; exit 1' 1 2 3 13 15
68 sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP
71 # DO NOT DELETE THIS LINE -- g++dep uses it.
72 # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
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'
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
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
108 # .obj/foo.o .shobj/foo.o .obj/foo.so .shobj/foo.so:
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}") "
117 LONG_TARGET
=${LONG_TARGET}")"
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
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
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
165 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
168 # copy to preserve permissions
170 rm -f ${MAKE}.bak
$TMP