···382382383383### Build system:
384384385385-- #12198, #12321: continue the merge of the sub-makefiles into the root Makefile
386386- started with #11243, #11248, #11268, #11420 and #11675.
385385+- #12198, #12321, #12586: continue the merge of the sub-makefiles
386386+ into the root Makefile started with #11243, #11248, #11268, #11420
387387+ and #11675.
387388 (Sébastien Hinderer, review by David Allsopp and Florian Angeletti)
388389389390- #12569, #12570: remove 'otherlibraries' as a prerequisite for 'runtop';
···151151# Platform-dependent module for ocamlyacc
152152ocamlyacc_WSTR_MODULE = @ocamlyacc_wstr_module@
153153154154+# Architecture-specific modules, if any
155155+arch_specific_SOURCES = @arch_specific_SOURCES@
156156+154157# ThreadSanitizer support enabled
155158TSAN=@tsan@
156159# Contains TSan-specific runtime files, or nothing if TSan support is
+107-15
Makefile.common
···231231MERGEMANIFESTEXE = $(call if_file_exists, $(1).manifest, \
232232 mt -nologo -outputresource:$(1) -manifest $(1).manifest)
233233234234-# Macros and rules to compile OCaml programs
234234+# Macros and rules to compile OCaml programs and libraries
235235+236236+# The following variable is used to accumulate a list of all the CMX
237237+# files that get built. Is is then used in the root Makefile to express
238238+# the dependency on all these files on the native compiler, so that
239239+# they get rebuilt if the native compiler is updated
240240+241241+ALL_CMX_FILES =
235242236243# We use secondary expansion here so that variables like
237244# foo_LIBRARIES and foo_SOURCES can be defined after the calls
···240247241248.SECONDEXPANSION:
242249243243-# Each program foo is characterised by the foo_LIBRARIES and foo_SOURCES
244244-# variables. The following macros provide the infrastructure to build foo
245245-# from the object files whose names are derived from these two
246246-# varialbes. In particular, the following macros define several
247247-# variables whose names are prefixed with foo_ to compute the
248248-# different lists of files used to build foo.
250250+# Definitions that are common to both programs and libraries
249251250250-# The first macro, _OCAML_PROGRAM_BASE, is a private macro (hence the _ at the
251251-# beginning of its name) which defines foo_ variables common to both
252252-# bytecode and native programs. The next two macros, OCAML_BYTECODE_PROGRAM
253253-# and OCAML_NATIVE_PROGRAM are used to define programs that are provided
254254-# only in bytecode or native form, respectively. Programs provided
255255-# in both forms should use OCAML_PROGRAM.
256256-257257-define _OCAML_PROGRAM_BASE
252252+define _OCAML_COMMON_BASE
258253$(basename $(notdir $(1)))_C_FILES = \
259254 $$(filter %.c, $$($(basename $(notdir $(1)))_SOURCES))
260255$(basename $(notdir $(1)))_MLI_FILES = \
261256 $$(filter %.mli, \
262257 $$(subst .mly,.mli,\
263258 $$($(basename $(notdir $(1)))_SOURCES)))
259259+$(basename $(notdir $(1)))_CMI_FILES = \
260260+ $$(subst .mli,.cmi,$$($(basename $(notdir $(1)))_MLI_FILES))
264261$(basename $(notdir $(1)))_ML_FILES = \
265262 $$(filter %.ml, \
266263 $$(subst .ml.in,.ml,$$(subst .mll,.ml,$$(subst .mly,.ml,\
···280277$(basename $(notdir $(1)))_GENERATED_FILES = \
281278 $$($(basename $(notdir $(1)))_SECONDARY_FILES) \
282279 $$(patsubst %.mly,%.output, $$($(basename $(notdir $(1)))_MLY_FILES))
280280+endef # _OCAML_COMMON_BASE
281281+282282+# Macros to build OCaml programs
283283+284284+# Each program foo is characterised by the foo_LIBRARIES and foo_SOURCES
285285+# variables. The following macros provide the infrastructure to build foo
286286+# from the object files whose names are derived from these two
287287+# varialbes. In particular, the following macros define several
288288+# variables whose names are prefixed with foo_ to compute the
289289+# different lists of files used to build foo.
290290+291291+# The first macro, _OCAML_PROGRAM_BASE, is a private macro (hence the _ at the
292292+# beginning of its name) which defines foo_ variables common to both
293293+# bytecode and native programs. The next two macros, OCAML_BYTECODE_PROGRAM
294294+# and OCAML_NATIVE_PROGRAM are used to define programs that are provided
295295+# only in bytecode or native form, respectively. Programs provided
296296+# in both forms should use OCAML_PROGRAM.
297297+298298+define _OCAML_PROGRAM_BASE
299299+$(eval $(call _OCAML_COMMON_BASE,$(1)))
283300endef # _OCAML_PROGRAM_BASE
284301285302LINK_BYTECODE_PROGRAM =\
···323340 $$(patsubst %.c,%.n.$(O), $$($(basename $(notdir $(1)))_C_FILES))
324341$(basename $(notdir $(1)))_CMX_FILES = \
325342 $$(patsubst %.ml,%.cmx, $$($(basename $(notdir $(1)))_ML_FILES))
343343+ALL_CMX_FILES += $$($(basename $(notdir $(1)))_CMX_FILES)
326344$(basename $(notdir $(1)))_NCOBJS = \
327345 $$($(basename $(notdir $(1)))_CMXA_FILES) \
328346 $$($(basename $(notdir $(1)))_NO_FILES) \
···342360$(eval $(call _OCAML_BYTECODE_PROGRAM,$(1)))
343361$(eval $(call _OCAML_NATIVE_PROGRAM,$(1).opt))
344362endef # OCAML_PROGRAM
363363+364364+# Macros for OCaml libraries, similar to those for OCaml programs
365365+366366+define _OCAML_LIBRARY_BASE
367367+$(eval $(call _OCAML_COMMON_BASE,$(1)))
368368+endef # _OCAML_LIBRARY_BASE
369369+370370+LINK_BYTECODE_LIBRARY =\
371371+ $(CAMLC) $(OC_COMMON_LINKFLAGS) $(OC_BYTECODE_LINKFLAGS)
372372+373373+# The _OCAML_BYTECODE_LIBRARY macro defines a bytecode library but assuming
374374+# that _OCAML_LIBRARY_BASE has already been called. Its public counterpart
375375+# does not rely on this assumption and rather does call _OCAML_LIBRARY_BASE
376376+# itself.
377377+378378+define _OCAML_BYTECODE_LIBRARY
379379+$(basename $(notdir $(1)))_BYTE_CMI_FILES = \
380380+ $$(foreach F,$$($(basename $(notdir $(1)))_CMI_FILES),\
381381+ $$(if $$(findstring /native/,$$(F)),,$$(F)))
382382+$(basename $(notdir $(1)))_BO_FILES = \
383383+ $$(patsubst %.c,%.b.$(O), $$($(basename $(notdir $(1)))_C_FILES))
384384+$(basename $(notdir $(1)))_CMO_FILES = \
385385+ $$(patsubst %.ml,%.cmo, \
386386+ $$(foreach F,$$($(basename $(notdir $(1)))_ML_FILES),\
387387+ $$(if $$(findstring /native/,$$(F)),,$$(F))))
388388+$(basename $(notdir $(1)))_BCOBJS = \
389389+ $$($(basename $(notdir $(1)))_BO_FILES) \
390390+ $$($(basename $(notdir $(1)))_CMO_FILES)
391391+$(1).cma: \
392392+ $$$$($(basename $(notdir $(1)))_BYTE_CMI_FILES) \
393393+ $$$$($(basename $(notdir $(1)))_BCOBJS)
394394+ $$(V_LINKC)$$(LINK_BYTECODE_LIBRARY) -a -o $$@ \
395395+ $$($(basename $(notdir $(1)))_BCOBJS)
396396+endef # _OCAML_BYTECODE_LIBRARY
397397+398398+define OCAML_BYTECODE_LIBRARY
399399+$(eval $(call _OCAML_LIBRARY_BASE,$(1)))
400400+$(eval $(call _OCAML_BYTECODE_LIBRARY,$(1)))
401401+endef # OCAML_BYTECODE_LIBRARY
402402+403403+LINK_NATIVE_LIBRARY =\
404404+ $(CAMLOPT) $(OC_COMMON_LINKFLAGS) $(OC_NATIVE_LINKFLAGS)
405405+406406+define _OCAML_NATIVE_LIBRARY
407407+$(basename $(notdir $(1)))_NATIVE_CMI_FILES = \
408408+ $$(foreach F,$$($(basename $(notdir $(1)))_CMI_FILES),\
409409+ $$(if $$(findstring /byte/,$$(F)),,$$(F)))
410410+$(basename $(notdir $(1)))_NO_FILES = \
411411+ $$(patsubst %.c,%.n.$(O), $$($(basename $(notdir $(1)))_C_FILES))
412412+$(basename $(notdir $(1)))_CMX_FILES = \
413413+ $$(patsubst %.ml,%.cmx, \
414414+ $$(foreach F,$$($(basename $(notdir $(1)))_ML_FILES),\
415415+ $$(if $$(findstring /byte/,$$(F)),,$$(F))))
416416+ALL_CMX_FILES += $$($(basename $(notdir $(1)))_CMX_FILES)
417417+$(basename $(notdir $(1)))_NCOBJS = \
418418+ $$($(basename $(notdir $(1)))_NO_FILES) \
419419+ $$($(basename $(notdir $(1)))_CMX_FILES)
420420+$(1).cmxa: \
421421+ $$$$($(basename $(notdir $(1)))_NATIVE_CMI_FILES) \
422422+ $$$$($(basename $(notdir $(1)))_NCOBJS)
423423+ $$(V_LINKOPT)$$(LINK_NATIVE_LIBRARY) -a -o $$@ \
424424+ $$($(basename $(notdir $(1)))_NCOBJS)
425425+endef # _OCAML_NATIVE_LIBRARY
426426+427427+define OCAML_NATIVE_LIBRARY
428428+$(eval $(call _OCAML_LIBRARY_BASE,$(1)))
429429+$(eval $(call _OCAML_NATIVE_LIBRARY,$(1)))
430430+endef # OCAML_NATIVE_LIBRARY
431431+432432+define OCAML_LIBRARY
433433+$(eval $(call _OCAML_LIBRARY_BASE,$(1)))
434434+$(eval $(call _OCAML_BYTECODE_LIBRARY,$(1)))
435435+$(eval $(call _OCAML_NATIVE_LIBRARY,$(1)))
436436+endef # OCAML_LIBRARY
345437346438# Installing a bytecode executable, with debug information removed
347439define INSTALL_STRIPPED_BYTE_PROG