C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Makefile question

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Matthias Pieroth
Guest





PostPosted: Thu Mar 04, 2004 3:27 pm    Post subject: Makefile question Reply with quote



Hi NG,

I have the following MakeFile:

# Compiler
#---------------------------------------
CC = g++

APP = snake-client

# Compilerflags
#---------------------------------------
#CFLAGS += -O2

# Libraries
#---------------------------------------
LIB = -lncurses

# Sourcedateien
#---------------------------------------
SRC = snake-client.cpp CCursesWrapper.cpp

# Objektdateien
#---------------------------------------
OBJ = $(SRC:.cpp=.o)

$(APP): $(OBJ)
$(CC) $(OBJ) -o $(APP) $(LIB)

clean:
rm *.o

My problem is, I have a CCursesWrapper.h. I want to add this file to the
MakeFile, so that it will be included and newly compiled if I change the
CCursesWrapper.h. How can I do this?

Thank you

Matthias

Back to top
Emanuel Ziegler
Guest





PostPosted: Thu Mar 04, 2004 3:46 pm    Post subject: Re: Makefile question Reply with quote



Matthias Pieroth wrote:
Quote:
My problem is, I have a CCursesWrapper.h. I want to add this file to the
MakeFile, so that it will be included and newly compiled if I change the
CCursesWrapper.h. How can I do this?

I think you want to recompile CCursesWarpper.o whenever CCursesWarpper.cpp
or CCursesWrapper.h is changed. So, you simply have to add a rule for
CCursesWrapper.o like

CCursesWrapper.o: CCursesWrapper.cpp CCursesWrapper.h
$(CC) -c -o $@ $< $(LIB)

if CCursesWrapper.h is located in the current directory (otherwise you have
to add -I for the directory of CCursesWrapper.h).

HTH
Emanuel

Back to top
Gianni Mariani
Guest





PostPosted: Thu Mar 04, 2004 3:59 pm    Post subject: Re: Makefile question [OFF TOPIC] Reply with quote



Matthias Pieroth wrote:
Quote:
Hi NG,


Hi NG,

this is off-topic for comp.lang.c++. Try posting to comp.programming.

Quote:
I have the following MakeFile:
....

My problem is, I have a CCursesWrapper.h. I want to add this file to the
MakeFile, so that it will be included and newly compiled if I change the
CCursesWrapper.h. How can I do this?


you'll need to add the rule

$(OBJ) : CCursesWrapper.h
# no commands...


However - if you want all this to happen automagically, use MakeXS.

(shameless plug)

http://www.makexs.com



Back to top
Jorge Rivera
Guest





PostPosted: Fri Mar 05, 2004 4:43 am    Post subject: Re: Makefile question Reply with quote

Matthias Pieroth wrote:
Quote:
Hi NG,

I have the following MakeFile:

# Compiler
#---------------------------------------
CC = g++

APP = snake-client

# Compilerflags
#---------------------------------------
#CFLAGS += -O2

# Libraries
#---------------------------------------
LIB = -lncurses

# Sourcedateien
#---------------------------------------
SRC = snake-client.cpp CCursesWrapper.cpp

# Objektdateien
#---------------------------------------
OBJ = $(SRC:.cpp=.o)

$(APP): $(OBJ)
$(CC) $(OBJ) -o $(APP) $(LIB)

clean:
rm *.o

My problem is, I have a CCursesWrapper.h. I want to add this file to the
MakeFile, so that it will be included and newly compiled if I change the
CCursesWrapper.h. How can I do this?

Thank you

Matthias


You can automate this process somewhat...

Do a man on mkdepends. Read carefully. It writes rules, but it changes
your Makefile while doing it. It is nice because it will run a
preprocessor on your source files and determine all the header files it
requires. It then proceeds to create rules and append them to your Makefile

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.