summaryrefslogtreecommitdiffstats
path: root/src/Makefile.housekeeping
diff options
context:
space:
mode:
authorMichael Brown2005-04-17 01:28:36 +0200
committerMichael Brown2005-04-17 01:28:36 +0200
commita666eb34b56b4cea51cbe837d954e60b9c68c687 (patch)
treee268cac859436800f5081d9245fc691192a674ec /src/Makefile.housekeeping
parentPlace the call to adjust_pci_device() back in the individual drivers, (diff)
downloadipxe-a666eb34b56b4cea51cbe837d954e60b9c68c687.tar.gz
ipxe-a666eb34b56b4cea51cbe837d954e60b9c68c687.tar.xz
ipxe-a666eb34b56b4cea51cbe837d954e60b9c68c687.zip
Improved building of debugging objects. You can now specify a "DEBUG="
list for any build, e.g. make bin/pnic.dsk DEBUG=pci,pnic This will drag in debugging-enabled versions of pci.c and pnic.c.
Diffstat (limited to 'src/Makefile.housekeeping')
-rw-r--r--src/Makefile.housekeeping38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping
index c7bb1540..378435fa 100644
--- a/src/Makefile.housekeeping
+++ b/src/Makefile.housekeeping
@@ -111,7 +111,8 @@ define obj_template
$(foreach TGT,$(DEBUG_TARGETS), \
$(if $(RULE_$(3)_to_$(TGT)), \
'\n$$(BIN)/$(4).$(TGT) : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
- '\n\t$$(RULE_$(3)_to_$(TGT))\n' ) ) \
+ '\n\t$$(RULE_$(3)_to_$(TGT))\n' \
+ '\n$(TGT)_OBJS += $$(BIN)/$(4).$(TGT)\n' ) ) \
'\n$(2) : $$($(4)_DEPS)\n' \
'\nTAGS : $$($(4)_DEPS)\n' \
>> $(2)
@@ -222,6 +223,15 @@ TGT_LD_FLAGS = $(foreach SYM,$(TGT_LD_PREFIX) $(TGT_LD_DRIVERS) obj_config,\
TGT_MAKEROM_FLAGS = $(strip $(MAKEROM_FLAGS_$(TGT_ROM_NAME)) \
$(if $(TGT_PCI_VENDOR),$(strip -p $(TGT_PCI_VENDOR),$(TGT_PCI_DEVICE))))
+# Calculate list of debugging versions of objects to be included in
+# the target.
+#
+COMMA := ,
+DEBUG_OBJECTS = $(foreach D,$(subst $(COMMA), ,$(DEBUG)),$(BIN)/$(D).dbg.o)
+$(foreach OBJ,$(filter-out $(dbg.o_OBJS),$(DEBUG_OBJECTS)), \
+ $(error $(OBJ) is not a valid debug object) \
+)
+
# Print out all derived information for a given target.
#
$(BIN)/%.info :
@@ -242,13 +252,25 @@ $(BIN)/%.info :
@echo 'LD target flags : $(TGT_LD_FLAGS)'
@echo
@echo 'makerom target flags : $(TGT_MAKEROM_FLAGS)'
+ @echo
+ @echo 'Debugging objects : $(DEBUG_OBJECTS)'
# Build an intermediate object file from the objects required for the
# specified target.
-#
-$(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT)
- $(LD) $(LDFLAGS) -T $(LDSCRIPT) $(TGT_LD_FLAGS) $< -o $@ \
- -Map $(BIN)/$*.tmp.map
+#
+# If it's a debugging version, force a link to take place by making
+# this target depend on a phony target, and mark the resulting files
+# as being older than BLIB, so that any subsequent images will do a
+# fresh link. Otherwise, you won't get what you expect when you do
+# e.g. "make DEBUG=pci bin/pnic.dsk ; make bin/pnic.dsk ; make
+# DEBUG=pci bin/pnic.dsk"
+#
+$(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT) \
+ $(DEBUG_OBJECTS) $(if $(DEBUG),force_relink)
+ $(LD) $(LDFLAGS) -T $(LDSCRIPT) $(TGT_LD_FLAGS) \
+ $(DEBUG_OBJECTS) $(BLIB) -o $@ -Map $(BIN)/$*.tmp.map
+ $(if $(DEBUG_OBJECTS),$(TOUCH) -r $(BLIB) -B 2 $@ $(BIN)/$*.tmp.map)
+.PHONY : force_relink
# Show a linker map for the specified target
#
@@ -376,12 +398,6 @@ $(BIN)/%.rebuild :
rm -f $(BIN)/$*
$(MAKE) $(MAKEFLAGS) $(BIN)/$*
-# Build a debugging version of an object
-#
-$(BIN)/%.o.dbg :
- rm -f $(BIN)/$*.o
- $(MAKE) $(MAKEFLAGS) EXTRA_CFLAGS+=-Ddebug_$* $(BIN)/$*.o
-
# Clean-up
#
clean :