1 /* This is the Jmakefile for the runtime-system stuff.
2 This stuff is written in C (and cannot be written in Haskell).
4 Things are organised into exactly one level of subdirs.
6 At the moment, there are a few such subdirs:
7 c-as-asm -- mini-interpreter & register hackery
8 gum -- GUM-specific stuff
9 main -- "main", associated startup stuff, & MISC things
10 prims -- code for primitives that must be written in C
11 profiling -- cost-centre profiling
12 storage -- the storage manager(s)
14 We create two libraries. One, libHSrts<tag>.a, is built separately
15 for each "build". The other, libHSclib.a is built once: it is just
16 .lc files that end up the same no matter what, i.e. completely
19 Other sorta independent, compile-once subdirs are:
21 gmp -- GNU multi-precision library (for Integer)
28 /****************************************************************
30 * Jmakefile preamble-y things *
32 ****************************************************************/
34 GhcDriverNeededHere(depend all) /* we use its C-compiling know-how */
36 UnlitNeededHere(depend)
38 /****************************************************************
40 * options used for compiling/etc. things *
42 ****************************************************************/
45 If you use EXTRA_HC_OPTS on the command line (which you shouldn't,
46 strictly speaking), it will probably work -- it is pinned onto
47 GHC_OPTS, just for fun.
50 GHC_OPTS = $(EXTRA_HC_OPTS)
52 /* per-build options: shared with libraries */
53 #define rts_or_lib(r,l) r
54 #include "../mkworld/GHC_OPTS"
57 -I$(TOP_PWD)/$(CURRENT_DIR)/$(GHC_INCLUDES)
59 /****************************************************************
61 * what it is we are compiling; *
62 * these are long and tedious lists, but c'est la guerre *
64 ****************************************************************/
67 storage/SMmarkDefs.lh \
68 storage/SMcopying.lh \
69 storage/SMcompacting.lh \
74 c-as-asm/CallWrap_C.lc \
75 c-as-asm/HpOverflow.lc \
76 c-as-asm/StablePtr.lc \
77 c-as-asm/StablePtrOps.lc \
78 c-as-asm/StgDebug.lc \
79 c-as-asm/StgMiniInt.lc \
101 profiling/CostCentre.lc \
102 profiling/Hashing.lc \
103 profiling/HeapProfile.lc \
104 profiling/Indexing.lc \
110 storage/SMcompacting.lc \
111 storage/SMcopying.lc \
115 storage/SMinit.lc /*could clib except for GCdu option! */ \
116 storage/SMmarking.lc \
119 storage/SMstacks.lc \
120 storage/SMstatic.lc \
121 storage/SMstats.lc /*could clib except GCap affects printing*/ \
124 /*LATER?: storage/SMgen.lc */
127 main/StgStartup.lhc \
129 main/StgThreads.lhc \
130 c-as-asm/PerformIO.lhc \
136 hooks/FreeForeignObj.lc \
140 hooks/NoRunnableThrds.lc \
141 hooks/PatErrorHdr.lc \
142 hooks/TraceHooks.lc \
144 hooks/InitEachPE.lc \
147 H_FILES = $(RTS_LH:.lh=.h)
148 C_FILES = $(RTS_LC:.lc=.c) $(RTS_LHC:.lhc=.hc) $(CLIB_LC:.lc=.c)
152 all depend :: $(H_FILES)
154 ExtraStuffToClean ( $(C_FILES) )
156 /* Literate-pgmming suffix rules used herein */
157 UnlitSuffixRule(.lhc,.hc)
158 UnlitSuffixRule(.lc,.c)
159 UnlitSuffixRule(.lh,.h)
161 /****************************************************************
163 * interesting collections of .o files *
165 ****************************************************************/
167 RTS_OBJS_norm = $(RTS_LC:.lc=.o) $(RTS_LHC:.lhc=.o)
168 RTS_OBJS_p = $(RTS_LC:.lc=.p_o) $(RTS_LHC:.lhc=.p_o)
169 RTS_OBJS_t = $(RTS_LC:.lc=.t_o) $(RTS_LHC:.lhc=.t_o)
170 RTS_OBJS_u = $(RTS_LC:.lc=.u_o) $(RTS_LHC:.lhc=.u_o)
171 RTS_OBJS_mc = $(RTS_LC:.lc=.mc_o) $(RTS_LHC:.lhc=.mc_o)
172 RTS_OBJS_mr = $(RTS_LC:.lc=.mr_o) $(RTS_LHC:.lhc=.mr_o)
173 RTS_OBJS_mt = $(RTS_LC:.lc=.mt_o) $(RTS_LHC:.lhc=.mt_o)
174 RTS_OBJS_mp = $(RTS_LC:.lc=.mp_o) $(RTS_LHC:.lhc=.mp_o)
175 RTS_OBJS_mg = $(RTS_LC:.lc=.mg_o) $(RTS_LHC:.lhc=.mg_o)
176 RTS_OBJS_2s = $(RTS_LC:.lc=.2s_o) $(RTS_LHC:.lhc=.2s_o)
177 RTS_OBJS_1s = $(RTS_LC:.lc=.1s_o) $(RTS_LHC:.lhc=.1s_o)
178 RTS_OBJS_du = $(RTS_LC:.lc=.du_o) $(RTS_LHC:.lhc=.du_o)
179 RTS_OBJS_a = $(RTS_LC:.lc=.a_o) $(RTS_LHC:.lhc=.a_o)
180 RTS_OBJS_b = $(RTS_LC:.lc=.b_o) $(RTS_LHC:.lhc=.b_o)
181 RTS_OBJS_c = $(RTS_LC:.lc=.c_o) $(RTS_LHC:.lhc=.c_o)
182 RTS_OBJS_d = $(RTS_LC:.lc=.d_o) $(RTS_LHC:.lhc=.d_o)
183 RTS_OBJS_e = $(RTS_LC:.lc=.e_o) $(RTS_LHC:.lhc=.e_o)
184 RTS_OBJS_f = $(RTS_LC:.lc=.f_o) $(RTS_LHC:.lhc=.f_o)
185 RTS_OBJS_g = $(RTS_LC:.lc=.g_o) $(RTS_LHC:.lhc=.g_o)
186 RTS_OBJS_h = $(RTS_LC:.lc=.h_o) $(RTS_LHC:.lhc=.h_o)
187 RTS_OBJS_i = $(RTS_LC:.lc=.i_o) $(RTS_LHC:.lhc=.i_o)
188 RTS_OBJS_j = $(RTS_LC:.lc=.j_o) $(RTS_LHC:.lhc=.j_o)
189 RTS_OBJS_k = $(RTS_LC:.lc=.k_o) $(RTS_LHC:.lhc=.k_o)
190 RTS_OBJS_l = $(RTS_LC:.lc=.l_o) $(RTS_LHC:.lhc=.l_o)
191 RTS_OBJS_m = $(RTS_LC:.lc=.m_o) $(RTS_LHC:.lhc=.m_o)
192 RTS_OBJS_n = $(RTS_LC:.lc=.n_o) $(RTS_LHC:.lhc=.n_o)
193 RTS_OBJS_o = $(RTS_LC:.lc=.o_o) $(RTS_LHC:.lhc=.o_o)
194 RTS_OBJS_A = $(RTS_LC:.lc=.A_o) $(RTS_LHC:.lhc=.A_o)
195 RTS_OBJS_B = $(RTS_LC:.lc=.B_o) $(RTS_LHC:.lhc=.B_o)
197 CLIB_OBJS = $(CLIB_LC:.lc=.o)
199 /****************************************************************
201 * knock the "clib" (completely ordinary C, compiled once) *
202 * stuff over the head first... *
204 ****************************************************************/
206 NormalLibraryTarget(HSclib,$(CLIB_OBJS))
207 ExtraStuffToClean($(CLIB_OBJS))
208 #if DoInstallGHCSystem == YES
209 InstallLibraryTarget(HSclib,$(INSTLIBDIR_GHC))
212 /* all .lc files, so far */
213 CompileCBitsly(GHC,hooks/ErrorHdr,)
214 CompileCBitsly(GHC,hooks/FreeForeignObj,)
215 CompileCBitsly(GHC,hooks/OutOfHeap,)
216 CompileCBitsly(GHC,hooks/OutOfStk,)
217 CompileCBitsly(GHC,hooks/OutOfVM,)
218 CompileCBitsly(GHC,hooks/NoRunnableThrds,)
219 CompileCBitsly(GHC,hooks/PatErrorHdr,)
220 CompileCBitsly(GHC,hooks/TraceHooks,)
221 CompileCBitsly(GHC,hooks/SizeHooks,)
222 CompileCBitsly(GHC,hooks/InitEachPE,)
223 CompileCBitsly(GHC,main/Mallocs,)
224 CompileCBitsly(GHC,main/TopClosure,)
226 ExtraStuffToClean(main/TopClosure.o)
228 all :: main/TopClosure.o
230 install :: main/TopClosure.o
231 $(INSTALL) -c $(INSTLIBFLAGS) main/TopClosure.o $(INSTLIBDIR_GHC)/TopClosure.o
234 # if solaris2_TARGET_OS
235 # define __socket_libs -lsocket -lnsl
237 # define __socket_libs /*none*/
240 AllTarget(gum/SysMan)
241 gum/SysMan : gum/SysMan.mp_o gum/LLComms.mp_o main/Mallocs.o hooks/OutOfVM.o
243 $(CC) -o $@ gum/SysMan.mp_o gum/LLComms.mp_o main/Mallocs.o hooks/OutOfVM.o -L$$PVM_ROOT/lib/$$PVM_ARCH -lpvm3 -lgpvm3 __socket_libs
244 ExtraStuffToClean(gum/SysMan.mp_o gum/SysMan)
245 # if DoInstallGHCSystem == YES
246 install :: gum/SysMan
247 $(INSTALL) -c $(INSTBINFLAGS) gum/SysMan $(INSTLIBDIR_GHC)/SysMan
251 /****************************************************************
253 * special local make-world macros *
255 ****************************************************************/
257 /* to build and install the per-build rts stuff */
259 #ifndef SpecialGhcRtsLibTarget
260 #define SpecialGhcRtsLibTarget(tag,objs) @@\
261 AllTarget(CAT3(libHSrts,tag,.a)) @@\
262 ExtraStuffToClean(objs CAT3(libHSrts,tag,.a)) @@\
263 CAT3(libHSrts,tag,.a):: $(H_FILES) objs @@\
267 #endif /* SpecialGhcRtsLibTarget */
269 #ifndef SpecialGhcRtsLibInstallTarget
270 #if DoInstallGHCSystem == YES
271 #define SpecialGhcRtsLibInstallTarget(tag) @@\
272 install :: CAT3(libHSrts,tag,.a) @@\
273 $(INSTALL) $(INSTLIBFLAGS) \ @@\
274 CAT3(libHSrts,tag,.a) \ @@\
275 $(INSTLIBDIR_GHC)/CAT3(libHSrts,tag,.a) @@\
276 $(RANLIB) $(INSTLIBDIR_GHC)/CAT3(libHSrts,tag,.a)
277 #else /* ! DoInstallGHC... */
278 #define SpecialGhcRtsLibInstallTarget(tag) /*nothing*/
279 #endif /* ! DoInstallGHC... */
280 #endif /* SpecialGhcRtsLibInstallTarget */
282 #define BigBuildRtsTarget(tag,objs) \
283 SpecialGhcRtsLibTarget(tag,objs) @@\
284 SpecialGhcRtsLibInstallTarget(tag)
286 /****************************************************************
288 * creating and installing libHSrts.a (in its many flavors) *
290 ****************************************************************/
292 #if DoInstallGHCSystem == YES
293 MakeDirectories(install, $(INSTLIBDIR_GHC))
294 #endif /* DoInstallGHCSystem */
296 IfBuild_normal(BigBuildRtsTarget(,$(RTS_OBJS_norm)))
297 IfBuild_p(BigBuildRtsTarget(_p, $(RTS_OBJS_p)))
298 IfBuild_t(BigBuildRtsTarget(_t, $(RTS_OBJS_t)))
299 IfBuild_u(BigBuildRtsTarget(_u, $(RTS_OBJS_u)))
300 IfBuild_mc(BigBuildRtsTarget(_mc, $(RTS_OBJS_mc)))
301 IfBuild_mr(BigBuildRtsTarget(_mr, $(RTS_OBJS_mr)))
302 IfBuild_mt(BigBuildRtsTarget(_mt, $(RTS_OBJS_mt)))
303 IfBuild_mp(BigBuildRtsTarget(_mp, $(RTS_OBJS_mp)))
304 IfBuild_mg(BigBuildRtsTarget(_mg, $(RTS_OBJS_mg)))
305 IfBuild_2s(BigBuildRtsTarget(_2s, $(RTS_OBJS_2s)))
306 IfBuild_1s(BigBuildRtsTarget(_1s, $(RTS_OBJS_1s)))
307 IfBuild_du(BigBuildRtsTarget(_du, $(RTS_OBJS_du)))
308 IfBuild_a(BigBuildRtsTarget(_a, $(RTS_OBJS_a)))
309 IfBuild_b(BigBuildRtsTarget(_b, $(RTS_OBJS_b)))
310 IfBuild_c(BigBuildRtsTarget(_c, $(RTS_OBJS_c)))
311 IfBuild_d(BigBuildRtsTarget(_d, $(RTS_OBJS_d)))
312 IfBuild_e(BigBuildRtsTarget(_e, $(RTS_OBJS_e)))
313 IfBuild_f(BigBuildRtsTarget(_f, $(RTS_OBJS_f)))
314 IfBuild_g(BigBuildRtsTarget(_g, $(RTS_OBJS_g)))
315 IfBuild_h(BigBuildRtsTarget(_h, $(RTS_OBJS_h)))
316 IfBuild_i(BigBuildRtsTarget(_i, $(RTS_OBJS_i)))
317 IfBuild_j(BigBuildRtsTarget(_j, $(RTS_OBJS_j)))
318 IfBuild_k(BigBuildRtsTarget(_k, $(RTS_OBJS_k)))
319 IfBuild_l(BigBuildRtsTarget(_l, $(RTS_OBJS_l)))
320 IfBuild_m(BigBuildRtsTarget(_m, $(RTS_OBJS_m)))
321 IfBuild_n(BigBuildRtsTarget(_n, $(RTS_OBJS_n)))
322 IfBuild_o(BigBuildRtsTarget(_o, $(RTS_OBJS_o)))
323 IfBuild_A(BigBuildRtsTarget(_A, $(RTS_OBJS_A)))
324 IfBuild_B(BigBuildRtsTarget(_B, $(RTS_OBJS_B)))
327 /****************************************************************
329 * compile the individual RTS files *
331 ****************************************************************/
333 #define DoRtsFile(file,isuf,way,vsuf,flags) @@\
334 CAT3(file.,way,o) : CAT2(file,isuf) @@\
336 $(GHC) -c -o CAT3(file.,way,o) $(GHCFLAGS) flags $(CAT3(GHC,_OPTS,vsuf)) CAT2(file,isuf)
338 #define CompileRTSishly(file,isuf,flags) @@\
339 IfBuild_normal(DoRtsFile(file,isuf,,_norm,flags)) \
340 IfBuild_p(DoRtsFile(file,isuf,p_,_p, flags)) \
341 IfBuild_t(DoRtsFile(file,isuf,t_,_t, flags)) \
342 IfBuild_u(DoRtsFile(file,isuf,u_,_u, flags)) \
343 IfBuild_mc(DoRtsFile(file,isuf,mc_,_mc, flags)) \
344 IfBuild_mr(DoRtsFile(file,isuf,mr_,_mr, flags)) \
345 IfBuild_mt(DoRtsFile(file,isuf,mt_,_mt, flags)) \
346 IfBuild_mp(DoRtsFile(file,isuf,mp_,_mp, flags)) \
347 IfBuild_mg(DoRtsFile(file,isuf,mg_,_mg, flags)) \
348 IfBuild_2s(DoRtsFile(file,isuf,2s_,_2s, flags)) \
349 IfBuild_1s(DoRtsFile(file,isuf,1s_,_1s, flags)) \
350 IfBuild_du(DoRtsFile(file,isuf,du_,_du, flags)) \
351 IfBuild_a(DoRtsFile(file,isuf,a_,_a, flags)) \
352 IfBuild_b(DoRtsFile(file,isuf,b_,_b, flags)) \
353 IfBuild_c(DoRtsFile(file,isuf,c_,_c, flags)) \
354 IfBuild_d(DoRtsFile(file,isuf,d_,_d, flags)) \
355 IfBuild_e(DoRtsFile(file,isuf,e_,_e, flags)) \
356 IfBuild_f(DoRtsFile(file,isuf,f_,_f, flags)) \
357 IfBuild_g(DoRtsFile(file,isuf,g_,_g, flags)) \
358 IfBuild_h(DoRtsFile(file,isuf,h_,_h, flags)) \
359 IfBuild_i(DoRtsFile(file,isuf,i_,_i, flags)) \
360 IfBuild_j(DoRtsFile(file,isuf,j_,_j, flags)) \
361 IfBuild_k(DoRtsFile(file,isuf,k_,_k, flags)) \
362 IfBuild_l(DoRtsFile(file,isuf,l_,_l, flags)) \
363 IfBuild_m(DoRtsFile(file,isuf,m_,_m, flags)) \
364 IfBuild_n(DoRtsFile(file,isuf,n_,_n, flags)) \
365 IfBuild_o(DoRtsFile(file,isuf,o_,_o, flags)) \
366 IfBuild_A(DoRtsFile(file,isuf,A_,_A, flags)) \
367 IfBuild_B(DoRtsFile(file,isuf,B_,_B, flags))
371 CompileRTSishly(c-as-asm/CallWrap_C,.c,)
372 CompileRTSishly(c-as-asm/HpOverflow,.c,)
373 CompileRTSishly(c-as-asm/PerformIO,.hc,-optc-DIN_GHC_RTS=1)
374 CompileRTSishly(c-as-asm/StablePtr,.c,)
375 CompileRTSishly(c-as-asm/StablePtrOps,.c,)
376 CompileRTSishly(c-as-asm/StgDebug,.c,)
377 CompileRTSishly(c-as-asm/StgMiniInt,.c,)
378 CompileRTSishly(gum/FetchMe,.hc,-optc-DIN_GHC_RTS=1)
379 CompileRTSishly(gum/GlobAddr,.c,)
380 CompileRTSishly(gum/HLComms,.c,)
381 CompileRTSishly(gum/Hash,.c,)
382 CompileRTSishly(gum/LLComms,.c,)
383 CompileRTSishly(gum/Pack,.c,)
384 CompileRTSishly(gum/ParInit,.c,)
385 CompileRTSishly(gum/RBH,.c,)
386 CompileRTSishly(gum/Sparks,.c,)
387 CompileRTSishly(gum/SysMan,.c,) /* NB: not in library */
388 CompileRTSishly(gum/Unpack,.c,)
389 CompileRTSishly(main/GranSim,.c,)
390 CompileRTSishly(main/Itimer,.c,)
391 CompileRTSishly(main/Ticky,.c,)
392 CompileRTSishly(main/SMRep,.c,)
393 CompileRTSishly(main/Select,.c,)
394 CompileRTSishly(main/Signals,.c,)
395 CompileRTSishly(main/StgOverflow,.c,)
396 CompileRTSishly(main/StgStartup,.hc,-optc-DIN_GHC_RTS=1)
397 CompileRTSishly(main/StgThreads,.hc,-optc-DIN_GHC_RTS=1)
398 CompileRTSishly(main/StgUpdate,.hc,-optc-DIN_GHC_RTS=1)
399 CompileRTSishly(main/Threads,.c,)
400 CompileRTSishly(main/RtsFlags,.c,)
401 CompileRTSishly(main/main,.c,)
402 CompileRTSishly(profiling/CostCentre,.c,)
403 CompileRTSishly(profiling/Hashing,.c,)
404 CompileRTSishly(profiling/HeapProfile,.c,)
405 CompileRTSishly(profiling/Indexing,.c,)
406 CompileRTSishly(profiling/Timer,.c,)
407 CompileRTSishly(prims/PrimArith,.c,)
408 CompileRTSishly(prims/PrimMisc,.c,)
409 CompileRTSishly(storage/SM1s,.c,)
410 CompileRTSishly(storage/SM2s,.c,)
411 CompileRTSishly(storage/SMap,.c,)
412 CompileRTSishly(storage/SMcheck,.c,)
413 CompileRTSishly(storage/SMcompacting,.c,)
414 CompileRTSishly(storage/SMcopying,.c,)
415 CompileRTSishly(storage/SMdu,.c,)
416 CompileRTSishly(storage/SMevac,.c,)
417 CompileRTSishly(storage/SMextn,.c,)
418 CompileRTSishly(storage/SMgen,.c,)
419 CompileRTSishly(storage/SMinit,.c,)
420 CompileRTSishly(storage/SMmark,.hc,-optc-DIN_GHC_RTS=1 -optc-DMARK_REG_MAP)
421 CompileRTSishly(storage/SMmarking,.c,)
422 CompileRTSishly(storage/SMscan,.c,)
423 CompileRTSishly(storage/SMscav,.c,)
424 CompileRTSishly(storage/SMstacks,.c,)
425 CompileRTSishly(storage/SMstatic,.c,)
426 CompileRTSishly(storage/SMstats,.c,)
427 CompileRTSishly(storage/mprotect,.c,)
429 /****************************************************************
431 * misc "make" targets -- depend, clean, tags *
433 ****************************************************************/
436 /* this is not the way we should do this [WDP [lazy] 94/09] */
437 CTagsTarget( $(RTS_LC) $($RTS_LHC) $(CLIB_LC) )
438 CTagsTarget( gmp/[a-z]*.c )
440 CDependTarget( $(RTS_LC) $($RTS_LHC) $(CLIB_LC) )