65
# debug/profile build flags
64
66
CPPFLAGS := $(if $(PROFILEMODE),-pg -D PROFILE) $(CPPFLAGS)
65
CPPFLAGS := $(if $(DEBUGMODE),-g -D DEBUG,-O2) $(CPPFLAGS)
67
CPPFLAGS := $(if $(DEBUGMODE),-g -D DEBUG -Wall,-O2) $(CPPFLAGS)
68
DFLAGS := $(if $(DEBUGMODE),,-frelease)
66
69
ASFLAGS := -f elf $(if $(DEBUGMODE),-g -dDEBUG,-O2) $(ASFLAGS)
67
LDFLAGS := $(if $(PROFILEMODE),-pg,$(if $(DEBUGMODE),,-s)) $(LDFLAGS)
68
LDFLAGS := -Wall $(if $(LINKSTATIC),-static) $(LDFLAGS)
70
LDFLAGS := $(if $(PROFILEMODE),-pg) $(LDFLAGS)
71
LDFLAGS := $(if $(or $(PROFILEMODE), $(DEBUGMODE)),,-Wl,-S) $(LDFLAGS)
73
# setup options for shared/static libs
74
CPPFLAGS := $(if $(MKSHAREDLIB),-fPIC) $(CPPFLAGS)
75
LDFLAGS := $(if $(LINKSTATIC),-static) $(LDFLAGS)
78
LIBRARIES := $(LIBRARIES) $(if $(filter %.d, $(SOURCES)), gphobos pthread m)
80
# build flags for libraries
69
81
LDPOSTFLAGS := $(addprefix -l,$(LIBRARIES)) $(LDPOSTFLAGS)
71
83
#_______________________________________________________________________________
73
86
# object debug/profile suffix
74
87
BUILDSUFFIX := $(if $(PROFILEMODE),_p,$(if $(DEBUGMODE),_d))
89
# work out object and dependency files
77
90
OBJECTS := $(addsuffix $(BUILDSUFFIX).o,$(basename $(SOURCES)))
78
DEPFILES := $(addsuffix .d,$(basename $(SOURCES)))
91
DEPFILES := $(addsuffix .dep,$(basename $(SOURCES)))
82
95
TARGET := $(basename $(TARGET))$(BUILDSUFFIX)$(suffix $(TARGET))
83
96
TARGET := $(patsubst %.so,%,$(patsubst %.a,%,$(TARGET)))
97
ifneq ($(strip $(MKSHAREDLIB) $(MKSTATICLIB)),)
84
98
TARGET := $(TARGET)$(if $(MKSHAREDLIB),.so,$(if $(MKSTATICLIB),.a))
99
TARGET := lib$(patsubst lib%,%,$(TARGET))
87
103
# Set up dependancy generation build flags and a commands to be executed after
94
110
ifndef PROFILEMODE
95
111
FIXUP_DEPENDANCY_FILES = \
96
112
sed 's/\#.*//;s/^[^:]*://;s/^[ \t]*//;s/ *\\$$//;/^$$/d;s/$$/:/' < \
97
$(basename $<).d > .$$$$~; cat .$$$$~ >> $(basename $<).d; rm .$$$$~;
98
DEPFLAGS = -MD -MF $(basename $<).d
113
$(basename $<).dep > .$$$$~; cat .$$$$~ >> $(basename $<).dep; rm .$$$$~;
114
DEPFLAGS = -MD -MF $(basename $<).dep
169
189
%.o %_d.o %_p.o: %.asm
170
190
$(AS) $(ASFLAGS) -o $@ $<
173
$(AS) $(ASFLAGS) -M $< > $@
174
$(FIXUP_DEPENDANCY_FILES)
176
$(AS) $(ASFLAGS) -M $< > $@
177
$(FIXUP_DEPENDANCY_FILES)
193
$(AS) $(ASFLAGS) -M $< > $@
194
$(FIXUP_DEPENDANCY_FILES)
196
$(AS) $(ASFLAGS) -M $< > $@
197
$(FIXUP_DEPENDANCY_FILES)
179
199
$(AS) $(ASFLAGS) -M $< > $@
180
200
$(FIXUP_DEPENDANCY_FILES)