[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Make dependency check
From: |
Geraldin Arthy |
Subject: |
Re: Make dependency check |
Date: |
Thu, 23 Nov 2006 19:52:00 +0530 |
Hello Paul,
Thanks a lot for your suggestion.I have tried two possibilties out of which one works and the other doesn't.I definitely want to know why the other option doesn't work.
Now the problem is the makefile generates the .P files under the $(OUTPUT_DIR) directory.Even though the .P files refer to the proper path , when I modify a header file and give a make it does not rebuild.In my makefile I have given like below.(Please check the attachment
Make_no.zip.)
MAKEDEPEND = touch $(OUTPUT_DIR)/$*.d && makedepend $(CPPFLAGS) -I$(INCS) -f $(OUTPUT_DIR)/$*.d $<
$(OBJS):$(OUTPUT_DIR)/%.o: %.cxx
@$(MAKEDEPEND); \
cp $(OUTPUT_DIR)/$*.d $(OUTPUT_DIR)/$*.P; \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $(OUTPUT_DIR)/$*.d >> $(OUTPUT_DIR)/$*.P; \
rm -f $(OUTPUT_DIR)/$*.d
$(CXX) $(CFLAGS) $(@F:.o=.cxx) -o $@
-include $(SRCS:.cxx=$(OUTPUT_DIR)/%.P)
The .P files under $(OUTPUT_DIR)/ directory have info like this.
COvBucket.o: /home/geraldin/vobs/pdf_src/pdfoverload/COvBucket.h
COvBucket.o: /home/geraldin/vobs/pdf_src/pdfcommon/src/PdfType.h
COvBucket.o: /home/geraldin/vobs/pdf_src/pdfcommon/src/CPdfObject.h
COvBucket.o
: /home/geraldin/vobs/pdf_src/pdfcommon/src/CPdfTrace.h
I'm not able to fix what is wrong with my makefile.Please help me to solve this problem.
The second option is
I modified the makefile to create the .P and .o files in the same directory as the source code.Please check the attachment make_work.zip.
If I have my makefile like this it works.When I change any header file that is referred by the .P file it rebuilds again.
The only difference between this makefile and the previous makefile is that the previous one creates all the .o and .P file under the $(OUTPUT_DIR) and refers to the absolute path (i.e $(VIEWPATH) ) because if I specify the realtive path it is definitely wrong since it refers to the header files relative to $(OUTPUT_DIR). But this makefile which is working creates the .o and .P files in the source directory itself and refers to relative path.
But in our project, we defintely should have all the .o files or any files those are generated by make under the $(OUTPUT_DIR.
Please help me to fix this problem and let me know where I'm going wrong.
Please have a look at both the attachments
Thanks in advance,
GA
On 11/23/06, Paul D. Smith <address@hidden> wrote:
On Wednesday, 22 November, Geraldin Arthy (address@hidden
) wrote:
> MAKEDEPEND = touch $*.d && makedepend $(CPPFLAGS) -I$(INCS) -f $*.d -p$(OUTPUT_DIR) $<
> $(OBJS):$(OUTPUT_DIR)/%.o: %.cxx
> @$(MAKEDEPEND); \
> cp $*.d $*.P; \
> sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
> -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
> rm -f $*.d
> $(CXX) $(CFLAGS) $(@F:.o=.cxx) -o $@
> -include $(SRCS:.cxx=$(OUTPUT_DIR)/%.P)
This is not right.
Your MAKEDEPEND rule and the sed, etc. afterwards create a file $*.P, where $*
will expand to the stem of the target/prerequisite. For a pattern rule this
is essentially whatever text matches the pattern (%).
In your rules, for a target $(OUTPUT_DIR)/foo.o and a prerequisite foo.cxx,
the stem ($*) is "foo".
So, these commands will build a file
foo.P for every source file foo.cxx that
you compile.
BUT, your include line doesn't include foo.P, it includes $(OUTPUT_DIR)/foo.P,
which does not exist. So, that include line doesn't do anything at all and
none of the prerequisites defined in your .P file are being seen.
You should really use the -d (debug) option; these things would be clear. I
know it generates a ton of output but you can redirect it to a file, then
search through it for a representative file. It would tell you that it can't
open those included files. You can also use the -p option to have make print
its internal database: you'd see then that none of the prerequisites exist.
You should change your rules to create $(OUTPUT_DIR)/$*.P, not just $*.P.
Also, I recommend changing your command to use the variable $(OUTPUT_DIR) in
your .P files, rather than the expanded value of $(OUTPUT_DIR).
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
Make_no.zip
Description: Zip archive
make_work.zip
Description: Zip archive
- Re: Make dependency check, Geraldin Arthy, 2006/11/21
- Re: Make dependency check, Paul D. Smith, 2006/11/21
- Re: Make dependency check, Geraldin Arthy, 2006/11/22
- Re: Make dependency check, Paul D. Smith, 2006/11/22
- Re: Make dependency check, Geraldin Arthy, 2006/11/24
- Re: Make dependency check, Paul D. Smith, 2006/11/24
- Re: Make dependency check, Philip Guenther, 2006/11/24
- Re: Make dependency check, Paul D. Smith, 2006/11/25
- Re: Make dependency check, Philip Guenther, 2006/11/25
- Re: Make dependency check,
Geraldin Arthy <=
- Re: Make dependency check, Dave Hylands, 2006/11/24