Turns out we don't need sed to process the output of gcc -MD. We can just
do this:
read DEPS <filename.deps
The 'read' command in sh actually handles backslashes correctly, so we don't
have to sed them out after all. And then a simple ${DEPS#*:} removes the
"target:" prefix from the dependency line, and we're done!
11 lines
205 B
Text
11 lines
205 B
Text
redo-ifchange config.sh
|
|
. ./config.sh
|
|
exec >$3
|
|
cat <<-EOF
|
|
redo-ifchange \$1.c
|
|
gcc $CFLAGS -MD -MF \$3.deps -o \$3 -c \$1.c
|
|
read DEPS <\$3.deps
|
|
rm -f \$3.deps
|
|
redo-ifchange \${DEPS#*:}
|
|
EOF
|
|
chmod +x $3
|