forked from ocaml/ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
2729 lines (2227 loc) · 84.5 KB
/
Makefile
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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#**************************************************************************
#* *
#* OCaml *
#* *
#* Xavier Leroy, projet Cristal, INRIA Rocquencourt *
#* *
#* Copyright 1999 Institut National de Recherche en Informatique et *
#* en Automatique. *
#* *
#* All rights reserved. This file is distributed under the terms of *
#* the GNU Lesser General Public License version 2.1, with the *
#* special exception on linking described in the file LICENSE. *
#* *
#**************************************************************************
# The main Makefile
ROOTDIR = .
# NOTE: it is important that the OCAMLDEP and OCAMLLEX variables
# are defined *before* Makefile.common gets included, so that
# their local definitions here take precedence over their
# general shared definitions in Makefile.common.
OCAMLLEX ?= $(BOOT_OCAMLLEX)
include Makefile.common
include Makefile.best_binaries
.PHONY: defaultentry
defaultentry: $(DEFAULT_BUILD_TARGET)
include stdlib/StdlibModules
CAMLC = $(BOOT_OCAMLC) $(BOOT_STDLIBFLAGS) -use-prims runtime/primitives
CAMLOPT=$(OCAMLRUN) ./ocamlopt$(EXE) $(STDLIBFLAGS) -I otherlibs/dynlink
ARCHES=amd64 arm64 power s390x riscv
VPATH = utils parsing typing bytecomp file_formats lambda middle_end \
middle_end/closure middle_end/flambda middle_end/flambda/base_types \
asmcomp driver toplevel tools $(addprefix otherlibs/, $(ALL_OTHERLIBS))
INCLUDES = $(addprefix -I ,$(VPATH))
ifeq "$(strip $(NATDYNLINKOPTS))" ""
OCAML_NATDYNLINKOPTS=
else
OCAML_NATDYNLINKOPTS = -ccopt "$(NATDYNLINKOPTS)"
endif
OC_OCAMLDEPDIRS = $(VPATH)
# This list is passed to expunge, which accepts both uncapitalized and
# capitalized module names.
PERVASIVES=$(STDLIB_MODULES) outcometree topprinters topdirs toploop
LIBFILES=stdlib.cma std_exit.cmo *.cmi camlheader
COMPLIBDIR=$(LIBDIR)/compiler-libs
TOPINCLUDES=$(addprefix -I otherlibs/,$(filter-out %threads,$(OTHERLIBRARIES)))
expunge := expunge$(EXE)
# Targets and dependencies for the compilerlibs/*.{cma,cmxa} archives
utils_SOURCES = $(addprefix utils/, \
config.mli config.ml \
build_path_prefix_map.mli build_path_prefix_map.ml \
misc.mli misc.ml \
identifiable.mli identifiable.ml \
numbers.mli numbers.ml \
arg_helper.mli arg_helper.ml \
local_store.mli local_store.ml \
load_path.mli load_path.ml \
clflags.mli clflags.ml \
profile.mli profile.ml \
terminfo.mli terminfo.ml \
ccomp.mli ccomp.ml \
warnings.mli warnings.ml \
consistbl.mli consistbl.ml \
strongly_connected_components.mli strongly_connected_components.ml \
targetint.mli targetint.ml \
int_replace_polymorphic_compare.mli int_replace_polymorphic_compare.ml \
domainstate.mli domainstate.ml \
binutils.mli binutils.ml \
lazy_backtrack.mli lazy_backtrack.ml \
diffing.mli diffing.ml \
diffing_with_keys.mli diffing_with_keys.ml)
parsing_SOURCES = $(addprefix parsing/, \
location.mli location.ml \
unit_info.mli unit_info.ml \
asttypes.mli \
longident.mli longident.ml \
parsetree.mli \
docstrings.mli docstrings.ml \
syntaxerr.mli syntaxerr.ml \
ast_helper.mli ast_helper.ml \
ast_iterator.mli ast_iterator.ml \
builtin_attributes.mli builtin_attributes.ml \
camlinternalMenhirLib.mli camlinternalMenhirLib.ml \
parser.mly \
lexer.mll \
pprintast.mli pprintast.ml \
parse.mli parse.ml \
printast.mli printast.ml \
ast_mapper.mli ast_mapper.ml \
attr_helper.mli attr_helper.ml \
ast_invariants.mli ast_invariants.ml \
depend.mli depend.ml)
typing_SOURCES = \
typing/annot.mli \
typing/value_rec_types.mli \
typing/ident.mli typing/ident.ml \
typing/path.mli typing/path.ml \
typing/primitive.mli typing/primitive.ml \
typing/type_immediacy.mli typing/type_immediacy.ml \
typing/outcometree.mli \
typing/shape.mli typing/shape.ml \
typing/types.mli typing/types.ml \
typing/btype.mli typing/btype.ml \
typing/oprint.mli typing/oprint.ml \
typing/subst.mli typing/subst.ml \
typing/predef.mli typing/predef.ml \
typing/datarepr.mli typing/datarepr.ml \
file_formats/cmi_format.mli file_formats/cmi_format.ml \
typing/persistent_env.mli typing/persistent_env.ml \
typing/env.mli typing/env.ml \
typing/errortrace.mli typing/errortrace.ml \
typing/typedtree.mli typing/typedtree.ml \
typing/signature_group.mli typing/signature_group.ml \
typing/printtyped.mli typing/printtyped.ml \
typing/ctype.mli typing/ctype.ml \
typing/printtyp.mli typing/printtyp.ml \
typing/includeclass.mli typing/includeclass.ml \
typing/mtype.mli typing/mtype.ml \
typing/envaux.mli typing/envaux.ml \
typing/includecore.mli typing/includecore.ml \
typing/tast_iterator.mli typing/tast_iterator.ml \
typing/tast_mapper.mli typing/tast_mapper.ml \
typing/stypes.mli typing/stypes.ml \
file_formats/cmt_format.mli file_formats/cmt_format.ml \
typing/cmt2annot.mli typing/cmt2annot.ml \
typing/untypeast.mli typing/untypeast.ml \
typing/includemod.mli typing/includemod.ml \
typing/includemod_errorprinter.mli typing/includemod_errorprinter.ml \
typing/typetexp.mli typing/typetexp.ml \
typing/printpat.mli typing/printpat.ml \
typing/patterns.mli typing/patterns.ml \
typing/parmatch.mli typing/parmatch.ml \
typing/typedecl_properties.mli typing/typedecl_properties.ml \
typing/typedecl_variance.mli typing/typedecl_variance.ml \
typing/typedecl_unboxed.mli typing/typedecl_unboxed.ml \
typing/typedecl_immediacy.mli typing/typedecl_immediacy.ml \
typing/typedecl_separability.mli typing/typedecl_separability.ml \
typing/typeopt.mli typing/typeopt.ml \
typing/typedecl.mli typing/typedecl.ml \
typing/value_rec_check.mli typing/value_rec_check.ml \
typing/typecore.mli typing/typecore.ml \
typing/typeclass.mli typing/typeclass.ml \
typing/typemod.mli typing/typemod.ml
lambda_SOURCES = $(addprefix lambda/, \
debuginfo.mli debuginfo.ml \
lambda.mli lambda.ml \
printlambda.mli printlambda.ml \
switch.mli switch.ml \
matching.mli matching.ml \
translobj.mli translobj.ml \
translattribute.mli translattribute.ml \
translprim.mli translprim.ml \
translcore.mli translcore.ml \
translclass.mli translclass.ml \
translmod.mli translmod.ml \
tmc.mli tmc.ml \
simplif.mli simplif.ml \
runtimedef.mli runtimedef.ml)
comp_SOURCES = \
file_formats/cmo_format.mli \
file_formats/cmx_format.mli \
file_formats/cmxs_format.mli \
bytecomp/meta.mli bytecomp/meta.ml \
bytecomp/opcodes.mli bytecomp/opcodes.ml \
bytecomp/bytesections.mli bytecomp/bytesections.ml \
bytecomp/dll.mli bytecomp/dll.ml \
bytecomp/symtable.mli bytecomp/symtable.ml \
driver/pparse.mli driver/pparse.ml \
driver/compenv.mli driver/compenv.ml \
driver/main_args.mli driver/main_args.ml \
driver/compmisc.mli driver/compmisc.ml \
driver/makedepend.mli driver/makedepend.ml \
driver/compile_common.mli driver/compile_common.ml
# All file format descriptions (including cmx{,s}) are in the
# ocamlcommon library so that ocamlobjinfo can depend on them.
ocamlcommon_SOURCES = \
$(utils_SOURCES) $(parsing_SOURCES) $(typing_SOURCES) \
$(lambda_SOURCES) $(comp_SOURCES)
ocamlbytecomp_SOURCES = \
bytecomp/instruct.mli bytecomp/instruct.ml \
bytecomp/bytegen.mli bytecomp/bytegen.ml \
bytecomp/printinstr.mli bytecomp/printinstr.ml \
bytecomp/emitcode.mli bytecomp/emitcode.ml \
bytecomp/bytelink.mli bytecomp/bytelink.ml \
bytecomp/bytelibrarian.mli bytecomp/bytelibrarian.ml \
bytecomp/bytepackager.mli bytecomp/bytepackager.ml \
driver/errors.mli driver/errors.ml \
driver/compile.mli driver/compile.ml \
driver/maindriver.mli driver/maindriver.ml
intel_SOURCES = \
x86_ast.mli \
x86_proc.mli x86_proc.ml \
x86_dsl.mli x86_dsl.ml \
x86_gas.mli x86_gas.ml \
x86_masm.mli x86_masm.ml
asmcomp_SOURCES = \
$(addprefix asmcomp/, $(arch_specific_SOURCES)) \
asmcomp/arch.mli asmcomp/arch.ml \
asmcomp/cmm.mli asmcomp/cmm.ml \
asmcomp/printcmm.mli asmcomp/printcmm.ml \
asmcomp/reg.mli asmcomp/reg.ml \
asmcomp/mach.mli asmcomp/mach.ml \
asmcomp/proc.mli asmcomp/proc.ml \
asmcomp/strmatch.mli asmcomp/strmatch.ml \
asmcomp/cmmgen_state.mli asmcomp/cmmgen_state.ml \
asmcomp/cmm_helpers.mli asmcomp/cmm_helpers.ml \
asmcomp/afl_instrument.mli asmcomp/afl_instrument.ml \
asmcomp/thread_sanitizer.mli asmcomp/thread_sanitizer.ml \
asmcomp/cmmgen.mli asmcomp/cmmgen.ml \
asmcomp/cmm_invariants.mli asmcomp/cmm_invariants.ml \
asmcomp/interval.mli asmcomp/interval.ml \
asmcomp/printmach.mli asmcomp/printmach.ml \
asmcomp/dataflow.mli asmcomp/dataflow.ml \
asmcomp/polling.mli asmcomp/polling.ml \
asmcomp/selectgen.mli asmcomp/selectgen.ml \
asmcomp/selection.mli asmcomp/selection.ml \
asmcomp/comballoc.mli asmcomp/comballoc.ml \
asmcomp/CSEgen.mli asmcomp/CSEgen.ml \
asmcomp/CSE.mli asmcomp/CSE.ml \
asmcomp/liveness.mli asmcomp/liveness.ml \
asmcomp/spill.mli asmcomp/spill.ml \
asmcomp/split.mli asmcomp/split.ml \
asmcomp/interf.mli asmcomp/interf.ml \
asmcomp/coloring.mli asmcomp/coloring.ml \
asmcomp/linscan.mli asmcomp/linscan.ml \
asmcomp/reloadgen.mli asmcomp/reloadgen.ml \
asmcomp/reload.mli asmcomp/reload.ml \
asmcomp/deadcode.mli asmcomp/deadcode.ml \
asmcomp/stackframegen.mli asmcomp/stackframegen.ml \
asmcomp/stackframe.mli asmcomp/stackframe.ml \
asmcomp/linear.mli asmcomp/linear.ml \
asmcomp/printlinear.mli asmcomp/printlinear.ml \
asmcomp/linearize.mli asmcomp/linearize.ml \
file_formats/linear_format.mli file_formats/linear_format.ml \
asmcomp/schedgen.mli asmcomp/schedgen.ml \
asmcomp/scheduling.mli asmcomp/scheduling.ml \
asmcomp/branch_relaxation.mli asmcomp/branch_relaxation.ml \
asmcomp/emitaux.mli asmcomp/emitaux.ml \
asmcomp/emit.mli asmcomp/emit.ml \
asmcomp/asmgen.mli asmcomp/asmgen.ml \
asmcomp/asmlink.mli asmcomp/asmlink.ml \
asmcomp/asmlibrarian.mli asmcomp/asmlibrarian.ml \
asmcomp/asmpackager.mli asmcomp/asmpackager.ml \
driver/opterrors.mli driver/opterrors.ml \
driver/optcompile.mli driver/optcompile.ml \
driver/optmaindriver.mli driver/optmaindriver.ml
# Files under middle_end/ are not to reference files under asmcomp/.
# This ensures that the middle end can be linked (e.g. for objinfo) even when
# the native code compiler is not present for some particular target.
middle_end_closure_SOURCES = $(addprefix middle_end/closure/, \
closure.mli closure.ml \
closure_middle_end.mli closure_middle_end.ml)
# Owing to dependencies through [Compilenv], which would be
# difficult to remove, some of the lower parts of Flambda (anything that is
# saved in a .cmx file) have to be included in the [MIDDLE_END] stanza, below.
middle_end_flambda_SOURCES = \
$(addprefix middle_end/flambda/, \
import_approx.mli import_approx.ml \
lift_code.mli lift_code.ml \
closure_conversion_aux.mli closure_conversion_aux.ml \
closure_conversion.mli closure_conversion.ml \
initialize_symbol_to_let_symbol.mli initialize_symbol_to_let_symbol.ml \
lift_let_to_initialize_symbol.mli lift_let_to_initialize_symbol.ml \
find_recursive_functions.mli find_recursive_functions.ml \
invariant_params.mli invariant_params.ml \
inconstant_idents.mli inconstant_idents.ml \
alias_analysis.mli alias_analysis.ml \
lift_constants.mli lift_constants.ml \
share_constants.mli share_constants.ml \
simplify_common.mli simplify_common.ml \
remove_unused_arguments.mli remove_unused_arguments.ml \
remove_unused_closure_vars.mli remove_unused_closure_vars.ml \
remove_unused_program_constructs.mli remove_unused_program_constructs.ml \
simplify_boxed_integer_ops.mli simplify_boxed_integer_ops.ml \
simplify_primitives.mli simplify_primitives.ml \
inlining_stats_types.mli inlining_stats_types.ml \
inlining_stats.mli inlining_stats.ml \
inline_and_simplify_aux.mli inline_and_simplify_aux.ml \
inlining_decision_intf.mli \
remove_free_vars_equal_to_args.mli remove_free_vars_equal_to_args.ml \
extract_projections.mli extract_projections.ml \
augment_specialised_args.mli augment_specialised_args.ml \
unbox_free_vars_of_closures.mli unbox_free_vars_of_closures.ml \
unbox_specialised_args.mli unbox_specialised_args.ml \
unbox_closures.mli unbox_closures.ml \
inlining_transforms.mli inlining_transforms.ml \
inlining_decision.mli inlining_decision.ml \
inline_and_simplify.mli inline_and_simplify.ml \
ref_to_variables.mli ref_to_variables.ml \
flambda_invariants.mli flambda_invariants.ml \
traverse_for_exported_symbols.mli traverse_for_exported_symbols.ml \
build_export_info.mli build_export_info.ml \
closure_offsets.mli closure_offsets.ml \
un_anf.mli un_anf.ml \
flambda_to_clambda.mli flambda_to_clambda.ml \
flambda_middle_end.mli flambda_middle_end.ml \
simplify_boxed_integer_ops_intf.mli)
ocamlmiddleend_SOURCES = \
$(addprefix middle_end/, \
internal_variable_names.mli internal_variable_names.ml \
linkage_name.mli linkage_name.ml \
compilation_unit.mli compilation_unit.ml \
variable.mli variable.ml \
$(addprefix flambda/base_types/, \
closure_element.mli closure_element.ml \
closure_id.mli closure_id.ml) \
symbol.mli symbol.ml \
backend_var.mli backend_var.ml \
clambda_primitives.mli clambda_primitives.ml \
printclambda_primitives.mli printclambda_primitives.ml \
clambda.mli clambda.ml \
printclambda.mli printclambda.ml \
semantics_of_primitives.mli semantics_of_primitives.ml \
convert_primitives.mli convert_primitives.ml \
$(addprefix flambda/, \
$(addprefix base_types/, \
id_types.mli id_types.ml \
export_id.mli export_id.ml \
tag.mli tag.ml \
mutable_variable.mli mutable_variable.ml \
set_of_closures_id.mli set_of_closures_id.ml \
set_of_closures_origin.mli set_of_closures_origin.ml \
closure_origin.mli closure_origin.ml \
var_within_closure.mli var_within_closure.ml \
static_exception.mli static_exception.ml) \
pass_wrapper.mli pass_wrapper.ml \
allocated_const.mli allocated_const.ml \
parameter.mli parameter.ml \
projection.mli projection.ml \
flambda.mli flambda.ml \
flambda_iterators.mli flambda_iterators.ml \
flambda_utils.mli flambda_utils.ml \
freshening.mli freshening.ml \
effect_analysis.mli effect_analysis.ml \
inlining_cost.mli inlining_cost.ml \
simple_value_approx.mli simple_value_approx.ml \
export_info.mli export_info.ml \
export_info_for_pack.mli export_info_for_pack.ml) \
compilenv.mli compilenv.ml \
backend_intf.mli) \
$(middle_end_closure_SOURCES) \
$(middle_end_flambda_SOURCES)
ocamloptcomp_SOURCES = $(ocamlmiddleend_SOURCES) $(asmcomp_SOURCES)
ocamltoplevel_SOURCES = $(addprefix toplevel/, \
genprintval.mli genprintval.ml \
topcommon.mli topcommon.ml \
native/tophooks.mli native/tophooks.ml \
byte/topeval.mli byte/topeval.ml \
native/topeval.mli native/topeval.ml \
byte/trace.mli byte/trace.ml \
native/trace.mli native/trace.ml \
toploop.mli toploop.ml \
topprinters.mli topprinters.ml \
topdirs.mli topdirs.ml \
byte/topmain.mli byte/topmain.ml \
native/topmain.mli native/topmain.ml)
TOPLEVEL_SHARED_MLIS = topeval.mli trace.mli topmain.mli
TOPLEVEL_SHARED_CMIS = $(TOPLEVEL_SHARED_MLIS:%.mli=%.cmi)
TOPLEVEL_SHARED_ARTEFACTS = $(TOPLEVEL_SHARED_MLIS) $(TOPLEVEL_SHARED_CMIS)
$(addprefix toplevel/byte/, $(TOPLEVEL_SHARED_CMIS)):\
toplevel/byte/%.cmi: toplevel/%.cmi
cp $< toplevel/$*.mli $(@D)
$(addprefix toplevel/native/, $(TOPLEVEL_SHARED_CMIS)):\
toplevel/native/%.cmi: toplevel/%.cmi
cp $< toplevel/$*.mli $(@D)
beforedepend::
cd toplevel ; cp $(TOPLEVEL_SHARED_MLIS) byte/
cd toplevel ; cp $(TOPLEVEL_SHARED_MLIS) native/
partialclean::
cd toplevel/byte ; rm -f $(TOPLEVEL_SHARED_ARTEFACTS)
cd toplevel/native ; rm -f $(TOPLEVEL_SHARED_ARTEFACTS)
ALL_CONFIG_CMO = utils/config_main.cmo utils/config_boot.cmo
utils/config_%.mli: utils/config.mli
cp $^ $@
beforedepend:: utils/config_main.mli utils/config_boot.mli
$(addprefix compilerlibs/ocamlcommon., cma cmxa): \
OC_COMMON_LINKFLAGS += -linkall
partialclean::
rm -f compilerlibs/ocamlcommon.cma
partialclean::
rm -f compilerlibs/ocamlcommon.cmxa \
compilerlibs/ocamlcommon.a compilerlibs/ocamlcommon.lib
partialclean::
rm -f compilerlibs/ocamlbytecomp.cma
partialclean::
rm -f compilerlibs/ocamlbytecomp.cmxa \
compilerlibs/ocamlbytecomp.a compilerlibs/ocamlbytecomp.lib
partialclean::
rm -f compilerlibs/ocamlmiddleend.cma \
compilerlibs/ocamlmiddleend.cmxa \
compilerlibs/ocamlmiddleend.a \
compilerlibs/ocamlmiddleend.lib
partialclean::
rm -f compilerlibs/ocamloptcomp.cma
partialclean::
rm -f compilerlibs/ocamloptcomp.cmxa \
compilerlibs/ocamloptcomp.a compilerlibs/ocamloptcomp.lib
compilerlibs/ocamltoplevel.cma: VPATH += toplevel/byte
partialclean::
rm -f compilerlibs/ocamltoplevel.cma
compilerlibs/ocamltoplevel.cmxa: VPATH += toplevel/native
partialclean::
rm -f compilerlibs/ocamltoplevel.cmxa \
compilerlibs/ocamltoplevel.a compilerlibs/ocamltoplevel.lib
# The configuration file
utils/config.ml: \
utils/config_$(if $(filter true,$(IN_COREBOOT_CYCLE)),boot,main).ml
$(V_GEN)cp $< $@
utils/config_boot.ml: utils/config.fixed.ml utils/config.common.ml
$(V_GEN)cat $^ > $@
utils/config_main.ml: utils/config.generated.ml utils/config.common.ml
$(V_GEN)cat $^ > $@
.PHONY: reconfigure
reconfigure:
ac_read_git_config=true ./configure $(CONFIGURE_ARGS)
utils/domainstate.ml: utils/domainstate.ml.c runtime/caml/domain_state.tbl
$(V_GEN)$(CPP) -I runtime/caml $< > $@
utils/domainstate.mli: utils/domainstate.mli.c runtime/caml/domain_state.tbl
$(V_GEN)$(CPP) -I runtime/caml $< > $@
configure: tools/autogen configure.ac aclocal.m4 build-aux/ocaml_version.m4
$<
.PHONY: partialclean
partialclean::
rm -f utils/config.ml \
utils/config_main.ml utils/config_main.mli \
utils/config_boot.ml utils/config_boot.mli \
utils/domainstate.ml utils/domainstate.mli
.PHONY: beforedepend
beforedepend:: \
utils/config.ml utils/config_boot.ml utils/config_main.ml \
utils/domainstate.ml utils/domainstate.mli
ocamllex_PROGRAMS = $(addprefix lex/,ocamllex ocamllex.opt)
ocamlyacc_PROGRAM = yacc/ocamlyacc
# Tools to be compiled to native and bytecode, then installed
TOOLS_TO_INSTALL_NAT = ocamldep ocamlobjinfo
# Tools to be compiled to bytecode only, then installed
TOOLS_TO_INSTALL_BYT = \
ocamlcmt ocamlprof ocamlcp ocamlmklib ocamlmktop
ifeq "$(NATIVE_COMPILER)" "true"
TOOLS_TO_INSTALL_BYT += ocamloptp
endif
# Clean should remove tools/ocamloptp etc. unconditionally because
# the configuration is not available during clean so we don't
# know whether they have been configured / built or not
clean::
rm -f $(addprefix tools/ocamlopt,p p.opt p.exe p.opt.exe)
TOOLS_NAT = $(TOOLS_TO_INSTALL_NAT)
TOOLS_BYT = $(TOOLS_TO_INSTALL_BYT) dumpobj primreq stripdebug cmpbyt
TOOLS_NAT_PROGRAMS = $(addprefix tools/,$(TOOLS_NAT))
TOOLS_BYT_PROGRAMS = $(addprefix tools/,$(TOOLS_BYT))
TOOLS_MODULES = tools/profiling
# C programs
C_PROGRAMS = $(ocamlyacc_PROGRAM)
$(foreach PROGRAM, $(C_PROGRAMS),\
$(eval $(call PROGRAM_SYNONYM,$(PROGRAM))))
# OCaml programs that are compiled in both bytecode and native code
OCAML_PROGRAMS = ocamlc ocamlopt lex/ocamllex $(TOOLS_NAT_PROGRAMS) \
ocamldoc/ocamldoc ocamltest/ocamltest
$(foreach PROGRAM, $(OCAML_PROGRAMS),\
$(eval $(call OCAML_PROGRAM,$(PROGRAM))))
# OCaml programs that are compiled only in bytecode
# Note: the bytecode toplevel, ocaml, is a bytecode program but at the
# moment it's a special one, because it needs to be expunged, so we
# cannot declare it as we do for other bytecode-only programs.
# We have to use dedicated rules to build it
OCAML_BYTECODE_PROGRAMS = expunge \
$(TOOLS_BYT_PROGRAMS) \
$(addprefix tools/, cvt_emit make_opcodes ocamltex) \
$(OPTIONAL_BYTECODE_TOOLS)
$(foreach PROGRAM, $(OCAML_BYTECODE_PROGRAMS),\
$(eval $(call OCAML_BYTECODE_PROGRAM,$(PROGRAM))))
# OCaml programs that are compiled only in native code
OCAML_NATIVE_PROGRAMS = \
ocamlnat tools/lintapidiff.opt $(OPTIONAL_NATIVE_TOOLS)
$(foreach PROGRAM, $(OCAML_NATIVE_PROGRAMS),\
$(eval $(call OCAML_NATIVE_PROGRAM,$(PROGRAM))))
# OCaml libraries that are compiled in both bytecode and native code
# List of compilerlibs
COMPILERLIBS = $(addprefix compilerlibs/, \
ocamlbytecomp \
ocamlcommon \
ocamlmiddleend \
ocamloptcomp \
ocamltoplevel)
# Since the compiler libraries are necessarily compiled with boot/ocamlc,
# make sure they *always are*, even when rebuilding a program compiled
# with ./ocamlc (e.g. ocamltex)
$(COMPILERLIBS:=.cma): \
CAMLC = $(BOOT_OCAMLC) $(BOOT_STDLIBFLAGS) -use-prims runtime/primitives
# The following dependency ensures that the two versions of the
# configuration module (the one for the bootstrap compiler and the
# one for the compiler to be installed) are compiled. This is to make
# sure these two versions remain in sync with each other
compilerlibs/ocamlcommon.cma: $(ALL_CONFIG_CMO)
OCAML_LIBRARIES = $(COMPILERLIBS) $(OPTIONAL_LIBRARIES)
$(foreach LIBRARY, $(OCAML_LIBRARIES),\
$(eval $(call OCAML_LIBRARY,$(LIBRARY))))
# OCaml libraries that are compiled only in bytecode
OCAML_BYTECODE_LIBRARIES =
$(foreach LIBRARY, $(OCAML_BYTECODE_LIBRARIES),\
$(eval $(call OCAML_BYTECODE_LIBRARY,$(LIBRARY))))
# OCaml libraries that are compiled only in native code
OCAML_NATIVE_LIBRARIES =
$(foreach LIBRARY, $(OCAML_NATIVE_LIBRARIES),\
$(eval $(call OCAML_NATIVE_LIBRARY,$(LIBRARY))))
USE_RUNTIME_PRIMS = -use-prims ../runtime/primitives
USE_STDLIB = -nostdlib -I ../stdlib
FLEXDLL_OBJECTS = \
flexdll_$(FLEXDLL_CHAIN).$(O) flexdll_initer_$(FLEXDLL_CHAIN).$(O)
FLEXLINK_BUILD_ENV = \
MSVC_DETECT=0 OCAML_CONFIG_FILE=../Makefile.config \
CHAINS=$(FLEXDLL_CHAIN) ROOTDIR=..
FLEXDLL_SOURCES = \
$(addprefix $(FLEXDLL_SOURCE_DIR)/, flexdll.c flexdll_initer.c flexdll.h) \
$(wildcard $(FLEXDLL_SOURCE_DIR)/*.ml*)
$(BYTE_BINDIR) $(OPT_BINDIR):
$(MKDIR) $@
flexlink.byte$(EXE): $(FLEXDLL_SOURCES)
rm -f $(FLEXDLL_SOURCE_DIR)/flexlink.exe
$(MAKE) -C $(FLEXDLL_SOURCE_DIR) $(FLEXLINK_BUILD_ENV) \
OCAMLRUN='$$(ROOTDIR)/boot/ocamlrun$(EXE)' NATDYNLINK=false \
OCAMLOPT='$(value BOOT_OCAMLC) $(USE_RUNTIME_PRIMS) $(USE_STDLIB)' \
flexlink.exe support
cp $(FLEXDLL_SOURCE_DIR)/flexlink.exe $@
partialclean::
rm -f flexlink.byte flexlink.byte.exe
$(BYTE_BINDIR)/flexlink$(EXE): \
boot/ocamlrun$(EXE) flexlink.byte$(EXE) | $(BYTE_BINDIR)
rm -f $@
# Start with a copy to ensure that the result is always executable
cp boot/ocamlrun$(EXE) $@
cat flexlink.byte$(EXE) >> $@
cp $(addprefix $(FLEXDLL_SOURCE_DIR)/, $(FLEXDLL_OBJECTS)) $(BYTE_BINDIR)
partialclean::
rm -f $(BYTE_BINDIR)/flexlink $(BYTE_BINDIR)/flexlink.exe
ifeq "$(BOOTSTRAPPING_FLEXDLL)" "true"
# The recipe for runtime/ocamlruns$(EXE) also produces runtime/primitives
boot/ocamlrun$(EXE): runtime/ocamlruns$(EXE)
$(foreach runtime, ocamlrun ocamlrund ocamlruni, \
$(eval runtime/$(runtime)$(EXE): | $(BYTE_BINDIR)/flexlink$(EXE)))
tools/checkstack$(EXE): | $(BYTE_BINDIR)/flexlink$(EXE)
else
boot/ocamlrun$(EXE): runtime/ocamlrun$(EXE) runtime/primitives
endif
# $< refers to runtime/ocamlruns when bootstrapping flexlink and
# runtime/ocamlrun otherwise (see above).
boot/ocamlrun$(EXE):
cp $< $@
# Start up the system from the distribution compiler
.PHONY: coldstart
coldstart: boot/ocamlrun$(EXE) runtime/libcamlrun.$(A)
$(MAKE) -C stdlib OCAMLRUN='$$(ROOTDIR)/$<' \
CAMLC='$$(BOOT_OCAMLC) $(USE_RUNTIME_PRIMS)' all
rm -f $(addprefix boot/, libcamlrun.$(A) $(LIBFILES))
cp $(addprefix stdlib/, $(LIBFILES)) boot
cd boot; $(LN) ../runtime/libcamlrun.$(A) .
# Recompile the core system using the bootstrap compiler
.PHONY: coreall
coreall: runtime
$(MAKE) ocamlc
$(MAKE) ocamllex ocamltools library
# Build the core system: the minimum needed to make depend and bootstrap
.PHONY: core
core: coldstart
$(MAKE) coreall
# Check if fixpoint reached
# We use tools/cmpbyt because it has better error reporting, but cmp could also
# be used.
CMPCMD ?= $(OCAMLRUN) tools/cmpbyt$(EXE)
.PHONY: compare
compare:
# The core system has to be rebuilt after bootstrap anyway, so strip ocamlc
# and ocamllex, which means the artefacts should be identical.
mv ocamlc$(EXE) ocamlc.tmp
$(OCAMLRUN) tools/stripdebug -all ocamlc.tmp ocamlc$(EXE)
mv lex/ocamllex$(EXE) ocamllex.tmp
$(OCAMLRUN) tools/stripdebug -all ocamllex.tmp lex/ocamllex$(EXE)
rm -f ocamllex.tmp ocamlc.tmp
@if $(CMPCMD) boot/ocamlc ocamlc$(EXE) \
&& $(CMPCMD) boot/ocamllex lex/ocamllex$(EXE); \
then echo "Fixpoint reached, bootstrap succeeded."; \
else \
echo "Fixpoint not reached, try one more bootstrapping cycle."; \
exit 1; \
fi
# Promote a compiler
PROMOTE ?= cp
.PHONY: promote-common
promote-common:
$(PROMOTE) ocamlc$(EXE) boot/ocamlc
$(PROMOTE) lex/ocamllex$(EXE) boot/ocamllex
cd stdlib; cp $(LIBFILES) ../boot
# Promote the newly compiled system to the rank of cross compiler
# (Runs on the old runtime, produces code for the new runtime)
.PHONY: promote-cross
promote-cross: promote-common
# Promote the newly compiled system to the rank of bootstrap compiler
# (Runs on the new runtime, produces code for the new runtime)
.PHONY: promote
promote: PROMOTE = $(OCAMLRUN) tools/stripdebug -all
promote: promote-common
rm -f boot/ocamlrun$(EXE)
cp runtime/ocamlrun$(EXE) boot/ocamlrun$(EXE)
# Compile the native-code compiler
.PHONY: opt-core
opt-core: runtimeopt
$(MAKE) ocamlopt
$(MAKE) libraryopt
.PHONY: opt
opt: checknative
$(MAKE) runtimeopt
$(MAKE) ocamlopt
$(MAKE) libraryopt
$(MAKE) otherlibrariesopt ocamltoolsopt
# Native-code versions of the tools
.PHONY: opt.opt
opt.opt: checknative
$(MAKE) checkstack
$(MAKE) coreall
$(MAKE) ocaml
$(MAKE) opt-core
ifeq "$(BOOTSTRAPPING_FLEXDLL)" "true"
$(MAKE) flexlink.opt$(EXE)
endif
$(MAKE) ocamlc.opt
# TODO: introduce OPTIONAL_LIBRARIES and OPTIONAL_TOOLS variables to be
# computed at configure time to keep track of which tools and libraries
# need to be built
$(MAKE) otherlibraries $(WITH_DEBUGGER) $(OCAMLDOC_TARGET) \
$(OCAMLTEST_TARGET)
$(MAKE) ocamlopt.opt
$(MAKE) otherlibrariesopt
$(MAKE) ocamllex.opt ocamltoolsopt ocamltoolsopt.opt \
$(OCAMLDOC_OPT_TARGET) \
$(OCAMLTEST_OPT_TARGET) othertools ocamlnat
ifeq "$(build_libraries_manpages)" "true"
$(MAKE) manpages
endif
# Core bootstrapping cycle
.PHONY: coreboot
ifeq "$(FLAT_FLOAT_ARRAY)" "true"
coreboot:
# Promote the new compiler but keep the old runtime
# This compiler runs on boot/ocamlrun and produces bytecode for
# runtime/ocamlrun
$(MAKE) promote-cross
# Rebuild ocamlc and ocamllex (run on runtime/ocamlrun)
# utils/config.ml will have the fixed bootstrap configuration
$(MAKE) partialclean
$(MAKE) IN_COREBOOT_CYCLE=true ocamlc ocamllex ocamltools
# Rebuild the library (using runtime/ocamlrun ./ocamlc)
$(MAKE) library-cross
# Promote the new compiler and the new runtime
$(MAKE) OCAMLRUN=runtime/ocamlrun$(EXE) promote
# Rebuild the core system
# utils/config.ml must still have the fixed bootstrap configuration
$(MAKE) partialclean
$(MAKE) IN_COREBOOT_CYCLE=true core
# Check if fixpoint reached
$(MAKE) compare
else
coreboot:
$(error Cannot bootstrap when configured with \
--disable-flat-float-array)
endif
# Recompile the system using the bootstrap compiler
.PHONY: all
all: coreall
$(MAKE) ocaml
$(MAKE) otherlibraries $(WITH_DEBUGGER) $(OCAMLDOC_TARGET) \
$(OCAMLTEST_TARGET)
$(MAKE) othertools
ifeq "$(build_libraries_manpages)" "true"
$(MAKE) manpages
endif
# Bootstrap and rebuild the whole system.
# The compilation of ocaml will fail if the runtime has changed.
# Never mind, just do make bootstrap to reach fixpoint again.
.PHONY: bootstrap
bootstrap: coreboot
# utils/config.ml must be restored to config.status's configuration
# lex/ocamllex$(EXE) was stripped in order to compare it
rm -f utils/config.ml lex/ocamllex$(EXE)
$(MAKE) all
# Compile everything the first time
.PHONY: world
world: coldstart
$(MAKE) all
# Compile also native code compiler and libraries, fast
.PHONY: world.opt
world.opt: checknative
$(MAKE) coldstart
$(MAKE) opt.opt
# FlexDLL sources missing error messages
# Different git mechanism displayed depending on whether this source tree came
# from a git clone or a source tarball.
.PHONY: flexdll flexlink flexlink.opt
ifeq "$(BOOTSTRAPPING_FLEXDLL)" "true"
.PHONY: flexdll
flexdll: flexdll/Makefile
@echo WARNING! make flexdll is no longer required
@echo This target will be removed in a future release.
.PHONY: flexlink
flexlink:
@echo Bootstrapping just flexlink.exe is no longer supported
@echo Bootstrapping FlexDLL is now enabled with
@echo ./configure --with-flexdll
@false
ifeq "$(wildcard ocamlopt.opt$(EXE))" ""
FLEXLINK_OCAMLOPT=../runtime/ocamlrun$(EXE) ../ocamlopt$(EXE)
else
FLEXLINK_OCAMLOPT=../ocamlopt.opt$(EXE)
endif
flexlink.opt$(EXE): \
$(FLEXDLL_SOURCES) | $(BYTE_BINDIR)/flexlink$(EXE) $(OPT_BINDIR)
rm -f $(FLEXDLL_SOURCE_DIR)/flexlink.exe
$(MAKE) -C $(FLEXDLL_SOURCE_DIR) $(FLEXLINK_BUILD_ENV) \
OCAMLOPT='$(FLEXLINK_OCAMLOPT) -nostdlib -I ../stdlib' flexlink.exe
cp $(FLEXDLL_SOURCE_DIR)/flexlink.exe $@
rm -f $(OPT_BINDIR)/flexlink$(EXE)
cd $(OPT_BINDIR); $(LN) $(call ROOT_FROM, $(OPT_BINDIR))/$@ flexlink$(EXE)
cp $(addprefix $(BYTE_BINDIR)/, $(FLEXDLL_OBJECTS)) $(OPT_BINDIR)
partialclean::
rm -f flexlink.opt$(EXE) $(OPT_BINDIR)/flexlink$(EXE)
else
flexdll flexlink flexlink.opt:
@echo It is no longer necessary to bootstrap FlexDLL with a separate
@echo make invocation. Simply place the sources for FlexDLL in a
@echo sub-directory.
@echo This can either be done by downloading a source tarball from
@echo \ https://github.com/alainfrisch/flexdll/releases
@if [ -d .git ]; then \
echo or by checking out the flexdll submodule with; \
echo \ git submodule update --init; \
else \
echo or by cloning the git repository; \
echo \ git clone https://github.com/alainfrisch/flexdll.git; \
fi
@echo "Then pass --with-flexdll=<dir> to configure and build as normal."
@false
endif # ifeq "$(BOOTSTRAPPING_FLEXDLL)" "true"
INSTALL_COMPLIBDIR = $(DESTDIR)$(COMPLIBDIR)
INSTALL_FLEXDLLDIR = $(INSTALL_LIBDIR)/flexdll
FLEXDLL_MANIFEST = default_$(ARCH).manifest
DOC_FILES=\
Changes \
README.adoc \
README.win32.adoc \
LICENSE
# Run all tests
.PHONY: tests
tests:
$(MAKE) -C testsuite all
# Make clean in the test suite
.PHONY: clean
clean::
$(MAKE) -C testsuite clean
# Build the manual latex files from the etex source files
# (see manual/README.md)
.PHONY: manual-pregen
manual-pregen: opt.opt
cd manual; $(MAKE) clean && $(MAKE) pregen-etex
clean::
$(MAKE) -C manual clean
# The clean target
clean:: partialclean
rm -f configure~
rm -f $(C_PROGRAMS) $(C_PROGRAMS:=.exe)
rm -f $(OCAML_PROGRAMS) $(OCAML_PROGRAMS:=.exe)
rm -f $(OCAML_PROGRAMS:=.opt) $(OCAML_PROGRAMS:=.opt.exe)
rm -f $(OCAML_BYTECODE_PROGRAMS) $(OCAML_BYTECODE_PROGRAMS:=.exe)
rm -f $(OCAML_NATIVE_PROGRAMS) $(OCAML_NATIVE_PROGRAMS:=.exe)
# The bytecode compiler
ocamlc_LIBRARIES = $(addprefix compilerlibs/,ocamlcommon ocamlbytecomp)
ocamlc_SOURCES = driver/main.mli driver/main.ml
ocamlc$(EXE): OC_BYTECODE_LINKFLAGS += -compat-32 -g
ocamlc.opt$(EXE): OC_NATIVE_LINKFLAGS += $(addprefix -cclib ,$(BYTECCLIBS))
partialclean::
rm -f ocamlc ocamlc.exe ocamlc.opt ocamlc.opt.exe
# The native-code compiler
ocamlopt_LIBRARIES = $(addprefix compilerlibs/,ocamlcommon ocamloptcomp)
ocamlopt_SOURCES = driver/optmain.mli driver/optmain.ml
ocamlopt$(EXE): OC_BYTECODE_LINKFLAGS += -g
partialclean::
rm -f ocamlopt ocamlopt.exe ocamlopt.opt ocamlopt.opt.exe
# The toplevel
# At the moment, the toplevel can't be built with the general build macros
# because its build involves calling expunge. We thus give its build
# rules explicitly until the day expunge can hopefully be removed.
ocaml_LIBRARIES = \
$(addprefix compilerlibs/,ocamlcommon ocamlbytecomp ocamltoplevel)
ocaml_CMA_FILES = $(ocaml_LIBRARIES:=.cma)
ocaml_SOURCES = toplevel/topstart.mli toplevel/topstart.ml
ocaml_CMO_FILES = toplevel/topstart.cmo
.INTERMEDIATE: ocaml.tmp
ocaml.tmp: OC_BYTECODE_LINKFLAGS += -I toplevel/byte -linkall -g
ocaml.tmp: $(ocaml_CMA_FILES) $(ocaml_CMO_FILES)
$(V_LINKC)$(LINK_BYTECODE_PROGRAM) -o $@ $^
$(eval $(call PROGRAM_SYNONYM,ocaml))
ocaml$(EXE): $(expunge) ocaml.tmp
- $(V_GEN)$(OCAMLRUN) $^ $@ $(PERVASIVES)
partialclean::
rm -f ocaml ocaml.exe
# Use TOPFLAGS to pass additional flags to the bytecode or native toplevel
# when running make runtop or make natruntop
TOPFLAGS ?=
OC_TOPFLAGS = $(STDLIBFLAGS) -I toplevel -noinit $(TOPINCLUDES) $(TOPFLAGS)
RUN_OCAML = $(RLWRAP) $(OCAMLRUN) ./ocaml$(EXE) $(OC_TOPFLAGS)
RUN_OCAMLNAT = $(RLWRAP) ./ocamlnat$(EXE) $(OC_TOPFLAGS)
# Note: Beware that, since these rules begin with a coldstart, both
# boot/ocamlrun and runtime/ocamlrun will be the same when the toplevel
# is run.
.PHONY: runtop
runtop: coldstart
$(MAKE) ocamlc
$(MAKE) ocaml
@$(RUN_OCAML)
.PHONY: runtop-with-otherlibs
runtop-with-otherlibs: coldstart
$(MAKE) ocamlc
$(MAKE) otherlibraries
$(MAKE) ocaml
@$(RUN_OCAML)
.PHONY: natruntop
natruntop:
$(MAKE) core
$(MAKE) opt
$(MAKE) ocamlnat
@$(RUN_OCAMLNAT)