[project @ 1997-09-05 09:16:19 by simonm]
[ghc-hetmet.git] / ghc / compiler / Makefile
index 972a8ca..721f190 100644 (file)
@@ -1,5 +1,4 @@
 # -----------------------------------------------------------------------------
-# $Id: Makefile,v 1.9 1997/03/17 20:34:30 simonpj Exp $
 
 TOP = ..
 include $(TOP)/mk/boilerplate.mk
@@ -21,6 +20,14 @@ endif
 # (included below) to kick in.
 
 LIBRARY=libhsp.a
+
+#
+# Note: there have been reports of people running up against the ARG_MAX limit
+# when linking hsc with all its constituent object files. The likely source of 
+# the problem is that the environment is a bit too big, so a workaround could
+# 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
 
 
@@ -42,12 +49,7 @@ ifeq ($(GhcWithDeforester),YES)
 endif
 
 ifeq ($(GhcWithNativeCodeGen),YES)
-  ifeq ($(GhcWithHscBuiltViaC),YES)
-    # If building via C, we *assume* that it is the distributed C files,
-    # which do not have a native-code generator in them
-  else
-    DIRS += nativeGen
-  endif
+DIRS += nativeGen
 else
 SRC_HC_OPTS += -DOMIT_NATIVE_CODEGEN
 endif
@@ -55,15 +57,30 @@ endif
 
 HS_SRCS = $(SRCS_UGNHS) \
           $(foreach dir,$(DIRS),$(wildcard $(dir)/*.lhs)) \
-         rename/ParseIface.hs rename/ParseType.hs rename/ParseUnfolding.hs \
-         main/LoopHack.hc 
+         rename/ParseIface.hs rename/ParseType.hs rename/ParseUnfolding.hs
+
+ifneq "$(Ghc2_0)" "YES"
+HS_SRCS += main/LoopHack.hc 
+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.
 
-LOOPS   = $(patsubst %.lhi, %.hi, $(wildcard */*.lhi))
-HCS     = $(patsubst %.lhs, %.hc, $(patsubst %.hs, %.hc, $(HS_SRCS)))
 
