+ALL_SRCS = $(wildcard $(patsubst ./%, %, \
+ $(patsubst %,%/*.hs, . $(ALL_DIRS)) \
+ $(patsubst %,%/*.lhs, . $(ALL_DIRS)) \
+ $(patsubst %,%/*.hs-boot, . $(ALL_DIRS)) \
+ $(patsubst %,%/*.lhs-boot, . $(ALL_DIRS)) \
+ $(patsubst %,%/*.y, . $(ALL_DIRS)) \
+ $(patsubst %,%/*.ly, . $(ALL_DIRS)) \
+ $(patsubst %,%/*.x, . $(ALL_DIRS)) \
+ $(patsubst %,%/*.c, . $(ALL_DIRS)) \
+ $(patsubst %,%/*.hc, . $(ALL_DIRS)) \
+ $(patsubst %,%/*.S, . $(ALL_DIRS)) \
+ $(patsubst %,%/*.prl, . $(ALL_DIRS)) \
+ $(patsubst %,%/*.lprl, . $(ALL_DIRS)) \
+ $(patsubst %,%/*.lit, . $(ALL_DIRS)) \
+ $(patsubst %,%/*.verb, . $(ALL_DIRS)) \
+ $(patsubst %,%/*.hsc, . $(ALL_DIRS)) \
+ $(patsubst %,%/*.gc, . $(ALL_DIRS)) \
+ )) $(EXTRA_SRCS)
+
+# ALL_SRCS is computed once and for all into PRE_SRCS at the top of
+# target.mk. Otherwise, we end up re-computing ALL_SRCS every time it
+# is expanded (it is used in several variables below, and these
+# variables are used in several others, etc.), which can really slow
+# down make.
+
+PRE_HS_SRCS = $(filter %.hs, $(PRE_SRCS))
+PRE_LHS_SRCS = $(filter %.lhs, $(PRE_SRCS))
+
+PRE_HS_BOOT_SRCS = $(filter %.hs-boot, $(PRE_SRCS)) \
+ $(filter %.lhs-boot, $(PRE_SRCS))
+
+GC_SRCS = $(filter %.gc, $(PRE_SRCS))
+HSC_SRCS = $(filter %.hsc, $(PRE_SRCS))
+HAPPY_Y_SRCS = $(filter %.y, $(PRE_SRCS))
+HAPPY_LY_SRCS = $(filter %.ly, $(PRE_SRCS))
+HAPPY_SRCS = $(HAPPY_Y_SRCS) $(HAPPY_LY_SRCS)
+ALEX_SRCS = $(filter %.x, $(PRE_SRCS))
+
+DERIVED_GC_SRCS = $(patsubst %.gc, %.hs, $(GC_SRCS)) \
+ $(patsubst %.gc, %_stub_ffi.c, $(GC_SRCS)) \
+ $(patsubst %.gc, %_stub_ffi.h, $(GC_SRCS))
+
+DERIVED_HSC_SRCS = $(patsubst %.hsc, %.hs, $(HSC_SRCS)) \
+ $(patsubst %.hsc, %_hsc.c, $(HSC_SRCS)) \
+ $(patsubst %.hsc, %_hsc.h, $(HSC_SRCS)) \
+ $(patsubst %.hsc, %.hc, $(HSC_SRCS))
+
+DERIVED_HAPPY_SRCS = $(patsubst %.y, %.hs, $(HAPPY_Y_SRCS)) \
+ $(patsubst %.ly, %.hs, $(HAPPY_LY_SRCS))
+
+DERIVED_ALEX_SRCS = $(patsubst %.x, %.hs, $(ALEX_SRCS))
+
+DERIVED_HC_SRCS = $(patsubst %.hs, %.hc, $(PRE_HS_SRCS)) \
+ $(patsubst %.lhs, %.hc, $(PRE_LHS_SRCS))
+
+DERIVED_SRCS = $(DERIVED_GC_SRCS) \
+ $(DERIVED_HSC_SRCS) \
+ $(DERIVED_HAPPY_SRCS) \
+ $(DERIVED_ALEX_SRCS) \
+ $(DERIVED_HC_SRCS)