[project @ 2005-03-02 11:06:58 by simonmar]
[ghc-hetmet.git] / ghc / compiler / Makefile
index 8324e8b..4f0d8c6 100644 (file)
@@ -90,11 +90,15 @@ ifeq "$(stage)" ""
 stage=1
 endif
 
-boot ::
+.DUMMY: stage_dir
+stage_dirs :
        $(MKDIRHIER) stage$(stage)
        for i in $(ALL_DIRS); do \
            $(MKDIRHIER) stage$(stage)/$$i; \
        done
+
+boot :: stage_dirs
+
 # On Windows, we can't use symbolic links for the -hi-boot files
 # because GHC itself is a Mingw program and does not understand
 # symbolic links.  So we have to copy the files instead of link them.
@@ -237,7 +241,7 @@ CLEAN_FILES += $(CONFIG_HS)
 
 PLATFORM_H = ghc_boot_platform.h
 
-stage1/$(PLATFORM_H) : $(FPTOOLS_TOP)/mk/config.mk Makefile
+stage1/$(PLATFORM_H) : stage_dirs $(FPTOOLS_TOP)/mk/config.mk Makefile
        @echo "Creating $@..."
        @$(RM) $@
        @echo "#ifndef __PLATFORM_H__"  >$@
@@ -283,7 +287,7 @@ endif
 # For stage2 and above, the BUILD platform is the HOST of stage1, and
 # the HOST platform is the TARGET of stage1.  The TARGET remains the same
 # (stage1 is the cross-compiler, not stage2).
-stage2/$(PLATFORM_H) : $(FPTOOLS_TOP)/mk/config.mk Makefile
+stage2/$(PLATFORM_H) : stage_dirs $(FPTOOLS_TOP)/mk/config.mk Makefile
        @echo "Creating $@..."
        @$(RM) $@
        @echo "#ifndef __PLATFORM_H__"  >$@
@@ -326,10 +330,12 @@ endif
        @echo "#endif /* __PLATFORM_H__ */"          >> $@
        @echo "Done."
 
-stage3/$(PLATFORM_H) : stage2/$(PLATFORM_H)
+stage3/$(PLATFORM_H) : stage_dirs stage2/$(PLATFORM_H)
        $(CP) stage2/$(PLATFORM_H) stage3/$(PLATFORM_H)
 
-boot :: stage$(stage)/$(PLATFORM_H)
+STAGE_PLATFORM_H = stage$(stage)/$(PLATFORM_H)
+
+boot :: $(STAGE_PLATFORM_H)
 
 SRC_HC_OPTS += -Istage$(stage)
 
@@ -388,10 +394,6 @@ ifeq "$(GhcWithInterpreter) $(bootstrapped)" "YES YES"
 # Yes, include the interepreter, readline, and Template Haskell extensions
 SRC_HC_OPTS += -DGHCI -package template-haskell
 
-ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-SRC_HC_OPTS += -package unix
-endif
-
 ALL_DIRS += ghci
 
 # Enable readline if either:
@@ -420,10 +422,6 @@ EXCLUDED_SRCS += deSugar/DsMeta.hs typecheck/TcSplice.lhs hsSyn/Convert.lhs
 
 endif # bootstrapped with interpreter
 
-ifeq "$(bootstrapped)" "YES"
-SRC_HC_OPTS += -package Cabal
-endif
-
 # -----------------------------------------------
 # mkdependC stuff
 #
@@ -458,16 +456,19 @@ SRC_HC_OPTS += \
 # which needs it).
 SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
 
-# When bootstrapped, we don't make use of *any* packages
-# (except possibly readline if GHCi is enabled, see above)
-ifneq "$(bootstrapped)" "YES"
-ifneq "$(mingw32_HOST_OS)" "1"
-SRC_HC_OPTS += -package concurrent -package posix -package util
+# We need System.Posix (or Posix when ghc < 6.2)
+ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
+ifeq "$(bootstrapped) $(ghc_ge_601)" "NO NO"
+SRC_HC_OPTS += -package posix
 else
-SRC_HC_OPTS += -package concurrent -package util
+SRC_HC_OPTS += -package unix
 endif
 endif
 
+ifneq "$(findstring YES, $(bootstrapped) $(ghc_ge_603))" ""
+SRC_HC_OPTS += -package Cabal
+endif
+
 SRC_CC_OPTS += -Iparser -I. -O
 SRC_HC_OPTS += -recomp $(GhcHcOpts) $(GhcStage$(stage)HcOpts)
 SRC_HC_OPTS += -H16M
@@ -520,6 +521,11 @@ utils/Binary_HC_OPTS               += -O
 utils/FastMutInt_HC_OPTS       += -O
 
 
+# ---- Profiling ----
+#simplCore/Simplify_HC_OPTS = -auto-all
+#simplCore/SimplEnv_HC_OPTS = -auto-all
+#simplCore/SimplUtils_HC_OPTS = -auto-all
+
 # CSE interacts badly with top-level IORefs (reportedly in DriverState and
 # DriverMkDepend), causing some of them to be commoned up.  We have a fix for
 # this in 5.00+, but earlier versions of the compiler will need CSE turned off.
@@ -760,7 +766,7 @@ MKDEPENDHS_HC_OPTS = $(patsubst -i$(odir)/%, -i%, $(HC_OPTS))
 MKDEPENDHS=$(HC)
 
 # Must do this *after* including target.mk, because $(HS_SRCS) isn't set yet.
-depend :: $(HS_SRCS) $(C_SRCS)
+depend :: $(STAGE_PLATFORM_H) $(HS_SRCS) $(C_SRCS)
        touch .depend-BASE
 ifneq "$(BootingFromHc)" "YES"
        $(MKDEPENDHS) -M -optdep-f -optdep.depend-BASE $(foreach way,$(WAYS),-optdep-s -optdep$(way)) $(foreach obj,$(MKDEPENDHS_OBJ_SUFFICES),-osuf $(obj)) $(MKDEPENDHS_OPTS) $(filter-out -split-objs, $(MKDEPENDHS_HC_OPTS)) $(HS_SRCS)