+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)
+# always (only when $(Ghc2_0) is equal to YES)
+ifeq "$(Ghc2_0)" "YES"
+MKDEPENDHS_SRCS = $(HS_SRCS)
+else
+LOOPS   = $(patsubst %.lhi, %.hi, $(wildcard */*.lhi))
+endif
 HS_OBJS  = \
   $(patsubst %.hc, %.o, $(HCS)) \
   parser/hsclink.o parser/hschooks.o libhsp.a
@@ -104,22 +121,35 @@ SRC_DIST_FILES += rename/ParseIface.hs \
 #
 HC=$(WithGhcHc)
 
+# magic from GNU make manual to convert a list of values
+# into a colon-separated list
+empty:=
+space:= $(empty) $(empty)
+
 SRC_HC_OPTS += \
-  -cpp -fhaskell-1.3 -syslib ghc \
-  -fglasgow-exts -DCOMPILING_GHC -Rghc-timing -I. -IcodeGen \
-  -InativeGen -Iparser $(foreach dir,$(DIRS),-i$(dir))
+  -cpp -fglasgow-exts -Rghc-timing \
+  -I. -IcodeGen -InativeGen -Iparser \
+  -i$(subst $(space),:,$(DIRS))
 
-# -syslib ghc just needed for utils/CharSeq.lhs use of PackedString.hPutPS
+ifeq "$(Ghc2_0)" "NO"
+SRC_HC_OPTS += -fhaskell-1.3
+endif
 
+# -syslib ghc just needed for use of PackedString.hPutPS
 
-SRC_CC_OPTS += -Iparser -I.
+SRC_CC_OPTS += -Iparser -I. -I$(TOP)/includes -O
 
-ifneq ($(Ghc2_0),NO)
-  SRC_HC_OPTS += -fomit-derived-read -fomit-reexported-instances
+ifeq "$(Ghc2_0)" "NO"
+SRC_HC_OPTS += -fomit-derived-read -fomit-reexported-instances
+else
+SRC_HC_OPTS += -recomp
 endif
 
 ifeq ($(GhcWithDeforester),NO)
-  SRC_HC_OPTS += -DOMIT_DEFORESTER
+ ifeq "$(Ghc2_0)" "NO"
+  SRC_MKDEPENDHS_OPTS += -DOMIT_DEFORESTER
+ endif
+SRC_HC_OPTS += -DOMIT_DEFORESTER
 endif
 
 SRC_HC_OPTS += $(GhcHcOpts)
@@ -133,9 +163,10 @@ 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
+main/Main_HC_OPTS              = -fvia-C -DPROJECTVERSION=$(GhcProjectVersion)
 main/CmdLineOpts_HC_OPTS       = -fvia-C
 nativeGen/PprMach_HC_OPTS      = -K2m
+nativeGen/MachMisc_HC_OPTS     = -K2m -fvia-C
 parser/UgenAll_HC_OPTS                 = -fvia-C '-\#include"hspincl.h"'
 parser/UgenUtil_HC_OPTS        = -fvia-C '-\#include"hspincl.h"'
 parser/U_constr_HC_OPTS        = -fvia-C '-\#include"hspincl.h"'
@@ -150,32 +181,51 @@ parser/U_qid_HC_OPTS              = -fvia-C '-\#include"hspincl.h"'
 parser/U_tree_HC_OPTS          = -fvia-C '-\#include"hspincl.h"'
 parser/U_ttype_HC_OPTS                 = -fvia-C '-\#include"hspincl.h"'
 prelude/PrimOp_HC_OPTS                 = -K3m
-reader/Lex_HC_OPTS             = -K2m
+reader/Lex_HC_OPTS             = -K2m -H16m -fvia-C
 reader/ReadPrefix_HC_OPTS      = -fvia-C '-\#include"hspincl.h"'
-rename/ParseIface_HC_OPTS      = -Onot -H16m
-rename/ParseType_HC_OPTS       = -Onot -H16m
-rename/ParseUnfolding_HC_OPTS  = -Onot -H16m
+rename/ParseIface_HC_OPTS      += -Onot -H16m
+rename/ParseType_HC_OPTS       += -Onot -H16m
+rename/ParseUnfolding_HC_OPTS  += -Onot -H30m
+ifeq "$(Ghc2_0)" "YES"
+rename/ParseIface_HC_OPTS       += -fno-warn-incomplete-patterns
+rename/ParseType_HC_OPTS        += -fno-warn-incomplete-patterns
+rename/ParseUnfolding_HC_OPTS   += -fno-warn-incomplete-patterns
+endif
+
 ifeq "$(TARGETPLATFORM)" "hppa1.1-hp-hpux9"
 rename/RnMonad_HC_OPTS                 = -fvia-C -O2 -O2-for-C
 else
+ifeq "$(Ghc2_0)" "NO"
 rename/RnMonad_HC_OPTS                 = -fvia-C
 endif
+endif
 rename/RnEnv_HC_OPTS           = -fvia-C
 rename/RnSource_HC_OPTS                = -H12m
 rename/RnIfaces_HC_OPTS                = -H8m -fvia-C
 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
-typecheck/TcMonad_HC_OPTS      = -fvia-C
 typecheck/TcGenDeriv_HC_OPTS   = -H10m
 typecheck/TcExpr_HC_OPTS       = -H10m
+typecheck/TcEnv_HC_OPTS                = -H10m
+ifeq "$(Ghc2_0)" "NO"
+typecheck/TcMonad_HC_OPTS      = -fvia-C       
+endif
 utils/Argv_HC_OPTS             = -fvia-C
-utils/CharSeq_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
+utils/FastString_HC_OPTS       = -fvia-C -monly-3-regs
 utils/StringBuffer_HC_OPTS     = -fvia-C
+utils/Digraph_HC_OPTS          = -fglasgow-exts -fvia-C
 
+# optimiser misbehaving in 0.29, occurrence analyser fails to terminate when
+# compiling lib/required/Time.lhs
+ifeq "$(Ghc2_0)" "NO"
+simplCore/OccurAnal_HC_OPTS    = -Onot
+endif
 
 # ----------------------------------------------------------------------------
 #              C compilations
@@ -192,7 +242,7 @@ SRC_YACC_OPTS  += -d -v
 #
 # Want to keep the intermediate (included in src distribs).
 #
-.PRECIOUS: parser/%.tab.c parser/hslexer.c
+.PRECIOUS: %.tab.c %.tab.h parser/hslexer.c
 
 parser/hschooks.o : parser/hschooks.c
        @$(RM) $@
@@ -202,6 +252,10 @@ parser/hschooks.o : parser/hschooks.c
 # Interface-file parser uses Happy
 SRC_HAPPY_OPTS += +RTS -K2m -H10m -RTS
 
+ifeq ($(Ghc2_0),NO)
+SRC_HAPPY_OPTS+= -1.2
+endif
+
 rename/ParseIface.hs : rename/ParseIface.y
        @$(RM) rename/ParseIface.hs rename/ParseIface.hinfo
        $(HAPPY) $(HAPPY_OPTS) -g rename/ParseIface.y
@@ -234,18 +288,22 @@ CLEAN_FILES += hsp
 # inside it. (compilation is handled by the suffix rules).
 
 #
-# Building the loop breakers from .lhi files
+# Building the loop breakers from .lhi (0.2x) or .hi-boot (2.xx) files
 #
-ifeq ($(Ghc2_0),YES)
-  %.hi : %_1_3.lhi
+ifeq "$(Ghc2_0)" "NO"
+hi-boot :: $(LOOPS)
+
+%.hi : %.lhi
        $(RM) $@
        $(UNLIT) $<  $@ || ( $(RM) $@ && exit 1 )
        @chmod 444 $@
+
+boot :: hi-boot
 else
-  %.hi : %.lhi
-       $(RM) $@
-       $(UNLIT) $<  $@ || ( $(RM) $@ && exit 1 )
-       @chmod 444 $@
+# hi-boot not needed when using 2.04+ as HC, defining it here
+# to be consistent across setting of Ghc2_0
+hi-boot :
+       @echo "Done."
 endif
 
 #-----------------------------------------------------------------------------
@@ -253,10 +311,6 @@ endif
 
 SRC_LD_OPTS += -no-link-chk
 
-# Build-specific
-#SRC_LD_OPTS += "-pgml time gcc -B/projects/unsupported/gnu/sparc-sunos5/bin/g"
-
-
 #-----------------------------------------------------------------------------
 #              install
 
@@ -283,16 +337,17 @@ endif
 #
 depend :: $(LOOPS) $(SRCS_UGNHS) rename/ParseIface.hs rename/ParseUnfolding.hs rename/ParseType.hs
 
-ifeq ($(GhcWithDeforester),NO)
-  SRC_MKDEPENDHS_OPTS += -DOMIT_DEFORESTER
-endif
 
-ifeq ($(Ghc2_0),YES)
-SRC_MKDEPENDHS_OPTS += $(SRC_HC_OPTS)
+ifeq "$(GhcWithHscBuiltViaC)" "YES"
+ifeq "$(Ghc2_0)" "NO"
+SRC_MKDEPENDHS_OPTS += -o hc
+else
+SRC_MKDEPENDHS_OPTS += -optdep-o -optdephc
 endif
-
-ifeq ($(GhcWithHscBuiltViaC),YES)
-  SRC_MKDEPENDHS_OPTS += -o .hc
+# 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) ?
 endif
@@ -311,16 +366,18 @@ MAINTAINER_CLEAN_FILES += $(wildcard */*.hc)
 
 
 #-----------------------------------------------------------------------------
-#              TAGS
+#              TAGS setup
 
 SRC_HSTAGS_OPTS += -fglasgow-exts -cpp
-
+TAGS_HS_SRCS=$(foreach dir,$(DIRS),$(wildcard $(dir)/*.lhs))
+TAGS_C_SRCS=$(strip $(foreach f,$(foreach dir,$(DIRS),$(wildcard $(dir)/*.c)),$(shell if [ -w $(f) ]; then echo $(f); else echo ''; fi)))
 
 #-----------------------------------------------------------------------------
 #              Include target-rule boilerplate
 
 include $(TOP)/mk/target.mk
 
+
 #
 # Special extra dependencies for yukky ugen stuff
 #