summaryrefslogtreecommitdiff
path: root/ghc/lib/Jmakefile
blob: c25b3b4d573151f2af72c6809493e0f763f8aab2 (plain)
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
/* This is the Jmakefile for the library stuff.
   This stuff is all written in (Glasgow-extended) Haskell.

Everything here *must* be compiled w/ the Glasgow Haskell compiler.
(Hence the use of $(GHC), rather than $(HC) [the latter is your "standard"
Haskell compiler -- whatever you've configured]).

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.
*/

/****************************************************************
*								*
* Jmakefile preamble-y things					*
*								*
****************************************************************/

#define IHaveSubdirs

#if IncludeTestDirsInBuild == YES
#define __ghc_lib_tests_dir tests
#else
#define __ghc_lib_tests_dir /* nothing */
#endif

SUBDIRS = cbits __ghc_lib_tests_dir

#define NoDocsTargetForSubdirs
#define NoInstallDocsTargetForSubdirs
#define NoDependTargetForSubdirs

GhcDriverNeededHere(depend all)
EtagsNeededHere(tags)

/****************************************************************
*								*
* options used for compiling/etc. things			*
*								*
****************************************************************/

/* The driver will give warnings if -split-objs, but that's cool... */
GHC_OPTS=-short -cpp 		\
	 -dcore-lint 		\
	 -irequired		\
	 -fusing-ghc-internals	\
	 HcMaxHeapFlag $(EXTRA_HC_OPTS)

PREL_OPTS=/*???-fcompiling-ghc-internals -fno-implicit-prelude*/

/* per-build options: shared with RTS */
#define rts_or_lib(r,l) l
#include "../mkworld/GHC_OPTS"

/* this is just friendliness to "hstags" */
HSTAGS_OPTS=-fglasgow-exts

/***************************************************************/

/****************************************************************
*								*
* what it is we are compiling;					*
*   these are long and tedious lists, but c'est la guerre	*
*								*
****************************************************************/

BASIC_HS =			\
prelude/Prelude.hs		\
prelude/GHCbase.hs		\
prelude/GHCps.hs		\
prelude/GHCio.hs		\
prelude/GHCmain.hs		\
prelude/PreludeGlaST.hs		\
				\
required/Array.hs		\
required/Char.hs		\
required/Complex.hs		\
required/Directory.hs		\
required/IO.hs			\
required/Ix.hs			\
required/List.hs		\
required/Maybe.hs		\
required/Monad.hs		\
required/Ratio.hs		\
required/System.hs		\
\
concurrent/Channel.hs		\
concurrent/ChannelVar.hs	\
concurrent/Merge.hs		\
concurrent/Parallel.hs		\
concurrent/SampleVar.hs		\
concurrent/Semaphore.hs		\
concurrent/Concurrent.hs

BASIC_OBJS_DIRS	= $(BASIC_HS:.hs=)

/* easy way to make many many Make variables: */
WayThingVars(BASIC)

/************************************************************************
*									*
* Macros for creating and installing libHS<x>.a (in its many flavors).	*
*									*
*************************************************************************/

#ifndef SpecialGhcLibraryTarget
#define SpecialGhcLibraryTarget(lib,tag,objs_DEP,objs_DIR,find_pat) @@\
AllTarget(CAT3(lib,tag,.a))					@@\
CAT3(lib,tag,.a):: objs_DEP					@@\
	$(RM) $@						@@\
	TMPDIR=$(TMPDIR); export TMPDIR;			\
	find objs_DIR -name find_pat -print | xargs ar q $@	@@\
	$(RANLIB) CAT3(lib,tag,.a)				@@\
clean  ::							@@\
	$(RM) CAT3(lib,tag,.a)
#endif /* SpecialGhcLibraryTarget */

#ifndef SpecialGhcLibInstallTarget
#if DoInstallGHCSystem == YES
#define SpecialGhcLibInstallTarget(lib,tag)			@@\
install :: CAT3(lib,tag,.a)					@@\
	$(INSTALL) $(INSTLIBFLAGS) CAT3(lib,tag,.a)		\
		$(INSTLIBDIR_GHC)/CAT3(lib,tag,.a)		@@\
	$(RANLIB) $(INSTLIBDIR_GHC)/CAT3(lib,tag,.a)
#else  /* ! DoInstallGhc... */
#define SpecialGhcLibInstallTarget(lib,tag) /*nothing*/
#endif /* ! DoInstallGhc... */
#endif /* SpecialGhcLibInstallTarget */

/* build/install all the diff libs for a particular build */

#define BigHisTarget(targeti,basei)				@@\
targeti ::							@@\
InstallTarget(targeti)						@@\
InstallMultNonExecTargets(targeti,basei,$(INSTDATADIR_GHC)/imports)

