[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/1.17.4.1 |
(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:
http://make.paulandlesley.org/vpath.html
<quote>
PROGS = foo
OBJECTS = foo.o bar.o
# Shouldn't need to change anything below here...
OBJDIR = ../obj
VPATH = $(OBJDIR)
$(OBJDIR)/%.o : %.c
$(COMPILE.c) $< -o $@
OBJPROG = $(addprefix $(OBJDIR)/, $(PROGS))
all: $(OBJPROG)
$(OBJPROG): $(addprefix $(OBJDIR)/, $(OBJECTS))
$(LINK.o) $^ $(LDLIBS) -o $@
</quote>
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++
libraries?
3/ What's the best way of integrating the required header files into
this makefile?
--
Simon Elliott http://www.ctsn.co.uk
- a few simple make questions,
Simon Elliott <=