File: mkdep

package info (click to toggle)
bsdgames 2.5-4
  • links: PTS
  • area: main
  • in suites: slink
  • size: 8,412 kB
  • ctags: 4,665
  • sloc: ansic: 59,763; sh: 643; yacc: 327; lex: 79; makefile: 53; sed: 13; csh: 5
file content (19 lines) | stat: -rwxr-xr-x 439 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
# mkdep - create dependencies
# usage: mkdep source output compiler flags
# e.g. mkdep foo/bar.c foo/bar.d gcc -g -O2 -DFOOBAR

set -e

source_file=$1
base_name=${source_file%%.c}
base_base_name=`basename $base_name`
output_file=$2
compiler=$3
shift 3

"$compiler" -M "$@" "$source_file" >"$output_file".tmp

sed "s!$base_base_name.o *:!$base_name.o $base_name.d:!g" <"$output_file".tmp >"$output_file"

rm -f "$output_file".tmp