Mostly fix Trac #2431: make empty case acceptable to (most of) GHC
[ghc-hetmet.git] / rts / Makefile
index 74a37fd..09f5766 100644 (file)
@@ -36,7 +36,7 @@ endif
 # -----------------------------------------------------------------------------
 # RTS ways
 
-WAYS=$(GhcLibWays) $(GhcRTSWays)
+WAYS=$(strip $(GhcLibWays) $(GhcRTSWays))
 
 ifneq "$(findstring debug, $(way))" ""
 GhcRtsHcOpts=
@@ -93,6 +93,15 @@ endif
 
 EXCLUDED_SRCS += parallel/SysMan.c
 
+EXCLUDED_SRCS += dyn-wrapper.c
+
+# compile generatic patchable dyn-wrapper
+
+DYNWRAPPER_SRC = dyn-wrapper.c
+DYNWRAPPER_PROG = dyn-wrapper$(exeext)
+$(DYNWRAPPER_PROG): $(DYNWRAPPER_SRC)
+       $(HC) -cpp -optc-include -optcdyn-wrapper-patchable-behaviour.h $(INPLACE_EXTRA_FLAGS) $< -o $@
+
 # The build system doesn't give us these
 CMM_SRCS = $(filter-out AutoApply%.cmm, $(wildcard *.cmm)) $(EXTRA_CMM_SRCS)
 CMM_OBJS = $(patsubst %.cmm,%.$(way_)o, $(CMM_SRCS))
@@ -148,9 +157,14 @@ SRC_CC_OPTS += -DNOSMP
 SRC_HC_OPTS += -optc-DNOSMP
 endif
 
-ifeq "$(UseLibFFI)" "YES"
-SRC_CC_OPTS += -DUSE_LIBFFI
-PACKAGE_CPP_OPTS += -DUSE_LIBFFI
+ifeq "$(UseLibFFIForAdjustors)" "YES"
+SRC_CC_OPTS += -DUSE_LIBFFI_FOR_ADJUSTORS
+endif
+
+ifeq "$(Windows)" "YES"
+# SDM: when compiled with -fasm the RTS currently has bogus references to 
+# __imp_base_ things, so working around for now:
+SRC_HC_OPTS = -fvia-C
 endif
 
 ifneq "$(DYNAMIC_RTS)" "YES"
