[Cook] How can I make my cook file stop always generating dependency files? -- LONG --
Henderson, Michael D
michael.d.henderson at lmco.com
Tue Aug 23 10:59:52 EST 2005
I'm trying to create a cook book based on the sample that uses dependency files in the user's guide. I've got it working, but there are a few things that I don't understand. The cook file is attached, it's long but I don't know which parts to cut out and still make it understandable.
1. When I run a "cook what" to create a dump of my variables so that I can verify what I'm doing, it always re-creates all of my _dep files. I'm pretty sure it's because of this line
#include-cooked [pkg_dependencies]
Is there a way to make that conditional?
2. The sample had the cpp_dep files created with "set no-cascade" and the hpp_dep files created without that. I've tried it both ways and it seems to work, so I guess that I'm not understanding what it is that the no-cascade option does. I've looked at the manual but remain utterly clueless.
3. Why does the hpp_dep rule look at dirname %0%.cpp? Shouldn't it look at %0%.hpp or since it's doing a dirname, does it even matter?
8<------------------------------->8
set tell-position;
gnuProject = TestCook_dep;
gnuAuthor = Mike Henderson;
gnuVer = 0.0.1;
gnuDir = [gnuProject]-[gnuVer];
gnuRoot = /hrapp/devl/[gnuProject]/;
gnuTest = /userhome/mdhender/bin/testit;
gnuInclude = ;
gnuLibrary = ;
inst_root = /hrapp/packages/;
inst_lib = [inst_root]lib/[gnuProject]/;
inst_inc = [inst_root]include/[gnuProject]/;
/*===========================================================================
* Package Identification Strings
*/
gnuIdentFlags = [catenate -DPKG_VER\= '\'"' [gnuVer] '"\'']
[catenate -DPKG_IDENT\= "'" '"@(#)' [gnuProject]-[gnuVer] ' " ' '__DATE__ " " __TIME__ " " __FILE__' "'" ]
[catenate -DSRC_IDENT\= "'" '"@(#)"__DATE__" "__TIME__" "__FILE__' "'"]
;
/*==========================================================================*/
ar = /usr/ccs/bin/ar;
cpp = g++;
install = echo install.sh [gnuVer];
ranlib = /usr/ccs/bin/ranlib;
/*==========================================================================*/
cpp_incl = -Isrc;
cpp_flags = [gnuIdentFlags]
[cpp_incl]
;
cpp_libs = ;
/*===========================================================================
* allow cook to generate the list of sources files that we have
*/
MANIFEST = [stripdot [collect find . -type f ]];
/*===========================================================================
* allow cook to generate the list of packages files that we have
*/
pkg_names = Foo
Froob
;
pkg_libraries = ;
pkg_dependencies = ;
/* turn the list of packages into a list of libraries */
list_loop = [pkg_names];
loop {
local var_name = [head [list_loop]];
if [not [count [var_name]]] then
loopstop;
list_loop = [tail [list_loop]];
local var_lib = lib/lib[var_name].a;
[var_lib]_src = [match_mask [var_name]/%0%.cpp [MANIFEST]];
[var_lib]_hdr = [match_mask [var_name]/%0%.hpp [MANIFEST]];
[var_lib]_xml = [match_mask [var_name]/%0%.xml [MANIFEST]];
[var_lib]_obj = [fromto %0%.cpp %0%.o [[var_lib]_src]];
[var_lib]_dep = [fromto %0%.cpp %0%.cpp_dep [[var_lib]_src]]
[fromto %0%.hpp %0%.hpp_dep [[var_lib]_hdr]]
;
function print [var_lib]_src is [[var_lib]_src];
function print [var_lib]_dep is [[var_lib]_dep];
if [count [[var_lib]_obj]] then
pkg_libraries = [pkg_libraries] [var_lib];
if [count [[var_lib]_obj]] then
pkg_dependencies = [pkg_dependencies] [[var_lib]_dep];
}
function print packages names are [pkg_names];
function print dependency files are [pkg_dependencies];
#include-cooked [pkg_dependencies]
/*===========================================================================*/
all: all_libraries
{
function print life is good;
}
all_libraries: [pkg_libraries]
{
function print pkg_libraries is [pkg_libraries];
}
/*===========================================================================*/
clean:
{
clean_list = Howto.list
[match_mask %0%.o [MANIFEST]]
[match_mask %0%~ [MANIFEST]]
[match_mask %0core [MANIFEST]]
;
if [count [clean_list]] then
delete [clean_list] set silent;
}
clobber: clean
{
clean_list = .c_inclrc
[pkg_libraries]
[pkg_dependencies]
;
if [count [clean_list]] then
delete [clean_list] set silent;
}
what: /* document our libraries */
{
list_loop = [pkg_names];
loop {
local var_name = [head [list_loop]];
if [not [count [var_name]]] then
loopstop;
list_loop = [tail [list_loop]];
local var_lib = lib/lib[var_name].a;
function print var_lib "=" [var_lib];
function print [var_lib]_src "=" [[var_lib]_src];
function print [var_lib]_hdr "=" [[var_lib]_hdr];
function print [var_lib]_xml "=" [[var_lib]_xml];
function print [var_lib]_obj "=" [[var_lib]_obj];
}
}
/*===========================================================================*/
function Say-Why =
{
if [count [@1]] then
@1 = [@1];
if [count [@2]] then
@2 = [@2];
local tt = [target];
if [defined targets] then
tt = [targets];
if [in [count [younger]] 0 1 2 3] then {
function print [@1] [@2]
Building [target] because of [younger];
} else {
function print [@1] [@2]
Building [target] because of [wordlist 1 3 [younger]] et al;
}
}
/*===========================================================================
* force a C++ source file to compile in the current directory with the right
* include files -- assumes that dependency files have been created
*/
%0%.o: %0%.cpp
{
function Say-Why [__FILE__] [__LINE__];
[cpp] -I[dirname %0%.cpp] [cpp_flags] -c %0%.cpp -o [target];
}
/*===========================================================================
* create a library from object files
*/
lib/lib%.a: [[target]_obj]
set unlink
{
function Say-Why [__FILE__] [__LINE__];
[ar] cq [target] [[target]_obj];
[ranlib] [target];
}
/*===========================================================================
* from the sample, create dependency list files for CPP files
*/
%0%.cpp_dep: %0%.cpp
set no-cascade
{
function Say-Why [__FILE__] [__LINE__];
c_incl --no-cache --no-recurs %0%.cpp
-I[dirname %0%.cpp] [cpp_incl]
"--prefix='cascade %0%.cpp = '"
"--suffix=';'"
-o [target]
set silent;
}
/*===========================================================================
* from the sample, create dependency list files for HPP files
*/
%0%.hpp_dep: %0%.hpp
set no-cascade
{
function Say-Why [__FILE__] [__LINE__];
c_incl --no-cache --no-recurs %0%.hpp
-I[dirname %0%.cpp] [cpp_incl]
"--prefix='cascade %0%.hpp = '"
"--suffix=';'"
-o [target]
set silent;
}
8<------------------------------->8
More information about the Cook-users
mailing list