1 #-----------------------------------------------------------------------------
3 # This is the Makefile for the runtime-system stuff.
4 # This stuff is written in C (and cannot be written in Haskell).
6 # .c files are vanilla C,
7 # .hc files are "Haskellized-C", compiled using the C compiler and
8 # (possibly) the assembly-mangler. The GHC driver script
9 # knows how to compile this stuff.
11 # Other sorta independent, compile-once subdirs are:
12 # gmp -- GNU multi-precision library (for Integer)
14 #-----------------------------------------------------------------------------
19 # Set UseGhcForCc: this causes the fptools build system to use a different
20 # set of suffix rules for compiling C code, using $(HC) rather than $(CC)
21 # and prepending "-optc" to $(CC_OPTS). NB. must be done before including
22 # boilerplate.mk below.
25 include $(TOP)/mk/boilerplate.mk
31 # -----------------------------------------------------------------------------
34 WAYS=$(GhcLibWays) thr debug
36 ifneq "$(findstring p, $(GhcLibWays))" ""
42 WAY_thr_HC_OPTS=-optc-DTHREADED_RTS
45 WAY_thr_p_NAME=threaded profiled
46 WAY_thr_p_HC_OPTS=-optc-DTHREADED_RTS -prof
50 WAY_debug_HC_OPTS=-optc-DDEBUG
53 WAY_debug_p_NAME=debug profiled
54 WAY_debug_p_HC_OPTS=-optc-DDEBUG -prof
56 ifneq "$(findstring $(way), debug debug_p)" ""
61 # -----------------------------------------------------------------------------
63 # Tells the build system not to add various Haskellish options to $(SRC_HC_OPTS)
66 # grab sources from these subdirectories
67 ALL_DIRS = hooks parallel
69 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
71 EXCLUDED_SRCS += Itimer.c Select.c Signals.c
74 ifneq "$(DLLized)" "YES"
75 EXCLUDED_SRCS += RtsDllMain.c
77 EXCLUDED_SRCS += Main.c
80 EXCLUDED_SRCS += parallel/SysMan.c
82 # The build system doesn't give us these
83 HC_SRCS = $(filter %.hc, $(SRCS))
84 HC_OBJS = $(patsubst %.hc,%.$(way_)o, $(HC_SRCS))
86 CLEAN_FILES += $(HC_OBJS)
88 # Override the default $(LIBOBJS) (defaults to $(HS_OBJS))
89 LIBOBJS = $(C_OBJS) $(HC_OBJS)
93 #-----------------------------------------------------------------------------
94 # Flags for compiling RTS .c and .hc files
96 # gcc provides lots of useful warnings if you ask it.
97 # This is a pretty good list to start with - use a # to comment out
101 WARNING_OPTS += -Wstrict-prototypes
102 WARNING_OPTS += -Wmissing-prototypes
103 WARNING_OPTS += -Wmissing-declarations
104 WARNING_OPTS += -Winline
105 WARNING_OPTS += -Waggregate-return
106 #WARNING_OPTS += -Wpointer-arith
107 WARNING_OPTS += -Wbad-function-cast
108 #WARNING_OPTS += -Wcast-align
109 #WARNING_OPTS += -Wnested-externs
110 #WARNING_OPTS += -Wshadow
111 #WARNING_OPTS += -Wcast-qual
112 #WARNING_OPTS += -Wno-unused
113 #WARNING_OPTS += -Wredundant-decls
114 #WARNING_OPTS += -Wconversion
116 STANDARD_OPTS += -I../includes -I. -Iparallel
117 # COMPILING_RTS is only used when building Win32 DLL support.
118 STANDARD_OPTS += -DCOMPILING_RTS
120 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
121 STANDARD_OPTS += -Iwin32
124 # HC_OPTS is included in both .c and .hc compilations, whereas CC_OPTS is
125 # only included in .c compilations. HC_OPTS included the WAY_* opts, which
126 # must be included in both types of compilations.
128 SRC_CC_OPTS += $(WARNING_OPTS)
129 SRC_CC_OPTS += $(STANDARD_OPTS)
131 SRC_CC_OPTS += $(GhcRtsCcOpts)
132 SRC_HC_OPTS += $(GhcRtsHcOpts)
134 ifneq "$(DLLized)" "YES"
135 SRC_HC_OPTS += -static
137 # SRC_HC_OPTS += -fPIC
140 SRC_HC_OPTS += -I$$PVM_ROOT/include
143 # If -DDEBUG is in effect, adjust package conf accordingly..
144 ifneq "$(strip $(filter -optc-DDEBUG,$(GhcRtsHcOpts)))" ""
145 PACKAGE_CPP_OPTS += -DDEBUG
148 ifeq "$(HaveLibMingwEx)" "YES"
149 PACKAGE_CPP_OPTS += -DHAVE_LIBMINGWEX
152 ifeq "$(DotnetSupport)" "YES"
155 # Would like to just use SUBDIRS here, but need to
156 # descend into dotnet/ earlier than that.
159 $(MAKE) -C dotnet all
161 # But use SUBDIRS for other recursive targets.
164 LIBOBJS += dotnet/Invoke.o
167 #-----------------------------------------------------------------------------
168 # Include the Front panel code?
170 # we need GTK+ for the front panel
171 ifneq "$(GTK_CONFIG)" ""
172 ifeq "$(GhcRtsWithFrontPanel)" "YES"
173 SRC_HC_OPTS += `$(GTK_CONFIG) --cflags` -optc-DRTS_GTK_FRONTPANEL
174 VisCallbacks_CC_OPTS += -Wno-unused
175 SRC_MKDEPENDC_OPTS += `$(GTK_CONFIG) --cflags`
176 else # GhcRtsWithFrontPanel
177 EXCLUDED_SRCS += $(wildcard Vis*.c)
180 EXCLUDED_SRCS += $(wildcard Vis*.c)
183 #-----------------------------------------------------------------------------
186 MKDEPENDC_SRCS = $(C_SRCS) $(HC_SRCS)
187 SRC_MKDEPENDC_OPTS += -I. -I../includes
189 # -----------------------------------------------------------------------------
190 # The auto-generated apply code
192 AUTO_APPLY = AutoApply.hc
194 ifneq "$(BootingFromHc)" "YES"
195 $(AUTO_APPLY): $(GHC_GENAPPLY)
200 EXTRA_SRCS += $(AUTO_APPLY)
202 CLEAN_FILES += $(AUTO_APPLY)
204 # -----------------------------------------------------------------------------
206 # Building DLLs is only supported on mingw32 at the moment.
208 ifeq "$(DLLized)" "YES"
209 SRC_BLD_DLL_OPTS += -lHS_imp_stub -lgmp_imp
211 # It's not included in the DLL, but we need to compile it up separately.
214 # Need an import library containing the symbols the RTS uses from the Prelude.
215 # So, to avoid bootstrapping trouble, we build one containing just the syms
216 # we need. Weirdly named to avoid clashing later on when compiling the contents
219 # Note: if you do change the name of the Prelude DLL, the "--dllname <nm>.dll"
220 # below will need to be updated as well.
222 $(DLL_PEN)/HSrts$(_way).dll :: libHS_imp_stub.a
225 dlltool --output-lib libHS_imp_stub.a --def HSprel.def --dllname HSstd.dll
229 # -----------------------------------------------------------------------------
230 # Compile GMP only if we don't have it already
232 # We use GMP's own configuration stuff, because it's all rather hairy
233 # and not worth re-implementing in our Makefile framework.
235 ifneq "$(HaveLibGmp)" "YES"
236 ifneq "$(HaveFrameworkHaskellSupport)" "YES"
238 cd gmp && CC=$(WhatGccIsCalled) ./configure --enable-shared=no \
239 --host=`echo $(HOSTPLATFORM) | sed 's/i[567]86/i486/g'`
241 # Slight cheatage here to pass host as target, but x-compilation isn't supported by ghc.
245 ifeq "$(DLLized)" "YES"
246 all :: $(DLL_PEN)/gmp.dll
249 $(MAKE) -C gmp gmp.dll
250 $(MV) gmp/gmp.dll $(DLL_PEN)
253 install :: gmp/libgmp.a
256 clean distclean maintainer-clean ::
257 -$(MAKE) -C gmp MAKEFLAGS= $@
259 INSTALL_LIBS += gmp/libgmp.a
264 $(MAKE) -C gmp MAKEFLAGS=
265 @$(CP) gmp/.libs/libgmp.a gmp
266 @$(RANLIB) gmp/libgmp.a
269 CLEAN_FILES += gmp/libgmp.a
271 #-----------------------------------------------------------------------------
273 # Building the GUM SysMan
277 all :: parallel/SysMan
279 ifdef solaris2_TARGET_OS
280 __socket_libs = -lsocket -lnsl
285 parallel/SysMan : parallel/SysMan.mp_o parallel/LLComms.mp_o RtsUtils.mp_o RtsFlags.mp_o
287 gcc -o $@ parallel/SysMan.mp_o parallel/LLComms.mp_o -L$$PVM_ROOT/lib/$$PVM_ARCH -lgpvm3 -lpvm3 $(__socket_libs)
289 CLEAN_FILES += parallel/SysMan.mp_o parallel/SysMan
290 INSTALL_LIBEXECS += parallel/SysMan
293 #-----------------------------------------------------------------------------
297 # Just libHSrts is installed uniformly across ways
299 INSTALL_LIBS += $(LIBRARY)
300 ifeq "$(DLLized)" "YES"
301 INSTALL_PROGS += $(DLL_NAME) gmp/gmp.dll
302 INSTALL_LIBS += $(patsubst %.a,%_imp.a,$(LIBARY))
303 INSTALL_LIBS += gmp/libgmp_imp.a Main.dll_o
306 include $(TOP)/mk/target.mk