Debian Codegraph @

stdlib/Makefile

raw symbols SCIP
1 #**************************************************************************
2 #* *
3 #* OCaml *
4 #* *
5 #* Xavier Leroy, projet Cristal, INRIA Rocquencourt *
6 #* *
7 #* Copyright 1999 Institut National de Recherche en Informatique et *
8 #* en Automatique. *
9 #* *
10 #* All rights reserved. This file is distributed under the terms of *
11 #* the GNU Lesser General Public License version 2.1, with the *
12 #* special exception on linking described in the file LICENSE. *
13 #* *
14 #**************************************************************************
15
16 ROOTDIR = ..
17 # NOTE: it is important that the OCAMLDEP variable is defined *before*
18 # Makefile.common gets included, so that its local definition here
19 # take precedence over its general shared definitions in Makefile.common.
20 OCAMLDEP ?= $(BOOT_OCAMLDEP)
21
22 include $(ROOTDIR)/Makefile.common
23
24 # There are three ways the Standard Library is compiled in bytecode:
25 # 1. During coldstart
26 # - using ../boot/ocamlc which runs on ../boot/ocamlrun
27 # 2. During coreall (via library),
28 # - using ../ocamlc which runs on ../boot/ocamlrun
29 # 3. During coreboot (via library-cross),
30 # - using ../ocamlc which at that point runs on ../runtime/ocamlrun
31 # If $(USE_BOOT_OCAMLC) is non-empty, we select case 1 and use $(BOOT_OCAMLC).
32 # Otherwise, we use $(OCAMLRUN) ../ocamlc, with $(OCAMLRUN) being
33 # ../boot/ocamlrun by default, but able to overridden by library-cross to
34 # ../runtime/ocamlrun.
35 USE_BOOT_OCAMLC ?=
36
37 ifeq "$(USE_BOOT_OCAMLC)" ""
38 CAMLC = $(OCAMLRUN) $(ROOTDIR)/ocamlc$(EXE)
39 else
40 CAMLC = $(BOOT_OCAMLC)
41 endif
42 COMPFLAGS = -strict-sequence -absname -w +a-4-9-41-42-44-45-48 \
43 -g -warn-error +A -bin-annot -nostdlib -principal
44 ifeq "$(FLAMBDA)" "true"
45 OPTCOMPFLAGS += -O3
46 endif
47 OPTCOMPILER=$(ROOTDIR)/ocamlopt$(EXE)
48 CAMLOPT=$(OCAMLRUN) $(OPTCOMPILER)
49
50 include StdlibModules
51
52 OBJS=$(addsuffix .cmo,$(STDLIB_MODULES))
53 NOSTDLIB= camlinternalFormatBasics.cmo stdlib.cmo
54 OTHERS=$(filter-out $(NOSTDLIB),$(OBJS))
55
56 .PHONY: all
57 all: stdlib.cma std_exit.cmo $(HEADER_NAME) target_$(HEADER_NAME)
58
59 .PHONY: allopt opt.opt # allopt and opt.opt are synonyms
60 allopt: stdlib.cmxa std_exit.cmx
61 opt.opt: allopt
62
63 INSTALL_STDLIB_META_DIR=$(DESTDIR)$(LIBDIR)/stdlib
64
65 .PHONY: install
66 install::
67 $(INSTALL_DATA) \
68 stdlib.cma std_exit.cmo *.cmi "$(INSTALL_LIBDIR)"
69 $(MKDIR) "$(INSTALL_STDLIB_META_DIR)"
70 $(INSTALL_DATA) META "$(INSTALL_STDLIB_META_DIR)"
71 ifeq "$(INSTALL_SOURCE_ARTIFACTS)" "true"
72 $(INSTALL_DATA) \
73 *.cmt *.cmti *.mli *.ml *.ml.in \
74 "$(INSTALL_LIBDIR)"
75 endif
76 $(INSTALL_DATA) target_$(HEADER_NAME) "$(INSTALL_LIBDIR)/$(HEADER_NAME)"
77
78 .PHONY: installopt
79 installopt: installopt-default
80
81 .PHONY: installopt-default
82 installopt-default:
83 $(INSTALL_DATA) \
84 stdlib.cmxa stdlib.$(A) std_exit.$(O) *.cmx \
85 "$(INSTALL_LIBDIR)"
86
87 ifeq "$(UNIX_OR_WIN32)" "unix"
88 HEADERPROGRAM = header
89 else # Windows
90 HEADERPROGRAM = headernt
91 endif
92
93 %-launch-info: %.info tmpheader.exe
94 @cat $^ >> $@
95
96 .INTERMEDIATE: tmpheader.exe
97 tmpheader.exe: $(HEADERPROGRAM).$(O)
98 $(V_MKEXE)$(call MKEXE_VIA_CC,$@,$^)
99 $(STRIP) $@
100
101 stdlib.cma: $(OBJS)
102 $(V_LINKC)$(CAMLC) -a -o $@ $^
103
104 stdlib.cmxa: $(OBJS:.cmo=.cmx)
105 $(V_LINKOPT)$(CAMLOPT) -a -o $@ $^
106
107 .PHONY: distclean
108 distclean: clean
109 rm -f sys.ml META runtime.info target_runtime.info
110
111 .PHONY: clean
112 clean::
113 rm -f $(HEADER_NAME) target_$(HEADER_NAME)
114
115 export AWK
116
117 %.cmi: %.mli
118 $(V_OCAMLC)$(CAMLC) $(COMPFLAGS) $(shell ./Compflags $@) -c $<
119
120 # The dependency on the .mli file is in .depend (since stdlib__Foo.cmi
121 # depends on stdlib__foo.mli)
122 stdlib__%.cmi:
123 $(V_OCAMLC)$(CAMLC) $(COMPFLAGS) $(shell ./Compflags $@) \
124 -o $@ -c $(filter %.mli, $^)
125
126 %.cmo: %.ml
127 $(V_OCAMLC)$(CAMLC) $(COMPFLAGS) $(shell ./Compflags $@) -c $<
128
129 # The dependency on the .ml file is in .depend (since stdlib__Foo.cmo
130 # depends on stdlib__foo.ml)
131 stdlib__%.cmo:
132 $(V_OCAMLC)$(CAMLC) $(COMPFLAGS) $(shell ./Compflags $@) \
133 -o $@ -c $(filter %.ml, $^)
134
135 %.cmx: %.ml
136 $(V_OCAMLOPT)$(CAMLOPT) $(COMPFLAGS) $(OPTCOMPFLAGS) $(shell ./Compflags $@) -c $<
137
138 # The dependency on the .ml file is in .depend (since stdlib__Foo.cmx
139 # depends on stdlib__foo.ml)
140 stdlib__%.cmx:
141 $(V_OCAMLOPT)$(CAMLOPT) $(COMPFLAGS) $(OPTCOMPFLAGS) $(shell ./Compflags $@) \
142 -o $@ -c $(filter %.ml, $^)
143
144 # Dependencies on the compiler
145 COMPILER_DEPS=$(filter-out $(OCAMLRUN), $(CAMLC))
146 $(OBJS) std_exit.cmo: $(COMPILER_DEPS)
147 $(OBJS:.cmo=.cmi) std_exit.cmi: $(COMPILER_DEPS)
148 $(OBJS:.cmo=.cmx) std_exit.cmx: $(OPTCOMPILER)
149
150 # Dependencies on Stdlib (not tracked by ocamlc -depend)
151
152 $(OTHERS) std_exit.cmo: stdlib.cmi
153 $(OTHERS:.cmo=.cmi) std_exit.cmi: stdlib.cmi
154 $(OBJS:.cmo=.cmx) std_exit.cmx: stdlib.cmi
155 $(OTHERS:.cmo=.cmx) std_exit.cmx: stdlib.cmx
156
157 clean::
158 rm -f *.cm* *.o *.obj *.a *.lib *.odoc
159
160 include .depend
161
162 STDLIB_NAMESPACE_MODULES = $(subst $(SPACE),|,$(STDLIB_PREFIXED_MODULES))
163
164 GNUISH_SED = \
165 $(if $(filter X,$(shell echo x | $(SED) -E -e 's/./\u&/' 2>/dev/null)),\
166 $(SED),$(error GNU sed is needed for make depend))
167
168 .PHONY: depend
169 depend:
170 $(V_OCAMLDEP){ \
171 $(OCAMLDEP_CMD) $(filter-out stdlib.%,$(wildcard *.mli *.ml)); \
172 $(OCAMLDEP_CMD) -pp "$(AWK) -f ./remove_module_aliases.awk" \
173 stdlib.ml stdlib.mli; \
174 } | \
175 $(GNUISH_SED) -E \
176 -e 's/^(${STDLIB_NAMESPACE_MODULES})(\.[^i]*)(i?) :/\1\2\3 : \1.ml\3/' \
177 -e 's#(^| )(${STDLIB_NAMESPACE_MODULES})[.]#\1stdlib__\u\2.#' \
178 > .$@