/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: 2009-03-05 14:28:02 UTC
  • Revision ID: edam@waxworlds.org-20090305142802-um4qc3qwifzlc0ei
Tags: 3.3
- added NOLIBPROFIX switch
- fixed typo in documentation

Show diffs side-by-side

added added

removed removed

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