+PRE_SRCS = $(wildcard *.lhs *.hs *.c *.prl *.lprl *.lit *.verb *.hsc)
+
+DERIVED_SRCS = $(patsubst %.hsc, %.hs %_hsc.c %_hsc.h, \
+ $(filter %.hsc, $(PRE_SRCS) ))
+
+# EXCLUDED_SRCS can be set in the Makefile, otherwise it defaults to empty.
+EXCLUDED_DERIVED_SRCS = $(patsubst %.hsc,%.hs %_hsc.c, \
+ $(filter %.hsc, $(EXCLUDED_SRCS)))
+CLOSED_EXCLUDED_SRCS = $(sort $(EXCLUDED_SRCS) $(EXCLUDED_DERIVED_SRCS))
+
+SRCS = $(filter-out $(CLOSED_EXCLUDED_SRCS), \
+ $(sort $(PRE_SRCS) $(HSC_DERIVED_SRCS)))
+
+HS_SRCS = $(filter %.lhs %.hs %.hc,$(sort $(SRCS) $(BOOT_SRCS)))
+HS_OBJS = $(addsuffix .$(way_)o,$(basename $(HS_SRCS)))
+HS_HCS = $(addsuffix .$(way_)hc,$(basename $(HS_SRCS)))
+HS_SS = $(addsuffix .$(way_)s,$(basename $(HS_SRCS)))
+HS_IFACES = $(addsuffix .$(way_)hi,$(basename $(HS_SRCS)))