/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.4
 
5
#                                                                    version 3.5
6
6
#
7
7
# Copyright (c) 2009 Tim Marston <edam@waxworlds.org>.
8
8
#
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 'subdir.mk' exists in a subdirectory, it
 
89
#              Note that if the file 'emake.mk' exists in a subdirectory, it
90
90
#              will be used explicitly, rather than any default makefile.
91
91
#
92
92
# SUBPROJS     A list of the names of other makefiles to run before attempting
119
119
# run          Builds the target of your Makefile and, if successful, runs it.
120
120
#              This is not available if you're building a library of some kind.
121
121
#
 
122
# debug        The same as the run goal, except instead of running the target,
 
123
#              it is debugged with gdb.
 
124
#
122
125
# clean        Deletes temporary files.
123
126
#
124
127
# clean_all    Deletes temporary files and then goes through then project's
158
161
 
159
162
# debug/profile build flags
160
163
CPPFLAGS        := $(if $(PROFILEMODE),-pg -D PROFILE) $(if $(DEBUGMODE),\
161
 
        -g -D DEBUG -Wall -Wextra,-D NDEBUG -O2) $(CPPFLAGS)
 
164
        -g3 -D DEBUG -Wall -Wextra,-D NDEBUG -O2) $(CPPFLAGS)
162
165
CXXFLAGS        := $(if $(DEBUGMODE),-Woverloaded-virtual -Wreorder \
163
166
        -Wctor-dtor-privacy) $(CXXFLAGS)
164
167
DFLAGS          := $(if $(DEBUGMODE),,-frelease)
171
174
LDFLAGS         := $(if $(LINKSTATIC),-static) $(LDFLAGS)
172
175
 
173
176
# add libraries for d
174
 
LIBRARIES       := $(LIBRARIES) $(if $(filter %.d, $(SOURCES)), gphobos pthread m)
 
177
LIBRARIES       := $(LIBRARIES) $(if $(filter %.d, $(SOURCES)), gphobos2 rt)
175
178
 
176
179
# build flags for libraries
177
180
LDPOSTFLAGS := $(addprefix -l,$(LIBRARIES)) $(LDPOSTFLAGS)
224
227
#_______________________________________________________________________________
225
228
#                                                                          RULES
226
229
 
227
 
.PHONY: all subdirs subprojs target clean clean_all run depend dep \
 
230
.PHONY: all subdirs subprojs target clean clean_all run debug depend dep \
228
231
        $(SUBDIRS) $(SUBPROJS)
229
232
 
230
233
all: subdirs subprojs target
250
253
ifndef MKSHAREDLIB
251
254
run: target
252
255
        ./$(TARGET)
 
256
 
 
257
debug: target
 
258
        gdb ./$(TARGET)
253
259
endif
254
260
endif
255
261
 
256
262
$(SUBDIRS) $(SUBPROJS):
257
263
        @if [ "$@" = "$(firstword $(SUBDIRS) $(SUBPROJS))" ]; then echo; fi
258
264
        @$(MAKE) $(if $(filter $@,$(SUBPROJS)), -f $@.mk, \
259
 
                -C $@ $(if $(wildcard $@/subdir.mk),-f subdir.mk,)) \
 
265
                -C $@ $(if $(wildcard $@/emake.mk),-f emake.mk,)) \
260
266
                $(filter-out $(SUBDIRS) $(SUBPROJS) subdirs subprojs,$(MAKECMDGOALS))
261
267
        @echo
262
268