Improved rules for stubs. Not perfect yet, but better than before.
@$(RM) $@
$(FLEX) -t $(FLEX_OPTS) $< > $@ || ( $(RM) $@ && exit 1 )
+# stubs are automatically generated and compiled by GHC
+%_stub.$(way_)o: %.o
+ @:
+
#-----------------------------------------------------------------------------
# Yacc stuff
define BUILD_LIB
$(RM) $@
-$(AR) $(AR_OPTS) $@ $(LIBOBJS)
+$(AR) $(AR_OPTS) $@ $(STUBOBJS) $(LIBOBJS)
$(RANLIB) $@
endef
define BUILD_LIB
$(RM) $@
-TMPDIR=$(TMPDIR); export TMPDIR; $(FIND) $(patsubst %.$(way_)o,%,$(LIBOBJS)) -name '*.$(way_)o' -print | xargs ar q $@
+TMPDIR=$(TMPDIR); export TMPDIR; ( echo $(STUBOBJS) ; $(FIND) $(patsubst %.$(way_)o,%,$(LIBOBJS)) -name '*.$(way_)o' -print ) | xargs ar q $@
$(RANLIB) $@
endef
endif
endif
-$(LIBRARY) :: $(LIBOBJS)
+$(LIBRARY) :: $(STUBOBJS) $(LIBOBJS)
$(BUILD_LIB)
endif