-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 09/15/10 16:43, David M. Syzdek wrote:
> Make can keep variable values across commands. Here is an example which
> creates a blank file and then uses sed to replace the placeholders with
> values. I'd explain it more, but I have to run.
> On Wed, Sep 15, 2010 at 4:40 PM, Tim Gibney <timgibney76@gmail.com> wrote:
I received the Makefile because you CC'd it to me. That still doesn't
count, according to my rules, because you used all those back-slashes
and semicolons, meaning you basically put a lot of commands onto one
line, while I was talking about preserving values across /separate/
lines in the Makefile. But that does seem like a decent workaround, I'll
admit, at least as far as the variable value issue.
$ cat Makefile
# substitution routine
srcdir = .
do_subst = sed \
-e "s,[@]NAME[@],David Syzdek,g" \
-e 's,[@]PROGRAM[@],make,g' \
-e 's,[@]NOUN[@],challenge,g' \
-e "s,[@]DATE[@],$${DATE},g"
do_subst_dt = \
echo "do_subst < ${@}.in > ${@}"; \
mkdir -p `dirname ${@}` || exit 1; \
${do_subst} < $(srcdir)/${@}.in > ${@} || exit 1; \
chmod 0644 ${@}
all: challenge-accepted.txt
challenge-accepted.txt.in:
echo "Creating template file..."
echo " \
My name is @NAME@. \
I use @PROGRAM@ for a living. \
I accepted your @NOUN@. \
I hope this helps around the time of @DATE@. \
" > challenge-accepted.txt.in;
challenge-accepted.txt: challenge-accepted.txt.in
echo "replacing template with values..."
DATE=`date`; \
$(do_subst_dt)
clean:
rm -f challenge-accepted.txt
rm -f challenge-accepted.txt.in
- --
Christopher Howard
frigidcode.com
theologia.indicium.us
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkyRfywACgkQQ5FLNdi0BcWL9wCeIvqRloiyCQRAs/h5mpGWmY16
EHEAoJ8nzaVI27gOJannVlFaTKGzlham
=rrAp
-----END PGP SIGNATURE-----
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Wed Sep 15 18:21:29 2010
This archive was generated by hypermail 2.1.8 : Wed Sep 15 2010 - 18:21:29 AKDT