Hi, all

I am confusing about one implict rules on GNU Make.
It is
%: %.c
#  commands to execute (built-in):
    $(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@

I did a test according to the example in chapter 2 of the book <Managing
Projects with GNU Make 3rd>.

This is the make file I used.

vpath %.c src
vpath %.l src
vpath %.h include
CPPFLAGS = -I include
CC = gcc

SOURCES = count_words.c lexer.c counter.c

.PHONY: all clean help

all: count_words
    @echo Everything is Ok!


count_words: counter.o lexer.o -lfl

counter_words.o: counter.h

counter.o: counter.h lexer.h


lexer.o: lexer.h



%.d: %.c
    $(CC) -M $(CPPFLAGS) $< > [EMAIL PROTECTED];                  \
    sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < [EMAIL PROTECTED] > $@; \
    rm -f [EMAIL PROTECTED]


-include $(subst .c,.d,$(SOURCES))

clean:
    rm -f *.o lexer.c count_words *.d



I run the make, and get the result below:

..............

..............

lex  -t src/lexer.l > lexer.c
gcc  -I include  -c -o count_words.o src/count_words.c
gcc  -I include  -c -o counter.o src/counter.c
gcc  -I include  -c -o lexer.o lexer.c
gcc   count_words.o counter.o lexer.o /usr/lib/libfl.a   -o count_words

But when I comment the line with "include", the result is ;

gcc  -I include  -c -o counter.o src/counter.c
lex  -t src/lexer.l > lexer.c
gcc  -I include  -c -o lexer.o lexer.c
gcc  -I include   src/count_words.c counter.o lexer.o /usr/lib/libfl.a   -o
count_words



According to the implicit rule , I think the last one is right which compile
and link from the source code.But the previous one is the fact.

So I am confusing.



My platform is RH AS4, GNU Make 3.80.

Any knows the reason?



Thanks

Richard
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to