]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/contrib/Makefile
update
[l4.git] / l4 / pkg / ocaml / contrib / Makefile
1 #########################################################################
2 #                                                                       #
3 #                            Objective Caml                             #
4 #                                                                       #
5 #            Xavier Leroy, projet Cristal, INRIA Rocquencourt           #
6 #                                                                       #
7 #   Copyright 1999 Institut National de Recherche en Informatique et    #
8 #   en Automatique.  All rights reserved.  This file is distributed     #
9 #   under the terms of the Q Public License version 1.0.                #
10 #                                                                       #
11 #########################################################################
12
13 # $Id: Makefile 9480 2009-12-18 23:04:13Z doligez $
14
15 # The main Makefile
16
17 include config/Makefile
18 include stdlib/StdlibModules
19
20 CAMLC=boot/ocamlrun boot/ocamlc -nostdlib -I boot
21 CAMLOPT=boot/ocamlrun ./ocamlopt -nostdlib -I stdlib -I otherlibs/dynlink
22 COMPFLAGS=-warn-error A $(INCLUDES)
23 LINKFLAGS=
24
25 CAMLYACC=boot/ocamlyacc
26 YACCFLAGS=-v
27 CAMLLEX=boot/ocamlrun boot/ocamllex
28 CAMLDEP=boot/ocamlrun tools/ocamldep
29 DEPFLAGS=$(INCLUDES)
30 CAMLRUN=byterun/ocamlrun
31 SHELL=/bin/sh
32 MKDIR=mkdir -p
33
34 INCLUDES=-I utils -I parsing -I typing -I bytecomp -I asmcomp -I driver \
35          -I toplevel
36
37 UTILS=utils/misc.cmo utils/tbl.cmo utils/config.cmo \
38   utils/clflags.cmo utils/terminfo.cmo utils/ccomp.cmo utils/warnings.cmo \
39   utils/consistbl.cmo
40
41 OPTUTILS=$(UTILS)
42
43 PARSING=parsing/linenum.cmo parsing/location.cmo parsing/longident.cmo \
44   parsing/syntaxerr.cmo parsing/parser.cmo \
45   parsing/lexer.cmo parsing/parse.cmo parsing/printast.cmo
46
47 TYPING=typing/unused_var.cmo typing/ident.cmo typing/path.cmo \
48   typing/primitive.cmo typing/types.cmo \
49   typing/btype.cmo typing/oprint.cmo \
50   typing/subst.cmo typing/predef.cmo \
51   typing/datarepr.cmo typing/env.cmo \
52   typing/typedtree.cmo typing/ctype.cmo \
53   typing/printtyp.cmo typing/includeclass.cmo \
54   typing/mtype.cmo typing/includecore.cmo \
55   typing/includemod.cmo typing/parmatch.cmo \
56   typing/typetexp.cmo typing/stypes.cmo typing/typecore.cmo \
57   typing/typedecl.cmo typing/typeclass.cmo \
58   typing/typemod.cmo
59
60 COMP=bytecomp/lambda.cmo bytecomp/printlambda.cmo \
61   bytecomp/typeopt.cmo bytecomp/switch.cmo bytecomp/matching.cmo \
62   bytecomp/translobj.cmo bytecomp/translcore.cmo \
63   bytecomp/translclass.cmo bytecomp/translmod.cmo \
64   bytecomp/simplif.cmo bytecomp/runtimedef.cmo
65
66 BYTECOMP=bytecomp/meta.cmo bytecomp/instruct.cmo bytecomp/bytegen.cmo \
67   bytecomp/printinstr.cmo bytecomp/opcodes.cmo bytecomp/emitcode.cmo \
68   bytecomp/bytesections.cmo bytecomp/dll.cmo bytecomp/symtable.cmo \
69   bytecomp/bytelink.cmo bytecomp/bytelibrarian.cmo bytecomp/bytepackager.cmo
70
71 ASMCOMP=asmcomp/arch.cmo asmcomp/debuginfo.cmo \
72   asmcomp/cmm.cmo asmcomp/printcmm.cmo \
73   asmcomp/reg.cmo asmcomp/mach.cmo asmcomp/proc.cmo \
74   asmcomp/clambda.cmo asmcomp/compilenv.cmo \
75   asmcomp/closure.cmo asmcomp/cmmgen.cmo \
76   asmcomp/printmach.cmo asmcomp/selectgen.cmo asmcomp/selection.cmo \
77   asmcomp/comballoc.cmo asmcomp/liveness.cmo \
78   asmcomp/spill.cmo asmcomp/split.cmo \
79   asmcomp/interf.cmo asmcomp/coloring.cmo \
80   asmcomp/reloadgen.cmo asmcomp/reload.cmo \
81   asmcomp/printlinear.cmo asmcomp/linearize.cmo \
82   asmcomp/schedgen.cmo asmcomp/scheduling.cmo \
83   asmcomp/emitaux.cmo asmcomp/emit.cmo asmcomp/asmgen.cmo \
84   asmcomp/asmlink.cmo asmcomp/asmlibrarian.cmo asmcomp/asmpackager.cmo
85
86 DRIVER=driver/pparse.cmo driver/errors.cmo driver/compile.cmo \
87   driver/main_args.cmo driver/main.cmo
88
89 OPTDRIVER= driver/pparse.cmo driver/opterrors.cmo driver/optcompile.cmo \
90   driver/optmain.cmo
91
92 TOPLEVEL=driver/pparse.cmo driver/errors.cmo driver/compile.cmo \
93   toplevel/genprintval.cmo toplevel/toploop.cmo \
94   toplevel/trace.cmo toplevel/topdirs.cmo toplevel/topmain.cmo
95
96 TOPLEVELLIB=toplevel/toplevellib.cma
97 TOPLEVELSTART=toplevel/topstart.cmo
98
99 COMPOBJS=$(UTILS) $(PARSING) $(TYPING) $(COMP) $(BYTECOMP) $(DRIVER)
100
101 TOPLIB=$(UTILS) $(PARSING) $(TYPING) $(COMP) $(BYTECOMP) $(TOPLEVEL)
102
103 TOPOBJS=$(TOPLEVELLIB) $(TOPLEVELSTART)
104
105 NATTOPOBJS=$(OPTUTILS) $(PARSING) $(TYPING) $(COMP) $(ASMCOMP) \
106   driver/pparse.cmo driver/opterrors.cmo driver/optcompile.cmo \
107   toplevel/genprintval.cmo toplevel/opttoploop.cmo toplevel/opttopdirs.cmo \
108   toplevel/opttopmain.cmo toplevel/opttopstart.cmo
109
110 OPTOBJS=$(OPTUTILS) $(PARSING) $(TYPING) $(COMP) $(ASMCOMP) $(OPTDRIVER)
111
112 EXPUNGEOBJS=utils/misc.cmo utils/tbl.cmo \
113   utils/config.cmo utils/clflags.cmo \
114   typing/ident.cmo typing/path.cmo typing/types.cmo typing/btype.cmo \
115   typing/predef.cmo bytecomp/runtimedef.cmo bytecomp/bytesections.cmo \
116   bytecomp/dll.cmo bytecomp/meta.cmo bytecomp/symtable.cmo toplevel/expunge.cmo
117
118 PERVASIVES=$(STDLIB_MODULES) outcometree topdirs toploop
119
120 # For users who don't read the INSTALL file
121 defaultentry:
122         @echo "Please refer to the installation instructions in file INSTALL."
123         @echo "If you've just unpacked the distribution, something like"
124         @echo " ./configure"
125         @echo " make world"
126         @echo " make opt"
127         @echo " make install"
128         @echo "should work.  But see the file INSTALL for more details."
129
130 # Recompile the system using the bootstrap compiler
131 all: runtime ocamlc ocamllex ocamlyacc ocamltools library ocaml \
132   otherlibraries ocamlbuild.byte camlp4out $(DEBUGGER) ocamldoc
133
134 # Compile everything the first time
135 world:
136         $(MAKE) coldstart
137         $(MAKE) all
138
139 # Compile also native code compiler and libraries, fast
140 world.opt:
141         $(MAKE) coldstart
142         $(MAKE) opt.opt
143
144 # Hard bootstrap how-to:
145 # (only necessary in some cases, for example if you remove some primitive)
146 #
147 # make coreboot     [old system -- you were in a stable state]
148 # <change the source>
149 # make core         [cross-compiler]
150 # make partialclean [if you get "inconsistent assumptions"]
151 # <debug your changes>
152 # make core         [cross-compiler]
153 # make coreboot     [new system -- now you are in a stable state]
154
155 # Core bootstrapping cycle
156 coreboot:
157 # Save the original bootstrap compiler
158         $(MAKE) backup
159 # Promote the new compiler but keep the old runtime
160 # This compiler runs on boot/ocamlrun and produces bytecode for
161 # byterun/ocamlrun
162         $(MAKE) promote-cross
163 # Rebuild ocamlc and ocamllex (run on byterun/ocamlrun)
164         $(MAKE) partialclean
165         $(MAKE) ocamlc ocamllex ocamltools
166 # Rebuild the library (using byterun/ocamlrun ./ocamlc)
167         $(MAKE) library-cross
168 # Promote the new compiler and the new runtime
169         $(MAKE) promote
170 # Rebuild the core system
171         $(MAKE) partialclean
172         $(MAKE) core
173 # Check if fixpoint reached
174         $(MAKE) compare
175
176 # Bootstrap and rebuild the whole system.
177 # The compilation of ocaml will fail if the runtime has changed.
178 # Never mind, just do make bootstrap to reach fixpoint again.
179 bootstrap:
180         $(MAKE) coreboot
181         $(MAKE) all
182         $(MAKE) compare
183
184 LIBFILES=stdlib.cma std_exit.cmo *.cmi camlheader
185
186 # Start up the system from the distribution compiler
187 coldstart:
188         cd byterun; $(MAKE) all
189         cp byterun/ocamlrun$(EXE) boot/ocamlrun$(EXE)
190         cd yacc; $(MAKE) all
191         cp yacc/ocamlyacc$(EXE) boot/ocamlyacc$(EXE)
192         cd stdlib; $(MAKE) COMPILER=../boot/ocamlc all
193         cd stdlib; cp $(LIBFILES) ../boot
194         if test -f boot/libcamlrun.a; then :; else \
195           ln -s ../byterun/libcamlrun.a boot/libcamlrun.a; fi
196         if test -d stdlib/caml; then :; else \
197           ln -s ../byterun stdlib/caml; fi
198
199 # Build the core system: the minimum needed to make depend and bootstrap
200 core: coldstart ocamlc ocamllex ocamlyacc ocamltools library
201
202 # Recompile the core system using the bootstrap compiler
203 coreall: ocamlc ocamllex ocamlyacc ocamltools library
204
205 # Save the current bootstrap compiler
206 MAXSAVED=boot/Saved/Saved.prev/Saved.prev/Saved.prev/Saved.prev/Saved.prev
207 backup:
208         if test -d boot/Saved; then : ; else mkdir boot/Saved; fi
209         if test -d $(MAXSAVED); then rm -r $(MAXSAVED); else : ; fi
210         mv boot/Saved boot/Saved.prev
211         mkdir boot/Saved
212         mv boot/Saved.prev boot/Saved/Saved.prev
213         cp boot/ocamlrun$(EXE) boot/Saved
214         mv boot/ocamlc boot/ocamllex boot/ocamlyacc$(EXE) boot/ocamldep \
215            boot/Saved
216         cd boot; cp $(LIBFILES) Saved
217
218 # Promote the newly compiled system to the rank of cross compiler
219 # (Runs on the old runtime, produces code for the new runtime)
220 promote-cross:
221         cp ocamlc boot/ocamlc
222         cp lex/ocamllex boot/ocamllex
223         cp yacc/ocamlyacc$(EXE) boot/ocamlyacc$(EXE)
224         cp tools/ocamldep boot/ocamldep
225         cd stdlib; cp $(LIBFILES) ../boot
226
227 # Promote the newly compiled system to the rank of bootstrap compiler
228 # (Runs on the new runtime, produces code for the new runtime)
229 promote: promote-cross
230         cp byterun/ocamlrun$(EXE) boot/ocamlrun$(EXE)
231
232 # Restore the saved bootstrap compiler if a problem arises
233 restore:
234         mv boot/Saved/* boot
235         rmdir boot/Saved
236         mv boot/Saved.prev boot/Saved
237
238 # Check if fixpoint reached
239 compare:
240         @if cmp boot/ocamlc ocamlc && cmp boot/ocamllex lex/ocamllex \
241             && cmp boot/ocamldep tools/ocamldep; \
242         then echo "Fixpoint reached, bootstrap succeeded."; \
243         else echo "Fixpoint not reached, try one more bootstrapping cycle."; \
244         fi
245
246 # Remove old bootstrap compilers
247 cleanboot:
248         rm -rf boot/Saved/Saved.prev/*
249
250 # Compile the native-code compiler
251 opt-core:
252         $(MAKE) runtimeopt
253         $(MAKE) ocamlopt
254         $(MAKE) libraryopt
255
256 opt:
257         $(MAKE) runtimeopt
258         $(MAKE) ocamlopt
259         $(MAKE) libraryopt
260         $(MAKE) otherlibrariesopt
261         $(MAKE) ocamlbuildlib.native
262
263 # Native-code versions of the tools
264 opt.opt: checkstack runtime core ocaml opt-core ocamlc.opt otherlibraries \
265          ocamlbuild.byte camlp4out $(DEBUGGER) ocamldoc ocamlopt.opt \
266          otherlibrariesopt \
267          ocamllex.opt ocamltoolsopt.opt ocamlbuild.native camlp4opt ocamldoc.opt
268
269 # Installation
270 install:
271         if test -d $(BINDIR); then : ; else $(MKDIR) $(BINDIR); fi
272         if test -d $(LIBDIR); then : ; else $(MKDIR) $(LIBDIR); fi
273         if test -d $(STUBLIBDIR); then : ; else $(MKDIR) $(STUBLIBDIR); fi
274         if test -d $(MANDIR)/man$(MANEXT); then : ; \
275           else $(MKDIR) $(MANDIR)/man$(MANEXT); fi
276         cd $(LIBDIR); rm -f dllbigarray.so dlllabltk.so dllnums.so \
277           dllthreads.so dllunix.so dllgraphics.so dllmldbm.so dllstr.so \
278           dlltkanim.so
279         cd byterun; $(MAKE) install
280         cp ocamlc $(BINDIR)/ocamlc$(EXE)
281         cp ocaml $(BINDIR)/ocaml$(EXE)
282         cd stdlib; $(MAKE) install
283         cp lex/ocamllex $(BINDIR)/ocamllex$(EXE)
284         cp yacc/ocamlyacc$(EXE) $(BINDIR)/ocamlyacc$(EXE)
285         cp toplevel/toplevellib.cma $(LIBDIR)/toplevellib.cma
286         cp expunge $(LIBDIR)/expunge$(EXE)
287         cp typing/outcometree.cmi typing/outcometree.mli $(LIBDIR)
288         cp toplevel/topstart.cmo $(LIBDIR)
289         cp toplevel/toploop.cmi toplevel/topdirs.cmi toplevel/topmain.cmi \
290            $(LIBDIR)
291         cd tools; $(MAKE) install
292         -$(MAKE) -C man install
293         for i in $(OTHERLIBRARIES); do \
294           (cd otherlibs/$$i; $(MAKE) install) || exit $$?; \
295         done
296         cd ocamldoc; $(MAKE) install
297         if test -f ocamlopt; then $(MAKE) installopt; else :; fi
298         if test -f debugger/ocamldebug; then (cd debugger; $(MAKE) install); \
299            else :; fi
300         cp config/Makefile $(LIBDIR)/Makefile.config
301         BINDIR=$(BINDIR) LIBDIR=$(LIBDIR) PREFIX=$(PREFIX) \
302           ./build/partial-install.sh
303
304 # Installation of the native-code compiler
305 installopt:
306         cd asmrun; $(MAKE) install
307         cp ocamlopt $(BINDIR)/ocamlopt$(EXE)
308         cd stdlib; $(MAKE) installopt
309         cd ocamldoc; $(MAKE) installopt
310         for i in $(OTHERLIBRARIES); \
311           do (cd otherlibs/$$i; $(MAKE) installopt) || exit $$?; done
312         if test -f ocamlc.opt; \
313           then cp ocamlc.opt $(BINDIR)/ocamlc.opt$(EXE); else :; fi
314         if test -f ocamlopt.opt; \
315           then cp ocamlopt.opt $(BINDIR)/ocamlopt.opt$(EXE); else :; fi
316         if test -f lex/ocamllex.opt; \
317           then cp lex/ocamllex.opt $(BINDIR)/ocamllex.opt$(EXE); else :; fi
318
319 clean:: partialclean
320
321 # The compiler
322
323 ocamlc: $(COMPOBJS)
324         $(CAMLC) $(LINKFLAGS) -o ocamlc $(COMPOBJS)
325         @sed -e 's|@compiler@|$$topdir/boot/ocamlrun $$topdir/ocamlc|' \
326           driver/ocamlcomp.sh.in > ocamlcomp.sh
327         @chmod +x ocamlcomp.sh
328
329 partialclean::
330         rm -f ocamlc ocamlcomp.sh
331
332 # The native-code compiler
333
334 ocamlopt: $(OPTOBJS)
335         $(CAMLC) $(LINKFLAGS) -o ocamlopt $(OPTOBJS)
336         @sed -e 's|@compiler@|$$topdir/boot/ocamlrun $$topdir/ocamlopt|' \
337           driver/ocamlcomp.sh.in > ocamlcompopt.sh
338         @chmod +x ocamlcompopt.sh
339
340 partialclean::
341         rm -f ocamlopt ocamlcompopt.sh
342
343 # The toplevel
344
345 ocaml: $(TOPOBJS) expunge
346         $(CAMLC) $(LINKFLAGS) -linkall -o ocaml.tmp $(TOPOBJS)
347         - $(CAMLRUN) ./expunge ocaml.tmp ocaml $(PERVASIVES)
348         rm -f ocaml.tmp
349
350 toplevel/toplevellib.cma: $(TOPLIB)
351         $(CAMLC) -a -o $@ $(TOPLIB)
352
353 partialclean::
354         rm -f ocaml toplevel/toplevellib.cma
355
356 # The native toplevel
357
358 ocamlnat: ocamlopt otherlibs/dynlink/dynlink.cmxa $(NATTOPOBJS:.cmo=.cmx) 
359         $(CAMLOPT) $(LINKFLAGS) otherlibs/dynlink/dynlink.cmxa -o ocamlnat \
360                    $(NATTOPOBJS:.cmo=.cmx) -linkall
361
362 toplevel/opttoploop.cmx: otherlibs/dynlink/dynlink.cmxa
363
364 otherlibs/dynlink/dynlink.cmxa: otherlibs/dynlink/natdynlink.ml
365         cd otherlibs/dynlink && make allopt
366
367 # The configuration file
368
369 utils/config.ml: utils/config.mlp config/Makefile
370         @rm -f utils/config.ml
371         sed -e 's|%%LIBDIR%%|$(LIBDIR)|' \
372             -e 's|%%BYTERUN%%|$(BINDIR)/ocamlrun|' \
373             -e 's|%%CCOMPTYPE%%|cc|' \
374             -e 's|%%BYTECC%%|$(BYTECC) $(BYTECCCOMPOPTS) $(SHAREDCCCOMPOPTS)|' \
375             -e 's|%%NATIVECC%%|$(NATIVECC) $(NATIVECCCOMPOPTS)|' \
376             -e 's|%%PACKLD%%|$(PACKLD)|' \
377             -e 's|%%BYTECCLIBS%%|$(BYTECCLIBS)|' \
378             -e 's|%%NATIVECCLIBS%%|$(NATIVECCLIBS)|' \
379             -e 's|%%RANLIBCMD%%|$(RANLIBCMD)|' \
380             -e 's|%%CC_PROFILE%%|$(CC_PROFILE)|' \
381             -e 's|%%ARCH%%|$(ARCH)|' \
382             -e 's|%%MODEL%%|$(MODEL)|' \
383             -e 's|%%SYSTEM%%|$(SYSTEM)|' \
384             -e 's|%%EXT_OBJ%%|.o|' \
385             -e 's|%%EXT_ASM%%|.s|' \
386             -e 's|%%EXT_LIB%%|.a|' \
387             -e 's|%%EXT_DLL%%|.so|' \
388             -e 's|%%SYSTHREAD_SUPPORT%%|$(SYSTHREAD_SUPPORT)|' \
389             -e 's|%%ASM%%|$(ASM)|' \
390             -e 's|%%MKDLL%%|$(MKDLL)|' \
391             -e 's|%%MKEXE%%|$(MKEXE)|' \
392             -e 's|%%MKMAINDLL%%|$(MKMAINDLL)|' \
393             utils/config.mlp > utils/config.ml
394         @chmod -w utils/config.ml
395
396 partialclean::
397         rm -f utils/config.ml
398
399 beforedepend:: utils/config.ml
400
401 # The parser
402
403 parsing/parser.mli parsing/parser.ml: parsing/parser.mly
404         $(CAMLYACC) $(YACCFLAGS) parsing/parser.mly
405
406 partialclean::
407         rm -f parsing/parser.mli parsing/parser.ml parsing/parser.output
408
409 beforedepend:: parsing/parser.mli parsing/parser.ml
410
411 # The lexer
412
413 parsing/lexer.ml: parsing/lexer.mll
414         $(CAMLLEX) parsing/lexer.mll
415
416 partialclean::
417         rm -f parsing/lexer.ml
418
419 beforedepend:: parsing/lexer.ml
420
421 # The auxiliary lexer for counting line numbers
422
423 parsing/linenum.ml: parsing/linenum.mll
424         $(CAMLLEX) parsing/linenum.mll
425
426 partialclean::
427         rm -f parsing/linenum.ml
428
429 beforedepend:: parsing/linenum.ml
430
431 # The bytecode compiler compiled with the native-code compiler
432
433 ocamlc.opt: $(COMPOBJS:.cmo=.cmx)
434         cd asmrun; $(MAKE) meta.o dynlink.o
435         $(CAMLOPT) $(LINKFLAGS) -ccopt "$(BYTECCLINKOPTS)" -o ocamlc.opt \
436           $(COMPOBJS:.cmo=.cmx) \
437           asmrun/meta.o asmrun/dynlink.o -cclib "$(BYTECCLIBS)"
438         @sed -e 's|@compiler@|$$topdir/ocamlc.opt|' \
439           driver/ocamlcomp.sh.in > ocamlcomp.sh
440         @chmod +x ocamlcomp.sh
441
442 partialclean::
443         rm -f ocamlc.opt
444
445 # The native-code compiler compiled with itself
446
447 ocamlopt.opt: $(OPTOBJS:.cmo=.cmx)
448         $(CAMLOPT) $(LINKFLAGS) -o ocamlopt.opt $(OPTOBJS:.cmo=.cmx)
449         @sed -e 's|@compiler@|$$topdir/ocamlopt.opt|' \
450           driver/ocamlcomp.sh.in > ocamlcompopt.sh
451         @chmod +x ocamlcompopt.sh
452
453 partialclean::
454         rm -f ocamlopt.opt
455
456 $(OPTOBJS:.cmo=.cmx): ocamlopt
457
458 # The numeric opcodes
459
460 bytecomp/opcodes.ml: byterun/instruct.h
461         sed -n -e '/^enum/p' -e 's/,//g' -e '/^  /p' byterun/instruct.h | \
462         awk -f tools/make-opcodes > bytecomp/opcodes.ml
463
464 partialclean::
465         rm -f bytecomp/opcodes.ml
466
467 beforedepend:: bytecomp/opcodes.ml
468
469 # The predefined exceptions and primitives
470
471 byterun/primitives:
472         cd byterun; $(MAKE) primitives
473
474 bytecomp/runtimedef.ml: byterun/primitives byterun/fail.h
475         (echo 'let builtin_exceptions = [|'; \
476          sed -n -e 's|.*/\* \("[A-Za-z_]*"\) \*/$$|  \1;|p' byterun/fail.h | \
477          sed -e '$$s/;$$//'; \
478          echo '|]'; \
479          echo 'let builtin_primitives = [|'; \
480          sed -e 's/.*/  "&";/' -e '$$s/;$$//' byterun/primitives; \
481          echo '|]') > bytecomp/runtimedef.ml
482
483 partialclean::
484         rm -f bytecomp/runtimedef.ml
485
486 beforedepend:: bytecomp/runtimedef.ml
487
488 # Choose the right machine-dependent files
489
490 asmcomp/arch.ml: asmcomp/$(ARCH)/arch.ml
491         ln -s $(ARCH)/arch.ml asmcomp/arch.ml
492
493 partialclean::
494         rm -f asmcomp/arch.ml
495
496 beforedepend:: asmcomp/arch.ml
497
498 asmcomp/proc.ml: asmcomp/$(ARCH)/proc.ml
499         ln -s $(ARCH)/proc.ml asmcomp/proc.ml
500
501 partialclean::
502         rm -f asmcomp/proc.ml
503
504 beforedepend:: asmcomp/proc.ml
505
506 asmcomp/selection.ml: asmcomp/$(ARCH)/selection.ml
507         ln -s $(ARCH)/selection.ml asmcomp/selection.ml
508
509 partialclean::
510         rm -f asmcomp/selection.ml
511
512 beforedepend:: asmcomp/selection.ml
513
514 asmcomp/reload.ml: asmcomp/$(ARCH)/reload.ml
515         ln -s $(ARCH)/reload.ml asmcomp/reload.ml
516
517 partialclean::
518         rm -f asmcomp/reload.ml
519
520 beforedepend:: asmcomp/reload.ml
521
522 asmcomp/scheduling.ml: asmcomp/$(ARCH)/scheduling.ml
523         ln -s $(ARCH)/scheduling.ml asmcomp/scheduling.ml
524
525 partialclean::
526         rm -f asmcomp/scheduling.ml
527
528 beforedepend:: asmcomp/scheduling.ml
529
530 # Preprocess the code emitters
531
532 asmcomp/emit.ml: asmcomp/$(ARCH)/emit.mlp tools/cvt_emit
533         $(CAMLRUN) tools/cvt_emit < asmcomp/$(ARCH)/emit.mlp > asmcomp/emit.ml \
534         || { rm -f asmcomp/emit.ml; exit 2; }
535
536 partialclean::
537         rm -f asmcomp/emit.ml
538
539 beforedepend:: asmcomp/emit.ml
540
541 tools/cvt_emit: tools/cvt_emit.mll
542         cd tools; \
543         $(MAKE) CAMLC="../$(CAMLRUN) ../boot/ocamlc -I ../stdlib" cvt_emit
544
545 # The "expunge" utility
546
547 expunge: $(EXPUNGEOBJS)
548         $(CAMLC) $(LINKFLAGS) -o expunge $(EXPUNGEOBJS)
549
550 partialclean::
551         rm -f expunge
552
553 # The runtime system for the bytecode compiler
554
555 runtime:
556         cd byterun; $(MAKE) all
557         if test -f stdlib/libcamlrun.a; then :; else \
558           ln -s ../byterun/libcamlrun.a stdlib/libcamlrun.a; fi
559
560 clean::
561         cd byterun; $(MAKE) clean
562         rm -f stdlib/libcamlrun.a
563         rm -f stdlib/caml
564
565 alldepend::
566         cd byterun; $(MAKE) depend
567
568 # The runtime system for the native-code compiler
569
570 runtimeopt: makeruntimeopt
571         cp asmrun/libasmrun.a stdlib/libasmrun.a
572
573 makeruntimeopt:
574         cd asmrun; $(MAKE) all
575
576 clean::
577         cd asmrun; $(MAKE) clean
578         rm -f stdlib/libasmrun.a
579
580 alldepend::
581         cd asmrun; $(MAKE) depend
582
583 # The library
584
585 library: ocamlc
586         cd stdlib; $(MAKE) all
587
588 library-cross:
589         cd stdlib; $(MAKE) RUNTIME=../byterun/ocamlrun all
590
591 libraryopt:
592         cd stdlib; $(MAKE) allopt
593
594 partialclean::
595         cd stdlib; $(MAKE) clean
596
597 alldepend::
598         cd stdlib; $(MAKE) depend
599
600 # The lexer and parser generators
601
602 ocamllex: ocamlyacc ocamlc
603         cd lex; $(MAKE) all
604
605 ocamllex.opt: ocamlopt
606         cd lex; $(MAKE) allopt
607
608 partialclean::
609         cd lex; $(MAKE) clean
610
611 alldepend::
612         cd lex; $(MAKE) depend
613
614 ocamlyacc:
615         cd yacc; $(MAKE) all
616
617 clean::
618         cd yacc; $(MAKE) clean
619
620 # Tools
621
622 ocamltools: ocamlc ocamlyacc ocamllex
623         cd tools; $(MAKE) all
624
625 ocamltoolsopt.opt: ocamlc.opt ocamlyacc ocamllex
626         cd tools; $(MAKE) opt.opt
627
628 partialclean::
629         cd tools; $(MAKE) clean
630
631 alldepend::
632         cd tools; $(MAKE) depend
633
634 # OCamldoc
635
636 ocamldoc: ocamlc ocamlyacc ocamllex otherlibraries
637         cd ocamldoc && $(MAKE) all
638
639 ocamldoc.opt: ocamlc.opt ocamlyacc ocamllex
640         cd ocamldoc && $(MAKE) opt.opt
641
642 partialclean::
643         cd ocamldoc && $(MAKE) clean
644
645 alldepend::
646         cd ocamldoc && $(MAKE) depend
647
648 # The extra libraries
649
650 otherlibraries: ocamltools
651         for i in $(OTHERLIBRARIES); do \
652           (cd otherlibs/$$i; $(MAKE) RUNTIME=$(RUNTIME) all) || exit $$?; \
653         done
654
655 otherlibrariesopt:
656         for i in $(OTHERLIBRARIES); do \
657           (cd otherlibs/$$i; $(MAKE) allopt) || exit $$?; \
658         done
659
660 partialclean::
661         for i in $(OTHERLIBRARIES); do \
662           (cd otherlibs/$$i; $(MAKE) partialclean); \
663         done
664
665 clean::
666         for i in $(OTHERLIBRARIES); do (cd otherlibs/$$i; $(MAKE) clean); done
667
668 alldepend::
669         for i in $(OTHERLIBRARIES); do (cd otherlibs/$$i; $(MAKE) depend); done
670
671 # The replay debugger
672
673 ocamldebugger: ocamlc ocamlyacc ocamllex otherlibraries
674         cd debugger; $(MAKE) all
675
676 partialclean::
677         cd debugger; $(MAKE) clean
678
679 alldepend::
680         cd debugger; $(MAKE) depend
681
682 # Camlp4
683
684 camlp4out: ocamlc otherlibraries ocamlbuild-mixed-boot ocamlbuild.byte
685         ./build/camlp4-byte-only.sh
686
687 camlp4opt: ocamlopt otherlibrariesopt ocamlbuild-mixed-boot ocamlbuild.native
688         ./build/camlp4-native-only.sh
689
690 # Ocamlbuild
691
692 ocamlbuild.byte: ocamlc otherlibraries ocamlbuild-mixed-boot
693         ./build/ocamlbuild-byte-only.sh
694
695 ocamlbuild.native: ocamlopt otherlibrariesopt ocamlbuild-mixed-boot
696         ./build/ocamlbuild-native-only.sh
697 ocamlbuildlib.native: ocamlopt otherlibrariesopt ocamlbuild-mixed-boot
698         ./build/ocamlbuildlib-native-only.sh
699
700 ocamlbuild-mixed-boot: ocamlc otherlibraries
701         ./build/mixed-boot.sh
702
703 partialclean::
704         rm -rf _build
705         if test -d test; then \
706          (cd test; $(MAKE) clean); \
707         fi
708
709 # Check that the stack limit is reasonable.
710
711 checkstack:
712         @if $(BYTECC) -o tools/checkstack tools/checkstack.c; \
713           then tools/checkstack; \
714           else :; \
715         fi
716         @rm -f tools/checkstack
717
718 # Make MacOS X package
719
720 package-macosx:
721         sudo rm -rf package-macosx/root
722         make PREFIX="`pwd`"/package-macosx/root install
723         tools/make-package-macosx
724         sudo rm -rf package-macosx/root
725
726 clean::
727         rm -rf package-macosx/*.pkg package-macosx/*.dmg
728
729 # Default rules
730
731 .SUFFIXES: .ml .mli .cmo .cmi .cmx
732
733 .ml.cmo:
734         $(CAMLC) $(COMPFLAGS) -c $<
735
736 .mli.cmi:
737         $(CAMLC) $(COMPFLAGS) -c $<
738
739 .ml.cmx:
740         $(CAMLOPT) $(COMPFLAGS) -c $<
741
742 partialclean::
743         for d in utils parsing typing bytecomp asmcomp driver toplevel tools; \
744           do rm -f $$d/*.cm[iox] $$d/*.annot $$d/*.[so] $$d/*~; done
745         rm -f *~
746
747 depend: beforedepend
748         (for d in utils parsing typing bytecomp asmcomp driver toplevel; \
749          do $(CAMLDEP) $(DEPFLAGS) $$d/*.mli $$d/*.ml; \
750          done) > .depend
751
752 alldepend:: depend
753
754 distclean:
755         ./build/distclean.sh
756
757 .PHONY: all backup bootstrap camlp4opt camlp4out checkstack clean
758 .PHONY: partialclean beforedepend alldepend cleanboot coldstart
759 .PHONY: compare core coreall
760 .PHONY: coreboot defaultentry depend distclean install installopt
761 .PHONY: library library-cross libraryopt ocamlbuild-mixed-boot
762 .PHONY: ocamlbuild.byte ocamlbuild.native ocamldebugger ocamldoc
763 .PHONY: ocamldoc.opt ocamllex ocamllex.opt ocamltools ocamltools.opt
764 .PHONY: ocamlyacc opt-core opt opt.opt otherlibraries
765 .PHONY: otherlibrariesopt package-macosx promote promote-cross
766 .PHONY: restore runtime runtimeopt makeruntimeopt world world.opt
767
768 include .depend