[project @ 2005-07-19 16:44:50 by simonpj]
[ghc-hetmet.git] / ghc / compiler / Makefile
index 49890d1..3dd345e 100644 (file)
@@ -157,10 +157,10 @@ 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.
+# 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
+CLEAN_FILES += $(odir)/*/*.hi $(odir)/*/*.hi-boot $(odir)/*/*.o-boot
 
 ifeq "$(UsingHsBoot)" "YES"
 CLEAN_FILES += $(odir)/*/*.hi-boot $(odir)/*/*.o-boot
@@ -181,7 +181,6 @@ endif
 # be to do `env PATH=$(PATH) make ghc' to minimise the environment. (or the
 # equivalent of `env' if it doesn't exist locally).
 #
-ifneq "$(BuildPackageGHC)" "YES"
 ifneq "$(way)" "dll"
 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
 HS_PROG=$(odir)/ghc$(_way)-$(ProjectVersion)
@@ -191,7 +190,6 @@ endif
 else
 HS_PROG=$(odir)/ghc-$(ProjectVersion)
 endif
-endif
 
 # -----------------------------------------------------------------------------
 # Create compiler configuration
@@ -369,9 +367,6 @@ 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
@@ -410,9 +405,20 @@ ifeq "$(GhcWithInterpreter) $(bootstrapped)" "YES YES"
 
 # Yes, include the interepreter, readline, and Template Haskell extensions
 SRC_HC_OPTS += -DGHCI -package template-haskell
+PKG_DEPENDS += template-haskell
 
 ALL_DIRS += ghci
 
+# If we are going to use dynamic libraries instead of .o files for ghci,
+# we will need to always retain CAFs in the compiler.
+# ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
+# function which sets the keepCAFs flag for the RTS before any Haskell
+# code is run.
+ifeq "$(GhcBuildDylibs)" "YES"
+else
+EXCLUDED_SRCS += ghci/keepCAFsForGHCi.c
+endif
+
 # Enable readline if either:
 #   - we're building stage 1 and $(GhcHasReadline)="YES"
 #   - we're building stage 2/3, and we have built the readline package
@@ -424,10 +430,12 @@ ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
 ifeq "$(stage)" "1"
 ifeq "$(GhcHasReadline)" "YES"
 SRC_HC_OPTS += -package readline -DUSE_READLINE
+PKG_DEPENDS += readline
 endif
 else
 ifeq "$(GhcLibsWithReadline)" "YES"
 SRC_HC_OPTS += -package readline -DUSE_READLINE
+PKG_DEPENDS += readline
 endif
 endif # stage=1
 endif # not windows
@@ -479,11 +487,20 @@ ifeq "$(bootstrapped) $(ghc_ge_601)" "NO NO"
 SRC_HC_OPTS += -package posix
 else
 SRC_HC_OPTS += -package unix
+PKG_DEPENDS += unix
 endif
 endif
 
 ifneq "$(findstring YES, $(bootstrapped) $(ghc_ge_603))" ""
 SRC_HC_OPTS += -package Cabal
+PKG_DEPENDS += Cabal
+endif
+
+ifeq "$(ghc_ge_603)" "YES"
+# Ignore lang, to avoid potential clash with the Generics module if
+# lang happens to be a dependency of some exposed package in the local
+# GHC installation (eg. wxHaskell did this around 6.4).
+SRC_HC_OPTS += -ignore-package lang
 endif
 
 SRC_CC_OPTS += -Iparser -I. -O
@@ -632,30 +649,9 @@ primop-usage.hs-incl: prelude/primops.txt
 
 # Include libghccompat in stage1 only.  In stage2 onwards, all these
 # libraries will be available from the main libraries.
+
 ifeq "$(stage)" "1"
-SRC_HC_OPTS += -i$(GHC_LIB_COMPAT_DIR)
-SRC_LD_OPTS += -L$(GHC_LIB_COMPAT_DIR) -lghccompat
-
-ifeq "$(Windows)" "YES"
-# not very nice, but required for -lghccompat on Windows
-SRC_LD_OPTS += -lshell32
-endif
-
-# This is horrible.  We ought to be able to omit the entire directory
-# from mkDependHS.
-SRC_MKDEPENDHS_OPTS += \
-       -optdep--exclude-module=Compat.RawSystem \
-       -optdep--exclude-module=Compat.Directory \
-       -optdep--exclude-module=Distribution.Compat.ReadP \
-       -optdep--exclude-module=Distribution.Extension \
-       -optdep--exclude-module=Distribution.GetOpt \
-       -optdep--exclude-module=Distribution.InstalledPackageInfo \
-       -optdep--exclude-module=Distribution.License \
-       -optdep--exclude-module=Distribution.Package \
-       -optdep--exclude-module=Distribution.ParseUtils \
-       -optdep--exclude-module=Distribution.Setup \
-       -optdep--exclude-module=Distribution.Version \
-       -optdep--exclude-module=System.Directory.Internals
+include $(GHC_LIB_COMPAT_DIR)/compat.mk
 endif
 
 SRC_LD_OPTS += -no-link-chk
@@ -735,15 +731,36 @@ endif
 coreSyn/CorePrep_HC_OPTS += -auto-all
 
 #-----------------------------------------------------------------------------
-# Building GHC package
+# Building the GHC package
 
-ifeq "$(BuildPackageGHC)" "YES"
+# The GHC package is made from the stage 2 build.  Fortunately the
+# package build system framework more or less does the right thing for
+# us here.
 
+ifeq "$(stage)" "2"
 PACKAGE = ghc
-VERSION = 6.4
-STANDALONE_PACKAGE = YES
-PACKAGE_DEPS =
+HIERARCHICAL_LIB = NO
+VERSION = $(ProjectVersion)
+PKG_DEPENDS += base haskell98
+PACKAGE_CPP_OPTS += -DPKG_DEPENDS='$(PKG_DEPENDS)'
+
+# disable splitting: it won't really help with GHC, and the specialised
+# build system for ghc/compiler isn't set up to handle it.
+SplitObjs = NO
+
+# the package build system likes to set WAYS=$(GhcLibWays), but we don't 
+# really want to build the whole of GHC multiple ways... if you do,
+# set GhcCompilerWays instead.
+GhcLibWays = $(GhcCompilerWays)
+
+# override $(GhcLibHcOpts): we want GhcStage2HcOpts to take precedence
+GhcLibHcOpts =
+
+# override default definition of HS_IFACES so we can add $(odir)
+HS_IFACES   = $(addsuffix .$(way_)hi,$(basename $(HS_OBJS)))
 
+# Haddock can't handle recursive modules currently, so we disable it for now.
+NO_HADDOCK_DOCS = YES
 endif
 
 #-----------------------------------------------------------------------------