[Cook] how to split src/bin/query/foobar.o into src/ bin/query /foobar.o

Henderson, Michael D michael.d.henderson at lmco.com
Sat Jun 5 05:29:43 EST 2010


I'm trying to split a string like "src/bin/query/foobar.o" into three parts so that I can build a variable. I'm using this to set up compile flags for each specific target.

For each target, I already set variables for the dependencies and libraries. For example, for the target bin/query, I set:

bin/query_ldflags = -L/some/path -lsomelib;

Today I needed to put an include path in for a project but didn't want it in the global list of includes. So, I wanted to do something like this:

bin/query_cflags = -I/a/path;

I have the LDFLAGS working but can't figure out the CFLAGS.

I build the [[target]_src] variable automatically, using a loop against the manifest. The convention is that there is a src/bin directory. In there, I have a set of directories. Each directory contains the source for one (and only one) target. The loop uses this to set ourTarget and pkgPath. Then I create a variable and assign the source files.

[ourTarget]_src = [stringset [match_mask [pkgPath]/%0%.c [MANIFEST]];

Then I have another variable to build the [[target]_obj] from the source.

[ourTarget]_obj = [fromto %0%.%1 %0%.o [[ourTarget]_src]];

That allows me to do the following:

bin/%: [[target]_dep] set unlink {
  [cc] -o [target] [[target]_obj] [[target]_ldflags] [all_libs];
}

So, I thought that I could change my compile command to

%0%.o: %0%.c {
  [cc] [[target]_cflags] [CFLAGS] -c %0%.c -o [target];
}

Of course that doesn't work since target is something like src/bin/query/foobar.o.

Since I have a standard directory path, how can I split this into "src/" "bin/query" "foobar.o" so that I can take "bin/query" and build the variable name bin/query_cflags that holds the CFLAGS for the compilation?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.auug.org.au/pipermail/cook-users/attachments/20100604/b58b51ed/attachment.htm>


More information about the Cook-users mailing list