-# In the event that the driver developer does not wish to include a header to
-# any internal modules, the developer may instead create a file with the same
-# basename as the driver, but with the '.ld' suffix, which contains a space
-# separated list of internal modules to link together during compilation
-$(eval DRIVER_LDVALS := $(file <$(1:%.$2=%.ld)))
-$(eval DRIVER_LFLAGS := $(filter -l%,$(DRIVER_LDVALS)))
-$(eval DRIVER_MODULES += $(filter-out -l%,$(DRIVER_LDVALS)))
-$(eval DRIVER_MODULES := $(sort $(DRIVER_MODULES)))
-# List of module archives to link together during compilation
-$(eval DRIVER_ARCHIVES := $(DRIVER_MODULES:%=$(SRC_DIR)/%.$($2_AROBJ)))
-$(eval DRIVER_DEPS := $(DRIVER_SOB) $(DRIVER_ARCHIVES))
-$(eval DRIVER_DBGARCHIVES := $(DRIVER_MODULES:%=$(SRC_DIR)/.$($2_DBG)/%.$($2_AROBJ)))
-$(eval DRIVER_DBGDEPS := $(dir $(DRIVER_SOB)).$($2_DBG)/$(notdir $(DRIVER_SOB)))
-$(eval DRIVER_DBGDEPS += $(DRIVER_DBGARCHIVES))
-
-# If the compiler supports linking, distinguish static from dynamic links,
-# otherwise set all libraries to static
-$(if $($($2_C)_LD),\
-$(eval STLIBS := $(filter-out $($($2_C)_LDLIBS),$($2_LIBS)))\
-$(eval DLIBS := $(filter-out $(STLIBS),$($2_LIBS))),\
-$(eval STLIBS := $($2_LIBS)))
+# Read associated linking data for the driver. If no link data is available,
+# all libraries are assumed to be statically linked by the build system. files
+# prefixed with 'test' will first attempt to find a 'ld' file matching its
+# basename with the 'test' prefix removed (i.e. ./src/bin/testscanner.c will
+# first attempt to find ./src/bin/scanner.ld for its ld information. if not
+# available, it will instead use ./src/bin/testscanner.ld. if still not
+# available, all libraries will attempt static linking - and if those static
+# libs are not available, the system will attempt to retrieve the source code
+# and build the static lib
+$(eval DRIVER_LDFILE := $(1:%.$2=%.ld))
+$(if $(filter test%,$(DRIVER_NAME)),
+$(eval DRV_LD := $(subst $(DRIVER_NAME).$2,$(DRIVER_NAME:test%=%).ld,$1))
+$(if $(wildcard $(DRV_LD)),
+$(eval DRIVER_LDFILE := $(DRV_LD))
+))
+$(eval $1_LD := $(file <$(DRIVER_LDFILE)))
+$(eval undefine DRIVER_LDINFO)
+$(eval undefine DRIVER_LDINFO_D)
+$(foreach ldobj,$($1_LD),
+$(if $(filter -l%,$(ldobj)),
+$(eval ldlibname := $(ldobj:-l%=%))
+$(if $(filter $(ldlibname),$($($2_C)_LDLIBS)),
+$(eval DRIVER_LDINFO += $(ldobj))
+$(eval DRIVER_LDINFO_D += $(ldobj)),
+$(info Statically linking '$(ldobj:-l%=lib%)', linker '$($($2_C)_LD)' for compiler '$($2_C)' cannot link this lib.)
+$(if $($(ldlibname)_INIT),,$(call LANG_LIB_INIT,$2,$(ldlibname),$1))
+$(foreach deplib,$($(ldlibname)_DEPS) $(ldlibname),
+$(eval DRIVER_LDINFO += $(LIB_DIR)/$(deplib).$($2_AROBJ))
+$(eval DRIVER_LDINFO_D += $(LIB_DIR)/.$($2_DBG)/$(deplib).$($2_AROBJ)))
+),
+$(if $(findstring $(ldobj),$(MODULES)),
+$(eval DRIVER_LDINFO += $(SRC_DIR)/$(ldobj).$($2_AROBJ))
+$(eval DRIVER_LDINFO_D += $(SRC_DIR)/.$($2_DBG)/$(ldobj).$($2_AROBJ)),
+$(info Resolving static dependencies for '$(ldobj:%=lib%)'.)
+$(if $($(ldobj)_INIT),,$(call LANG_LIB_INIT,$2,$(ldobj),$1))
+$(foreach deplib,$($(ldobj)_DEPS) $(ldobj),
+$(eval DRIVER_LDINFO += $(LIB_DIR)/$(deplib).$($2_AROBJ))
+$(eval DRIVER_LDINFO_D += $(LIB_DIR)/.$($2_DBG)/$(deplib).$($2_AROBJ)))
+))
+)
+$(eval DRIVER_LDINFO += $(1:%.$2=%.$($2_OBJ)))
+$(eval DRIVER_LDINFO_D += $(1:$(dir $1)%.$2=$(dir $1).$($2_DBG)/%.$($2_OBJ)))
+$(info DRIVER_INFO: $(DRIVER_LDINFO))
+$(info DRIVER_INFO:: $(DRIVER_LDINFO_D))