[project @ 2000-04-20 15:22:54 by panne]
[ghc-hetmet.git] / mk / target.mk
index b9db06c..7afcf51 100644 (file)
@@ -437,7 +437,7 @@ all :: $(LIBRARY)
 
 define BUILD_LIB
 $(RM) $@
-$(AR) $(AR_OPTS) $@ $(LIBOBJS)
+$(AR) $(AR_OPTS) $@ $(STUBOBJS) $(LIBOBJS)
 $(RANLIB) $@
 endef
 
@@ -450,13 +450,37 @@ endef
 
 ifneq "$(HS_SRCS)" ""
 ifeq "$(SplitObjs)" "YES"
+
+SRC_HC_OPTS += -split-objs
+
 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 # $(filter...
-endif
+
+# Extra stuff for compiling Haskell files with $(SplitObjs):
+
+HC_SPLIT_PRE= \
+if [ ! -d $(basename $@) ]; then mkdir $(basename $@); else \
+ $(FIND) $(basename $@) -name '*.$(way_)o' -print | xargs $(RM) __rm_food ; fi
+HC_SPLIT_POST  = touch $@
+
+SRC_HC_PRE_OPTS  += $(HC_SPLIT_PRE) ;
+SRC_HC_POST_OPTS += $(HC_SPLIT_POST) ;
+
+#
+# If (Haskell) object files are split, cleaning up 
+# consist of descending into the directories where
+# the myriads of object files have been put.
+#
+
+clean ::
+       $(FIND) $(patsubst %.$(way_)o,%,$(HS_OBJS)) -name '*.$(way_)o' -print | xargs $(RM) __rm_food
+       -rmdir $(patsubst %.$(way_)o,%,$(HS_OBJS)) > /dev/null 2>&1
+
+endif # $(SplitObjs)
+endif # $(HS_SRCS)
 
 #
 # Remove local symbols from library objects if requested.
@@ -475,7 +499,7 @@ SRC_HC_POST_OPTS += \
 endif
 endif
 
-$(LIBRARY) :: $(LIBOBJS)
+$(LIBRARY) :: $(STUBOBJS) $(LIBOBJS)
        $(BUILD_LIB)
 endif
 
@@ -1076,21 +1100,6 @@ maintainer-clean:: mostlyclean clean distclean
        rm -f $(MAINTAINER_CLEAN_FILES)
 endif
 
-#
-# If (Haskell) object files are split, cleaning up 
-# consist of descending into the directories where
-# the myriads of object files have been put.
-#
-
-ifneq "$(HS_OBJS)" ""
-ifneq "$(filter -split-objs,$(HC_OPTS))" ""
-clean ::
-       $(FIND) $(patsubst %.$(way_)o,%,$(HS_OBJS)) -name '*.$(way_)o' -print | xargs $(RM) __rm_food
-       -rmdir $(patsubst %.$(way_)o,%,$(HS_OBJS)) > /dev/null 2>&1
-endif
-endif
-
-
 #################################################################################
 #
 #                      Way management