[NTLUG:Discuss] gnu make

Kevin Brannen kbrannen at gte.net
Mon Feb 21 22:45:16 CST 2000


Michael Sandfort wrote:
> 
> Sorry for the off-topic post, but I'm hoping someone can give me a quick
> and easy fix to this. I've got some source code that I need to compile
> with an included Makefile.

I don't consider it off-topic, or at least not too far off... :-)

> 
> Short version of the problem:
> Does anyone know a quick-and-dirty workaround to the fact that gnu make
> does not support the $$@ macro?

Yes, use the extension functions if offers, e.g. subst, patsubst,
wildcard, etc.; depending on your needs.

> 
> Long version:
> The Makefile is designed to compile against a variety of setups (i.e., do
> you have software packages Matlab, Gauss, etc.).
> 
> Problem 1) When I try to compile for my setup, I get the following error
> from gnu make:
> Makefile:170: *** target pattern contains no `%'.  Stop.
> 
> Getting rid of the offending line (it pertains to another system setup)
> gets rid of this error, but I would like to know why it is happening.
> Line 170 reads:
> 
> $(MATLAB_MEX): $${@:.mexsol=.o} $(MATLAB_DIR)/mexversion.o $(MATLAB_OTHER) $(OPENLIBS_Matlab) $(CLOSEDLIBS)

I'd have to see the whole makefile (or at least more of it) to be 100%
correct, but this should be easily solved with an extra var.  Try
something like:

MATLAB_MEX_OBJS = $(MATLAB_MEX:.mexsol=.o)
$(MATLAB_MEX): $(MATLAB_MEX_OBJS) $(MATLAB_DIR)/mexversion.o ...etc...

>         $(LD) $(MLDFLAGS) -o $@ ${@:.mexsol=.o} $(MATLAB_DIR)/mexversion.o \
>         $(MATLAB_OTHER) $(OPENLIBS_Matlab) $(CLOSEDLIBS)

Same thing here.  Put $(MATLAB_MEX_OBJS) in place of ${@:.mexsol=.o}.

Also see patsubst() in the gmake manual.

> 
> Problem 2) Even when the offending line is removed, I get the error:
> make: *** No rule to make target `$@.o', needed by `Unix/expect1'.  Stop.
> 
> The offending line appears to be
> 
> $(UNIXOTHER): $$@.o $(UNIXDEP) $(OPENLIBS) $(CLOSEDLIBS)
>         $(CC) -o $@ $@.o $(UNIXOBJ) $(OPENLIBS) $(CLOSEDLIBS) -lm
>         $(CC) -g -o $@_db $@_db.o $(UNIXOBJ_DB) $(OPENLIBS_DB) $(CLOSEDLIBS) -lm
> 
> Having read the make manual, I know that $$@ is not supported by gnu make
> (unlike it is on SysV and BSD). Is there any way to get around this,
> short of listing every single source/object file?

Hmmm, I thought gmake supported that.  Oh well, it's been a while since
I was that deep in it.  First, try changing $$@.o into $@.o.  If that
doesn't do it, introduce another temp var as above, or change it to
$(UNIXOTHER).o which is what it means anyway.

HTH,
Kevin




More information about the Discuss mailing list