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: Larry Smith
Subject: Re: Need help with the following make file
Date: Thu, 07 Feb 2008 15:13:56 GMT
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.11) Gecko/20070803 SUSE/1.1.7-0.1 SeaMonkey/1.1.7

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)


reply via email to

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