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/FreeMallocPtr.lc \
76 c-as-asm/HpOverflow.lc \
77 c-as-asm/StablePtr.lc \
78 c-as-asm/StablePtrOps.lc \
79 c-as-asm/StgDebug.lc \
80 c-as-asm/StgMiniInt.lc \
102 profiling/CostCentre.lc \
103 profiling/Hashing.lc \
104 profiling/HeapProfile.lc \
105 profiling/Indexing.lc \
111 storage/SMcompacting.lc \
112 storage/SMcopying.lc \
116 storage/SMinit.lc /*could clib except for GCdu option! */ \
117 storage/SMmarking.lc \
120 storage/SMstacks.lc \
121 storage/SMstatic.lc \
122 storage/SMstats.lc /*could clib except GCap affects printing*/ \
125 /*LATER?: storage/SMgen.lc */
128 main/StgStartup.lhc \
130 main/StgThreads.lhc \
131 c-as-asm/PerformIO.lhc \
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 #define CompileClibishly(file,flags) @@\
207 CAT2(file,.o) : CAT2(file,.c) @@\
209 $(GHC) -c -o CAT2(file,.o) $(GHCFLAGS) flags CAT2(file,.c)
211 NormalLibraryTarget(HSclib,$(CLIB_OBJS))
212 ExtraStuffToClean($(CLIB_OBJS))
213 #if DoInstallGHCSystem == YES
214 InstallLibraryTarget(HSclib,$(INSTLIBDIR_GHC))
217 /* all .lc files, so far */
218 CompileClibishly(hooks/ErrorHdr,)
219 CompileClibishly(hooks/OutOfHeap,)
220 CompileClibishly(hooks/OutOfStk,)
221 CompileClibishly(hooks/OutOfVM,)
222 CompileClibishly(hooks/NoRunnableThrds,)
223 CompileClibishly(hooks/PatErrorHdr,)
224 CompileClibishly(hooks/TraceHooks,)
225 CompileClibishly(hooks/SizeHooks,)
226 CompileClibishly(hooks/InitEachPE,)
227 CompileClibishly(main/Mallocs,)
228 CompileClibishly(main/TopClosure,)
230 ExtraStuffToClean(main/TopClosure.o)
232 all :: main/TopClosure.o
234 install :: main/TopClosure.o
235 $(INSTALL) -c $(INSTLIBFLAGS) main/TopClosure.o $(INSTLIBDIR_GHC)/TopClosure.o
238 # if solaris2_TARGET_OS
239 # define __socket_libs -lsocket -lnsl
241 # define __socket_libs /*none*/
244 AllTarget(gum/SysMan)
245 gum/SysMan : gum/SysMan_mp.o gum/LLComms_mp.o main/Mallocs.o hooks/OutOfVM.o
247 $(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
248 ExtraStuffToClean(gum/SysMan_mp.o gum/SysMan)
249 # if DoInstallGHCSystem == YES
250 install :: gum/SysMan
251 $(INSTALL) -c $(INSTBINFLAGS) gum/SysMan $(INSTLIBDIR_GHC)/SysMan
255 /****************************************************************
257 * special local make-world macros *
259 ****************************************************************/
261 /* to build and install the per-build rts stuff */
263 #ifndef SpecialGhcRtsLibTarget
264 #define SpecialGhcRtsLibTarget(tag,objs) @@\
265 AllTarget(CAT3(libHSrts,tag,.a)) @@\
266 ExtraStuffToClean(objs CAT3(libHSrts,tag,.a)) @@\
267 CAT3(libHSrts,tag,.a):: $(H_FILES) objs @@\
271 #endif /* SpecialGhcRtsLibTarget */
273 #ifndef SpecialGhcRtsLibInstallTarget
274 #if DoInstallGHCSystem == YES
275 #define SpecialGhcRtsLibInstallTarget(tag) @@\
276 install :: CAT3(libHSrts,tag,.a) @@\
277 $(INSTALL) $(INSTLIBFLAGS) \ @@\
278 CAT3(libHSrts,tag,.a) \ @@\
279 $(INSTLIBDIR_GHC)/CAT3(libHSrts,tag,.a) @@\
280 $(RANLIB) $(INSTLIBDIR_GHC)/CAT3(libHSrts,tag,.a)
281 #else /* ! DoInstallGHC... */
282 #define SpecialGhcRtsLibInstallTarget(tag) /*nothing*/
283 #endif /* ! DoInstallGHC... */
284 #endif /* SpecialGhcRtsLibInstallTarget */
286 #define BigBuildTarget(tag,objs) \
287 SpecialGhcRtsLibTarget(tag,objs) @@\
288 SpecialGhcRtsLibInstallTarget(tag)
290 /****************************************************************
292 * creating and installing libHSrts.a (in its many flavors) *
294 ****************************************************************/
296 #if DoInstallGHCSystem == YES
297 MakeDirectories(install, $(INSTLIBDIR_GHC))
298 #endif /* DoInstallGHCSystem */
300 IfBuild_normal(BigBuildTarget(,$(RTS_OBJS_norm)))
301 IfBuild_p(BigBuildTarget(_p, $(RTS_OBJS_p)))
302 IfBuild_t(BigBuildTarget(_t, $(RTS_OBJS_t)))
303 IfBuild_u(BigBuildTarget(_u, $(RTS_OBJS_u)))
304 IfBuild_mc(BigBuildTarget(_mc, $(RTS_OBJS_mc)))
305 IfBuild_mr(BigBuildTarget(_mr, $(RTS_OBJS_mr)))
306 IfBuild_mt(BigBuildTarget(_mt, $(RTS_OBJS_mt)))
307 IfBuild_mp(BigBuildTarget(_mp, $(RTS_OBJS_mp)))
308 IfBuild_mg(BigBuildTarget(_mg, $(RTS_OBJS_mg)))
309 IfBuild_2s(BigBuildTarget(_2s, $(RTS_OBJS_2s)))
310 IfBuild_1s(BigBuildTarget(_1s, $(RTS_OBJS_1s)))
311 IfBuild_du(BigBuildTarget(_du, $(RTS_OBJS_du)))
312 IfBuild_a(BigBuildTarget(_a, $(RTS_OBJS_a)))
313 IfBuild_b(BigBuildTarget(_b, $(RTS_OBJS_b)))
314 IfBuild_c(BigBuildTarget(_c, $(RTS_OBJS_c)))
315 IfBuild_d(BigBuildTarget(_d, $(RTS_OBJS_d)))
316 IfBuild_e(BigBuildTarget(_e, $(RTS_OBJS_e)))
317 IfBuild_f(BigBuildTarget(_f, $(RTS_OBJS_f)))
318 IfBuild_g(BigBuildTarget(_g, $(RTS_OBJS_g)))
319 IfBuild_h(BigBuildTarget(_h, $(RTS_OBJS_h)))
320 IfBuild_i(BigBuildTarget(_i, $(RTS_OBJS_i)))
321 IfBuild_j(BigBuildTarget(_j, $(RTS_OBJS_j)))
322 IfBuild_k(BigBuildTarget(_k, $(RTS_OBJS_k)))
323 IfBuild_l(BigBuildTarget(_l, $(RTS_OBJS_l)))
324 IfBuild_m(BigBuildTarget(_m, $(RTS_OBJS_m)))
325 IfBuild_n(BigBuildTarget(_n, $(RTS_OBJS_n)))
326 IfBuild_o(BigBuildTarget(_o, $(RTS_OBJS_o)))
327 IfBuild_A(BigBuildTarget(_A, $(RTS_OBJS_A)))
328 IfBuild_B(BigBuildTarget(_B, $(RTS_OBJS_B)))
331 /****************************************************************
333 * compile the individual RTS files *
335 ****************************************************************/
337 #define DoRtsFile(file,isuf,way,flags) @@\
338 CAT3(file.,way,o) : CAT2(file,isuf) @@\
340 $(GHC) -c -o CAT3(file.,way,o) $(GHCFLAGS) flags $(CAT4(GHC,_,way,OPTS)) CAT2(file,isuf)
342 #define CompileRTSishly(file,isuf,flags) @@\
343 IfBuild_normal(DoRtsFile(file,isuf,,flags)) \
344 IfBuild_p(DoRtsFile(file,isuf,p_, flags)) \
345 IfBuild_t(DoRtsFile(file,isuf,t_, flags)) \
346 IfBuild_u(DoRtsFile(file,isuf,u_, flags)) \
347 IfBuild_mc(DoRtsFile(file,isuf,mc_, flags)) \
348 IfBuild_mr(DoRtsFile(file,isuf,mr_, flags)) \
349 IfBuild_mt(DoRtsFile(file,isuf,mt_, flags)) \
350 IfBuild_mp(DoRtsFile(file,isuf,mp_, flags)) \
351 IfBuild_mg(DoRtsFile(file,isuf,mg_, flags)) \
352 IfBuild_2s(DoRtsFile(file,isuf,2s_, flags)) \
353 IfBuild_1s(DoRtsFile(file,isuf,1s_, flags)) \
354 IfBuild_du(DoRtsFile(file,isuf,du_, flags)) \
355 IfBuild_a(DoRtsFile(file,isuf,a_, flags)) \
356 IfBuild_b(DoRtsFile(file,isuf,b_, flags)) \
357 IfBuild_c(DoRtsFile(file,isuf,c_, flags)) \
358 IfBuild_d(DoRtsFile(file,isuf,d_, flags)) \
359 IfBuild_e(DoRtsFile(file,isuf,e_, flags)) \
360 IfBuild_f(DoRtsFile(file,isuf,f_, flags)) \
361 IfBuild_g(DoRtsFile(file,isuf,g_, flags)) \
362 IfBuild_h(DoRtsFile(file,isuf,h_, flags)) \
363 IfBuild_i(DoRtsFile(file,isuf,i_, flags)) \
364 IfBuild_j(DoRtsFile(file,isuf,j_, flags)) \
365 IfBuild_k(DoRtsFile(file,isuf,k_, flags)) \
366 IfBuild_l(DoRtsFile(file,isuf,l_, flags)) \
367 IfBuild_m(DoRtsFile(file,isuf,m_, flags)) \
368 IfBuild_n(DoRtsFile(file,isuf,n_, flags)) \
369 IfBuild_o(DoRtsFile(file,isuf,o_, flags)) \
370 IfBuild_A(DoRtsFile(file,isuf,A_, flags)) \
371 IfBuild_B(DoRtsFile(file,isuf,B_, flags))
375 CompileRTSishly(c-as-asm/CallWrap_C,.c,)
376 CompileRTSishly(c-as-asm/FreeMallocPtr,.c,)
377 CompileRTSishly(c-as-asm/HpOverflow,.c,)
378 CompileRTSishly(c-as-asm/PerformIO,.hc,-optc-DIN_GHC_RTS=1)
379 CompileRTSishly(c-as-asm/StablePtr,.c,)
380 CompileRTSishly(c-as-asm/StablePtrOps,.c,)
381 CompileRTSishly(c-as-asm/StgDebug,.c,)
382 CompileRTSishly(c-as-asm/StgMiniInt,.c,)
383 CompileRTSishly(gum/FetchMe,.hc,-optc-DIN_GHC_RTS=1)
384 CompileRTSishly(gum/GlobAddr,.c,)
385 CompileRTSishly(gum/HLComms,.c,)
386 CompileRTSishly(gum/Hash,.c,)
387 CompileRTSishly(gum/LLComms,.c,)
388 CompileRTSishly(gum/Pack,.c,)
389 CompileRTSishly(gum/ParInit,.c,)
390 CompileRTSishly(gum/RBH,.c,)
391 CompileRTSishly(gum/Sparks,.c,)
392 CompileRTSishly(gum/SysMan,.c,) /* NB: not in library */
393 CompileRTSishly(gum/Unpack,.c,)
394 CompileRTSishly(main/GranSim,.c,)
395 CompileRTSishly(main/Itimer,.c,)
396 CompileRTSishly(main/Ticky,.c,)
397 CompileRTSishly(main/SMRep,.c,)
398 CompileRTSishly(main/Select,.c,)
399 CompileRTSishly(main/Signals,.c,)
400 CompileRTSishly(main/StgOverflow,.c,)
401 CompileRTSishly(main/StgStartup,.hc,-optc-DIN_GHC_RTS=1)
402 CompileRTSishly(main/StgThreads,.hc,-optc-DIN_GHC_RTS=1)
403 CompileRTSishly(main/StgUpdate,.hc,-optc-DIN_GHC_RTS=1)
404 CompileRTSishly(main/Threads,.c,)
405 CompileRTSishly(main/RtsFlags,.c,)
406 CompileRTSishly(main/main,.c,)
407 CompileRTSishly(profiling/CostCentre,.c,)
408 CompileRTSishly(profiling/Hashing,.c,)
409 CompileRTSishly(profiling/HeapProfile,.c,)
410 CompileRTSishly(profiling/Indexing,.c,)
411 CompileRTSishly(profiling/Timer,.c,)
412 CompileRTSishly(prims/PrimArith,.c,)
413 CompileRTSishly(prims/PrimMisc,.c,)
414 CompileRTSishly(storage/SM1s,.c,)
415 CompileRTSishly(storage/SM2s,.c,)
416 CompileRTSishly(storage/SMap,.c,)
417 CompileRTSishly(storage/SMcheck,.c,)
418 CompileRTSishly(storage/SMcompacting,.c,)
419 CompileRTSishly(storage/SMcopying,.c,)
420 CompileRTSishly(storage/SMdu,.c,)
421 CompileRTSishly(storage/SMevac,.c,)
422 CompileRTSishly(storage/SMextn,.c,)
423 CompileRTSishly(storage/SMgen,.c,)
424 CompileRTSishly(storage/SMinit,.c,)
425 CompileRTSishly(storage/SMmark,.hc,-optc-DIN_GHC_RTS=1 -optc-DMARK_REG_MAP)
426 CompileRTSishly(storage/SMmarking,.c,)
427 CompileRTSishly(storage/SMscan,.c,)
428 CompileRTSishly(storage/SMscav,.c,)
429 CompileRTSishly(storage/SMstacks,.c,)
430 CompileRTSishly(storage/SMstatic,.c,)
431 CompileRTSishly(storage/SMstats,.c,)
432 CompileRTSishly(storage/mprotect,.c,)
434 /****************************************************************
436 * misc "make" targets -- depend, clean, tags *
438 ****************************************************************/
441 /* this is not the way we should do this [WDP [lazy] 94/09] */
442 CTagsTarget( $(RTS_LC) $($RTS_LHC) $(CLIB_LC) )
443 CTagsTarget( gmp/[a-z]*.c )
445 CDependTarget( $(RTS_LC) $($RTS_LHC) $(CLIB_LC) )