Rev 145 | Blame | Compare with Previous | Last modification | View Log | RSS feed
SHELL = /bin/sh
.SUFFIXES:
.SUFFIXES: .cpp .o .c
### the user configuration makefile
include ${SOURCEROOT}/makefiles/config.mk
### Include platform specific makefile
include ${SOURCEROOT}/makefiles/${PLATFORM}.mk
### BUILD is the subdirectory where all builds reside.
BUILD = .build
### BUILDDIR is the directory where the compilation for a specific
### platform and target combination takes place.
BUILDDIR = ./${BUILD}/$(PLATFORM_TARG)
### Append path to compiler flags
CXXFLAGS += -I${SOURCEROOT}/src
### Generate list of source files.
sources = $(shell ls *.cpp)
### Generate list if object files from list of sources.
objects = $(sources:.cpp=.o)
### Generate list if dependency files from list of sources.
deps = $(addprefix ${BUILDDIR}/,$(sources:.cpp=.d))
### Set up vpath so that make finds object files in builddir
### hence does not rebuild unneccesarily
VPATH = ${BUILDDIR}
### Make dependencies,
ifneq (clean,$(findstring clean,${MAKECMDGOALS}))
${BUILDDIR}/%.d:%.cpp
$(shell if \[ \! -d ${BUILDDIR} \] ; then mkdir -p ${BUILDDIR} ; fi)
$(CXX) ${DEPFLAGS} ${CXXFLAGS} $< > $@
### Include dependencies - but not if we are cleaning
include ${deps}
endif
### Rule for building object files from C++ source files
%.o: %.cpp
$(shell if \[ \! -d ${BUILDDIR} \] ; then mkdir -p ${BUILDDIR} ; fi)
${CXX} -c ${CXXFLAGS} -o ${BUILDDIR}/$@ $<
### Rule for building object files from C source files
### I use a C++ compiler. I think this is best.
%.o: %.c
$(shell if \[ \! -d ${BUILDDIR} \] ; then mkdir -p ${BUILDDIR} ; fi)
${CXX} -c ${CXXFLAGS} -o ${BUILDDIR}/$@ $<