[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / compiler / Makefile
index ad5d6da..a89de68 100644 (file)
@@ -1,5 +1,5 @@
 # -----------------------------------------------------------------------------
-# $Id: Makefile,v 1.34 1998/02/25 19:48:54 sof Exp $
+# $Id: Makefile,v 1.46 1998/12/02 13:17:15 simonm Exp $
 
 TOP = ..
 include $(TOP)/mk/boilerplate.mk
@@ -29,7 +29,7 @@ LIBRARY=libhsp.a
 # be to do ` env PATH=$(PATH) make hsc 'to minimise the environment. (or the
 # equivalent of `env' if it doesn't exist locally).
 #
-HS_PROG=hsc
+HS_PROG=hsc$(_way)
 
 
 # -----------------------------------------------------------------------------
@@ -60,29 +60,28 @@ endif
 
 
 HS_SRCS = $(SRCS_UGNHS) \
-          $(foreach dir,$(DIRS),$(wildcard $(dir)/*.lhs)) \
-         rename/ParseIface.hs
+          $(foreach dir,$(DIRS),$(wildcard $(dir)/*.lhs))
+
+ifneq "$(GhcWithHscBuiltViaC)" "YES"
+HS_SRCS += rename/ParseIface.hs
+endif
 
 # NB: it's no good to include *.hs in the top-line wildcard, because the .hs files
 #     in parser/ may not have been created at that point.
 
-
 HCS      = $(patsubst %.lhs, %.hc, $(patsubst %.hs, %.hc, $(HS_SRCS)))
 
-#
-# When booting using a ghc-2.xx compiler, the loop breakers are actually written in
-# Haskell, source stubs just re-exporting info from the various .hi-boot files.
-# (Reason: we don't want to fiddle with the imports in the sources). We give them
-# the suffix .hs, since they're special and don't fall under the umbrella of $(HS_SRCS)
+# ParseIface.hs ain't part of HS_SRCS when this is on..
+ifeq "$(GhcWithHscBuiltViaC)" "YES"
+HCS      += rename/ParseIface.hc
+endif
 
-MKDEPENDHS_SRCS = $(HS_SRCS)
 HS_OBJS  = \
   $(patsubst %.hc, %.o, $(HCS)) \
   parser/hsclink.o parser/hschooks.o libhsp.a
 
 
-DESTDIR         = $(INSTALL_LIBRARY_DIR_GHC)
+DESTDIR       = $(INSTALL_LIBRARY_DIR_GHC)
 
 SRCS_UGN      = $(wildcard parser/*.ugn)
 SRCS_UGNC     = $(patsubst %.ugn, %.c, $(SRCS_UGN))
@@ -99,22 +98,27 @@ C_SRCS += $(SRCS_UGNC)
 LIBOBJS = \
   $(SRCS_UGN_OBJS) parser/hslexer.o parser/hsparser.tab.o \
   parser/id.o parser/infix.o parser/syntax.o parser/type2context.o \
-  parser/util.o
+  parser/util.o parser/ctypes.o
 
-#
 # stuff you get for free in a source distribution
 # 
-SRC_DIST_FILES += rename/ParseIface.hs \
- parser/U_tree.c parser/tree.h parser/tree.c \
- parser/hsparser.tab.c parser/hsparser.tab.h \
- parser/hslexer.c
+# SRC_DIST_FILES += rename/ParseIface.hs \
+#  parser/U_tree.c parser/tree.h parser/tree.c \
+#  parser/hsparser.tab.c parser/hsparser.tab.h \
+#  parser/hslexer.c
 
 # -----------------------------------------------------------------------------
 #              Haskell compilations
 
-# Compiler to use for building hsc
 #
+# Compiler to use for building hsc, use the build tree
+# driver when booting.
+#
+ifneq "$(GhcWithHscBuiltViaC)" "YES"
 HC=$(WithGhcHc)
+else
+HC=$(GHC_DRIVER_DIR)/ghc
+endif
 
 # magic from GNU make manual to convert a list of values
 # into a colon-separated list
@@ -126,8 +130,6 @@ SRC_HC_OPTS += \
   -I. -IcodeGen -InativeGen -Iparser \
   -i$(subst $(space),:,$(DIRS))
 
-# -syslib ghc just needed for use of PackedString.hPutPS
-
 SRC_CC_OPTS += -Iparser -I. -I$(TOP)/includes -O
 
 SRC_HC_OPTS += -recomp $(GhcHcOpts)
@@ -136,18 +138,20 @@ SRC_HC_OPTS += -recomp $(GhcHcOpts)
 #      The standard suffix rule for compiling a Haskell file
 #      adds these flags to the command line
 
-absCSyn/AbsCSyn_HC_OPTS        = -fno-omit-reexported-instances
-absCSyn/CStrings_HC_OPTS       = -monly-3-regs
-
 # Was 6m with 2.10
 absCSyn/PprAbsC_HC_OPTS        = -H10m
 
 basicTypes/IdInfo_HC_OPTS      = -K2m
-coreSyn/AnnCoreSyn_HC_OPTS     = -fno-omit-reexported-instances
 hsSyn/HsExpr_HC_OPTS           = -K2m
-hsSyn/HsSyn_HC_OPTS            = -fno-omit-reexported-instances
-main/Main_HC_OPTS              = -fvia-C -DPROJECTVERSION=$(GhcProjectVersion)
-main/MkIface_HC_OPTS            = -DPROJECTVERSION=$(GhcProjectVersionInt)
+main/Main_HC_OPTS              = -fvia-C
+main/Constants_HC_OPTS         = -DHscIfaceFileVersion=$(HscIfaceFileVersion)
+
+ifneq "$(GhcWithHscBuiltViaC)" "YES"
+ifeq "$(GhcReportCompiles)" "YES"
+main/Main_HC_OPTS              += -syslib misc -DREPORT_TO_MOTHERLODE
+endif
+endif
+
 main/CmdLineOpts_HC_OPTS       = -fvia-C
 nativeGen/PprMach_HC_OPTS      = -K2m
 nativeGen/MachMisc_HC_OPTS     = -K2m -fvia-C
@@ -166,43 +170,65 @@ parser/U_qid_HC_OPTS              = -fvia-C '-\#include"hspincl.h"'
 parser/U_tree_HC_OPTS          = -H12m -fvia-C '-\#include"hspincl.h"'
 parser/U_ttype_HC_OPTS                 = -fvia-C '-\#include"hspincl.h"'
 prelude/PrimOp_HC_OPTS                 = -H12m -K3m
-reader/Lex_HC_OPTS             = -K2m -H16m -fvia-C -DPROJECTVERSION=$(GhcProjectVersionInt)
+reader/Lex_HC_OPTS             = -K2m -H16m -fvia-C
 
 # Heap was 6m with 2.10
 reader/ReadPrefix_HC_OPTS      = -fvia-C '-\#include"hspincl.h"' -H10m
 
 rename/ParseIface_HC_OPTS      += -Onot -H30m -fno-warn-incomplete-patterns
+rename/ParseIface_HAPPY_OPTS    += -g
 
 ifeq "$(TARGETPLATFORM)" "hppa1.1-hp-hpux9"
 rename/RnMonad_HC_OPTS                 = -fvia-C -O2 -O2-for-C
-else
 endif
+
 rename/RnEnv_HC_OPTS           = -fvia-C
 rename/RnSource_HC_OPTS                = -H12m
 rename/RnIfaces_HC_OPTS                = -H8m -fvia-C
 rename/RnExpr_HC_OPTS          = -H10m
 rename/RnNames_HC_OPTS         = -H12m
 rename/RnMonad_HC_OPTS         = -fvia-C
-# Urk!  Really big heap for ParseUnfolding
-#rename/ParseUnfolding_HC_OPTS = -H45m         
 specialise/Specialise_HC_OPTS  = -Onot -H12m
-stgSyn/StgSyn_HC_OPTS          = -fno-omit-reexported-instances
+simplCore/Simplify_HC_OPTS     = -H15m 
 typecheck/TcGenDeriv_HC_OPTS   = -H10m
 
+# tmp, -- SDM
+specialise/Specialise_HC_OPTS  += -fno-prune-tydecls
+
 # Was 10m for 2.10
 typecheck/TcHsSyn_HC_OPTS      = -H15m 
 
+
 # Was 10m for 2.10
 typecheck/TcExpr_HC_OPTS       = -H15m
+typecheck/TcBinds_HC_OPTS       = -H10m
 
 typecheck/TcEnv_HC_OPTS                = -H10m
-utils/Argv_HC_OPTS             = -fvia-C -monly-3-regs
+utils/Argv_HC_OPTS             = -fvia-C
 utils/SST_HC_OPTS              = -fvia-C
-utils/PrimPacked_HC_OPTS       = -fvia-C -monly-3-regs
-utils/FastString_HC_OPTS       = -fvia-C -monly-3-regs
-utils/StringBuffer_HC_OPTS     = -fvia-C
+utils/FastString_HC_OPTS       = -fvia-C
+utils/StringBuffer_HC_OPTS     = -fvia-C -fno-prune-tydecls
 utils/Digraph_HC_OPTS          = -fglasgow-exts -fvia-C
-utils/Outputable_HC_OPTS       = -monly-3-regs
+utils/DirUtils_HC_OPTS                 = -fvia-C
+
+ifeq "$(alpha_HOST_ARCH)" "1"
+# "stbu" bug in alpha native code generator...
+basicTypes/Unique_HC_OPTS      = -fvia-C
+endif
+
+# flags for PrimPacked:
+#
+# -monly-3-regs 
+#      because it contains a 'ccall strlen', which gets inlined by
+#      gcc, causing a lack of registers.
+#
+# -optC-funfolding-interface-threshold10
+#      To stop the definition of 'strLength', which calls strlen, getting
+#      into the interface file and spreading the -monly-3-regs virus.
+#      We need -optC here because the driver before 3.02 didn't understand
+#      the -funfolding flags.
+
+utils/PrimPacked_HC_OPTS       = -fvia-C -monly-3-regs -optC-funfolding-interface-threshold10
 
 # Strictness analyser misbehaving in 2.10, fails to terminate on
 # UpdAnal.lhs due to weird recursive datatype.  Bug was exposed by a
@@ -216,10 +242,12 @@ SRC_C_OPTS     += -O -Iparser -I. -IcodeGen
 
 
 # ----------------------------------------------------------------------------
-#              Parsers
+#              Parsers/lexers
 
 # Main parser uses Yacc/Bison
 SRC_YACC_OPTS  += -d -v
+# Suppress the generation of a default rule
+SRC_FLEX_OPTS += -s
 
 #
 # Want to keep the intermediate (included in src distribs).
@@ -228,7 +256,7 @@ SRC_YACC_OPTS  += -d -v
 
 parser/hschooks.o : parser/hschooks.c
        @$(RM) $@
-       $(HC) -c -o $@ $(HCFLAGS) parser/hschooks.c
+       $(HC) -c -o $@ -I$(GHC_INCLUDE_DIR) $(HC_OPTS) parser/hschooks.c
 
 
 # Interface-file parser uses Happy
@@ -255,6 +283,12 @@ CLEAN_FILES += hsp
 
 SRC_LD_OPTS += -no-link-chk
 
+ifneq "$(GhcWithHscBuiltViaC)" "YES"
+ifeq "$(GhcReportCompiles)" "YES"
+SRC_LD_OPTS += -syslib misc -syslib exts
+endif
+endif
+
 #-----------------------------------------------------------------------------
 #              install
 
@@ -270,21 +304,12 @@ INSTALL_LIBEXECS += hsc hsp
 #
 # Before doing `make depend', need to build all derived Haskell source files
 #
-depend :: $(LOOPS) $(SRCS_UGNHS) rename/ParseIface.hs
-
+depend :: $(LOOPS) $(SRCS_UGNHS)
 
-ifeq "$(GhcWithHscBuiltViaC)" "YES"
-SRC_MKDEPENDHS_OPTS += -optdep-o -optdephc
-
-# When booting from .hc, (hackily) remove the suffix rule for 
-# .l?hs -> .o, so that the .hc -> .o is used instead.
-%.$(way_)o : %.lhs
-%.$(way_)o : %.hs
-else
-  SRCS_MKDEPENDHS = $(SRCS_HC) # should add $(LOOPS) ?
+ifneq "$(GhcWithHscBuiltViaC)" "YES"
+depend :: rename/ParseIface.hs
 endif
 
-
 #-----------------------------------------------------------------------------
 #              clean