Subversion Repositories gelsvn

Rev

Rev 138 | Go to most recent revision | 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)

### LIBDIR is the directory where we stick .a files pertaining to 
### the specific combination of platform and target.
LIBDIR                                                  = ${SOURCEROOT}/lib/${PLATFORM_TARG}

### BINDIR is the directory where binary files are put.
BINDIR                                                  = ${SOURCEROOT}/bin

### Append path to compiler flags
CXXFLAGS                                                += -I${SOURCEROOT}/src -I${SOURCEROOT}/include

### 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}/$@ $<