#define BigLibsTarget(tag,glob,base)				@@\
SpecialGhcLibraryTarget(libHS,tag,base,$(BASIC_OBJS_DIRS),glob)	@@\
SpecialGhcLibInstallTarget(libHS,tag)

/* build *everything* -- monster macro from hell */
#define BigBuildTarget(tag,glob,targeti,base,basei)		\
BigLibsTarget(tag,glob,base)					@@\
BigHisTarget(targeti,basei)

/****************************************************************
*								*
* Creating and installing...					*
*	libHS_<tag>.a		standard Prelude library	*
*								*
****************************************************************/

/* make sure install's target dir is there */
#if DoInstallGHCSystem == YES
MakeDirectories(install, $(INSTLIBDIR_GHC) 		\
			 $(INSTDATADIR_GHC)/imports)

basic_his :: /* nothing */
InstallTarget(basic_his)
InstallMultNonExecTargets(basic_his, $(BASIC_HIs),  $(INSTDATADIR_GHC)/imports)
#endif /* installing */

IfBuild_normal(BigBuildTarget(,'*.o',basic_his, $(BASIC_DEP_norm),  $(BASIC_HIs)))
IfBuild_p(BigBuildTarget(_p,'*.p_o',his_p, $(BASIC_DEP_p),  $(BASIC_HIs_p)))
IfBuild_t(BigBuildTarget(_t,'*.t_o',his_t, $(BASIC_DEP_t),  $(BASIC_HIs_t)))
IfBuild_u(BigBuildTarget(,'*.u_o',his_u, $(BASIC_DEP_u),  $(BASIC_HIs_u)))
IfBuild_mc(BigBuildTarget(_mc,'*.mc_o',his_mc, $(BASIC_DEP_mc),  $(BASIC_HIs_mc)))
IfBuild_mr(BigBuildTarget(_mr,'*.mr_o',his_mr, $(BASIC_DEP_mr),  $(BASIC_HIs_mr)))
IfBuild_mt(BigBuildTarget(_mr,'*.mt_o',his_mt, $(BASIC_DEP_mt),  $(BASIC_HIs_mt)))
IfBuild_mp(BigBuildTarget(_mp,'*.mp_o',his_mp, $(BASIC_DEP_mp),  $(BASIC_HIs_mp)))
IfBuild_mg(BigBuildTarget(_mg,'*.mg_o',his_mg, $(BASIC_DEP_mg),  $(BASIC_HIs_mg)))

/* these GC ones do not *really* need separate .hi files,
   but it really makes life easier to do it this way
*/
IfBuild_2s(BigBuildTarget(_2s,'*.2s_o',his_2s, $(BASIC_DEP_2s),  $(BASIC_HIs_2s)))
IfBuild_1s(BigBuildTarget(_1s,'*.1s_o',his_1s, $(BASIC_DEP_1s),  $(BASIC_HIs_1s)))
IfBuild_du(BigBuildTarget(_du,'*.du_o',his_du, $(BASIC_DEP_du),  $(BASIC_HIs_du)))

/* user ways -- yeeps! */

IfBuild_a(BigBuildTarget(_a,'*.a_o',his_a, $(BASIC_DEP_a),  $(BASIC_HIs_a)))
IfBuild_b(BigBuildTarget(_b,'*.b_o',his_b, $(BASIC_DEP_b),  $(BASIC_HIs_b)))
IfBuild_c(BigBuildTarget(_c,'*.c_o',his_c, $(BASIC_DEP_c),  $(BASIC_HIs_c)))
IfBuild_d(BigBuildTarget(_d,'*.d_o',his_d, $(BASIC_DEP_d),  $(BASIC_HIs_d)))
IfBuild_e(BigBuildTarget(_e,'*.e_o',his_e, $(BASIC_DEP_e),  $(BASIC_HIs_e)))
IfBuild_f(BigBuildTarget(_f,'*.f_o',his_f, $(BASIC_DEP_f),  $(BASIC_HIs_f)))
IfBuild_g(BigBuildTarget(_g,'*.g_o',his_g, $(BASIC_DEP_g),  $(BASIC_HIs_g)))
IfBuild_h(BigBuildTarget(_h,'*.h_o',his_h, $(BASIC_DEP_h),  $(BASIC_HIs_h)))
IfBuild_i(BigBuildTarget(_i,'*.i_o',his_i, $(BASIC_DEP_i),  $(BASIC_HIs_i)))
IfBuild_j(BigBuildTarget(_j,'*.j_o',his_j, $(BASIC_DEP_j),  $(BASIC_HIs_j)))
IfBuild_k(BigBuildTarget(_k,'*.k_o',his_k, $(BASIC_DEP_k),  $(BASIC_HIs_k)))
IfBuild_l(BigBuildTarget(_l,'*.l_o',his_l, $(BASIC_DEP_l),  $(BASIC_HIs_l)))
IfBuild_m(BigBuildTarget(_m,'*.m_o',his_m, $(BASIC_DEP_m),  $(BASIC_HIs_m)))
IfBuild_n(BigBuildTarget(_n,'*.n_o',his_n, $(BASIC_DEP_n),  $(BASIC_HIs_n)))
IfBuild_o(BigBuildTarget(_o,'*.o_o',his_o, $(BASIC_DEP_o),  $(BASIC_HIs_o)))
IfBuild_A(BigBuildTarget(_A,'*.A_o',his_A, $(BASIC_DEP_A),  $(BASIC_HIs_A)))
IfBuild_B(BigBuildTarget(_B,'*.B_o',his_B, $(BASIC_DEP_B),  $(BASIC_HIs_B)))

