/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:56:51 UTC
  • Revision ID: edam@waxworlds.org-20090305135651-rycwzitsuwfrd1ee
Tags: 2.3
- optimised dependency generation: generate stub dependencies from the compiler and don't use the sed script where possible
- fix spelling mistake in dependencies
- only generate dependency files in debug mode

Show diffs side-by-side

added added

removed removed

1
1
#_______________________________________________________________________________
2
2
#
3
 
#                     edam's general-purpose makefile v2.2
 
3
#                       edam's general-purpose makefile                     v2.3
4
4
#_______________________________________________________________________________
5
5
#                                                                COMMON SETTINGS
6
6
 
100
100
endif
101
101
endif
102
102
 
103
 
# Set up dependancy generation build flags and a commands to be executed after
104
 
# generating any dependancy file. The commands append the names of all the
105
 
# depended-on files in the dependancy file to the end of the dependancy file as
 
103
# Set up dependency generation build flags and, for those languages where the
 
104
# the compiler/assembler doesn't support dependency generation, commands to be
 
105
# executed after generating any dependency file. The commands append the names
 
106
# of all the depended-on files in the dependency file to the end of the file as
106
107
# empty rules with no prerequesits or commands. This causes make not to fail if
107
 
# one of these files becomes non-existant, but causes files dependant on these
108
 
# files to be rebuilt (and thus also have their dependancies regenerated).
 
108
# one of these files becomes non-existant, but causes files dependent on these
 
109
# files to be rebuilt (and thus also have their dependencies regenerated).
109
110
ifdef DEBUGMODE
110
111
ifndef PROFILEMODE
111
 
FIXUP_DEPENDANCY_FILES = \
 
112
FIXUP_DEPENDENCY_FILES = \
112
113
        sed 's/\#.*//;s/^[^:]*://;s/^[ \t]*//;s/ *\\$$//;/^$$/d;s/$$/:/' < \
113
114
        $(basename $<).dep > .$$$$~; cat .$$$$~ >> $(basename $<).dep; rm .$$$$~;
114
 
DEPFLAGS        = -MD -MF $(basename $<).dep
 
115
DEPFLAGS        = -MMD -MP -MF $(basename $<).dep
115
116
endif
116
117
endif
117
118
 
118
 
# include dependancies
 
119
# include dependencies
119
120
ifneq "$(MAKECMDGOALS)" "clean"
120
121
ifneq "$(MAKECMDGOALS)" "clean_all"
121
122
-include $(DEPFILES)
167
168
 
168
169
%.o %_d.o %_p.o: %.c
169
170
        $(CC) -c $(CPPFLAGS) $(DEPFLAGS) $(CFLAGS) -o $@ $<
170
 
        $(FIXUP_DEPENDANCY_FILES)
171
171
 
172
172
%.o %_d.o %_p.o: %.cc
173
173
        $(CXX) -c $(CPPFLAGS) $(DEPFLAGS) $(CXXFLAGS) -o $@ $<
174
 
        $(FIXUP_DEPENDANCY_FILES)
175
174
%.o %_d.o %_p.o: %.C
176
175
        $(CXX) -c $(CPPFLAGS) $(DEPFLAGS) $(CXXFLAGS) -o $@ $<
177
 
        $(FIXUP_DEPENDANCY_FILES)
178
176
%.o %_d.o %_p.o: %.cpp
179
177
        $(CXX) -c $(CPPFLAGS) $(DEPFLAGS) $(CXXFLAGS) -o $@ $<
180
 
        $(FIXUP_DEPENDANCY_FILES)
181
178
 
182
179
%.o %_d.o %_p.o: %.d
183
180
        $(GDC) -c $(CPPFLAGS) $(DFLAGS) -o $@ $<
184
181
 
185
182
%.o %_d.o %_p.o: %.s
186
183
        $(AS) $(ASFLAGS) -o $@ $<
 
184
ifdef DEBUGMODE
 
185
        $(AS) $(ASFLAGS) -M $< > $(basename $<).dep
 
186
        $(FIXUP_DEPENDENCY_FILES)
 
187
endif
187
188
%.o %_d.o %_p.o: %.S
188
189
        $(AS) $(ASFLAGS) -o $@ $<
 
190
ifdef DEBUGMODE
 
191
        $(AS) $(ASFLAGS) -M $< > $(basename $<).dep
 
192
        $(FIXUP_DEPENDENCY_FILES)
 
193
endif
189
194
%.o %_d.o %_p.o: %.asm
190
195
        $(AS) $(ASFLAGS) -o $@ $<
191
 
 
192
 
%.dep: %.s
193
 
        $(AS) $(ASFLAGS) -M $< > $@
194
 
        $(FIXUP_DEPENDANCY_FILES)
195
 
%.dep: %.S
196
 
        $(AS) $(ASFLAGS) -M $< > $@
197
 
        $(FIXUP_DEPENDANCY_FILES)
198
 
%.dep: %.asm
199
 
        $(AS) $(ASFLAGS) -M $< > $@
200
 
        $(FIXUP_DEPENDANCY_FILES)
 
196
ifdef DEBUGMODE
 
197
        $(AS) $(ASFLAGS) -M $< > $(basename $<).dep
 
198
        $(FIXUP_DEPENDENCY_FILES)
 
199
endif
201
200
 
202
201
#_______________________________________________________________________________