1#-*-makefile-*-   ; force emacs to enter makefile-mode
2# ----------------------------------------------------
3# Make include file for otp
4#
5# %CopyrightBegin%
6#
7# Copyright Ericsson AB 1997-2019. All Rights Reserved.
8#
9# Licensed under the Apache License, Version 2.0 (the "License");
10# you may not use this file except in compliance with the License.
11# You may obtain a copy of the License at
12#
13#     http://www.apache.org/licenses/LICENSE-2.0
14#
15# Unless required by applicable law or agreed to in writing, software
16# distributed under the License is distributed on an "AS IS" BASIS,
17# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18# See the License for the specific language governing permissions and
19# limitations under the License.
20#
21# %CopyrightEnd%
22#
23# Author: Lars Thorsen
24# ----------------------------------------------------
25.SUFFIXES: .erl .beam .yrl .xrl .bin .mib .hrl .sgml .xml .xmlsrc .html .ps \
26	.3 .1 .fig .dvi .tex .class .java .pdf .fo .psframe .pscrop .el .elc
27
28# ----------------------------------------------------
29#	Output
30# ----------------------------------------------------
31include $(ERL_TOP)/make/output.mk
32
33# ----------------------------------------------------
34#       Version
35# ----------------------------------------------------
36
37OTP_VERSION = @OTP_VERSION@
38SYSTEM_VSN = @SYSTEM_VSN@
39
40# ----------------------------------------------------
41#	Cross Compiling
42# ----------------------------------------------------
43CROSS_COMPILING = @CROSS_COMPILING@
44
45# ----------------------------------------------------
46#	Common macros
47# ----------------------------------------------------
48DEFAULT_TARGETS =  opt debug release release_docs clean docs
49
50TYPES = @TYPES@
51FLAVORS = @FLAVORS@
52PRIMARY_FLAVOR= @PRIMARY_FLAVOR@
53
54USE_PGO = @USE_PGO@
55
56USE_ESOCK = @USE_ESOCK@
57
58# Slash separated list of return values from $(origin VAR)
59# that are untrusted - set default in this file instead.
60# The list is not space separated since some return values
61# contain space, and we want to use $(findstring ...) to
62# search the list.
63DUBIOUS_ORIGINS = /undefined/environment/
64
65# ----------------------------------------------------
66#	Command macros
67# ----------------------------------------------------
68INSTALL         = @INSTALL@
69INSTALL_DIR     = @INSTALL_DIR@
70INSTALL_PROGRAM = @INSTALL_PROGRAM@
71INSTALL_SCRIPT  = @INSTALL_SCRIPT@
72INSTALL_DATA    = @INSTALL_DATA@
73INSTALL_DIR_DATA = $(ERL_TOP)/make/install_dir_data.sh
74
75CC = @CC@
76GCC = @GCC@
77HCC = @HCC@
78CC32 = @CC32@
79CXX = @CXX@
80CFLAGS32 = @CFLAGS32@
81BASIC_CFLAGS = @CFLAGS@
82DEBUG_FLAGS =  @DEBUG_FLAGS@
83LD = @LD@
84RANLIB = @RANLIB@
85AR = @AR@
86PERL = @PERL@
87LLVM_PROFDATA = @LLVM_PROFDATA@
88
89MIXED_VC = @MIXED_VC@
90MIXED_MINGW = @MIXED_MINGW@
91
92BITS64 = @BITS64@
93
94OTP_RELEASE = @OTP_RELEASE@
95
96# ----------------------------------------------------
97#	Erlang language section
98# ----------------------------------------------------
99EMULATOR = beam
100ifeq ($(ERL_COMPILE_WARNINGS_AS_ERRORS),yes)
101  ERL_COMPILE_FLAGS += -Werror
102endif
103ifdef BOOTSTRAP
104  ERL_COMPILE_FLAGS += +slim
105else
106  ERL_COMPILE_FLAGS += +debug_info
107endif
108ifeq ($(USE_ESOCK),yes)
109ERL_COMPILE_FLAGS += -DUSE_ESOCK=true
110endif
111
112ERLC_WFLAGS = -W
113ERLC = erlc $(ERLC_WFLAGS) $(ERLC_FLAGS)
114ERL = erl -boot start_clean
115
116ifneq (,$(findstring $(origin EBIN),$(DUBIOUS_ORIGINS)))
117EBIN = ../ebin
118endif
119
120# Generated (non ebin) files...
121ifneq (,$(findstring $(origin EGEN),$(DUBIOUS_ORIGINS)))
122EGEN = .
123endif
124
125ifneq (,$(findstring $(origin ESRC),$(DUBIOUS_ORIGINS)))
126ESRC = .
127endif
128
129$(EBIN)/%.beam: $(EGEN)/%.erl
130	$(V_ERLC) $(ERL_COMPILE_FLAGS) -o$(EBIN) $<
131
132$(EBIN)/%.beam: $(ESRC)/%.erl
133	$(V_ERLC) $(ERL_COMPILE_FLAGS) -o$(EBIN) $<
134
135
136.erl.beam:
137	$(V_ERLC) $(ERL_COMPILE_FLAGS) -o$(dir $@) $<
138
139#
140# When .erl files are automatically created GNU make removes them if
141# they were the result of a chain of implicit rules. To prevent this
142# we say that all .erl files are "precious".
143#
144.PRECIOUS: %.erl %.fo
145
146## Uncomment these lines and add .idl to suffixes above to have erlc
147## eat IDL files
148##$(EGEN)/%.erl: $(ESRC)/%.idl
149##	$(ERLC) $(IDL_FLAGS) $<
150
151$(EGEN)/%.erl: $(ESRC)/%.yrl
152	$(yecc_verbose)$(ERLC) $(YRL_FLAGS) -o$(EGEN) $<
153
154$(EGEN)/%.erl: $(ESRC)/%.xrl
155	$(leex_verbose)$(ERLC) $(XRL_FLAGS) -o$(EGEN) $<
156
157# ----------------------------------------------------
158#	SNMP language section
159# ----------------------------------------------------
160SNMP_TOOLKIT = $(ERL_TOP)/lib/snmp
161ifeq ($(SNMP_BIN_TARGET_DIR),)
162  SNMP_BIN_TARGET_DIR = ../priv/mibs
163endif
164ifeq ($(SNMP_HRL_TARGET_DIR),)
165  SNMP_HRL_TARGET_DIR = ../include
166endif
167
168
169$(SNMP_BIN_TARGET_DIR)/%.bin: %.mib
170	$(snmp_verbose)$(ERLC) -pa $(SNMP_TOOLKIT)/ebin -I $(SNMP_TOOLKIT)/priv/mibs $(SNMP_FLAGS) -o $(SNMP_BIN_TARGET_DIR) $<
171
172$(SNMP_HRL_TARGET_DIR)/%.hrl: $(SNMP_BIN_TARGET_DIR)/%.bin
173	$(snmp_verbose)$(ERLC) -pa $(SNMP_TOOLKIT)/ebin -o $(SNMP_HRL_TARGET_DIR) $<
174
175.mib.bin:
176	$(snmp_verbose)$(ERLC) -pa $(SNMP_TOOLKIT)/ebin -I $(SNMP_TOOLKIT)/priv/mibs $(SNMP_FLAGS) $<
177
178.bin.hrl:
179	$(snmp_verbose)$(ERLC) -pa $(SNMP_TOOLKIT)/ebin $<
180
181# ----------------------------------------------------
182#	Java language section
183# ----------------------------------------------------
184JAVA= @JAVAC@
185
186ifneq (,$(findstring $(origin JAVA_DEST_ROOT),$(DUBIOUS_ORIGINS)))
187JAVA_DEST_ROOT = ../priv/
188endif
189
190.java.class:
191	$(javac_verbose)CLASSPATH=$(CLASSPATH) $(JAVA) $(JAVA_OPTIONS) $<
192
193
194$(JAVA_DEST_ROOT)$(JAVA_CLASS_SUBDIR)%.class: %.java
195	$(javac_verbose)CLASSPATH=$(CLASSPATH) $(JAVA) $(JAVA_OPTIONS) -d $(JAVA_DEST_ROOT) $<
196
197# ----------------------------------------------------
198#	Emacs byte code compiling
199# ----------------------------------------------------
200EMACS_COMPILER=emacs-20
201EMACS_COMPILE_OPTIONS=-q --no-site-file -batch -f batch-byte-compile
202
203.el.elc:
204	$(emacs_verbose)$(EMACS_COMPILER) $(EMACS_COMPILE_OPTIONS) $<
205
206# ----------------------------------------------------
207#	Documentation section
208# ----------------------------------------------------
209export VSN
210
211TOPDOCDIR=../../../../doc
212
213DOCDIR = ..
214
215PDFDIR=$(DOCDIR)/pdf
216
217HTMLDIR = $(DOCDIR)/html
218
219MAN1DIR = $(DOCDIR)/man1
220MAN2DIR = $(DOCDIR)/man2
221MAN3DIR = $(DOCDIR)/man3
222MAN4DIR = $(DOCDIR)/man4
223MAN5DIR = $(DOCDIR)/man5
224MAN6DIR = $(DOCDIR)/man6
225MAN7DIR = $(DOCDIR)/man7
226MAN9DIR = $(DOCDIR)/man9
227
228TEXDIR = .
229
230SPECDIR = $(DOCDIR)/specs
231XMLDIR = $(DOCDIR)/xml
232CHUNKSDIR = $(DOCDIR)/chunks
233
234ifeq ($(CSS_FILE),)
235CSS_FILE = otp_doc.css
236endif
237ifeq ($(WINPREFIX),)
238WINPREFIX = Erlang
239endif
240ifeq ($(HTMLLOGO),)
241HTMLLOGO_FILE = erlang-logo.png
242endif
243ifeq ($(PDFLOGO),)
244PDFLOGO_FILE = $(DOCGEN)/priv/images/erlang-logo.gif
245endif
246ifeq ($(PDFCOLOR),)
247PDFCOLOR = \#960003
248endif
249
250# HTML & GIF files that always are generated and must be delivered
251SGML_COLL_FILES = $(SGML_APPLICATION_FILES) $(SGML_PART_FILES)
252XML_COLL_FILES = $(XML_APPLICATION_FILES) $(XML_PART_FILES)
253DEFAULT_HTML_FILES = \
254	$(SGML_COLL_FILES:%.sgml=$(HTMLDIR)/%_frame.html) \
255	$(SGML_COLL_FILES:%.sgml=$(HTMLDIR)/%_first.html) \
256	$(SGML_COLL_FILES:%.sgml=$(HTMLDIR)/%_term.html) \
257	$(SGML_COLL_FILES:%.sgml=$(HTMLDIR)/%_cite.html) \
258	$(SGML_APPLICATION_FILES:%.sgml=$(HTMLDIR)/%_index.html) \
259	$(SGML_APPLICATION_FILES:%.sgml=$(HTMLDIR)/%.kwc) \
260	$(XML_COLL_FILES:%.xml=$(HTMLDIR)/%_frame.html) \
261	$(XML_COLL_FILES:%.xml=$(HTMLDIR)/%_first.html) \
262	$(XML_COLL_FILES:%.xml=$(HTMLDIR)/%_term.html) \
263	$(XML_COLL_FILES:%.xml=$(HTMLDIR)/%_cite.html) \
264	$(XML_APPLICATION_FILES:%.xml=$(HTMLDIR)/%_index.html) \
265	$(XML_APPLICATION_FILES:%.xml=$(HTMLDIR)/%.kwc) \
266	$(HTMLDIR)/index.html
267
268DEFAULT_GIF_FILES =
269
270#
271# Flags & Commands
272#
273XSLTPROC = @XSLTPROC@
274FOP = @FOP@
275XMLLINT = @XMLLINT@
276CP = @CP@
277MKDIR = @MKDIR@
278
279DOCGEN?=$(ERL_TOP)/lib/erl_docgen
280FOP_CONFIG = $(DOCGEN)/priv/fop.xconf
281
282ifneq (,$(findstring $(origin SPECS_ESRC),$(DUBIOUS_ORIGINS)))
283SPECS_ESRC = ../../src
284endif
285SPECS_EXTRACTOR=$(DOCGEN)/priv/bin/specs_gen.escript
286# Extract specifications and types from Erlang source files (-spec, -type)
287$(SPECDIR)/specs_%.xml: $(SPECS_ESRC)/%.erl $(TOP_SPECS_FILE)
288	$(gen_verbose)escript $(SPECS_EXTRACTOR) $(SPECS_FLAGS) -o$(dir $@) $<
289$(SPECDIR)/specs_%.xml: $(SPECS_ESRC)/gen/%.erl $(TOP_SPECS_FILE)
290	$(gen_verbose)escript $(SPECS_EXTRACTOR) $(SPECS_FLAGS) -o$(dir $@) $<
291
292MANXSLTARGS=--stringparam company "Ericsson AB" --stringparam docgen "$(DOCGEN)" --stringparam gendate "$$date" --stringparam appname "$(APPLICATION)" --stringparam appver "$(VSN)" --xinclude -path $(DOCGEN)/priv/dtd  -path $(DOCGEN)/priv/dtd_man_entities -path .
293
294$(MAN1DIR)/%.1: $(XMLDIR)/%_cmd.xml
295	$(gen_verbose)date=`date +"%B %e, %Y"`; \
296	xsltproc --output "$@" $(MANXSLTARGS) $(DOCGEN)/priv/xsl/db_man.xsl $<
297
298$(MAN2DIR)/%.2 $(MAN4DIR)/%.4 $(MAN4DIR)/%.5 $(MAN9DIR)/%.9: $(XMLDIR)/%.xml
299	$(gen_verbose)date=`date +"%B %e, %Y"`; \
300	xsltproc --output "$@" $(MANXSLTARGS) $(DOCGEN)/priv/xsl/db_man.xsl $<
301
302ifneq ($(wildcard $(SPECDIR)),)
303$(MAN3DIR)/%.3: $(XMLDIR)/%.xml $(SPECDIR)/specs_%.xml
304	$(gen_verbose)date=`date +"%B %e, %Y"`; \
305	specs_file=`pwd`/$(SPECDIR)/specs_$*.xml; \
306	xsltproc --output "$@" $(MANXSLTARGS) --stringparam specs_file "$$specs_file" $(DOCGEN)/priv/xsl/db_man.xsl $<
307else
308$(MAN3DIR)/%.3: $(XMLDIR)/%.xml
309	$(gen_verbose)date=`date +"%B %e, %Y"`; \
310	xsltproc --output "$@" $(MANXSLTARGS) $(DOCGEN)/priv/xsl/db_man.xsl $<
311endif
312
313# left for compatibility
314$(MAN6DIR)/%.6 $(MAN6DIR)/%.7: $(XMLDIR)/%_app.xml
315	$(gen_verbose)date=`date +"%B %e, %Y"`; \
316	xsltproc --output "$@" $(MANXSLTARGS) $(DOCGEN)/priv/xsl/db_man.xsl $<
317
318$(XMLDIR)/%.xml: $(XMLDIR)/%.xmlsrc
319	$(gen_verbose)escript $(DOCGEN)/priv/bin/codeline_preprocessing.escript $(shell pwd) $< $@
320
321$(PDFDIR)/%.pdf: %.fo
322	$(FOP) -c $(FOP_CONFIG) -cache $(ERL_TOP)/make/$(TARGET)/fop-fonts.cache -fo $< -pdf $@
323
324$(CHUNKSDIR)/%.chunk: $(XMLDIR)/%.xml ../../ebin/%.beam $(DOCGEN)/ebin/docgen_xml_to_chunk.beam
325	$(gen_verbose)escript $(DOCGEN)/priv/bin/chunk.escript $(APPLICATION) $^ $@
326
327$(CHUNKSDIR)/%.chunk: $(XMLDIR)/%.xml ../../preloaded/ebin/%.beam $(DOCGEN)/ebin/docgen_xml_to_chunk.beam
328	$(gen_verbose)escript $(DOCGEN)/priv/bin/chunk.escript $(APPLICATION) $^ $@
329
330$(CHUNKSDIR)/%.chunk: ../../ebin/%.beam $(DOCGEN)/ebin/docgen_xml_to_chunk.beam
331	$(gen_verbose)escript $(DOCGEN)/priv/bin/chunk.escript $(APPLICATION) $^ $@
332