[project @ 2002-06-25 15:49:58 by mthomas]
[ghc-hetmet.git] / ghc / rts / Makefile
1 #-----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.71 2002/06/25 15:49:58 mthomas Exp $
3 #
4 #  This is the Makefile for the runtime-system stuff.
5 #  This stuff is written in C (and cannot be written in Haskell).
6 #
7 #  .c  files are vanilla C,
8 #  .hc files are "Haskellized-C", compiled using the C compiler and
9 #      (possibly) the assembly-mangler.  The GHC driver script
10 #      knows how to compile this stuff.
11 #
12 #  Other sorta independent, compile-once subdirs are:
13 #       gmp             -- GNU multi-precision library (for Integer)
14
15 #-----------------------------------------------------------------------------
16 # Preamble
17
18 TOP=..
19
20 # Set UseGhcForCc: this causes the fptools build system to use a different
21 # set of suffix rules for compiling C code, using $(HC) rather than $(CC)
22 # and prepending "-optc" to $(CC_OPTS).  NB. must be done before including
23 # boilerplate.mk below.
24 ifneq "$(BootingFromHc)" "YES"
25 UseGhcForCc = YES
26 endif
27
28 include $(TOP)/mk/boilerplate.mk
29
30 HC=$(GHC_INPLACE)
31
32 WAYS=$(GhcLibWays)
33
34 PACKAGE = rts
35
36 # Tells the build system not to add various Haskellish options to $(SRC_HC_OPTS)
37 NON_HS_PKG = YES
38
39 # grab sources from these subdirectories
40 ALL_DIRS = hooks parallel
41
42 ifeq "$(HaveLibGmp)" "YES"
43 PACKAGE_CPP_OPTS += -DHAVE_LIBGMP
44 endif
45
46 ifeq "$(HaveLibMingwEx)" "YES"
47 PACKAGE_CPP_OPTS += -DHAVE_LIBMINGWEX
48 endif
49
50 ifneq "$(DLLized)" "YES"
51 EXCLUDED_SRCS += RtsDllMain.c
52 else
53 EXCLUDED_SRCS += Main.c
54 endif
55
56 EXCLUDED_SRCS += parallel/SysMan.c
57
58 # The build system doesn't give us these
59 HC_SRCS = $(filter %.hc, $(SRCS))
60 HC_OBJS = $(patsubst %.hc,%.$(way_)o, $(HC_SRCS))
61
62 CLEAN_FILES += $(HC_OBJS)
63
64 # Override the default $(LIBOBJS) (defaults to $(HS_OBJS))
65 LIBOBJS = $(C_OBJS) $(HC_OBJS)
66
67 SplitObjs=NO
68
69 #-----------------------------------------------------------------------------
70 # Flags for compiling RTS .c and .hc files
71
72 # gcc provides lots of useful warnings if you ask it.
73 # This is a pretty good list to start with - use a # to comment out
74 # any you don't like.
75 WARNING_OPTS += -Wall 
76 WARNING_OPTS += -W
77 WARNING_OPTS += -Wstrict-prototypes 
78 WARNING_OPTS += -Wmissing-prototypes 
79 WARNING_OPTS += -Wmissing-declarations
80 WARNING_OPTS += -Winline
81 WARNING_OPTS += -Waggregate-return
82 #WARNING_OPTS += -Wpointer-arith
83 WARNING_OPTS += -Wbad-function-cast
84 WARNING_OPTS += -Wcast-align
85 #WARNING_OPTS += -Wnested-externs
86 #WARNING_OPTS += -Wshadow
87 #WARNING_OPTS += -Wcast-qual
88 #WARNING_OPTS += -Wno-unused 
89 #WARNING_OPTS += -Wredundant-decls 
90 #WARNING_OPTS += -Wconversion
91
92 STANDARD_OPTS += -I../includes -I. -Iparallel
93 # COMPILING_RTS is only used when building Win32 DLL support.
94 STANDARD_OPTS += -DCOMPILING_RTS
95
96 # HC_OPTS is included in both .c and .hc compilations, whereas CC_OPTS is
97 # only included in .c compilations.  HC_OPTS included the WAY_* opts, which
98 # must be included in both types of compilations.
99
100 SRC_CC_OPTS += $(WARNING_OPTS)
101 SRC_CC_OPTS += $(STANDARD_OPTS)
102
103 SRC_CC_OPTS += $(GhcRtsCcOpts)
104 SRC_HC_OPTS += $(GhcRtsHcOpts)
105
106 ifneq "$(DLLized)" "YES"
107 SRC_HC_OPTS += -static
108 endif
109 # SRC_HC_OPTS += -fPIC
110
111 ifeq "$(way)" "mp"
112 SRC_HC_OPTS += -I$$PVM_ROOT/include
113 endif
114
115 ifeq "$(BootingFromHc)" "YES"
116 # use the normal $(CC) when booting from .hc files
117 SRC_CC_OPTS += $(HC_OPTS)
118 endif
119
120 # Currently, you only get 'threads support' in the normal
121 # way.
122 ifeq "$(GhcRtsThreaded)" "YES"
123 ifeq "$(way)" ""
124 SRC_CC_OPTS += -DTHREADED_RTS
125 PACKAGE_CPP_OPTS += -DTHREADED_RTS
126 endif
127 endif
128
129 # If -DDEBUG is in effect, adjust package conf accordingly..
130 ifneq "$(strip $(filter -DDEBUG,$(GhcHcOpts)))" ""
131 PACKAGE_CPP_OPTS += -DDEBUG -DUSING_LIBBFD
132 endif
133
134 #-----------------------------------------------------------------------------
135 # Include the Front panel code?
136
137 # we need GTK+ for the front panel
138 ifneq "$(GTK_CONFIG)" ""
139 ifeq "$(GhcRtsWithFrontPanel)" "YES"
140 SRC_HC_OPTS             += `$(GTK_CONFIG) --cflags` -optc-DRTS_GTK_FRONTPANEL
141 VisCallbacks_CC_OPTS    += -Wno-unused
142 else # GhcRtsWithFrontPanel
143 EXCLUDED_SRCS           += $(wildcard Vis*.c)
144 endif
145 else # GTK_CONFIG
146 EXCLUDED_SRCS           += $(wildcard Vis*.c)
147 endif
148
149 #-----------------------------------------------------------------------------
150 # make depend setup
151
152 MKDEPENDC_SRCS     = $(C_SRCS) $(HC_SRCS)
153 SRC_MKDEPENDC_OPTS += -I. -I../includes
154
155 # -----------------------------------------------------------------------------
156 #
157 #  Building DLLs is only supported on mingw32 at the moment.
158 #
159 ifeq "$(DLLized)" "YES"
160 SRC_BLD_DLL_OPTS += -lHS_imp_stub -lgmp_imp
161
162 # It's not included in the DLL, but we need to compile it up separately.
163 all :: Main.dll_o
164
165 # Need an import library containing the symbols the RTS uses from the Prelude.
166 # So, to avoid bootstrapping trouble, we build one containing just the syms
167 # we need. Weirdly named to avoid clashing later on when compiling the contents
168 # of ghc/lib/..
169 #
170 # Note: if you do change the name of the Prelude DLL, the "--dllname <nm>.dll"
171 # below will need to be updated as well.
172
173 $(DLL_PEN)/HSrts$(_way).dll :: libHS_imp_stub.a
174
175 libHS_imp_stub.a :
176         dlltool --output-lib libHS_imp_stub.a --def HSprel.def --dllname HSstd.dll
177
178 endif
179
180 # -----------------------------------------------------------------------------
181 # Compile GMP only if we don't have it already
182 #
183 # We use GMP's own configuration stuff, because it's all rather hairy
184 # and not worth re-implementing in our Makefile framework.
185
186 ifneq "$(HaveLibGmp)" "YES"
187 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
188 boot ::
189         cd gmp && ./configure --enable-shared=no \
190                 --host=`echo $(HOSTPLATFORM) | sed 's/i[567]86/i486/g'`
191 else
192 # Pass --target to configure of GMP, so that building for mingwin under
193 # cygwin works properly (when the host is not the same as the target)
194 boot ::
195         cd gmp && CC=$(WhatGccIsCalled) ./configure --enable-shared=no --target=$(HOSTPLATFORM)
196 endif
197
198 # Slight cheatage here to pass host as target, but x-compilation isn't supported by ghc.
199
200 all :: gmp/libgmp.a
201
202 ifeq "$(DLLized)" "YES"
203 all :: $(DLL_PEN)/gmp.dll
204
205 $(DLL_PEN)/gmp.dll:
206         $(MAKE) -C gmp gmp.dll
207         $(MV) gmp/gmp.dll $(DLL_PEN)
208 endif
209
210 install :: gmp/libgmp.a
211
212 ifeq "$(way)" ""
213 clean distclean maintainer-clean ::
214         -$(MAKE) -C gmp MAKEFLAGS= $@
215
216 INSTALL_LIBS += gmp/libgmp.a
217 endif
218
219 gmp/libgmp.a ::
220         $(MAKE) -C gmp MAKEFLAGS=
221         @$(CP) gmp/.libs/libgmp.a gmp
222         @$(RANLIB) gmp/libgmp.a
223 endif
224
225 CLEAN_FILES += gmp/libgmp.a
226
227 #-----------------------------------------------------------------------------
228 #
229 # Building the GUM SysMan
230 #
231
232 ifeq "$(way)" "mp"
233 all :: parallel/SysMan
234
235 ifdef solaris2_TARGET_OS
236 __socket_libs = -lsocket -lnsl
237 else
238 __socket_libs =
239 endif
240
241 parallel/SysMan : parallel/SysMan.mp_o parallel/LLComms.mp_o RtsUtils.mp_o RtsFlags.mp_o
242         $(RM) $@
243         gcc -o $@ parallel/SysMan.mp_o parallel/LLComms.mp_o -L$$PVM_ROOT/lib/$$PVM_ARCH -lgpvm3 -lpvm3 $(__socket_libs)
244
245 CLEAN_FILES  += parallel/SysMan.mp_o parallel/SysMan
246 INSTALL_LIBEXECS += parallel/SysMan
247 endif
248
249 #-----------------------------------------------------------------------------
250 #
251 # Files to install
252 #
253 # Just libHSrts is installed uniformly across ways
254 #
255 INSTALL_LIBS += $(LIBRARY)
256 ifeq "$(DLLized)" "YES"
257 INSTALL_PROGS += $(DLL_NAME) gmp/gmp.dll
258 INSTALL_LIBS += $(patsubst %.a,%_imp.a,$(LIBARY))
259 INSTALL_LIBS += gmp/libgmp_imp.a Main.dll_o
260 endif
261
262 include $(TOP)/mk/target.mk