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