[Gllug] GNU make expert question: write variable value to a file

rich at annexia.org rich at annexia.org
Sat Mar 1 18:12:33 UTC 2003


This is a tricky GNU make question.

How do I write the value of a makefile variable to a named file?

The variable has been defined with:

define foo
...
...
endef

So it may contain newlines, quotes, etc. and I want those exactly
preserved in the output of course. I want variables references to
be expanded.

I can't export the variable to a shell script, so the obvious
method doesn't work:

export foo

file: Makefile
	write.sh> $@

where write.sh is:

#!/bin/sh
cat <<EOF
$foo
EOF

This does work but isn't acceptable because the variable in question
is very large, and so overflows the environment for this and every
other process that the Makefile runs.

Ideas???

Rich.

-- 
Richard Jones, Red Hat Inc. (London, UK) http://www.redhat.com/software/ccm
http://www.annexia.org/ Freshmeat projects: http://freshmeat.net/users/rwmj
MONOLITH is an advanced framework for writing web applications in C, easier
than using Perl & Java, much faster and smaller, reusable widget-based arch,
database-backed, discussion, chat, calendaring:
http://www.annexia.org/freeware/monolith/

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list