30
30
# This is a general-purpose makefile for use with GNU make. It can be downloaded
31
31
# from http://www.waxworlds.org/edam/software/general-purpose-makefile where you
32
# can also find more information and documentation on it's use. The following
33
# text can only really be considered a reference to it's use.
32
# can also find more information/documentation on it's use. The following text
33
# can only really be considered a reference to it's use.
35
35
# To use this makefile, put a file named "Makefile" in your project directory.
36
36
# Add all your project's settings to your Makefile and then include this file
87
87
# SUBDIRS A list of subdirectories to build before attempting to build the
88
88
# target. These subdirectories are also included in a clean_all.
89
# Note that if the file 'emake.mk' exists in a subdirectory, it
90
# will be used explicitly, rather than any default makefile.
92
90
# SUBPROJS A list of the names of other makefiles to run before attempting
93
91
# to build the target. This allows you to build multiple targets.
159
157
# debug/profile build flags
160
CPPFLAGS := $(if $(PROFILEMODE),-pg -D PROFILE) $(if $(DEBUGMODE),\
161
-g3 -D DEBUG -Wall -Wextra,-D NDEBUG -O2) $(CPPFLAGS)
162
CXXFLAGS := $(if $(DEBUGMODE),-Woverloaded-virtual -Wreorder \
163
-Wctor-dtor-privacy) $(CXXFLAGS)
158
CPPFLAGS := $(if $(PROFILEMODE),-pg -D PROFILE) $(CPPFLAGS)
159
CPPFLAGS := $(if $(DEBUGMODE),-g -D DEBUG -Wall,-D NDEBUG -O2) $(CPPFLAGS)
164
160
DFLAGS := $(if $(DEBUGMODE),,-frelease)
165
161
ASFLAGS := -f elf $(if $(DEBUGMODE),-g -dDEBUG,-dNDEBUG -O2) $(ASFLAGS)
166
LDFLAGS := $(if $(PROFILEMODE),-pg) \
167
$(if $(or $(PROFILEMODE), $(DEBUGMODE)),,-Wl,-S) $(LDFLAGS)
162
LDFLAGS := $(if $(PROFILEMODE),-pg) $(LDFLAGS)
163
LDFLAGS := $(if $(or $(PROFILEMODE), $(DEBUGMODE)),,-Wl,-S) $(LDFLAGS)
169
165
# setup options for shared/static libs
170
CPPFLAGS := $(if $(or $(MKSHAREDLIB),$(MKSTATICLIB)),-fPIC) $(CPPFLAGS)
166
CPPFLAGS := $(if $(MKSHAREDLIB),-fPIC) $(CPPFLAGS)
171
167
LDFLAGS := $(if $(LINKSTATIC),-static) $(LDFLAGS)
173
169
# add libraries for d
176
172
# build flags for libraries
177
173
LDPOSTFLAGS := $(addprefix -l,$(LIBRARIES)) $(LDPOSTFLAGS)
175
#_______________________________________________________________________________
179
178
# object debug/profile suffix
180
179
BUILDSUFFIX := $(if $(PROFILEMODE),_p,$(if $(DEBUGMODE),_d))
224
223
#_______________________________________________________________________________
227
.PHONY: all subdirs subprojs target clean clean_all run depend dep \
228
$(SUBDIRS) $(SUBPROJS)
226
.PHONY: all subdirs subprojs target clean clean_all run depend dep $(SUBDIRS) $(SUBPROJS)
230
228
all: subdirs subprojs target
256
254
$(SUBDIRS) $(SUBPROJS):
257
255
@if [ "$@" = "$(firstword $(SUBDIRS) $(SUBPROJS))" ]; then echo; fi
258
@$(MAKE) $(if $(filter $@,$(SUBPROJS)), -f $@.mk, \
259
-C $@ $(if $(wildcard $@/emake.mk),-f emake.mk,)) \
256
@$(MAKE) $(if $(filter $@,$(SUBDIRS)),-C $@,-f $@.mk) \
260
257
$(filter-out $(SUBDIRS) $(SUBPROJS) subdirs subprojs,$(MAKECMDGOALS))