-# Driver sources
-DRIVERS := apc testapc
-$(foreach drv,$(DRIVERS),\
-$(eval $(drv)SRC := $(patsubst %.c,%.o,$(filter-out $(patsubst %,src/%.c,$(filter-out $(drv),$(DRIVERS))),$(cSRC) $(cGEN))))\
-$(eval $(drv)-dSRC := $(patsubst %.o,%-d.o,$($(drv)SRC))))
+# Determine if '1' is newer than '2'
+TSTAMP = $(if $(wildcard $1),$(shell stat -c %Y $1),0$(info nots: $1))
+NEWER = $(eval 4 := $(call TSTAMP,$(dir $2)$1))
+NEWER += $(eval 5 := $(call TSTAMP,$2))
+NEWER += $(if $(filter $5,$(firstword $(sort $4 $5))),$1,$2)
+
+ifeq (,$(filter clean,$(MAKECMDGOALS)))
+# Deps should be generated for each source file, when not cleaning
+cGENDEP = $(if $(wildcard $1),$(subst $(dir $1),,$(filter-out $1 \ %:,$(shell $(CC) -MM -MG $1))),\
+$(info [<$1>: no deps - file not found]))
+# S2S will print the command necessary to create a file when called
+S2S = $(if $(filter $2,$(call NEWER,$2,$3)),$(eval 4 := t),$(eval 4 :=))
+S2S += $(if $4,$(info $(call $1,$2,$3)))
+ifeq (,$(filter n,$(MAKEFLAGS)))
+# Unless we're in -n mode, S2S should also invoke the command on the shell
+S2S += $(if $4,$(shell $(call $1,$2,$3)))
+endif
+endif
+
+# Clean targets
+cleanCMD = $(if $(wildcard $1),rm $(wildcard $(sort $1)))