[Top][All Lists]

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

a few simple make questions

From: Simon Elliott
Subject: a few simple make questions
Date: 02 Feb 2006 10:07:40 GMT
User-agent: XanaNews/

(I originally posted this to comp.unix.programmer but I now think it
might be more appropriate here.)

I want to put together a makefile which will let me keep my object
files in a separate directory.

Paul Smith has this example makefile here:

PROGS   = foo
OBJECTS = foo.o bar.o

# Shouldn't need to change anything below here...

OBJDIR = ../obj


$(OBJDIR)/%.o : %.c
  $(COMPILE.c) $< -o $@

OBJPROG = $(addprefix $(OBJDIR)/, $(PROGS))

all: $(OBJPROG)

$(OBJPROG): $(addprefix $(OBJDIR)/, $(OBJECTS))
  $(LINK.o) $^ $(LDLIBS) -o $@


There's a few things I don't understand here:

1/ I can't find any reference to the LINK.o and COMPILE.c macros in the
make man pages. Are they documented anywhere?

2/ I've modified this to compile C++ code by adding a line 

$(OBJDIR)/%.o : %.cpp
        $(COMPILE.cpp) $< $(CFLAGS) -o $@

This works in that my C++ source is compiled and put into the correct
directory, but it fails at link time as it appears not to be linking
the standard C++ libraries. How can I make it link the standard C++

3/ What's the best way of integrating the required header files into
this makefile?

Simon Elliott

reply via email to

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