+# EXCLUDED_SRCS can be set in the Makefile, otherwise it defaults to empty.
+EXCLUDED_HSC_SRCS = $(filter %.hsc, $(EXCLUDED_SRCS))
+EXCLUDED_DERIVED_SRCS = $(patsubst %.hsc, %.hs, $(EXCLUDED_HSC_SRCS)) \
+ $(patsubst %.hsc, %_hsc.h, $(EXCLUDED_HSC_SRCS)) \
+ $(patsubst %.hsc, %_hsc.c, $(HSC_SRCS))
+# Exclude _hsc.c files; they get built as part of the cbits library,
+# not part of the main library
+
+CLOSED_EXCLUDED_SRCS = $(sort $(EXCLUDED_SRCS) $(EXCLUDED_DERIVED_SRCS))
+
+SRCS = $(filter-out $(CLOSED_EXCLUDED_SRCS), \
+ $(sort $(PRE_SRCS) $(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)))
+
+HSC_C_OBJS = $(addsuffix _hsc.$(way_)o,$(basename $(filter %.hsc,$(SRCS))))
+
+C_SRCS = $(filter %.c,$(SRCS))
+C_OBJS = $(addsuffix .$(way_)o,$(basename $(C_SRCS)))