LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Makefile question? (https://www.linuxquestions.org/questions/programming-9/makefile-question-4175461151/)

j3ski 05-08-2013 08:30 AM

Makefile question?
 
I have a Makefile with:
.PHONY: all clean distclean

all: $(LEXFILE) $(BINDIR)/$(APP)
where:
LEXFILE := lex.yy.c
APP = bridge
BINDIR = bin
If I redefine:
all: $(LEXFILE) $(OBJDIR)/%.o
where:
OBJDIR = obj
I get: make: *** No rule to make target `obj/%.o', needed by `all'. Stop.

Why?

pan64 05-08-2013 08:56 AM

the line all: $(LEXFILE) $(OBJDIR)/%.o is syntactically correct, but will not do what you want, you would need to check the documentation about how to use %.
In your case make is looking for a file named %.o in the dir obj.
Usually you need something like that:
%.ext1: %.ext2 where % can be replaced with a filename using ext1 and ext2 as target(result) and source.

NevemTeve 05-09-2013 02:14 AM

Well, what did you mean by $(OBJDIR)/%.o? What should make have substitute with?


All times are GMT -5. The time now is 02:41 PM.