Article View: comp.bugs.sys5
Article #939Re: make bug
From: Chris Torek
Date: Mon, 02 Jan 1989 23:51
Date: Mon, 02 Jan 1989 23:51
48 lines
1822 bytes
1822 bytes
In article <987@vsi.COM> friedl@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@mimsy.umd.edu Path: uunet!mimsy!chris
Technical Details
Message-ID:
<15232@mimsy.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!ukma!rutgers!iuvax!uxc!tank!mimsy!chrisReferences:
<502@Aragorn.dde.uucp> <904@philmds.UUCP> <987@vsi.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!ukma!rutgers!iuvax!uxc!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.bugs.sys5,comp.unix.wizards Subject: Re: make bug Message-ID: <15232@mimsy.UUCP> Date: 2 Jan 89 23:51:00 GMT References: <502@Aragorn.dde.uucp> <904@philmds.UUCP> <987@vsi.COM> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 48