[project @ 2005-03-18 13:37:27 by simonmar]
[ghc-hetmet.git] / ghc / compiler / Makefile
index 4cff048..fde3a7c 100644 (file)
@@ -90,11 +90,24 @@ 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
+
+ifeq "$(stage) $(ghc_ge_603)" "1 YES"
+UsingHsBoot = YES
+else
+ifneq "$(findstring $(stage), 2 3)" ""
+UsingHsBoot = YES
+else
+UsingHsBoot = NO
+endif
+endif
+
+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.
@@ -104,8 +117,7 @@ boot ::
 # PS: 'ln -s foo baz' takes 'foo' relative to the path to 'baz'
 #     whereas 'cp foo baz' treats the two paths independently.
 #     Hence the "../.." in the ln command line
-ifeq "$(stage)" "1"
-ifeq "$(ghc_ge_603)" "NO"
+ifeq "$(UsingHsBoot)" "NO"
 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
        for i in */*hi-boot*; do \
            cp -u -f $$i stage$(stage)/$$i; \
@@ -116,7 +128,6 @@ else
        done
 endif
 endif
-endif
 
 ifeq "$(stage)" "1"
 HC=$(GHC)
@@ -146,8 +157,15 @@ SRC_HC_OPTS += $(patsubst %, -i$(odir)/%, $(ALL_DIRS))
 HS_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(HS_SRCS))))
 C_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(C_SRCS))))
 
+# Our standard cleaning rules don't know that we're doing our output into $(odir), so
+# we have to augment CLEAN_FILES appropriateliy.
+
 CLEAN_FILES += $(odir)/*/*.hi
 
+ifeq "$(UsingHsBoot)" "YES"
+CLEAN_FILES += $(odir)/*/*.hi-boot $(odir)/*/*.o-boot
+endif
+
 ifeq "$(stage)" "1"
 mostlyclean clean distclean maintainer-clean ::
        $(MAKE) $@ stage=2
@@ -237,7 +255,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 +301,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 +344,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)
 
@@ -349,6 +369,9 @@ ALL_SRCS += $(CONFIG_HS)
 # HsGeneric.hs is not used just now
 EXCLUDED_SRCS += hsSyn/HsGeneric.hs
 
+# main/GHC.hs is not ready yet
+EXCLUDED_SRCS += main/GHC.hs
+
 ifeq ($(GhcWithNativeCodeGen),YES)
 ALL_DIRS += nativeGen
 else
@@ -515,6 +538,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.
@@ -714,6 +742,7 @@ coreSyn/CorePrep_HC_OPTS += -auto-all
 ifeq "$(BuildPackageGHC)" "YES"
 
 PACKAGE = ghc
+VERSION = 6.4
 STANDALONE_PACKAGE = YES
 PACKAGE_DEPS =
 
@@ -755,7 +784,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)