[project @ 1996-07-19 18:36:04 by partain]
[ghc-hetmet.git] / ghc / lib / Jmakefile
1 /* This is the Jmakefile for the library stuff.
2    This stuff is all written in (Glasgow-extended) Haskell.
3
4 Everything here *must* be compiled w/ the Glasgow Haskell compiler.
5 (Hence the use of $(GHC), rather than $(HC) [the latter is your "standard"
6 Haskell compiler -- whatever you've configured]).
7
8 If you use EXTRA_HC_OPTS on the command line (which you shouldn't,
9 strictly speaking), it will probably work -- it is pinned onto
10 GHC_OPTS, just for fun.
11 */
12
13 /****************************************************************
14 *                                                               *
15 * Jmakefile preamble-y things                                   *
16 *                                                               *
17 ****************************************************************/
18
19 #define IHaveSubdirs
20
21 #if IncludeTestDirsInBuild == YES
22 #define __ghc_lib_tests_dir tests
23 #else
24 #define __ghc_lib_tests_dir /* nothing */
25 #endif
26
27 SUBDIRS = cbits __ghc_lib_tests_dir
28
29 #define NoDocsTargetForSubdirs
30 #define NoInstallDocsTargetForSubdirs
31 #define NoDependTargetForSubdirs
32
33 GhcDriverNeededHere(depend all)
34 EtagsNeededHere(tags)
35
36 /****************************************************************
37 *                                                               *
38 * options used for compiling/etc. things                        *
39 *                                                               *
40 ****************************************************************/
41
42 /* The driver will give warnings if -split-objs, but that's cool... */
43 GHC_OPTS=-short -cpp            \
44          -dcore-lint            \
45          -irequired             \
46          -fusing-ghc-internals  \
47          HcMaxHeapFlag $(EXTRA_HC_OPTS)
48
49 PREL_OPTS=/*???-fcompiling-ghc-internals -fno-implicit-prelude*/
50
51 /* per-build options: shared with RTS */
52 #define rts_or_lib(r,l) l
53 #include "../mkworld/GHC_OPTS"
54
55 /* this is just friendliness to "hstags" */
56 HSTAGS_OPTS=-fglasgow-exts
57
58 /***************************************************************/
59
60 /****************************************************************
61 *                                                               *
62 * what it is we are compiling;                                  *
63 *   these are long and tedious lists, but c'est la guerre       *
64 *                                                               *
65 ****************************************************************/
66
67 BASIC_HS =                      \
68 prelude/Prelude.hs              \
69 prelude/GHCbase.hs              \
70 prelude/GHCps.hs                \
71 prelude/GHCio.hs                \
72 prelude/GHCmain.hs              \
73 prelude/PreludeGlaST.hs         \
74                                 \
75 required/Array.hs               \
76 required/Char.hs                \
77 required/Complex.hs             \
78 required/Directory.hs           \
79 required/IO.hs                  \
80 required/Ix.hs                  \
81 required/List.hs                \
82 required/Maybe.hs               \
83 required/Monad.hs               \
84 required/Ratio.hs               \
85 required/System.hs              \
86 \
87 concurrent/Channel.hs           \
88 concurrent/ChannelVar.hs        \
89 concurrent/Merge.hs             \
90 concurrent/Parallel.hs          \
91 concurrent/SampleVar.hs         \
92 concurrent/Semaphore.hs         \
93 concurrent/Concurrent.hs
94
95 BASIC_OBJS_DIRS = $(BASIC_HS:.hs=)
96
97 /* easy way to make many many Make variables: */
98 WayThingVars(BASIC)
99
100 /************************************************************************
101 *                                                                       *
102 * Macros for creating and installing libHS<x>.a (in its many flavors).  *
103 *                                                                       *
104 *************************************************************************/
105
106 #ifndef SpecialGhcLibraryTarget
107 #define SpecialGhcLibraryTarget(lib,tag,objs_DEP,objs_DIR,find_pat) @@\
108 AllTarget(CAT3(lib,tag,.a))                                     @@\
109 CAT3(lib,tag,.a):: objs_DEP                                     @@\
110         $(RM) $@                                                @@\
111         TMPDIR=$(TMPDIR); export TMPDIR;                        \
112         find objs_DIR -name find_pat -print | xargs ar q $@     @@\
113         $(RANLIB) CAT3(lib,tag,.a)                              @@\
114 clean  ::                                                       @@\
115         $(RM) CAT3(lib,tag,.a)
116 #endif /* SpecialGhcLibraryTarget */
117
118 #ifndef SpecialGhcLibInstallTarget
119 #if DoInstallGHCSystem == YES
120 #define SpecialGhcLibInstallTarget(lib,tag)                     @@\
121 install :: CAT3(lib,tag,.a)                                     @@\
122         $(INSTALL) $(INSTLIBFLAGS) CAT3(lib,tag,.a)             \
123                 $(INSTLIBDIR_GHC)/CAT3(lib,tag,.a)              @@\
124         $(RANLIB) $(INSTLIBDIR_GHC)/CAT3(lib,tag,.a)
125 #else  /* ! DoInstallGhc... */
126 #define SpecialGhcLibInstallTarget(lib,tag) /*nothing*/
127 #endif /* ! DoInstallGhc... */
128 #endif /* SpecialGhcLibInstallTarget */
129
130 /* build/install all the diff libs for a particular build */
131
132 #define BigHisTarget(targeti,basei)                             @@\
133 targeti ::                                                      @@\
134 InstallTarget(targeti)                                          @@\
135 InstallMultNonExecTargets(targeti,basei,$(INSTDATADIR_GHC)/imports)
136
137 #define BigLibsTarget(tag,glob,base)                            @@\
138 SpecialGhcLibraryTarget(libHS,tag,base,$(BASIC_OBJS_DIRS),glob) @@\
139 SpecialGhcLibInstallTarget(libHS,tag)
140
141 /* build *everything* -- monster macro from hell */
142 #define BigBuildTarget(tag,glob,targeti,base,basei)             \
143 BigLibsTarget(tag,glob,base)                                    @@\
144 BigHisTarget(targeti,basei)
145
146 /****************************************************************
147 *                                                               *
148 * Creating and installing...                                    *
149 *       libHS_<tag>.a           standard Prelude library        *
150 *                                                               *
151 ****************************************************************/
152
153 /* make sure install's target dir is there */
154 #if DoInstallGHCSystem == YES
155 MakeDirectories(install, $(INSTLIBDIR_GHC)              \
156                          $(INSTDATADIR_GHC)/imports)
157
158 basic_his :: /* nothing */
159 InstallTarget(basic_his)
160 InstallMultNonExecTargets(basic_his, $(BASIC_HIs),  $(INSTDATADIR_GHC)/imports)
161 #endif /* installing */
162
163 IfBuild_normal(BigBuildTarget(,'*.o',basic_his, $(BASIC_DEP_norm),  $(BASIC_HIs)))
164 IfBuild_p(BigBuildTarget(_p,'*.p_o',his_p, $(BASIC_DEP_p),  $(BASIC_HIs_p)))
165 IfBuild_t(BigBuildTarget(_t,'*.t_o',his_t, $(BASIC_DEP_t),  $(BASIC_HIs_t)))
166 IfBuild_u(BigBuildTarget(,'*.u_o',his_u, $(BASIC_DEP_u),  $(BASIC_HIs_u)))
167 IfBuild_mc(BigBuildTarget(_mc,'*.mc_o',his_mc, $(BASIC_DEP_mc),  $(BASIC_HIs_mc)))
168 IfBuild_mr(BigBuildTarget(_mr,'*.mr_o',his_mr, $(BASIC_DEP_mr),  $(BASIC_HIs_mr)))
169 IfBuild_mt(BigBuildTarget(_mr,'*.mt_o',his_mt, $(BASIC_DEP_mt),  $(BASIC_HIs_mt)))
170 IfBuild_mp(BigBuildTarget(_mp,'*.mp_o',his_mp, $(BASIC_DEP_mp),  $(BASIC_HIs_mp)))
171 IfBuild_mg(BigBuildTarget(_mg,'*.mg_o',his_mg, $(BASIC_DEP_mg),  $(BASIC_HIs_mg)))
172
173 /* these GC ones do not *really* need separate .hi files,
174    but it really makes life easier to do it this way
175 */
176 IfBuild_2s(BigBuildTarget(_2s,'*.2s_o',his_2s, $(BASIC_DEP_2s),  $(BASIC_HIs_2s)))
177 IfBuild_1s(BigBuildTarget(_1s,'*.1s_o',his_1s, $(BASIC_DEP_1s),  $(BASIC_HIs_1s)))
178 IfBuild_du(BigBuildTarget(_du,'*.du_o',his_du, $(BASIC_DEP_du),  $(BASIC_HIs_du)))
179
180 /* user ways -- yeeps! */
181
182 IfBuild_a(BigBuildTarget(_a,'*.a_o',his_a, $(BASIC_DEP_a),  $(BASIC_HIs_a)))
183 IfBuild_b(BigBuildTarget(_b,'*.b_o',his_b, $(BASIC_DEP_b),  $(BASIC_HIs_b)))
184 IfBuild_c(BigBuildTarget(_c,'*.c_o',his_c, $(BASIC_DEP_c),  $(BASIC_HIs_c)))
185 IfBuild_d(BigBuildTarget(_d,'*.d_o',his_d, $(BASIC_DEP_d),  $(BASIC_HIs_d)))
186 IfBuild_e(BigBuildTarget(_e,'*.e_o',his_e, $(BASIC_DEP_e),  $(BASIC_HIs_e)))
187 IfBuild_f(BigBuildTarget(_f,'*.f_o',his_f, $(BASIC_DEP_f),  $(BASIC_HIs_f)))
188 IfBuild_g(BigBuildTarget(_g,'*.g_o',his_g, $(BASIC_DEP_g),  $(BASIC_HIs_g)))
189 IfBuild_h(BigBuildTarget(_h,'*.h_o',his_h, $(BASIC_DEP_h),  $(BASIC_HIs_h)))
190 IfBuild_i(BigBuildTarget(_i,'*.i_o',his_i, $(BASIC_DEP_i),  $(BASIC_HIs_i)))
191 IfBuild_j(BigBuildTarget(_j,'*.j_o',his_j, $(BASIC_DEP_j),  $(BASIC_HIs_j)))
192 IfBuild_k(BigBuildTarget(_k,'*.k_o',his_k, $(BASIC_DEP_k),  $(BASIC_HIs_k)))
193 IfBuild_l(BigBuildTarget(_l,'*.l_o',his_l, $(BASIC_DEP_l),  $(BASIC_HIs_l)))
194 IfBuild_m(BigBuildTarget(_m,'*.m_o',his_m, $(BASIC_DEP_m),  $(BASIC_HIs_m)))
195 IfBuild_n(BigBuildTarget(_n,'*.n_o',his_n, $(BASIC_DEP_n),  $(BASIC_HIs_n)))
196 IfBuild_o(BigBuildTarget(_o,'*.o_o',his_o, $(BASIC_DEP_o),  $(BASIC_HIs_o)))
197 IfBuild_A(BigBuildTarget(_A,'*.A_o',his_A, $(BASIC_DEP_A),  $(BASIC_HIs_A)))
198 IfBuild_B(BigBuildTarget(_B,'*.B_o',his_B, $(BASIC_DEP_B),  $(BASIC_HIs_B)))
199
200 /****************************************************************
201 *                                                               *
202 * Creating the individual .hc files:                            *
203 *                                                               *
204 *   For the just-vary-the-GC-thanks flavors, we only need to    *
205 *   compile .hs->.hc once; then re-use the .hc file each time.  *
206 *                                                               *
207 *   For the profiling one (_p) and all the user-specified       *
208 *   ones, we recompile the Haskell each time.                   *
209 *                                                               *
210 *  NB: old (WDP 95/06)                                          *
211 ****************************************************************/
212
213 /* some "helpful" internal macros first... */
214
215 #if GhcWithHscBuiltViaC == YES && HaskellCompilerType == HC_USE_HC_FILES
216 #define CompileWayishly__(hc,file,isuf,way,flags)       @@\
217 clean  ::                                               @@\
218         $(RM) CAT3(file,way,.hc)
219 #endif
220
221 /* now use the macro: */
222
223 CompileWayishly(GHC,prelude/Prelude,hs,-iprelude -fglasgow-exts -fcompiling-ghc-internals Prelude -fno-implicit-prelude)
224 CompileWayishly(GHC,prelude/GHCbase,hs,-iprelude -fglasgow-exts -fcompiling-ghc-internals GHCbase)
225 CompileWayishly(GHC,prelude/GHCps,hs,  -iprelude -fglasgow-exts)
226 CompileWayishly(GHC,prelude/GHCio,hs,  -iprelude -fglasgow-exts)
227 CompileWayishly(GHC,prelude/GHCmain,hs,-iprelude -fglasgow-exts)
228 CompileWayishly(GHC,prelude/PreludeGlaST,hs,-iprelude -fglasgow-exts)
229
230 CompileWayishly(GHC,required/Array,hs,-fglasgow-exts -iprelude)
231 CompileWayishly(GHC,required/Char,hs,)
232 CompileWayishly(GHC,required/Complex,hs,)
233 CompileWayishly(GHC,required/Directory,hs,-fglasgow-exts)
234 CompileWayishly(GHC,required/IO,hs,-fglasgow-exts)
235 CompileWayishly(GHC,required/Ix,hs,-fglasgow-exts)
236 CompileWayishly(GHC,required/List,hs,)
237 CompileWayishly(GHC,required/Maybe,hs,)
238 CompileWayishly(GHC,required/Monad,hs,)
239 CompileWayishly(GHC,required/Ratio,hs,)
240 CompileWayishly(GHC,required/System,hs,-fglasgow-exts)
241
242 CompileWayishly(GHC,concurrent/Channel,hs,)
243 CompileWayishly(GHC,concurrent/ChannelVar,hs,)
244 CompileWayishly(GHC,concurrent/Merge,hs,-iconcurrent)
245 CompileWayishly(GHC,concurrent/Parallel,hs,)
246 CompileWayishly(GHC,concurrent/SampleVar,hs,)
247 CompileWayishly(GHC,concurrent/Semaphore,hs,)
248 CompileWayishly(GHC,concurrent/Concurrent,hs,-iconcurrent)
249
250 /****************************************************************
251 *                                                               *
252 * misc "make" targets -- depend, clean, tags                    *
253 *                                                               *
254 ****************************************************************/
255
256 /* this is a BAD idea!
257 ExtraStuffToClean( $(SRCS_C) )
258    without the .hc files, the distrib cannot boot itself
259 */
260 ExtraStuffToBeVeryClean( $(SRCS_C) )
261 ExtraStuffToBeVeryClean( $(STD_VERY_CLEAN) )
262
263 ClearTagsFile()
264 /* Ugly but OK? [WDP 94/09] */
265 HsTagsTarget( */[A-Z]*.*hs )
266 HSTAGS_OPTS=-cpp -fglasgow-exts
267
268 /* should be *LAST* */
269 #if HaskellCompilerType != HC_USE_HC_FILES
270     /* otherwise, the dependencies jeopardize our .hc files --
271         which are all we have! */
272 MAIN_INCLUDE_DIR = $(TOP_PWD)/$(CURRENT_DIR)/$(GHC_INCLUDES)
273 MKDEPENDHS_OPTS= -o .hc -I$(MAIN_INCLUDE_DIR) 
274
275 HaskellDependTarget( $(BASIC_HS_PREL) )
276 #endif