-# 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))
+# 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=%.mk))
+$(if $(filter test%,$(DRIVER_NAME)),
+$(eval DRV_LD := $(subst $(DRIVER_NAME).$2,$(DRIVER_NAME:test%=%).mk,$1))
+$(if $(wildcard $(DRV_LD)),
+$(eval DRIVER_LDFILE := $(DRV_LD))
+))
+$(eval undefine LINK_ORDER)
+$(eval undefine LINK_ORDER_D)
+$(eval $(file <$(DRIVER_LDFILE)))
+$(eval undefine DRIVER_LDINFO)
+$(eval undefine DRIVER_LDINFO_D)
+$(eval DRIVER_LDINFO += $(1:%.$2=%.$($2_OBJ)))
+$(eval DRIVER_LDINFO_D += $(1:$(dir $1)%.$2=$(dir $1).$($2_DBG)/%.$($2_OBJ)))
+$(eval DLIBS := $(patsubst +%,%,$(filter +%,$(LINK_ORDER))))
+$(eval SLIBS := $(patsubst -%,%,$(filter -%,$(LINK_ORDER))))
+$(foreach ldobj,$(patsubst +%,%,$(LINK_ORDER:-%=%)),
+$(if $(or $(filter $(ldobj),$(DLIBS)),$(and $(filter-out $(SLIBS),$(ldobj)), $(filter $(ldobj),$($($2_C)_LDLIBS)))),
+$(eval DRIVER_LDINFO += -l$(ldobj)),
+$(if $(filter $(ldobj),$(MODULES)),
+$(eval DRIVER_LDINFO += $(SRC_DIR)/$(ldobj).$($2_AROBJ))
+$(eval DRIVER_LDINFO_D += $(SRC_DIR)/.$($2_DBG)/$(ldobj).$($2_AROBJ)),
+$(if $($(ldobj)_INIT),,$(call LANG_LIB_INIT,$2,$(ldobj),$1))
+$(foreach dep,$($(ldobj)_DEPS)