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