mirror of
https://github.com/ipxe/ipxe
synced 2025-12-17 18:11:49 +03:00
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.
This commit is contained in:
16
src/Makefile
16
src/Makefile
@@ -96,12 +96,15 @@ LDFLAGS += $(EXTRA_LDFLAGS)
|
|||||||
CFLAGS_c +=
|
CFLAGS_c +=
|
||||||
CFLAGS_S += -DASSEMBLY
|
CFLAGS_S += -DASSEMBLY
|
||||||
|
|
||||||
|
# Base object name of the current target
|
||||||
|
#
|
||||||
|
OBJECT = $(firstword $(subst ., ,$(@F)))
|
||||||
|
|
||||||
# CFLAGS for specific object files. You can define
|
# CFLAGS for specific object files. You can define
|
||||||
# e.g. CFLAGS_rtl8139, and have those flags automatically used when
|
# e.g. CFLAGS_rtl8139, and have those flags automatically used when
|
||||||
# compiling bin/rtl8139.o.
|
# compiling bin/rtl8139.o.
|
||||||
#
|
#
|
||||||
OBJ_CFLAGS = $(CFLAGS_$(basename $(@F))) \
|
OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
|
||||||
-DOBJECT=$(subst -,_,$(basename $(@F)))
|
|
||||||
$(BIN)/%.flags :
|
$(BIN)/%.flags :
|
||||||
@echo $(OBJ_CFLAGS)
|
@echo $(OBJ_CFLAGS)
|
||||||
|
|
||||||
@@ -109,24 +112,27 @@ $(BIN)/%.flags :
|
|||||||
#
|
#
|
||||||
COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
|
COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
|
||||||
RULE_c = $(COMPILE_c) -c $< -o $@
|
RULE_c = $(COMPILE_c) -c $< -o $@
|
||||||
RULE_c_to_s = $(COMPILE_c) -S -c $< -o $@
|
RULE_c_to_dbg.o = $(COMPILE_c) -DDEBUG_$(OBJECT) -c $< -o $@
|
||||||
RULE_c_to_c = $(COMPILE_c) -E -c $< > $@
|
RULE_c_to_c = $(COMPILE_c) -E -c $< > $@
|
||||||
|
RULE_c_to_s = $(COMPILE_c) -S -c $< -o $@
|
||||||
|
|
||||||
PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
|
PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
|
||||||
ASSEMBLE_S = $(AS) $(ASFLAGS)
|
ASSEMBLE_S = $(AS) $(ASFLAGS)
|
||||||
RULE_S = $(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
|
RULE_S = $(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
|
||||||
RULE_S_to_s = $(PREPROCESS_S) $< > $@
|
RULE_S_to_s = $(PREPROCESS_S) $< > $@
|
||||||
|
|
||||||
DEBUG_TARGETS += c s
|
DEBUG_TARGETS += dbg.o c s
|
||||||
|
|
||||||
# SRCDIRS lists all directories containing source files.
|
# SRCDIRS lists all directories containing source files.
|
||||||
#
|
#
|
||||||
SRCDIRS += core drivers/net drivers/disk
|
SRCDIRS += core drivers/bus drivers/net
|
||||||
|
# drivers/disk
|
||||||
|
|
||||||
# NON_AUTO_SRCS lists files that are excluded from the normal
|
# NON_AUTO_SRCS lists files that are excluded from the normal
|
||||||
# automatic build system.
|
# automatic build system.
|
||||||
#
|
#
|
||||||
NON_AUTO_SRCS += core/elf_loader.c
|
NON_AUTO_SRCS += core/elf_loader.c
|
||||||
|
NON_AUTO_SRCS += drivers/net/prism2.c
|
||||||
|
|
||||||
# Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
|
# Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
|
||||||
# the automatic build system and varies by target; it includes the
|
# the automatic build system and varies by target; it includes the
|
||||||
|
|||||||
@@ -111,7 +111,8 @@ define obj_template
|
|||||||
$(foreach TGT,$(DEBUG_TARGETS), \
|
$(foreach TGT,$(DEBUG_TARGETS), \
|
||||||
$(if $(RULE_$(3)_to_$(TGT)), \
|
$(if $(RULE_$(3)_to_$(TGT)), \
|
||||||
'\n$$(BIN)/$(4).$(TGT) : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
|
'\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' \
|
'\n$(2) : $$($(4)_DEPS)\n' \
|
||||||
'\nTAGS : $$($(4)_DEPS)\n' \
|
'\nTAGS : $$($(4)_DEPS)\n' \
|
||||||
>> $(2)
|
>> $(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)) \
|
TGT_MAKEROM_FLAGS = $(strip $(MAKEROM_FLAGS_$(TGT_ROM_NAME)) \
|
||||||
$(if $(TGT_PCI_VENDOR),$(strip -p $(TGT_PCI_VENDOR),$(TGT_PCI_DEVICE))))
|
$(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.
|
# Print out all derived information for a given target.
|
||||||
#
|
#
|
||||||
$(BIN)/%.info :
|
$(BIN)/%.info :
|
||||||
@@ -242,13 +252,25 @@ $(BIN)/%.info :
|
|||||||
@echo 'LD target flags : $(TGT_LD_FLAGS)'
|
@echo 'LD target flags : $(TGT_LD_FLAGS)'
|
||||||
@echo
|
@echo
|
||||||
@echo 'makerom target flags : $(TGT_MAKEROM_FLAGS)'
|
@echo 'makerom target flags : $(TGT_MAKEROM_FLAGS)'
|
||||||
|
@echo
|
||||||
|
@echo 'Debugging objects : $(DEBUG_OBJECTS)'
|
||||||
|
|
||||||
# Build an intermediate object file from the objects required for the
|
# Build an intermediate object file from the objects required for the
|
||||||
# specified target.
|
# specified target.
|
||||||
|
#
|
||||||
|
# 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)
|
$(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT) \
|
||||||
$(LD) $(LDFLAGS) -T $(LDSCRIPT) $(TGT_LD_FLAGS) $< -o $@ \
|
$(DEBUG_OBJECTS) $(if $(DEBUG),force_relink)
|
||||||
-Map $(BIN)/$*.tmp.map
|
$(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
|
# Show a linker map for the specified target
|
||||||
#
|
#
|
||||||
@@ -376,12 +398,6 @@ $(BIN)/%.rebuild :
|
|||||||
rm -f $(BIN)/$*
|
rm -f $(BIN)/$*
|
||||||
$(MAKE) $(MAKEFLAGS) $(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-up
|
||||||
#
|
#
|
||||||
clean :
|
clean :
|
||||||
|
|||||||
Reference in New Issue
Block a user