Subversion Repositories gelsvn

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 bj 1
SHELL = /bin/sh
2
 
3
.SUFFIXES:
4
.SUFFIXES: .cpp .o .c
5
 
137 jab 6
### the user configuration makefile
7
include ${SOURCEROOT}/makefiles/config.mk
2 bj 8
 
137 jab 9
### Use a shell script to guess the compiler
10
ifeq ($(strip ${CXX}),)
11
CXX = $(shell ${SOURCEROOT}/makefiles/findcompiler.sh)
12
endif
13
 
14
### Define operating system and CPU
15
OS =$(subst ${empty} ${empty},_,$(shell uname -s))
16
CPU =$(subst ${empty} ${empty},_,$(shell uname -m))
17
 
18
### Define the empty string
19
empty =
20
 
21
### The platform is determined by OS CPU and compiler 
22
PLATFORM = ${OS}_${CPU}_${CXX}
23
 
24
### Default target is release, unless debug is given as goal
25
ifndef TARGET
26
TARGET = release
27
endif
28
 
29
### Concatenation of platform and target yields a string used as 
30
### suffix of makefiles and in the name of the builddir.
31
PLATFORM_TARG = ${PLATFORM}_$(TARGET)
32
 
2 bj 33
### Include platform specific makefile
34
include  ${SOURCEROOT}/makefiles/${PLATFORM}.mk
35
 
36
### BUILD is the subdirectory where all builds reside.
37
BUILD								= .build
38
 
39
### BUILDDIR is the directory where the compilation for a specific 
40
### platform and target combination takes place.
41
BUILDDIR						= ./${BUILD}/$(PLATFORM_TARG)
42
 
43
### LIBDIR is the directory where we stick .a files pertaining to 
44
### the specific combination of platform and target.
45
LIBDIR							= ${SOURCEROOT}/lib/${PLATFORM_TARG}
46
 
47
### BINDIR is the directory where binary files are put.
48
BINDIR							= ${SOURCEROOT}/bin
49
 
50
### Append path to compiler flags
6 jab 51
CXXFLAGS						+= -I${SOURCEROOT}/src -I${SOURCEROOT}/include
2 bj 52
 
53
### Generate list of source files.
54
sources							= $(shell ls *.cpp)
55
### Generate list if object files from list of sources.
56
objects							= $(sources:.cpp=.o)
57
### Generate list if dependency files from list of sources.
58
deps								= $(addprefix ${BUILDDIR}/,$(sources:.cpp=.d))
59
 
60
### Set up vpath so that make finds object files in builddir
61
### hence does not rebuild unneccesarily
62
VPATH 							= ${BUILDDIR}
63
 
137 jab 64
 
65
### Make dependencies,
66
ifneq (clean,$(findstring clean,${MAKECMDGOALS}))
67
${BUILDDIR}/%.d:%.cpp 
68
	$(shell if \[ \! -d ${BUILDDIR} \] ; then mkdir -p ${BUILDDIR} ; fi)
69
	$(CXX) ${DEPFLAGS} ${CXXFLAGS} $< > $@
70
 
2 bj 71
### Include dependencies - but not if we are cleaning
72
include ${deps}
73
endif
74
 
75
### Rule for building object files from C++ source files
137 jab 76
%.o: %.cpp 
77
	$(shell if \[ \! -d ${BUILDDIR} \] ; then mkdir -p ${BUILDDIR} ; fi)
2 bj 78
	${CXX} -c ${CXXFLAGS} -o ${BUILDDIR}/$@ $<
79
 
80
### Rule for building object files from C source files
81
### I use a C++ compiler. I think this is best.
137 jab 82
%.o: %.c 
83
	$(shell if \[ \! -d ${BUILDDIR} \] ; then mkdir -p ${BUILDDIR} ; fi)
2 bj 84
	${CXX} -c ${CXXFLAGS} -o ${BUILDDIR}/$@ $<
85
 
86