help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help with the following make file


From: emp1953
Subject: Re: Need help with the following make file
Date: Fri, 8 Feb 2008 08:56:33 -0800 (PST)
User-agent: G2/1.0

On Feb 7, 10:13 am, Larry Smith <lsm...@nospam.com> wrote:
> emp1953 wrote:
> > Below is my makefile
> > It works fine as it is
> > I want to put all the .o files into the ../bin/ directory OBJDIR
> > then upon a clean I want the .o's removed from that directory
> > I was able to get the executable to go into the ../exe/ directory and
> > it is removed upon a clean.
>
> > I cannot get it the .o's to work. any help would be appreciated.
>
> If you are using GNU Make...
> Note - CXX and CXXFLAGS are normally used for C++
>        in Makefiles because that's what GNU Make's
>        built-in rules use.  CC & CFLAGS are used
>        by Make's built-in rules for C files.
>        If using GNU Make, most of the built-in
>        compile & link rules can be used without
>        writing your own
>
> > CC=g++
> > CFLAGS=-c -Wall
> > LDFLAGS=
>
> OBJDIR=../bin
>
> > SOURCES=a.cpp \
> > b.cpp \
> > c.cpp \
> > d.cpp \
> > e.cpp
>
> OBJECTS=$(addprefix $(OBJDIR)/,$(SOURCES:.cpp=.o))
>
> > EXECUTABLE=../exe/msg_broker
>
> all : $(EXECUTABLE)
>
> > $(EXECUTABLE): $(OBJECTS)
> > $(CC) $(LDFLAGS) $(OBJECTS) -o $@
>
> $(OBJDIR)/%.o: %.cpp
>         $(CC) $(CFLAGS) -o $@ $<
>
> clean:
>   -rm -rf $(OBJECTS)
>   -rm -rf $(EXECUTABLE)



Works great thanks.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]