<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I believe you are creating more variables than you really need.<div>A couple different levels regarding the CCFLAGS portion.</div><div>1) You can use the recipe patterns to form the variable name by breaking</div><div> the pattern into known and variable portions</div><div>src/%0%/%.o: src/%0%/%.c {</div><div> [cc] [%0%_cflags] [CFLAGS] –c src/%0%/%.c –o [target];</div><div>}</div><div><br></div><div>2) If the whole purpose of this is to all the xx_cflags to point to the source directory like for</div><div>src/bin/query/foobar.o you want -I/src/bin/query</div><div>Then you don't need bin/query_cflags at all you get that by:</div><div>src/%0%/%.o: src/%0%/%.c {</div><div> [cc] -Isrc/%0% [CFLAGS] –c src/%0%/%.c –o [target];</div><div>}</div><div><br></div><div>And for your link recipe you can simplify your variable names by using the partial pattern portion rather than [target] ala:</div><div>query_ldflags = -L/some/path –lsomelib;</div><div>query_objs = ....;</div><div>bin/%: [[target]_dep] set unlink {</div><div> [cc] –o [target] [%_obj] [%_ldflags] [all_libs];</div><div>}</div><div><br></div><div>Hope that helps...</div><div><br></div><div>On 4 Jun, 2010, at 14:29 , Henderson, Michael D wrote:</div><div><div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Courier; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div><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><span class="Apple-style-span" style="font-family: Calibri, sans-serif; font-size: small; "> [cc] –o [target] [[target]_obj] [[target]_ldflags] [all_libs];</span></div><div><span class="Apple-style-span" style="font-family: Calibri, sans-serif; font-size: small; ">}</span></div><div><span class="Apple-style-span" style="font-family: Calibri, sans-serif; font-size: small; "> </span></div><div>So, I thought that I could change my compile command to</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> </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>_______________________________________________<br>Cook-users mailing list<br><a href="mailto:Cook-users@lists.auug.org.au">Cook-users@lists.auug.org.au</a><br><a href="http://lists.auug.org.au/listinfo/cook-users">http://lists.auug.org.au/listinfo/cook-users</a><br></div></span></blockquote><div><br></div></div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Courier; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Jerry Pendergraft</div><div><a href="mailto:jpendergraft@sjm.com">jpendergraft@sjm.com</a></div><div><br></div></div></span><br class="Apple-interchange-newline"> </div><br></div><DIV> </DIV>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.</body></html>