1#!/bin/bash 2# 3# dotd.sh 4# 5# Generate .d Makefile fragments, so we can use #include statements in source 6# for dependency info. Adapted from the GNU make manual: 7# 8# http://www.gnu.org/software/make/manual/html_node/Automatic-Prerequisites.html 9# 10# We are putting this in shell, so we just have 'sed in bash'. Not an unholy 11# mix of 'sed in bash in Make'. 12 13set -o nounset 14set -o pipefail 15set -o errexit 16 17# Munge gcc -MM output into .d files. 18main() { 19 if [ ! -d _tmp ]; then mkdir _tmp; fi 20 local basename=$1 21 local dotd=$2 # .d output name 22 shift 2 # rest of args are gcc invocation 23 24 rm --verbose -f $dotd # in case of failure? 25 26 # Execute the gcc -MM invocation. 27 # 28 # Change 29 # rappor_sim.o: rappor.sim.cc 30 # to 31 # _tmp/rappor_sim.o _tmp/rappor_sim.d : rappor.sim.cc 32 "$@" | sed "s|\($basename\).o|_tmp/\1.o _tmp/\1.d |" > $dotd 33} 34 35main "$@" 36