/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 Makefile

  • Committer: edam
  • Date: 2009-03-05 13:53:15 UTC
  • Revision ID: edam@waxworlds.org-20090305135315-6vqbac8z1n6861w5
Tags: 2.1
- compiler/linker gives all wornings when building in debug
- renamed dependency files .dep so they don't clash with D source
- try to echo a blank line when recursing

Show diffs side-by-side

added added

removed removed

1
1
#_______________________________________________________________________________
2
2
#
3
 
#                                       edam's general-purpose makefile v2.0
 
3
#                     edam's general-purpose makefile v2.2
4
4
#_______________________________________________________________________________
5
5
#                                                                COMMON SETTINGS
6
6
 
62
62
 
63
63
# build flags
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)
70
72
 
71
73
#_______________________________________________________________________________
 
74
#
72
75
 
73
76
# object debug/profile suffix
74
77
BUILDSUFFIX     := $(if $(PROFILEMODE),_p,$(if $(DEBUGMODE),_d))
75
78
 
76
79
# files
77
80
OBJECTS         := $(addsuffix $(BUILDSUFFIX).o,$(basename $(SOURCES)))
78
 
DEPFILES        := $(addsuffix .d,$(basename $(SOURCES)))
 
81
DEPFILES        := $(addsuffix .dep,$(basename $(SOURCES)))
79
82
 
80
83
# fixup target
81
84
ifdef TARGET
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))
 
90
endif
85
91
endif
86
92
 
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
99
105
endif
100
106
endif
101
107
 
138
144
endif
139
145
 
140
146
$(SUBDIRS):
 
147
        @if [ "$@" = "$(firstword $(SUBDIRS))" ]; then echo; fi
141
148
        @$(MAKE) -C $@ $(filter-out $(SUBDIRS),$(MAKECMDGOALS))
142
149
        @echo
143
150
 
169
176
%.o %_d.o %_p.o: %.asm
170
177
        $(AS) $(ASFLAGS) -o $@ $<
171
178
 
172
 
%.d: %.s
173
 
        $(AS) $(ASFLAGS) -M $< > $@
174
 
        $(FIXUP_DEPENDANCY_FILES)
175
 
%.d: %.S
176
 
        $(AS) $(ASFLAGS) -M $< > $@
177
 
        $(FIXUP_DEPENDANCY_FILES)
178
 
%.d: %.asm
 
179
%.dep: %.s
 
180
        $(AS) $(ASFLAGS) -M $< > $@
 
181
        $(FIXUP_DEPENDANCY_FILES)
 
182
%.dep: %.S
 
183
        $(AS) $(ASFLAGS) -M $< > $@
 
184
        $(FIXUP_DEPENDANCY_FILES)
 
185
%.dep: %.asm
179
186
        $(AS) $(ASFLAGS) -M $< > $@
180
187
        $(FIXUP_DEPENDANCY_FILES)
181
188