xref: /freebsd/contrib/ntp/scripts/build/fixautomakedepsmagic (revision 416ba5c74546f32a993436a99516d35008e9f384)
1*2b15cb3dSCy Schubert#!/bin/sh
2*2b15cb3dSCy Schubert
3*2b15cb3dSCy Schubertprog=`basename $0`
4*2b15cb3dSCy Schubert
5*2b15cb3dSCy Schubert
6*2b15cb3dSCy Schubertt=/tmp/$prog.$$
7*2b15cb3dSCy Schubert
8*2b15cb3dSCy Schuberttrap 'rm -f ${t} ; exit 1' 1 3 15
9*2b15cb3dSCy Schubert
10*2b15cb3dSCy Schubertwhile [ $# -gt 0 ]; do
11*2b15cb3dSCy Schubert        f=$1
12*2b15cb3dSCy Schubert	shift
13*2b15cb3dSCy Schubert	sed -e '/^DEPS_MAGIC :=/,/^-include \$/s/^/#/' $f > $t
14*2b15cb3dSCy Schubert	c="diff $f $t"
15*2b15cb3dSCy Schubert	echo $c
16*2b15cb3dSCy Schubert	$c
17*2b15cb3dSCy Schubert	tstatus=$?
18*2b15cb3dSCy Schubert	if [ $tstatus = 0 ]; then
19*2b15cb3dSCy Schubert		echo "$prog":" $f not modified"
20*2b15cb3dSCy Schubert	elif [ ! -w $f ]; then
21*2b15cb3dSCy Schubert		echo "$prog":" $f not not writable"
22*2b15cb3dSCy Schubert	else
23*2b15cb3dSCy Schubert		c="cp $t $f"
24*2b15cb3dSCy Schubert		echo $c
25*2b15cb3dSCy Schubert		$c
26*2b15cb3dSCy Schubert	fi
27*2b15cb3dSCy Schubert	rm -f $t
28*2b15cb3dSCy Schubertdone
29