$(if $(MAKECMDGOALS),
$(eval BUILDGOALS := $(filter-out clean scrub purge uninstall,$(MAKECMDGOALS))),
$(eval BUILDGOALS := all))
-$(if $(or $(MISSING_TRG), $(and $(BUILDGOALS),$(filter $(OLDER_TIME),$(NEWEST_TRG_TIME)))),
+$(if $(and $(BUILDGOALS),$(or $(MISSING_TRG), $(filter $(OLDER_TIME),$(NEWEST_TRG_TIME)))),
$(if $(findstring n,$(MAKEFLAGS)),
$(SLANG_TRG):
$(SHELL_CMD)
# 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_MODULES += $(file <$(1:%.$2=%.ld)))
+$(eval DRIVER_LDVALS := $(file <$(1:%.$2=%.ld)))
+$(eval DRIVER_LFLAGS := $(filter -l%,$(DRIVER_LDVALS)))
+$(eval DRIVER_MODULES += $(filter-out -l%,$(DRIVER_LDVALS)))
# List of module archives to link together during compilation
$(eval DRIVER_ARCHIVES := $(DRIVER_MODULES:%=%.$($2_AROBJ)))
# '_start'). This driver object is then simply linked to its libraries and
# module archives to create an executable binary in the output folder.
# ORDER MATTERS HERE, this is for the linker:
-$(eval DRIVER_SRC := $(DRIVER_DEPS))
-$(eval DRIVER_DBGSRC := $(DRIVER_DBGDEPS))
+$(eval DRIVER_SRC := $(DRIVER_LFLAGS) $(DRIVER_DEPS))
+$(eval DRIVER_DBGSRC := $(DRIVER_LFLAGS) $(DRIVER_DBGDEPS))
# Iterate through the list of libraries in our language and stack commands from
# left to right in the "sources" section of the LD command (or LD section of the
# commandline for the compiler), to preserve ordering and also ensure that it is