[Cook] -script and non-recipe softcoding

Aryeh M. Friedman aryeh at m-net.arbornet.org
Sun Feb 23 09:15:01 EST 2003


If I have something like this:

date = [collect date];

all:
{
	echo [date];
}

I get something like this from cook -script:

/* /usr/home/mudngdev/test/Howto.list */
#!/bin/csh

#line 4 Howto.cook
if test ! -e all
then
echo 'echo Sat Feb 22 16:49:53 GMT 2003'
( echo Sat Feb 22 16:49:53 GMT 2003 )
test $? -eq 0 || exit 1
fi
exit 0

In this trival example it is OK that the date is hardcoded but in a more 
complex one like creating a script to cross platform compiling where
I might have something like this:

Note this particular example uname -a is assumed to produce something like:

FreeBSD 7of9 4.6-RELEASE FreeBSD 4.6-RELEASE #0: Tue Jun 11 06:14:12 GMT 2002     murray at builder.freebsdmall.com:/usr/src/sys/compile/GENERIC  i386

Also note this is a slightly artifical example to show the issue not a
actual cook book if anyone needs to see the actual cookbook it is
http://arbornet.org/~aryeh/Howto.cook and http://arbornet.org/~aryeh/cook.hdr
and the actual output script is http://arbornet.org/~aryeh/Build.sh.

/* the description of what platform we are on */
CXX = g++;

unamestr = [split "=" [collect uname -a|tr "' .'" "'=V'"|tr -s "'='"|
        tr -d "'\!-/'"|sed "'s/RELEASE//g'"|tr "'A-Z'" "'a-z'"]];

os_flavor = [word 1 [unamestr]];
os_version = [unsplit _ [split v [word 3 [unamestr]]]];
hw_processor = [collect echo [word 14 [unamestr]]|tr "'a-z'" "'A-Z'"];

/* since many UNIX's do not tell you if they are sysv, bsd, or something weird
   we have slightly hardcode it */

if [match_mask freebsd [os_flavor]] then
{
        os_type="unix";
        os_family="bsdunix";
}

/* command lines */
CXXFLAGS = -Iinclude -Llib -W -Wall -Wold-style-cast -Werror -gstabs+3 -pipe
        "'-DHW_PROCESSOR='"[hw_processor] "'-DOS_FLAVOR='"[os_flavor];


all:
{
	[CXX] [CXXFLAGS] src1.cpp -o prog;
}

I get the following from -script:

/* /usr/home/mudngdev/test/Howto.list */
#!/bin/csh

#line 25 Howto.cook
if test ! -e all
then
echo "g++ -Iinclude -Llib -W -Wall -Wold-style-cast -Werror -gstabs+3 -pipe '-DHW_PROCESSOR='I386 '-DOS_FLAVOR='freebsd src1.cpp -o prog"
( g++ -Iinclude -Llib -W -Wall -Wold-style-cast -Werror -gstabs+3 -pipe '-DHW_PROCESSOR='I386 '-DOS_FLAVOR='freebsd src1.cpp -o prog )
test $? -eq 0 || exit 1
fi
exit 0

It is obvious that I do not want I386 or freebsd to be hardcoded 
HW_PROCESSOR and OS_FLAVOR respectivally.  The OS_TYPE and OS_FAMILY are used
else where in the cook book also and produce simelor hardcoded results.

Here is my question.  How do I FORCE the script to use local values not
the values that where produced on the system I did the build on.  I think
Peter has something like this since both Cook and Aegis "make" with no editing
on different platforms.  Note I do not want to use autoconf or any other
configuration tools except the source cook book due to some internal details.

	--Aryeh



More information about the Cook-users mailing list