[project @ 2002-01-15 05:39:14 by sof]
[ghc-hetmet.git] / ghc / rts / Makefile
index b923189..c01d5e2 100644 (file)
@@ -1,5 +1,5 @@
 #-----------------------------------------------------------------------------
-# $Id: Makefile,v 1.39 2000/11/07 10:42:57 simonmar Exp $
+# $Id: Makefile,v 1.56 2002/01/15 05:39:15 sof Exp $
 #
 #  This is the Makefile for the runtime-system stuff.
 #  This stuff is written in C (and cannot be written in Haskell).
@@ -32,40 +32,41 @@ else
 SRCS_RTS_C  := $(filter-out Main.c, $(SRCS_RTS_C))
 endif
 
-#-----------------------------------------------------------------------------
-# creating and installing libHSrts.a (in its many flavors)
-#
 LIBOBJS = $(patsubst %.c,%.$(way_)o,$(SRCS_RTS_C)) \
           $(patsubst %.hc,%.$(way_)o,$(SRCS_RTS_HC)) \
           $(patsubst %.S,%.$(way_)o,$(SRCS_RTS_S))
 
+#-----------------------------------------------------------------------------
+# Flags for compiling RTS .c and .hc files
+
 # gcc provides lots of useful warnings if you ask it.
 # This is a pretty good list to start with - use a # to comment out
 # any you don't like.
-WARNING_OPTS += -optc-Wall 
-WARNING_OPTS += -optc-W
-WARNING_OPTS += -optc-Wstrict-prototypes 
-WARNING_OPTS += -optc-Wmissing-prototypes 
-WARNING_OPTS += -optc-Wmissing-declarations
-WARNING_OPTS += -optc-Winline
-WARNING_OPTS += -optc-Waggregate-return
-#WARNING_OPTS += -optc-Wpointer-arith
-WARNING_OPTS += -optc-Wbad-function-cast
-#WARNING_OPTS += -optc-Wcast-align
-#WARNING_OPTS += -optc-Wnested-externs
-#WARNING_OPTS += -optc-Wshadow
-#WARNING_OPTS += -optc-Wcast-qual
-#WARNING_OPTS += -optc-Wno-unused 
-#WARNING_OPTS += -optc-Wredundant-decls 
-#WARNING_OPTS += -optc-Wconversion
-
-SRC_HC_OPTS += -I../includes -I. -Iparallel $(WARNING_OPTS) $(GhcRtsHcOpts) -optc-DCOMPILING_RTS
-SRC_CC_OPTS = $(GhcRtsCcOpts)
+WARNING_OPTS += -Wall 
+WARNING_OPTS += -W
+WARNING_OPTS += -Wstrict-prototypes 
+WARNING_OPTS += -Wmissing-prototypes 
+WARNING_OPTS += -Wmissing-declarations
+WARNING_OPTS += -Winline
+WARNING_OPTS += -Waggregate-return
+#WARNING_OPTS += -Wpointer-arith
+WARNING_OPTS += -Wbad-function-cast
+WARNING_OPTS += -Wcast-align
+#WARNING_OPTS += -Wnested-externs
+#WARNING_OPTS += -Wshadow
+#WARNING_OPTS += -Wcast-qual
+#WARNING_OPTS += -Wno-unused 
+#WARNING_OPTS += -Wredundant-decls 
+#WARNING_OPTS += -Wconversion
+
+SRC_CC_OPTS +=  $(GhcRtsCcOpts)  $(WARNING_OPTS) -DCOMPILING_RTS
+
+SRC_HC_OPTS += -I../includes -I. -Iparallel $(GhcRtsHcOpts) -DCOMPILING_RTS
 
 ifneq "$(DLLized)" "YES"
 SRC_HC_OPTS += -static
 endif
-# SRC_HC_OPTS += -optc-fPIC
+# SRC_HC_OPTS += -fPIC
 
 ifeq "$(way)" "mp"
 SRC_HC_OPTS += -I$$PVM_ROOT/include
@@ -74,17 +75,15 @@ endif
 #-----------------------------------------------------------------------------
 # Include the Front panel code?
 
+SRCS_RTS_C :=  $(filter-out Vis%.c, $(SRCS_RTS_C))
+
 # we need GTK+ for the front panel
 ifneq "$(GTK_CONFIG)" ""
