Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Using make
Using make [message #76900] Thu, 24 July 2003 16:19 Go to next message
shmuel siegel is currently offline shmuel siegelFriend
Messages: 75
Registered: July 2009
Member
I remember that there was a way to automatically have a makefile keep track
of the which "h" files are needed by a "cpp" file. Can someone refresh my
memory of how to set up a make-depend.
Re: Using make [message #76916 is a reply to message #76900] Thu, 24 July 2003 16:27 Go to previous messageGo to next message
John Camelon is currently offline John CamelonFriend
Messages: 50
Registered: July 2009
Member
http://opensource.cph.dk/xfree86/htdocs/4.3.0/makedepend.1.h tml

"shmuel siegel" <hard2@writeme.com> wrote in message
news:bfp0qr$a7t$1@eclipse.org...
> I remember that there was a way to automatically have a makefile keep
track
> of the which "h" files are needed by a "cpp" file. Can someone refresh my
> memory of how to set up a make-depend.
>
>
Re: Using make [message #76932 is a reply to message #76916] Thu, 24 July 2003 17:57 Go to previous messageGo to next message
Joost Kraaijeveld is currently offline Joost KraaijeveldFriend
Messages: 273
Registered: July 2009
Senior Member
> > I remember that there was a way to automatically have a makefile keep
track
> > of the which "h" files are needed by a "cpp" file. Can someone refresh
my
> > memory of how to set up a make-depend.
If you use gcc you can use "g++ -MM *.cpp >> .depend" which will write all
the dependencies of all cpp files to the file .depend, excluding all the
system headers. Below is a Makefile in which it is used.


Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
email: J.Kraaijeveld@Askesis.nl
web: www.askesis.nl




####### Start of a sample makefile

####### Directory options

TARGETDIR = ../../Targets/Bin
OBJECTSDIR = ../../Objects/Exe

####### Files

SOURCES := $(wildcard *.cpp)
OBJECTS = $(patsubst %.cpp, $(OBJECTSDIR)/%.o, $(SOURCES))
TARGET = $(TARGETDIR)/Main.exe

####### C++ Compiler options

CXX = g++
CXXFLAGS = -c

####### Common Compiler options

INCPATH = -I ../Dll

####### Linker options

LINK = g++
LFLAGS =
LIBS = $(TARGETDIR)/libObject.dll

####### Pattern matching rule for .cpp file

$(OBJECTSDIR)/%.o : %.cpp
$(CXX) $(CXXFLAGS) $(INCPATH) $< -o $@

####### Targets

all: $(TARGET)

$(TARGET) : .depend $(OBJECTS)
$(LINK) $(LFLAGS) -o$(TARGET) $(OBJECTS) $(LIBS)

..depend:
-rm -f .depend
$(CXX) -MM *.cpp | sed 's/^/$$(OBJECTSDIR)\//' >> .depend

clean:
-rm .depend
-rm $(OBJECTS)
-rm $(TARGET)

ifeq (.depend, $(wildcard .depend))
include .depend
endif


Cheers,

Joost
Re: Using make [message #77050 is a reply to message #76916] Thu, 24 July 2003 20:13 Go to previous messageGo to next message
shmuel siegel is currently offline shmuel siegelFriend
Messages: 75
Registered: July 2009
Member
Thank you, this is what I was looking for. Consider adding this information
to some help page since non Unix users are unlikely to know about it.

"John Camelon" <jcamelon@rational.com> wrote in message
news:bfp1c5$ar8$1@eclipse.org...
> http://opensource.cph.dk/xfree86/htdocs/4.3.0/makedepend.1.h tml
>
> "shmuel siegel" <hard2@writeme.com> wrote in message
> news:bfp0qr$a7t$1@eclipse.org...
> > I remember that there was a way to automatically have a makefile keep
> track
> > of the which "h" files are needed by a "cpp" file. Can someone refresh
my
> > memory of how to set up a make-depend.
> >
> >
>
>
Re: Using make [message #77071 is a reply to message #76932] Fri, 25 July 2003 01:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alain.nowhere.ca

Joost Kraaijeveld wrote:


Very clever.
They was a suggestion to provide an out-of-the-box
makefile when creating a "std make project" ...
hope you snippet below is not copyrighted 8-)

> ####### Start of a sample makefile

> ####### Directory options

> TARGETDIR = ../../Targets/Bin
> OBJECTSDIR = ../../Objects/Exe

> ####### Files

> SOURCES := $(wildcard *.cpp)
> OBJECTS = $(patsubst %.cpp, $(OBJECTSDIR)/%.o, $(SOURCES))
> TARGET = $(TARGETDIR)/Main.exe

> ####### C++ Compiler options

> CXX = g++
> CXXFLAGS = -c

> ####### Common Compiler options

> INCPATH = -I ../Dll

> ####### Linker options

> LINK = g++
> LFLAGS =
> LIBS = $(TARGETDIR)/libObject.dll

> ####### Pattern matching rule for .cpp file

> $(OBJECTSDIR)/%.o : %.cpp
> $(CXX) $(CXXFLAGS) $(INCPATH) $< -o $@

> ####### Targets

> all: $(TARGET)

> $(TARGET) : .depend $(OBJECTS)
> $(LINK) $(LFLAGS) -o$(TARGET) $(OBJECTS) $(LIBS)

> ..depend:
> -rm -f .depend
> $(CXX) -MM *.cpp | sed 's/^/$$(OBJECTSDIR)//' >> .depend

> clean:
> -rm .depend
> -rm $(OBJECTS)
> -rm $(TARGET)

> ifeq (.depend, $(wildcard .depend))
> include .depend
> endif
Re: Using make [message #77084 is a reply to message #77071] Fri, 25 July 2003 04:18 Go to previous messageGo to next message
Joost Kraaijeveld is currently offline Joost KraaijeveldFriend
Messages: 273
Registered: July 2009
Senior Member
"alain" <alain@nowhere.ca> wrote in message news:bfq1ga$ch4$1@eclipse.org...
> Joost Kraaijeveld wrote:
>
>
> Very clever.
> They was a suggestion to provide an out-of-the-box
> makefile when creating a "std make project" ...
> hope you snippet below is not copyrighted 8-)
>

Feel free to use it

--
Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
email: J.Kraaijeveld@Askesis.nl
web: www.askesis.nl


Cheers,

Joost
Re: Using make [message #77907 is a reply to message #77084] Wed, 06 August 2003 06:41 Go to previous message
Eclipse UserFriend
Originally posted by: simon.ou.edu

Hi Joost...

Could this kind of makefile be automated into a plugin? Thanks.

Regards...

Miguel.

Joost Kraaijeveld wrote:
> "alain" <alain@nowhere.ca> wrote in message news:bfq1ga$ch4$1@eclipse.org...
>
>>Joost Kraaijeveld wrote:
>>
>>
>>Very clever.
>>They was a suggestion to provide an out-of-the-box
>>makefile when creating a "std make project" ...
>>hope you snippet below is not copyrighted 8-)
>>
>
>
> Feel free to use it
>
Previous Topic:CDT for 3.0?
Next Topic:Does CDT work with Eclipse 2.1.1?
Goto Forum:
  


Current Time: Thu Dec 26 22:16:57 GMT 2024

Powered by FUDForum. Page generated in 0.03634 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top