[Cook] how to split src/bin/query/foobar.o into src/ bin/query /foobar.o
Jerry Pendergraft
jpendergraft at sjm.com
Sat Jun 5 07:37:34 EST 2010
I believe you are creating more variables than you really need.
A couple different levels regarding the CCFLAGS portion.
1) You can use the recipe patterns to form the variable name by breaking
the pattern into known and variable portions
src/%0%/%.o: src/%0%/%.c {
[cc] [%0%_cflags] [CFLAGS] –c src/%0%/%.c –o [target];
}
2) If the whole purpose of this is to all the xx_cflags to point to
the source directory like for
src/bin/query/foobar.o you want -I/src/bin/query
Then you don't need bin/query_cflags at all you get that by:
src/%0%/%.o: src/%0%/%.c {
[cc] -Isrc/%0% [CFLAGS] –c src/%0%/%.c –o [target];
}
And for your link recipe you can simplify your variable names by using
the partial pattern portion rather than [target] ala:
query_ldflags = -L/some/path –lsomelib;
query_objs = ....;
bin/%: [[target]_dep] set unlink {
[cc] –o [target] [%_obj] [%_ldflags] [all_libs];
}
Hope that helps...
On 4 Jun, 2010, at 14:29 , Henderson, Michael D wrote:
> 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?
>
> _______________________________________________
> Cook-users mailing list
> Cook-users at lists.auug.org.au
> http://lists.auug.org.au/listinfo/cook-users
Jerry Pendergraft
jpendergraft at sjm.com
This communication, including any attachments, may contain information that is proprietary, privileged, confidential or legally exempt from disclosure. If you are not a named addressee, you are hereby notified that you are not authorized to read, print, retain a copy of or disseminate any portion of this communication without the consent of the sender and that doing so may be unlawful. If you have received this communication in error, please immediately notify the sender via return e-mail and delete it from your system.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.auug.org.au/pipermail/cook-users/attachments/20100604/2bf16684/attachment.htm>
More information about the Cook-users
mailing list