make bug

Chris Torek chris at mimsy.UUCP
Tue Jan 3 09:51:00 AEST 1989


In article <987 at vsi.COM> friedl at vsi.COM (Stephen J. Friedl) writes:
>     New versions of make (augmake?) *do* allow this kind of
>substitution.  You can do:
>
>SRC	= $(OBJS:.o=.c)
>
>and it effectively does 's/\.o/.c/g' on each word in ${OBJS}.
>
>     It's very handy...

Indeed.  Since 4BSD still has a boring old make, I use a script
wrapped around `sed' to do the job:

	OBJS=	...
	SRCS=	`chgsuf .o .c` ${OBJS}
	lint: ${SRCS}
		lint ${LINTFL} ${SRCS}

The addsuf and chgsuf scripts (in /usr/local/bin) are trivial.
(Note that these break if the new suffix contains an `&'.  Sorry :-) )

#! /bin/sh
#
# addsuf - add suffix to each argument
# assumes no embedded spaces in arguments

case $# in 0) echo "usage: addsuf suffix files" 1>&2; exit 1;; esac

suf="$1"
shift
echo ${1+"$@"} | sed -e "s/ /$suf /g" -e "s/$/$suf/"

#! /bin/sh
#
# chgsuf - change suffix in each argument
# assumes no embedded spaces in arguments
# oldsuf is a string, not an R.E.

case $# in 0|1) echo "usage: chgsuf oldsuf newsuf files" 1>&2; exit 1;; esac

sed="sed -e s/[/.^[\*]/\\\\&/g"
oldsuf="`echo \"$1\" | $sed`"
newsuf="`echo \"$2\" | $sed`"
shift; shift
echo ${1+"$@"} | sed -e "s/$oldsuf /$newsuf /g" -e "s/$oldsuf$/$newsuf/"
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.bugs.sys5 mailing list