@@ -168,13 +182,13 @@ LIB_LD_OPTS = -L$(shell $(GHC_PKG_INPLACE) field base library-dirs | sed -e 's/l
 endif
 endif
 
-ifeq "$(Windows)" "YES"
-# On Windows GHC does its own commandline parsing, so we need extra
-# doublequote protection. Sigh.
-DQ = \\\"
-else
+# Mac OS X: make sure we compile for the right OS version
+SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
+SRC_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
+LIB_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
+
+# XXX DQ is now the same on all platforms, so get rid of it
 DQ = \"
-endif
 
 # If Main.c is built with optimisation then the SEH exception stuff on
 # Windows gets confused.
@@ -191,6 +205,10 @@ RtsUtils_CC_OPTS += -DTargetPlatform=$(DQ)$(TARGETPLATFORM)$(DQ)
 RtsUtils_CC_OPTS += -DGhcUnregisterised=$(DQ)$(GhcUnregisterised)$(DQ)
 RtsUtils_CC_OPTS += -DGhcEnableTablesNextToCode=$(DQ)$(GhcEnableTablesNextToCode)$(DQ)
 
+# ffi.h triggers prototype warnings, so disable them here:
+Interpreter_CC_OPTS += -Wno-strict-prototypes
+Adjustor_CC_OPTS += -Wno-strict-prototypes
+
 StgCRun_CC_OPTS += -w
 Typeable_CC_OPTS += -w
 RetainerProfile_CC_OPTS += -w
@@ -263,8 +281,26 @@ endif
 # Add PAPI library if needed
 
 ifeq "$(GhcRtsWithPapi)" "YES"
-SRC_HC_OPTS            += -optc-DUSE_PAPI
+
+SRC_CC_OPTS            += -DUSE_PAPI
 PACKAGE_CPP_OPTS       += -DUSE_PAPI
+
+PACKAGE_CPP_OPTS += -DPAPI_INCLUDE_DIR=$(PapiIncludeDir)
+PACKAGE_CPP_OPTS += -DPAPI_LIB_DIR=$(PapiLibDir)
+
+ifneq "$(PapiIncludeDir)" ""
+SRC_HC_OPTS += -I$(PapiIncludeDir)
+SRC_CC_OPTS += -I$(PapiIncludeDir)
+SRC_HSC2HS_OPTS += -I$(PapiIncludeDir)
+endif
+ifneq "$(PapiLibDirs)" ""
+SRC_LD_OPTS += -L$(PapiLibDirs)
+endif
+
+else # GhcRtsWithPapi==YES
+
+PACKAGE_CPP_OPTS += -DPAPI_LIB_DIR=""
+
 endif
 
 #-----------------------------------------------------------------------------
@@ -301,12 +337,6 @@ CLEAN_FILES += $(AUTO_APPLY_CMM)
 endif
 
 # -----------------------------------------------------------------------------
-# Compile GMP only if we don't have it already
-#
-# We use GMP's own configuration stuff, because it's all rather hairy
-# and not worth re-implementing in our Makefile framework.
-
-CLEAN_FILES += gmp/libgmp.a
 
 # Need to get the GMP vars in through CPP to package.conf.in, and put
 # quotes around each element.
@@ -332,6 +362,14 @@ SRC_HSC2HS_OPTS += -I../gmp/gmpbuild
 SRC_LD_OPTS += -L../gmp/gmpbuild
 
 #-----------------------------------------------------------------------------
+# libffi stuff
+
+SRC_CC_OPTS     += -I../libffi/build/include
+SRC_HC_OPTS     += -I../libffi/build/include
+SRC_HSC2HS_OPTS += -I../libffi/build/include
+SRC_LD_OPTS     += -L../libffi/build/include
+
+#-----------------------------------------------------------------------------
 #
 # Building the GUM SysMan
 #
@@ -357,13 +395,7 @@ endif
 # Compiling the cmm files
 
 # ToDo: should we really include Rts.h here?  Required for GNU_ATTRIBUTE().
-SRC_HC_OPTS += -I. -\#include HCIncludes.h
-
-ifeq "$(Windows)" "YES"
-PrimOps_HC_OPTS += -\#include '<windows.h>' -\#include win32/AsyncIO.h
-else
-PrimOps_HC_OPTS += -\#include posix/Itimer.h
-endif
+SRC_HC_OPTS += -I.
 
 # Otherwise the stack-smash handler gets triggered.
 ifeq "$(TargetOS_CPP)" "openbsd"
@@ -373,6 +405,20 @@ endif
 # -O3 helps unroll some loops (especially in copy() with a constant argument).
 sm/Evac_HC_OPTS += -optc-funroll-loops
 
+ifneq "$(findstring thr, $(way))" ""
+EXTRA_SRCS += sm/Evac_thr.c sm/Scav_thr.c
+
+sm/Evac_thr.c : sm/Evac.c
+       cp $< $@
+sm/Scav_thr.c : sm/Scav.c
+       cp $< $@
+
+sm/Evac_thr_HC_OPTS += -optc-DPARALLEL_GC
+sm/Scav_thr_HC_OPTS += -optc-DPARALLEL_GC
+else
+EXCLUDED_SRCS += sm/Evac_thr.c sm/Scav_thr.c
+endif
+
 # Without this, thread_obj will not be inlined (at least on x86 with GCC 4.1.0)
 sm/Compact_HC_OPTS += -optc-finline-limit=2500
 
@@ -380,7 +426,7 @@ sm/Compact_HC_OPTS += -optc-finline-limit=2500
 # use a variety of types to represent closure pointers (StgPtr,
 # StgClosure, StgMVar, etc.), and without -fno-strict-aliasing gcc is
 # allowed to assume that these pointers do not alias.  eg. without
-# this flag we get problems in GC.c:copy() with gcc 3.4.3, the
+# this flag we get problems in sm/Evac.c:copy() with gcc 3.4.3, the
 # upd_evacee() assigments get moved before the object copy.
 SRC_CC_OPTS += -fno-strict-aliasing
 
@@ -422,14 +468,8 @@ endif
 #
 # binary-dist
 
-binary-dist:
-       $(INSTALL_DIR)                         $(BIN_DIST_DIR)/rts
-       $(INSTALL_DIR)                         $(BIN_DIST_DIR)/rts/gmp
-       $(INSTALL_DATA)    Makefile            $(BIN_DIST_DIR)/rts/
-       $(INSTALL_DATA)    package.conf.in     $(BIN_DIST_DIR)/rts/
-ifneq "$(INSTALL_LIBS)" ""
-       $(INSTALL_DATA)    $(INSTALL_LIBS)     $(BIN_DIST_DIR)/rts/
-endif
-ifneq "$(INSTALL_LIBEXECS)" ""
-       $(INSTALL_PROGRAM) $(INSTALL_LIBEXECS) $(BIN_DIST_DIR)/rts/
-endif
+BINDIST_EXTRAS += package.conf.in
+BINDIST_EXTRAS += $(INSTALL_LIBS)
+BINDIST_EXTRAS += $(INSTALL_LIBEXECS)
+include $(TOP)/mk/bindist.mk
+