/make/edam-mk

To get this branch, use:
bzr branch http://bzr.ed.am/make/edam-mk

« back to all changes in this revision

Viewing changes to edam.mk

  • Committer: edam
  • Date: 2012-03-26 15:28:04 UTC
  • Revision ID: tim@ed.am-20120326152804-tgh62yxm32498ptg
added NEWS

Show diffs side-by-side

added added

removed removed

2
2
#
3
3
#                       edam's general-purpose makefile
4
4
#_______________________________________________________________________________
5
 
#                                                                    version 3.3
 
5
#                                                                    version 3.5
6
6
#
7
7
# Copyright (c) 2009 Tim Marston <edam@waxworlds.org>.
8
8
#
29
29
#
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/documentation on it's use. The following text
33
 
# can only really be considered a reference to it's use.
 
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.
34
34
#
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
86
86
#
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.
89
91
#
90
92
# SUBPROJS     A list of the names of other makefiles to run before attempting
91
93
#              to build the target. This allows you to build multiple targets.
117
119
# run          Builds the target of your Makefile and, if successful, runs it.
118
120
#              This is not available if you're building a library of some kind.
119
121
#
 
122
# debug        The same as the run goal, except instead of running the target,
 
123
#              it is debugged with gdb.
 
124
#
120
125
# clean        Deletes temporary files.
121
126
#
122
127
# clean_all    Deletes temporary files and then goes through then project's
155
160
MAKE            := make
156
161
 
157
162
# debug/profile build flags
158
 
CPPFLAGS        := $(if $(PROFILEMODE),-pg -D PROFILE) $(CPPFLAGS)
159
 
CPPFLAGS        := $(if $(DEBUGMODE),-g -D DEBUG -Wall,-D NDEBUG -O2) $(CPPFLAGS)
 
163
CPPFLAGS        := $(if $(PROFILEMODE),-pg -D PROFILE) $(if $(DEBUGMODE),\
 
164
        -g3 -D DEBUG -Wall -Wextra,-D NDEBUG -O2) $(CPPFLAGS)
 
165
CXXFLAGS        := $(if $(DEBUGMODE),-Woverloaded-virtual -Wreorder \
 
166
        -Wctor-dtor-privacy) $(CXXFLAGS)
160
167
DFLAGS          := $(if $(DEBUGMODE),,-frelease)
161
168
ASFLAGS         := -f elf $(if $(DEBUGMODE),-g -dDEBUG,-dNDEBUG -O2) $(ASFLAGS)
162
 
LDFLAGS         := $(if $(PROFILEMODE),-pg) $(LDFLAGS)
163
 
LDFLAGS         := $(if $(or $(PROFILEMODE), $(DEBUGMODE)),,-Wl,-S) $(LDFLAGS)
 
169
LDFLAGS         := $(if $(PROFILEMODE),-pg) \
 
170
        $(if $(or $(PROFILEMODE), $(DEBUGMODE)),,-Wl,-S) $(LDFLAGS)
164
171
 
165
172
# setup options for shared/static libs
166
 
CPPFLAGS        := $(if $(MKSHAREDLIB),-fPIC) $(CPPFLAGS)
 
173
CPPFLAGS        := $(if $(or $(MKSHAREDLIB),$(MKSTATICLIB)),-fPIC) $(CPPFLAGS)
167
174
LDFLAGS         := $(if $(LINKSTATIC),-static) $(LDFLAGS)
168
175
 
169
176
# add libraries for d
170
 
LIBRARIES       := $(LIBRARIES) $(if $(filter %.d, $(SOURCES)), gphobos pthread m)
 
177
LIBRARIES       := $(LIBRARIES) $(if $(filter %.d, $(SOURCES)), gphobos2 rt)
171
178
 
172
179
# build flags for libraries
173
180
LDPOSTFLAGS := $(addprefix -l,$(LIBRARIES)) $(LDPOSTFLAGS)
174
181
 
175
 
#_______________________________________________________________________________
176
 
#
177
 
 
178
182
# object debug/profile suffix
179
183
BUILDSUFFIX     := $(if $(PROFILEMODE),_p,$(if $(DEBUGMODE),_d))
180
184
 
223
227
#_______________________________________________________________________________
224
228
#                                                                          RULES
225
229
 
226
 
.PHONY: all subdirs subprojs target clean clean_all run depend dep $(SUBDIRS) $(SUBPROJS)
 
230
.PHONY: all subdirs subprojs target clean clean_all run debug depend dep \
 
231
        $(SUBDIRS) $(SUBPROJS)
227
232
 
228
233
all: subdirs subprojs target
229
234
 
240
245
                "subprojs as well"
241
246
endif
242
247
endif
243
 
        rm -f $(OBJECTS) $(TARGET) $(DEPFILES) core
 
248
        rm -f $(OBJECTS) $(TARGET) $(DEPFILES) core *~
244
249
 
245
250
clean_all: subdirs subprojs clean
246
251
 
248
253
ifndef MKSHAREDLIB
249
254
run: target
250
255
        ./$(TARGET)
 
256
 
 
257
debug: target
 
258
        gdb ./$(TARGET)
251
259
endif
252
260
endif
253
261
 
254
262
$(SUBDIRS) $(SUBPROJS):
255
263
        @if [ "$@" = "$(firstword $(SUBDIRS) $(SUBPROJS))" ]; then echo; fi
256
 
        @$(MAKE) $(if $(filter $@,$(SUBDIRS)),-C $@,-f $@.mk) \
 
264
        @$(MAKE) $(if $(filter $@,$(SUBPROJS)), -f $@.mk, \
 
265
                -C $@ $(if $(wildcard $@/emake.mk),-f emake.mk,)) \
257
266
                $(filter-out $(SUBDIRS) $(SUBPROJS) subdirs subprojs,$(MAKECMDGOALS))
258
267
        @echo
259
268