-
 ifeq "$(GhcRtsWithFrontPanel)" "YES"
-SRC_HC_OPTS += `$(GTK_CONFIG) --cflags` -optc-DRTS_GTK_FRONTPANEL
-else
-SRCS_RTS_C :=  $(filter-out Vis*.c, $(SRCS_RTS_C))
-endif
-
-VisCallbacks_CC_OPTS = -optc-Wno-unused
-
+SRC_HC_OPTS            += `$(GTK_CONFIG) --cflags` -optc-DRTS_GTK_FRONTPANEL
+SRCS_RTS_C             := $(SRCS_RTS_C) $(wildcard Vis*.c)
+VisCallbacks_CC_OPTS   += -Wno-unused
+endif # GhcRtsWithFrontPanel
 endif # GTK_CONFIG
 
 #-----------------------------------------------------------------------------
@@ -102,7 +101,17 @@ SRC_MKDEPENDC_OPTS += -I. -I../includes
 # ../driver/ghc (a better C compiler :-) to compile the
 # different RTS pieces
 #
-CC=$(GHC_INPLACE) $(HC_OPTS) $($*_HC_OPTS)
+
+ifeq "$(BootingFromHc)" "YES"
+# use the normal $(CC) when booting from .hc files
+SRC_CC_OPTS += $(HC_OPTS)
+SRC_CC_OPTS += -I../includes -I. -Iparallel -DCOMPILING_RTS
+else
+# otherwise, use $(GHC_INPLACE) as the C compiler.
+CC=$(GHC_INPLACE)
+CC_OPTS := $(addprefix -optc, $(CC_OPTS)) $(HC_OPTS)
+endif
+
 HC=$(GHC_INPLACE)
 
 # prevent this value from leaking into the GMP makefile
@@ -112,7 +121,7 @@ unexport CC
 #
 #  Building DLLs is only supported on mingw32 at the moment.
 #
-HSLIB             = rts
+PACKAGE             = rts
 
 ifeq "$(DLLized)" "YES"
 SRC_BLD_DLL_OPTS += -lHS_imp_stub -lgmp_imp
@@ -142,10 +151,18 @@ endif
 # and not worth re-implementing in our Makefile framework.
 
 ifneq "$(HaveLibGmp)" "YES"
+ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
+boot ::
+       cd gmp && ./configure --enable-shared=no \
+               --host=`echo $(HOSTPLATFORM) | sed 's/i[567]86/i486/g'`
+else
+# Pass --target to configure of GMP, so that building for mingwin under
+# cygwin works properly (when the host is not the same as the target)
 boot ::
-       cd gmp && ./configure --enable-shared=no --target=$(HOSTPLATFORM)
+       cd gmp && CC=$(WhatGccIsCalled) ./configure --enable-shared=no --target=$(HOSTPLATFORM)
+endif
 
-# Slight cheatage here to past host as target, but x-compilation isn't supported by ghc.
+# Slight cheatage here to pass host as target, but x-compilation isn't supported by ghc.
 
 all :: gmp/libgmp.a
 
@@ -153,24 +170,27 @@ ifeq "$(DLLized)" "YES"
 all :: $(DLL_PEN)/gmp.dll
 
 $(DLL_PEN)/gmp.dll:
-       make -C gmp gmp.dll
+       $(MAKE) -C gmp gmp.dll
        $(MV) gmp/gmp.dll $(DLL_PEN)
 endif
 
 install :: gmp/libgmp.a
 
-clean ::
-       $(MAKE) -C gmp MAKEFLAGS= clean
-
 ifeq "$(way)" ""
+clean distclean maintainer-clean ::
+       -$(MAKE) -C gmp MAKEFLAGS= $@
+
 INSTALL_LIBS += gmp/libgmp.a
 endif
 
 gmp/libgmp.a ::
        $(MAKE) -C gmp MAKEFLAGS=
        @$(CP) gmp/.libs/libgmp.a gmp
+       @$(RANLIB) gmp/libgmp.a
 endif
 
+CLEAN_FILES += gmp/libgmp.a
+
 #-----------------------------------------------------------------------------
 #
 # Building the GUM SysMan