<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Courier New, monospace" size="4">
<div>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.</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>For each target, I already set variables for the dependencies and libraries. For example, for the target bin/query, I set:</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>bin/query_ldflags = -L/some/path –lsomelib;</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>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:</div>
<div> </div>
<div>bin/query_cflags = -I/a/path;</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>I have the LDFLAGS working but can’t figure out the CFLAGS.</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>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.</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>[ourTarget]_src = [stringset [match_mask [pkgPath]/%0%.c [MANIFEST]];</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>Then I have another variable to build the [[target]_obj] from the source.</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>[ourTarget]_obj = [fromto %0%.%1 %0%.o [[ourTarget]_src]];</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>That allows me to do the following:</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>bin/%: [[target]_dep] set unlink {</div>
<div> [cc] –o [target] [[target]_obj] [[target]_ldflags] [all_libs];</div>
<div>}</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>So, I thought that I could change my compile command to</div>
<div> </div>
<div>%0%.o: %0%.c {</div>
<div> [cc] [[target]_cflags] [CFLAGS] –c %0%.c –o [target];</div>
<div>}</div>
<div> </div>
<div>Of course that doesn’t work since target is something like src/bin/query/foobar.o.</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>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?</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
</font>
</body>
</html>