Subject: Re: When to put \n in Makefile
To: Tomasz Luchowski <zuntum@eik.pl>
From: Alistair Crooks <agc@netbsd.org>
List: tech-pkg
Date: 01/22/2001 09:16:01
On Sun, Jan 21, 2001 at 11:16:08PM +0100, Tomasz Luchowski wrote:
> -               ${SED}  -e "s,@PREFIX@,${PREFIX},g" \
> -                       -e "s,@CC@,${CC},g" \
> -                       -e "s,@CFLAGS@,${CFLAGS},g" \
> -                       < ${WRKSRC}/Makefile > ${WRKSRC}/Makefile.done
> +               ${SED}  -e "s,@PREFIX@,${PREFIX},g" -e "s,@CC@,${CC},g" \
> +                       -e "s,@CFLAGS@,${CFLAGS},g" < ${WRKSRC}/Makefile \
> +                       > ${WRKSRC}/Makefile.done
> 
> These are changes that fredb made to my Makefile.
> I wonder which way is prefered -- shorter (many -e's in one line)
> or more readable and easier to edit (my version, minuses).
> [ I can easily delete one s/ with "dd" in my favourite editor,
> and don't need to modify other ]
> 
> I don't want to complain, I'm just asking.
> 
> -- 
> /* [zuntum] zuntum@eik.pl , [WWW] http://zuntum.eik.pl */

Well, since you asked, personally, I'd make the command:

               ${SED}  -e 's|@PREFIX@|${PREFIX}|g'			\
                       -e 's|@CC@|${CC}|g'				\
                       -e 's|@CFLAGS@|${CFLAGS}|g'			\
                       ${WRKSRC}/Makefile > ${WRKSRC}/Makefile.done

i.e. 

1. be consistent iin placing one expressino per line
2. Place backslashes at end of line on 72nd column (8 spaces per tab)
3. Don't redirect input, just use the file
4. Use '|' symbols, rather than ','s for the delimiter for substitution
expressions, since it is visually nearest to '/', is an obvious visual
break between expressions, and is probably not going to appear in a
pathname (well, less likelihood than ',' anyway)
5. place substitution expressions in single quotes, rather than doubles
(necessary for the '|' delimiters anyway).

but I consider the whole thing a bit superfluous, because you're
modifying a Makefile - can't you just grab the information from
the MAKE_ENV information that's passed down?

Regards,
Alistair