|
@@ -111,7 +111,8 @@ define obj_template
|
111
|
111
|
$(foreach TGT,$(DEBUG_TARGETS), \
|
112
|
112
|
$(if $(RULE_$(3)_to_$(TGT)), \
|
113
|
113
|
'\n$$(BIN)/$(4).$(TGT) : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
|
114
|
|
- '\n\t$$(RULE_$(3)_to_$(TGT))\n' ) ) \
|
|
114
|
+ '\n\t$$(RULE_$(3)_to_$(TGT))\n' \
|
|
115
|
+ '\n$(TGT)_OBJS += $$(BIN)/$(4).$(TGT)\n' ) ) \
|
115
|
116
|
'\n$(2) : $$($(4)_DEPS)\n' \
|
116
|
117
|
'\nTAGS : $$($(4)_DEPS)\n' \
|
117
|
118
|
>> $(2)
|
|
@@ -222,6 +223,15 @@ TGT_LD_FLAGS = $(foreach SYM,$(TGT_LD_PREFIX) $(TGT_LD_DRIVERS) obj_config,\
|
222
|
223
|
TGT_MAKEROM_FLAGS = $(strip $(MAKEROM_FLAGS_$(TGT_ROM_NAME)) \
|
223
|
224
|
$(if $(TGT_PCI_VENDOR),$(strip -p $(TGT_PCI_VENDOR),$(TGT_PCI_DEVICE))))
|
224
|
225
|
|
|
226
|
+# Calculate list of debugging versions of objects to be included in
|
|
227
|
+# the target.
|
|
228
|
+#
|
|
229
|
+COMMA := ,
|
|
230
|
+DEBUG_OBJECTS = $(foreach D,$(subst $(COMMA), ,$(DEBUG)),$(BIN)/$(D).dbg.o)
|
|
231
|
+$(foreach OBJ,$(filter-out $(dbg.o_OBJS),$(DEBUG_OBJECTS)), \
|
|
232
|
+ $(error $(OBJ) is not a valid debug object) \
|
|
233
|
+)
|
|
234
|
+
|
225
|
235
|
# Print out all derived information for a given target.
|
226
|
236
|
#
|
227
|
237
|
$(BIN)/%.info :
|
|
@@ -242,13 +252,25 @@ $(BIN)/%.info :
|
242
|
252
|
@echo 'LD target flags : $(TGT_LD_FLAGS)'
|
243
|
253
|
@echo
|
244
|
254
|
@echo 'makerom target flags : $(TGT_MAKEROM_FLAGS)'
|
|
255
|
+ @echo
|
|
256
|
+ @echo 'Debugging objects : $(DEBUG_OBJECTS)'
|
245
|
257
|
|
246
|
258
|
# Build an intermediate object file from the objects required for the
|
247
|
259
|
# specified target.
|
248
|
|
-#
|
249
|
|
-$(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT)
|
250
|
|
- $(LD) $(LDFLAGS) -T $(LDSCRIPT) $(TGT_LD_FLAGS) $< -o $@ \
|
251
|
|
- -Map $(BIN)/$*.tmp.map
|
|
260
|
+#
|
|
261
|
+# If it's a debugging version, force a link to take place by making
|
|
262
|
+# this target depend on a phony target, and mark the resulting files
|
|
263
|
+# as being older than BLIB, so that any subsequent images will do a
|
|
264
|
+# fresh link. Otherwise, you won't get what you expect when you do
|
|
265
|
+# e.g. "make DEBUG=pci bin/pnic.dsk ; make bin/pnic.dsk ; make
|
|
266
|
+# DEBUG=pci bin/pnic.dsk"
|
|
267
|
+#
|
|
268
|
+$(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT) \
|
|
269
|
+ $(DEBUG_OBJECTS) $(if $(DEBUG),force_relink)
|
|
270
|
+ $(LD) $(LDFLAGS) -T $(LDSCRIPT) $(TGT_LD_FLAGS) \
|
|
271
|
+ $(DEBUG_OBJECTS) $(BLIB) -o $@ -Map $(BIN)/$*.tmp.map
|
|
272
|
+ $(if $(DEBUG_OBJECTS),$(TOUCH) -r $(BLIB) -B 2 $@ $(BIN)/$*.tmp.map)
|
|
273
|
+.PHONY : force_relink
|
252
|
274
|
|
253
|
275
|
# Show a linker map for the specified target
|
254
|
276
|
#
|
|
@@ -376,12 +398,6 @@ $(BIN)/%.rebuild :
|
376
|
398
|
rm -f $(BIN)/$*
|
377
|
399
|
$(MAKE) $(MAKEFLAGS) $(BIN)/$*
|
378
|
400
|
|
379
|
|
-# Build a debugging version of an object
|
380
|
|
-#
|
381
|
|
-$(BIN)/%.o.dbg :
|
382
|
|
- rm -f $(BIN)/$*.o
|
383
|
|
- $(MAKE) $(MAKEFLAGS) EXTRA_CFLAGS+=-Ddebug_$* $(BIN)/$*.o
|
384
|
|
-
|
385
|
401
|
# Clean-up
|
386
|
402
|
#
|
387
|
403
|
clean :
|