+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))