Unix questions - Make file with objects in one directory

This is Interesting: Free IT Magazines  
Home > Archive > Unix questions > August 2006 > Make file with objects in one directory





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Make file with objects in one directory
kiranj.email@gmail.com

2006-08-21, 1:23 am

Hi,
I am new to unix make and so, this question may sound little silly. But
please help.

I need to compile a list of .c and .cpp source files that are in a big
directory structure.

Ex:

/code_root
/design/tools/test1.c
/design/tools/test2.c
/design/src/tcpstack.cpp
/design/src/tcpsrlze.c
/design/src/util/charconv.cpp
/arch/src/frmwrk/frmroot.cpp

like wise there are about 700 files in the directory structure.

I need to write a unix make file that can compile all these files and
then create the objects in one directory namely
/code_root/obj

Can some please help on how to write?

I have the following, but it compiles into the source itself.

$OBJECTS= \
/code_root/design/tools/test1.o \
/code_root/design/tools/test2.o \
/code_root/design/src/tcpstack.opp \
/code_root/design/src/tcpsrlze.o \
/code_root/design/src/util/charconv.opp \
/code_root/arch/src/frmwrk/frmroot.opp \

all: $(OBJECTS)

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

%.opp:%.cpp
$(CC) -c $< -o $@

Well, I downloaded this code from some where and I kind of understood
what it is doing. But couldn't change it to get what I want.

Thanks in advance for your help.

Pascal Bourguignon

2006-08-21, 1:23 am

kiranj.email@gmail.com writes:

> Hi,
> I am new to unix make and so, this question may sound little silly. But
> please help.
>
> I need to compile a list of .c and .cpp source files that are in a big
> directory structure.


man make
info make

Check for VPATH


--
__Pascal Bourguignon__ http://www.informatimago.com/

CAUTION: The mass of this product contains the energy equivalent of
85 million tons of TNT per net ounce of weight.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com