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 io -- support for libPOSIX
10 main -- "main", associated startup stuff, & MISC things
11 prims -- code for primitives that must be written in C
12 profiling -- cost-centre profiling
13 storage -- the storage manager(s)
15 We create two libraries. One, libHSrts<tag>.a, is built separately
16 for each "build". The other, libHSclib.a is built once: it is just
17 .lc files that end up the same no matter what, i.e. completely
20 Other sorta independent, compile-once subdirs are:
22 gmp -- GNU multi-precision library (for Integer)
23 regex -- GNU regexp package
30 /****************************************************************
32 * Jmakefile preamble-y things *
34 ****************************************************************/
36 GhcDriverNeededHere(depend all) /* we use its C-compiling know-how */
39 /****************************************************************
41 * options used for compiling/etc. things *
43 ****************************************************************/
46 If you use EXTRA_HC_OPTS on the command line (which you shouldn't,
47 strictly speaking), it will probably work -- it is pinned onto
48 GHC_OPTS, just for fun.
52 # define __plat_specific -mtoggle-sp-mangling
54 # define __plat_specific /*none*/
57 GHC_OPTS = -O2-for-C -optc-DFORCE_GC \
58 __plat_specific $(EXTRA_HC_OPTS)
60 /* per-build options: shared with libraries */
61 #define rts_or_lib(r,l) r
62 #include "../mkworld/GHC_OPTS"
65 -I$(TOP_PWD)/$(CURRENT_DIR)/$(GHC_INCLUDES)
67 /****************************************************************
69 * what it is we are compiling; *
70 * these are long and tedious lists, but c'est la guerre *
72 ****************************************************************/
75 storage/SMmarkDefs.lh \
76 storage/SMcopying.lh \
77 storage/SMcompacting.lh \
82 c-as-asm/CallWrap_C.lc \
83 c-as-asm/FreeMallocPtr.lc \
84 c-as-asm/HpOverflow.lc \
85 c-as-asm/StablePtr.lc \
86 c-as-asm/StablePtrOps.lc \
87 c-as-asm/StgDebug.lc \
88 c-as-asm/StgMiniInt.lc \
104 main/StgOverflow.lc \
110 profiling/CostCentre.lc \
111 profiling/Hashing.lc \
112 profiling/HeapProfile.lc \
113 profiling/Indexing.lc \
114 profiling/LifeProfile.lc \
116 storage/Force_GC.lc \
121 storage/SMcompacting.lc \
122 storage/SMcopying.lc \
126 storage/SMinit.lc /*could clib except for GCdu option! */ \
127 storage/SMmarking.lc \
130 storage/SMstacks.lc \
131 storage/SMstatic.lc \
132 storage/SMstats.lc /*could clib except GCap affects printing*/ \
135 /*LATER?: storage/SMgen.lc */
138 main/StgStartup.lhc \
140 main/StgThreads.lhc \
141 c-as-asm/PerformIO.lhc \
145 #if GhcWithReadline == YES
146 # define __readline_cfile io/ghcReadline.lc
148 # define __readline_cfile /*none*/
156 hooks/PatErrorHdr.lc \
157 hooks/TraceHooks.lc \
159 io/createDirectory.lc \
165 io/fileLookAhead.lc \
170 io/getBufferMode.lc \
173 io/getCurrentDirectory.lc \
174 io/getDirectoryContents.lc \
179 io/removeDirectory.lc \
181 io/renameDirectory.lc \
185 io/setCurrentDirectory.lc \
193 storage/SMalloc.lc __readline_cfile
195 H_FILES = $(RTS_LH:.lh=.h)
196 C_FILES = $(RTS_LC:.lc=.c) $(RTS_LHC:.lhc=.hc) $(CLIB_LC:.lc=.c)
200 all depend :: $(H_FILES)
202 ExtraStuffToClean ( $(C_FILES) )
204 /* Literate-pgmming suffix rules used herein */
205 LitSuffixRule(.lhc,.hc)
206 LitSuffixRule(.lc,.c)
207 LitSuffixRule(.lh,.h)
209 /****************************************************************
211 * interesting collections of .o files *
213 ****************************************************************/
215 RTS_OBJS_norm = $(RTS_LC:.lc=.o) $(RTS_LHC:.lhc=.o)
216 RTS_OBJS_p = $(RTS_LC:.lc=_p.o) $(RTS_LHC:.lhc=_p.o)
217 RTS_OBJS_t = $(RTS_LC:.lc=_t.o) $(RTS_LHC:.lhc=_t.o)
218 RTS_OBJS_u = $(RTS_LC:.lc=_u.o) $(RTS_LHC:.lhc=_u.o)
219 RTS_OBJS_mc = $(RTS_LC:.lc=_mc.o) $(RTS_LHC:.lhc=_mc.o)
220 RTS_OBJS_mr = $(R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S_LHC:.lhc=_m.o)
240 RTS_OBJS_n = $(RTS_LC:.lc=_n.o) $(RTS_LHC:.lhc=_n.o)
241 RTS_OBJS_o = $(RTS_LC:.lc=_o.o) $(RTS_LHC:.lhc=_o.o)
243 CLIB_OBJS = $(CLIB_LC:.lc=.o)
245 /****************************************************************
247 * knock the "clib" (completely ordinary C, compiled once) *
248 * stuff over the head first... *
250 ****************************************************************/
252 #define CompileClibishly(file,flags) @@\
253 CAT2(file,.o) : CAT2(file,.c) @@\
255 $(GHC) -c -o CAT2(file,.o) $(GHCFLAGS) flags CAT2(file,.c)
257 NormalLibraryTarget(HSclib,$(CLIB_OBJS))
258 ExtraStuffToClean($(CLIB_OBJS))
259 #if DoInstallGHCSystem == YES
260 InstallLibraryTarget(HSclib,$(INSTLIBDIR_GHC))
263 /* all .lc files, so far */
264 CompileClibishly(hooks/ErrorHdr,)
265 CompileClibishly(hooks/OutOfHeap,)
266 CompileClibishly(hooks/OutOfStk,)
267 CompileClibishly(hooks/OutOfVM,)
268 CompileClibishly(hooks/PatErrorHdr,)
269 CompileClibishly(hooks/TraceHooks,)
270 CompileClibishly(io/closeFile,)
271 CompileClibishly(io/createDirectory,)
272 CompileClibishly(io/env,)
273 CompileClibishly(io/errno,)
274 CompileClibishly(io/execvpe,)
275 CompileClibishly(io/fileEOF,)
276 CompileClibishly(io/fileGetc,)
277 CompileClibishly(io/fileLookAhead,)
278 CompileClibishly(io/filePosn,)
279 CompileClibishly(io/filePutc,)
280 CompileClibishly(io/fileSize,)
281 CompileClibishly(io/flushFile,)
282 CompileClibishly(io/getBufferMode,)
283 CompileClibishly(io/getCPUTime,)
284 CompileClibishly(io/getClockTime,)
285 CompileClibishly(io/getCurrentDirectory,)
286 CompileClibishly(io/getDirectoryContents,)
287 CompileClibishly(io/getLock,)
288 CompileClibishly(io/inputReady,)
289 CompileClibishly(io/openFile,)
290 CompileClibishly(io/readFile,)
291 CompileClibishly(io/removeDirectory,)
292 CompileClibishly(io/removeFile,)
293 CompileClibishly(io/renameDirectory,)
294 CompileClibishly(io/renameFile,)
295 CompileClibishly(io/seekFile,)
296 CompileClibishly(io/setBuffering,)
297 CompileClibishly(io/setCurrentDirectory,)
298 CompileClibishly(io/showTime,)
299 CompileClibishly(io/system,)
300 CompileClibishly(io/toClockSec,)
301 CompileClibishly(io/toLocalTime,)
302 CompileClibishly(io/toUTCTime,)
303 CompileClibishly(io/writeFile,)
304 CompileClibishly(main/TopClosure,) /* NB */
305 CompileClibishly(main/TopClosure13,) /* ditto */
306 CompileClibishly(prims/ByteOps,)
307 CompileClibishly(storage/SMalloc,)
308 #if GhcWithReadline == YES
309 CompileClibishly(io/ghcReadline,)
312 ExtraStuffToClean(main/TopClosure.o main/TopClosure13.o)
314 all :: main/TopClosure.o main/TopClosure13.o
316 install :: main/TopClosure.o main/TopClosure13.o
317 $(INSTALL) -c $(INSTLIBFLAGS) main/TopClosure.o $(INSTLIBDIR_GHC)/TopClosure.o
318 $(INSTALL) -c $(INSTLIBFLAGS) main/TopClosure13.o $(INSTLIBDIR_GHC)/TopClosure13.o
320 #if GhcBuild_mp == YES
321 # if solaris2_TARGET_OS
322 # define __socket_libs -lsocket -lnsl
324 # define __socket_libs /*none*/
327 AllTarget(gum/SysMan)
328 gum/SysMan : gum/SysMan_mp.o gum/LLComms_mp.o
330 $(CC) gum/SysMan_mp.o gum/LLComms_mp.o -o $@ -L$$PVM_ROOT/lib/$$PVM_ARCH -lpvm3 -lgpvm3 __socket_libs
331 ExtraStuffToClean(gum/SysMan_mp.o gum/SysMan)
332 # if DoInstallGHCSystem == YES
333 install :: gum/SysMan
334 $(INSTALL) -c $(INSTBINFLAGS) gum/SysMan $(INSTLIBDIR_GHC)/SysMan
338 /****************************************************************
340 * special local make-world macros *
342 ****************************************************************/
344 /* to build and install the per-build rts stuff */
346 #ifndef SpecialGhcRtsLibTarget
347 #define SpecialGhcRtsLibTarget(tag,objs) @@\
348 AllTarget(CAT3(libHSrts,tag,.a)) @@\
349 ExtraStuffToClean(objs CAT3(libHSrts,tag,.a)) @@\
350 CAT3(libHSrts,tag,.a):: $(H_FILES) objs @@\
354 #endif /* SpecialGhcRtsLibTarget */
356 #ifndef SpecialGhcRtsLibInstallTarget
357 #if DoInstallGHCSystem == YES
358 #define SpecialGhcRtsLibInstallTarget(tag) @@\
359 install :: CAT3(libHSrts,tag,.a) @@\
360 $(INSTALL) $(INSTLIBFLAGS) \ @@\
361 CAT3(libHSrts,tag,.a) \ @@\
362 $(INSTLIBDIR_GHC)/CAT3(libHSrts,tag,.a) @@\
363 $(RANLIB) $(INSTLIBDIR_GHC)/CAT3(libHSrts,tag,.a)
364 #else /* ! DoInstallGHC... */
365 #define SpecialGhcRtsLibInstallTarget(tag) /*nothing*/
366 #endif /* ! DoInstallGHC... */
367 #endif /* SpecialGhcRtsLibInstallTarget */
369 #define BigBuildTarget(tag,objs) \
370 SpecialGhcRtsLibTarget(tag,objs) @@\
371 SpecialGhcRtsLibInstallTarget(tag)
373 /****************************************************************
375 * creating and installing libHSrts.a (in its many flavors) *
377 ****************************************************************/
379 #if DoInstallGHCSystem == YES
380 MakeDirectories(install, $(INSTLIBDIR_GHC))
381 #endif /* DoInstallGHCSystem */
383 IfGhcBuild_normal(BigBuildTarget(,$(RTS_OBJS_norm)))
384 IfGhcBuild_p(BigBuildTarget(_p, $(RTS_OBJS_p)))
385 IfGhcBuild_t(BigBuildTarget(_t, $(RTS_OBJS_t)))
386 IfGhcBuild_u(BigBuildTarget(_u, $(RTS_OBJS_u)))
387 IfGhcBuild_mc(BigBuildTarget(_mc, $(RTS_OBJS_mc)))
388 IfGhcBuild_mr(BigBuildTarget(_mr, $(RTS_OBJS_mr)))
389 IfGhcBuild_mt(BigBuildTarget(_mt, $(RTS_OBJS_mt)))
390 IfGhcBuild_mp(BigBuildTarget(_mp, $(RTS_OBJS_mp)))
391 IfGhcBuild_mg(BigBuildTarget(_mg, $(RTS_OBJS_mg)))
392 IfGhcBuild_2s(BigBuildTarget(_2s, $(RTS_OBJS_2s)))
393 IfGhcBuild_1s(BigBuildTarget(_1s, $(RTS_OBJS_1s)))
394 IfGhcBuild_du(BigBuildTarget(_du, $(RTS_OBJS_du)))
395 IfGhcBuild_a(BigBuildTarget(_a, $(RTS_OBJS_a)))
396 IfGhcBuild_b(BigBuildTarget(_b, $(RTS_OBJS_b)))
397 IfGhcBuild_c(BigBuildTarget(_c, $(RTS_OBJS_c)))
398 IfGhcBuild_d(BigBuildTarget(_d, $(RTS_OBJS_d)))
399 IfGhcBuild_e(BigBuildTarget(_e, $(RTS_OBJS_e)))
400 IfGhcBuild_f(BigBuildTarget(_f, $(RTS_OBJS_f)))
401 IfGhcBuild_g(BigBuildTarget(_g, $(RTS_OBJS_g)))
402 IfGhcBuild_h(BigBuildTarget(_h, $(RTS_OBJS_h)))
403 IfGhcBuild_i(BigBuildTarget(_i, $(RTS_OBJS_i)))
404 IfGhcBuild_j(BigBuildTarget(_j, $(RTS_OBJS_j)))
405 IfGhcBuild_k(BigBuildTarget(_k, $(RTS_OBJS_k)))
406 IfGhcBuild_l(BigBuildTarget(_l, $(RTS_OBJS_l)))
407 IfGhcBuild_m(BigBuildTarget(_m, $(RTS_OBJS_m)))
408 IfGhcBuild_n(BigBuildTarget(_n, $(RTS_OBJS_n)))
409 IfGhcBuild_o(BigBuildTarget(_o, $(RTS_OBJS_o)))
412 /****************************************************************
414 * compile the individual RTS files *
416 ****************************************************************/
418 #define DoRtsFile(file,isuf,way,flags) @@\
419 CAT3(file,way,.o) : CAT2(file,isuf) @@\
421 $(GHC) -c -o CAT3(file,way,.o) $(GHCFLAGS) flags CAT2(file,isuf)
423 #define CompileRTSishly(file,isuf,flags) @@\
424 IfGhcBuild_normal(DoRtsFile(file,isuf,,flags $(GHC_OPTS_norm))) \
425 IfGhcBuild_p(DoRtsFile(file,isuf,_p, flags $(GHC_OPTS_p))) \
426 IfGhcBuild_t(DoRtsFile(file,isuf,_t, flags $(GHC_OPTS_t))) \
427 IfGhcBuild_u(DoRtsFile(file,isuf,_u, flags $(GHC_OPTS_u))) \
428 IfGhcBuild_mc(DoRtsFile(file,isuf,_mc, flags $(GHC_OPTS_mc))) \
429 IfGhcBuild_mr(DoRtsFile(file,isuf,_mr, flags $(GHC_OPTS_mr))) \
430 IfGhcBuild_mt(DoRtsFile(file,isuf,_mt, flags $(GHC_OPTS_mt))) \
431 IfGhcBuild_mp(DoRtsFile(file,isuf,_mp, flags $(GHC_OPTS_mp))) \
432 IfGhcBuild_mg(DoRtsFile(file,isuf,_mg, flags $(GHC_OPTS_mg))) \
433 IfGhcBuild_2s(DoRtsFile(file,isuf,_2s, flags $(GHC_OPTS_2s))) \
434 IfGhcBuild_1s(DoRtsFile(file,isuf,_1s, flags $(GHC_OPTS_1s))) \
435 IfGhcBuild_du(DoRtsFile(file,isuf,_du, flags $(GHC_OPTS_du))) \
436 IfGhcBuild_a(DoRtsFile(file,isuf,_a, flags $(GHC_OPTS_a))) \
437 IfGhcBuild_b(DoRtsFile(file,isuf,_b, flags $(GHC_OPTS_b))) \
438 IfGhcBuild_c(DoRtsFile(file,isuf,_c, flags $(GHC_OPTS_c))) \
439 IfGhcBuild_d(DoRtsFile(file,isuf,_d, flags $(GHC_OPTS_d))) \
440 IfGhcBuild_e(DoRtsFile(file,isuf,_e, flags $(GHC_OPTS_e))) \
441 IfGhcBuild_f(DoRtsFile(file,isuf,_f, flags $(GHC_OPTS_f))) \
442 IfGhcBuild_g(DoRtsFile(file,isuf,_g, flags $(GHC_OPTS_g))) \
443 IfGhcBuild_h(DoRtsFile(file,isuf,_h, flags $(GHC_OPTS_h))) \
444 IfGhcBuild_i(DoRtsFile(file,isuf,_i, flags $(GHC_OPTS_i))) \
445 IfGhcBuild_j(DoRtsFile(file,isuf,_j, flags $(GHC_OPTS_j))) \
446 IfGhcBuild_k(DoRtsFile(file,isuf,_k, flags $(GHC_OPTS_k))) \
447 IfGhcBuild_l(DoRtsFile(file,isuf,_l, flags $(GHC_OPTS_l))) \
448 IfGhcBuild_m(DoRtsFile(file,isuf,_m, flags $(GHC_OPTS_m))) \
449 IfGhcBuild_n(DoRtsFile(file,isuf,_n, flags $(GHC_OPTS_n))) \
450 IfGhcBuild_o(DoRtsFile(file,isuf,_o, flags $(GHC_OPTS_o)))
454 CompileRTSishly(c-as-asm/CallWrap_C,.c,)
455 CompileRTSishly(c-as-asm/FreeMallocPtr,.c,)
456 CompileRTSishly(c-as-asm/HpOverflow,.c,)
457 CompileRTSishly(c-as-asm/PerformIO,.hc,-mtoggle-sp-mangling/*toggle it back*/)
458 CompileRTSishly(c-as-asm/StablePtr,.c,)
459 CompileRTSishly(c-as-asm/StablePtrOps,.c,)
460 CompileRTSishly(c-as-asm/StgDebug,.c,)
461 CompileRTSishly(c-as-asm/StgMiniInt,.c,)
462 CompileRTSishly(gum/FetchMe,.hc,-mtoggle-sp-mangling/*toggle it back*/)
463 CompileRTSishly(gum/GlobAddr,.c,)
464 CompileRTSishly(gum/HLComms,.c,)
465 CompileRTSishly(gum/Hash,.c,)
466 CompileRTSishly(gum/LLComms,.c,)
467 CompileRTSishly(gum/Pack,.c,)
468 CompileRTSishly(gum/ParInit,.c,)
469 CompileRTSishly(gum/RBH,.c,)
470 CompileRTSishly(gum/Sparks,.c,)
471 CompileRTSishly(gum/SysMan,.c,) /* NB: not in library */
472 CompileRTSishly(gum/Unpack,.c,)
473 CompileRTSishly(main/GranSim,.c,)
474 CompileRTSishly(main/Itimer,.c,)
475 CompileRTSishly(main/RednCounts,.c,)
476 CompileRTSishly(main/SMRep,.c,)
477 CompileRTSishly(main/Select,.c,)
478 CompileRTSishly(main/Signals,.c,)
479 CompileRTSishly(main/StgOverflow,.c,)
480 CompileRTSishly(main/StgStartup,.hc,-mtoggle-sp-mangling/*toggle it back*/)
481 CompileRTSishly(main/StgThreads,.hc,-mtoggle-sp-mangling/*toggle it back*/)
482 CompileRTSishly(main/StgTrace,.c,)
483 CompileRTSishly(main/StgUpdate,.hc,-mtoggle-sp-mangling/*toggle it back*/)
484 CompileRTSishly(main/Threads,.c,)
485 CompileRTSishly(main/main,.c,)
486 CompileRTSishly(profiling/CostCentre,.c,)
487 CompileRTSishly(profiling/Hashing,.c,)
488 CompileRTSishly(profiling/HeapProfile,.c,)
489 CompileRTSishly(profiling/Indexing,.c,)
490 CompileRTSishly(profiling/LifeProfile,.c,)
491 CompileRTSishly(profiling/Timer,.c,)
492 CompileRTSishly(prims/PrimArith,.c,)
493 CompileRTSishly(prims/PrimMisc,.c,)
494 CompileRTSishly(storage/Force_GC,.c,)
495 CompileRTSishly(storage/SM1s,.c,)
496 CompileRTSishly(storage/SM2s,.c,)
497 CompileRTSishly(storage/SMap,.c,)
498 CompileRTSishly(storage/SMcheck,.c,)
499 CompileRTSishly(storage/SMcompacting,.c,)
500 CompileRTSishly(storage/SMcopying,.c,)
501 CompileRTSishly(storage/SMdu,.c,)
502 CompileRTSishly(storage/SMevac,.c,)
503 CompileRTSishly(storage/SMextn,.c,)
504 CompileRTSishly(storage/SMgen,.c,)
505 CompileRTSishly(storage/SMinit,.c,)
506 CompileRTSishly(storage/SMmark,.hc,-optc-DMARK_REG_MAP)
507 CompileRTSishly(storage/SMmarking,.c,)
508 CompileRTSishly(storage/SMscan,.c,)
509 CompileRTSishly(storage/SMscav,.c,)
510 CompileRTSishly(storage/SMstacks,.c,)
511 CompileRTSishly(storage/SMstatic,.c,)
512 CompileRTSishly(storage/SMstats,.c,)
513 CompileRTSishly(storage/mprotect,.c,)
515 /****************************************************************
517 * misc "make" targets -- depend, clean, tags *
519 ****************************************************************/
522 /* this is not the way we should do this [WDP [lazy] 94/09] */
523 CTagsTarget( $(RTS_LC) $($RTS_LHC) $(CLIB_LC) )
524 CTagsTarget( gmp/[a-z]*.c )
525 CTagsTarget( regex/[a-z]*.c )
527 CDependTarget( $(RTS_LC) $($RTS_LHC) $(CLIB_LC) )
529 LitStuffNeededHere(docs depend)
530 InfoStuffNeededHere(docs)
532 /*LitDocRootTargetWithNamedOutput(threadroot,lit,threadroot-standalone)*/