2 |
bj |
1 |
# application.mk - Application makefile. This makefile is included from
|
|
|
2 |
# Application directories.
|
|
|
3 |
#
|
|
|
4 |
#
|
|
|
5 |
#
|
|
|
6 |
|
|
|
7 |
### Make sure app is primary goal
|
|
|
8 |
all: app
|
|
|
9 |
|
|
|
10 |
### Include common rules and defs
|
|
|
11 |
include ${SOURCEROOT}/makefiles/common.mk
|
|
|
12 |
|
|
|
13 |
### Set up load libraries
|
|
|
14 |
LOADLIBES = $(addprefix -l,${OWN_LIBS}) ${LIBS}
|
|
|
15 |
|
|
|
16 |
### Where to find libraries
|
|
|
17 |
LDFLAGS += -L${LIBDIR} -L${SOURCEROOT}/lib/${PLATFORM}
|
|
|
18 |
|
|
|
19 |
### Generate a list of object files that are not programs.
|
|
|
20 |
not_main_objects = $(filter-out $(addsuffix .o,${PROGRAMS}), ${objects})
|
|
|
21 |
|
|
|
22 |
######################################################################
|
|
|
23 |
############ We are building #########################################
|
|
|
24 |
######################################################################
|
|
|
25 |
ifeq (${MAKECMDGOALS},clean)
|
|
|
26 |
|
|
|
27 |
clean:
|
|
|
28 |
rm -fr ${BUILDDIR}
|
|
|
29 |
|
|
|
30 |
else
|
|
|
31 |
|
|
|
32 |
# The force target is useful for recompiling libraries. Thus if the appliaction
|
|
|
33 |
# or any library it depends on have been changed, we only have to go
|
|
|
34 |
# > make force
|
|
|
35 |
# in the directory containing the application. Application is also compiled
|
|
|
36 |
# and linked.
|
|
|
37 |
force: ${not_main_objects}
|
|
|
38 |
$(foreach lib, ${OWN_LIBS}, ${MAKE} -C ${SOURCEROOT}/Libsrc/${lib};)
|
|
|
39 |
${MAKE} ${PROGRAMS}
|
|
|
40 |
$(foreach prg, ${PROGRAMS}, ${INSTALL} ${BUILDDIR}/${prg} ${SOURCEROOT}/bin/${prg};)
|
|
|
41 |
|
|
|
42 |
# app is default target. Compiles and links all applications.
|
|
|
43 |
app: ${not_main_objects}
|
|
|
44 |
${MAKE} ${PROGRAMS}
|
|
|
45 |
$(foreach prg, ${PROGRAMS}, ${INSTALL} ${BUILDDIR}/${prg} ${SOURCEROOT}/bin;)
|
|
|
46 |
|
|
|
47 |
# Do not compile programs directly from source. Always compile object file
|
|
|
48 |
#%:%.cpp
|
|
|
49 |
|
|
|
50 |
# Link application. .FORCE ensures that we always link. I haven't found a
|
|
|
51 |
# great way to make compilation depend on the timestamp of the libraries, but
|
|
|
52 |
# always linking solves the problem at moderate cost.
|
|
|
53 |
%:%.o .FORCE
|
|
|
54 |
${CXX} -o ${BUILDDIR}/$@ ${BUILDDIR}/$@.o \
|
|
|
55 |
${CXXFLAGS} ${LDFLAGS} $(addprefix ${BUILDDIR}/,${not_main_objects}) \
|
|
|
56 |
${LOADLIBES}
|
|
|
57 |
|
|
|
58 |
.FORCE:
|
|
|
59 |
|
|
|
60 |
endif
|
|
|
61 |
|