 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Matthias Pieroth Guest
|
Posted: Thu Mar 04, 2004 3:27 pm Post subject: Makefile question |
|
|
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
|
Posted: Thu Mar 04, 2004 3:46 pm Post subject: Re: Makefile question |
|
|
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
|
Posted: Thu Mar 04, 2004 3:59 pm Post subject: Re: Makefile question [OFF TOPIC] |
|
|
Matthias Pieroth wrote:
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
|
Posted: Fri Mar 05, 2004 4:43 am Post subject: Re: Makefile question |
|
|
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 |
|
 |
|
|
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
|
|