/****************************************************************
*								*
* Creating the individual .hc files: 				*
*								*
*   For the just-vary-the-GC-thanks flavors, we only need to	*
*   compile .hs->.hc once; then re-use the .hc file each time.	*
*								*
*   For the profiling one (_p) and all the user-specified	*
*   ones, we recompile the Haskell each time.			*
*								*
*  NB: old (WDP 95/06)						*
****************************************************************/

/* some "helpful" internal macros first... */

#if GhcWithHscBuiltViaC == YES && HaskellCompilerType == HC_USE_HC_FILES
#define CompileWayishly__(hc,file,isuf,way,flags)	@@\
clean  ::						@@\
	$(RM) CAT3(file,way,.hc)
#endif

/* now use the macro: */

CompileWayishly(GHC,prelude/Prelude,hs,-iprelude -fglasgow-exts -fcompiling-ghc-internals Prelude -fno-implicit-prelude)
CompileWayishly(GHC,prelude/GHCbase,hs,-iprelude -fglasgow-exts -fcompiling-ghc-internals GHCbase)
CompileWayishly(GHC,prelude/GHCps,hs,  -iprelude -fglasgow-exts)
CompileWayishly(GHC,prelude/GHCio,hs,  -iprelude -fglasgow-exts)
CompileWayishly(GHC,prelude/GHCmain,hs,-iprelude -fglasgow-exts)
CompileWayishly(GHC,prelude/PreludeGlaST,hs,-iprelude -fglasgow-exts)

CompileWayishly(GHC,required/Array,hs,-fglasgow-exts -iprelude)
CompileWayishly(GHC,required/Char,hs,)
CompileWayishly(GHC,required/Complex,hs,)
CompileWayishly(GHC,required/Directory,hs,-fglasgow-exts)
CompileWayishly(GHC,required/IO,hs,-fglasgow-exts)
CompileWayishly(GHC,required/Ix,hs,-fglasgow-exts)
CompileWayishly(GHC,required/List,hs,)
CompileWayishly(GHC,required/Maybe,hs,)
CompileWayishly(GHC,required/Monad,hs,)
CompileWayishly(GHC,required/Ratio,hs,)
CompileWayishly(GHC,required/System,hs,-fglasgow-exts)

CompileWayishly(GHC,concurrent/Channel,hs,)
CompileWayishly(GHC,concurrent/ChannelVar,hs,)
CompileWayishly(GHC,concurrent/Merge,hs,-iconcurrent)
CompileWayishly(GHC,concurrent/Parallel,hs,)
CompileWayishly(GHC,concurrent/SampleVar,hs,)
CompileWayishly(GHC,concurrent/Semaphore,hs,)
CompileWayishly(GHC,concurrent/Concurrent,hs,-iconcurrent)

/****************************************************************
*								*
* misc "make" targets -- depend, clean, tags			*
*								*
****************************************************************/

/* this is a BAD idea!
ExtraStuffToClean( $(SRCS_C) )
   without the .hc files, the distrib cannot boot itself
*/
ExtraStuffToBeVeryClean( $(SRCS_C) )
ExtraStuffToBeVeryClean( $(STD_VERY_CLEAN) )

ClearTagsFile()
/* Ugly but OK? [WDP 94/09] */
HsTagsTarget( */[A-Z]*.*hs )
HSTAGS_OPTS=-cpp -fglasgow-exts

/* should be *LAST* */
#if HaskellCompilerType != HC_USE_HC_FILES
    /* otherwise, the dependencies jeopardize our .hc files --
	which are all we have! */
MAIN_INCLUDE_DIR = $(TOP_PWD)/$(CURRENT_DIR)/$(GHC_INCLUDES)
MKDEPENDHS_OPTS= -o .hc -I$(MAIN_INCLUDE_DIR) 

HaskellDependTarget( $(BASIC_HS_PREL) )
#endif