I am writing a Makefile by hand to create a PHP extension lib using SWIG. I have the following directory structure:
wrappers/ # SWIG generated C++ wrappers and header
objects/ # I want to place my object files here
bin/ # I want to place my executable (shared lib) here
This is what my Makefile looks like:
CC=g++
CFLAGS=-fPIC -c -Wall
INCLUDES=`php-config --includes` -Iwrappers
LDFLAGS=-shared
SOURCES=foo_wrap.cpp \
foobar_wrap.cpp \
foofoobar_wrap.cpp \
foobarbar_wrap.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=php_foobarlib.so
all: wrappers/$(SOURCES) bin/$(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o objects/$(input)
.cpp.o:
$(CC) $(CFLAGS) $< -o objects/$(input)
clean:
rm -rf *o $(EXECUTABLE)
When I run make at the command line, I get the following error:
make: * No rule to make target
foobar_wrap.cpp', needed by
all'. Stop.
I want to build the shared library using CMake instead. Could someone please post an outline of the CMakeLists file I need to create to build the shared library, taking into accounts the directory structure of the project - i.e. where I want the built objects and binaries to go.