|
From: | 杨伟 |
Subject: | Help on the implicit rule |
Date: | Thu, 24 Jul 2008 00:10:40 +0800 |
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) $< > address@hidden; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < address@hidden > $@; \
rm -f address@hidden
-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
[Prev in Thread] | Current Thread | [Next in Thread] |