#!/bin/sh

# Find the first source file in the parameter list
for LINE in ${*}
do
	TARGET=$(echo ${LINE} | grep "\\.cc$") && break
done

# Emit dependency info
gcc -M ${*} | sed "
		s/ \/[^ ]*//g;
		s/^.*\\.o:/$(echo ${TARGET} | sed "
				s/^\(.*\)\\.cc/\1.d \1.o:/;
				s/\\//\\\\\\//g")/;
		s/\\\\$//;
		s/^ //" | paste -d "" -s
