help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help with make file rules


From: Brian Dessent
Subject: Re: help with make file rules
Date: Fri, 14 Mar 2008 23:45:28 -0700

anonymoussuperuser wrote:

> I do have the make file to extract libraries into a temporary folder but I
> can't read the directory listing into a variable to include that in the
> final archive command?

When make runs a rule, it first expands all variables and then runs the
command.  What you've written is the equivalent of telling make to run
this:

sh -c "cd ../bins; ls > ; ar cru libtarget.a "

That's nonsensical.  In the context of the command being executed there
is no means to access or modify any make variables -- they've already
been expanded at that point.  But that's not a problem as there's no
need to assign the object filenames to a variable.  You don't need any
"ls" here, just let the shell do it.  If you had typed "cd ../bins; ar
-cru libtarget.a *.o" at a regular shell prompt it would have worked, so
just put that in your rule:

${TARGET}: ${LIB_FILES}
        cd ${TEMP_DIR}; \
        ar -cru ${TARGET} *.o

If for some reason you really need to get a list of filenames from a
glob into a make variable then you can't do it by executing commands in
a recipe, you have to use the make function $(wildcard).

Brian




reply via email to

[Prev in Thread] Current Thread [Next in Thread]