Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

a question on makefile
Hi,

I'm not sure if this is the right place for discussing makefile. If it's not
correct, would u let me know the right news group? thanks.

I'm facing headache when I try to write a gnu style makefile for a project.
Due to the existing source directory structure of the project, the makefiles
have to be saved away from the source files, and the interim files and
output files need to be saved in a sub-dir of the makefile. The project
source file directory structure looks like:

/pjt_root/
/part1/
/file1.c
/file1.h
/part2/
/file2.c
/file2.h
/config/
/makefile
/debug/
/file1.o
/file2.o
/a.out
/release/
/file1.o
/file2.o
/a.out

If the target is for debug purpose, all .o and .out will be in 'debug'
purpose. The same rule applies to 'release'.

The makefile looks like:

SRC= part1/file1.c part2/file2.c
$OBJECTS:= $(foreach src, $(SRC),  $(basename $(notdir $(src))).o)

ALL_Debug: debug/a.out
OBJECTS_Debug:=$(foreach obj, $(OBJECTS), debug/$(obj))
debug/a.out: $(OBJECTS_Debug)
$(CC) $(CFLAGS) -o $@ $<

%.o:%.c
$(CC) $(CFLAGS) -c $<

But the problem comes. 'make' does NOT know how to make debug/file1.o
debug/file2.o.

Do I need to change the suffix rule as "$(target_folder)/%.o:%.c", and
specify VPATH= $(foreach src, $(SRC), $(dir $(src))) for c files at the same
time? But this approach not only looks awkward, but also error-prone. And
the rule doesn't work well.

May u kindly point out a better solution for this scenario? Thanks.

Regards,
Liang



Report this thread to moderator Post Follow-up to this message
Old Post
Liang
12-20-04 08:56 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 08:13 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.