64
64
CPPFLAGS := $(if $(PROFILEMODE),-pg -D PROFILE) $(CPPFLAGS)
65
CPPFLAGS := $(if $(DEBUGMODE),-g -D DEBUG,-O2) $(CPPFLAGS)
65
CPPFLAGS := $(if $(DEBUGMODE),-g -D DEBUG -Wall,-O2) $(CPPFLAGS)
66
CPPFLAGS := $(if $(MKSHAREDLIB),-fPIC) $(CPPFLAGS)
66
67
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)
68
LDFLAGS := $(if $(PROFILEMODE),-pg) $(LDFLAGS)
69
LDFLAGS := $(if $(or $(PROFILEMODE),$(DEBUGMODE)),,-Wl,-S) $(LDFLAGS)
70
LDFLAGS := $(if $(LINKSTATIC),-static) $(LDFLAGS)
69
71
LDPOSTFLAGS := $(addprefix -l,$(LIBRARIES)) $(LDPOSTFLAGS)
71
73
#_______________________________________________________________________________
73
76
# object debug/profile suffix
74
77
BUILDSUFFIX := $(if $(PROFILEMODE),_p,$(if $(DEBUGMODE),_d))
77
80
OBJECTS := $(addsuffix $(BUILDSUFFIX).o,$(basename $(SOURCES)))
78
DEPFILES := $(addsuffix .d,$(basename $(SOURCES)))
81
DEPFILES := $(addsuffix .dep,$(basename $(SOURCES)))
82
TARGET := $(basename $(TARGET))$(BUILDSUFFIX)$(suffix $(TARGET))
83
TARGET := $(patsubst %.so,%,$(patsubst %.a,%,$(TARGET)))
84
TARGET := $(TARGET)$(if $(MKSHAREDLIB),.so,$(if $(MKSTATICLIB),.a))
85
TARGET := $(basename $(TARGET))$(BUILDSUFFIX)$(suffix $(TARGET))
86
TARGET := $(patsubst %.so,%,$(patsubst %.a,%,$(TARGET)))
87
ifneq ($(strip $(MKSHAREDLIB) $(MKSTATICLIB)),)
88
TARGET := $(TARGET)$(if $(MKSHAREDLIB),.so,$(if $(MKSTATICLIB),.a))
89
TARGET := lib$(patsubst lib%,%,$(TARGET))
87
93
# Set up dependancy generation build flags and a commands to be executed after
94
100
ifndef PROFILEMODE
95
101
FIXUP_DEPENDANCY_FILES = \
96
102
sed 's/\#.*//;s/^[^:]*://;s/^[ \t]*//;s/ *\\$$//;/^$$/d;s/$$/:/' < \
97
$(basename $<).d > .$$$$~; cat .$$$$~ >> $(basename $<).d; rm .$$$$~;
98
DEPFLAGS = -MD -MF $(basename $<).d
103
$(basename $<).dep > .$$$$~; cat .$$$$~ >> $(basename $<).dep; rm .$$$$~;
104
DEPFLAGS = -MD -MF $(basename $<).dep
169
176
%.o %_d.o %_p.o: %.asm
170
177
$(AS) $(ASFLAGS) -o $@ $<
173
$(AS) $(ASFLAGS) -M $< > $@
174
$(FIXUP_DEPENDANCY_FILES)
176
$(AS) $(ASFLAGS) -M $< > $@
177
$(FIXUP_DEPENDANCY_FILES)
180
$(AS) $(ASFLAGS) -M $< > $@
181
$(FIXUP_DEPENDANCY_FILES)
183
$(AS) $(ASFLAGS) -M $< > $@
184
$(FIXUP_DEPENDANCY_FILES)
179
186
$(AS) $(ASFLAGS) -M $< > $@
180
187
$(FIXUP_DEPENDANCY_FILES)