1#
2# %CopyrightBegin%
3#
4# Copyright Ericsson AB 1997-2019. All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10#     http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18# %CopyrightEnd%
19#
20
21# ----------------------------------------------------
22# Release directory specification
23# ----------------------------------------------------
24ifeq ($(APPLICATION),erts)
25RELSYSDIR = $(RELEASE_PATH)/$(APPLICATION)-$(VSN)
26else
27RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN)
28endif
29RELCHUNKSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN)
30
31APP_DIR = $(ERL_TOP)/lib/$(APPLICATION)
32APP_SRC_DIR = $(APP_DIR)/src
33APP_EBIN_DIR = $(APP_DIR)/src
34
35# ----------------------------------------------------
36HTML_FILES = $(XML_APPLICATION_FILES:%.xml=$(HTMLDIR)/%.html) \
37	$(XML_HTML_FILES:%.xml=$(HTMLDIR)/%.html) \
38	$(XML_PART_FILES:%.xml=$(HTMLDIR)/%.html)
39
40XML_REF3_SRC_FILES=$(filter %.xmlsrc,$(XML_REF3_FILES))
41XML_REF3_XML_FILES=$(filter %.xml,$(XML_REF3_FILES))
42
43XML_ALL_REF3_FILES = $(XML_REF3_XML_FILES) $(XML_REF3_SRC_FILES:%.xmlsrc=%.xml) \
44	$(EDOC_REF3_FILES)
45XML_CHAPTER_FILES += $(EDOC_CHAPTER_FILE)
46XML_GEN_FILES += $(EDOC_REF3_FILES:%=$(XMLDIR)/%) \
47	$(EDOC_CHAPTER_FILE:%=$(XMLDIR)/%) \
48	$(XML_REF3_SRC_FILES:%.xmlsrc=$(XMLDIR)/%.xml)
49
50INFO_FILE = ../../info
51
52MAN1_FILES = $(XML_REF1_FILES:%_cmd.xml=$(MAN1DIR)/%.1)
53MAN2_FILES = $(XML_REF2_FILES:%.xml=$(MAN1DIR)/%.2)
54MAN3_FILES = $(XML_ALL_REF3_FILES:%.xml=$(MAN3DIR)/%.3)
55MAN4_FILES = $(XML_REF4_FILES:%.xml=$(MAN4DIR)/%.4)
56MAN5_FILES = $(XML_REF5_FILES:%.xml=$(MAN4DIR)/%.5)
57MAN6_FILES = $(XML_REF6_FILES:%_app.xml=$(MAN6DIR)/%.6)
58MAN7_FILES = $(MIB_REF7_FILES:$(MIBSDIR)/%.mib=$(MAN7DIR)/%.7)
59
60HTML_REF_MAN_FILE = $(HTMLDIR)/index.html
61
62TOP_PDF_FILE = $(PDFDIR)/$(APPLICATION)-$(VSN).pdf
63
64ifneq ($(TOP_SPECS_FILE),)
65SPECS_FILES = $(XML_ALL_REF3_FILES:%.xml=$(SPECDIR)/specs_%.xml)
66endif
67
68ifneq ($(strip $(CHUNKSDIR)),)
69_create_chunksdir_dirs := $(shell mkdir -p $(CHUNKSDIR))
70endif
71CHUNK_REF3_FILES = $(filter-out $(NO_CHUNKS), $(XML_ALL_REF3_FILES))
72CHUNK_FILES = $(CHUNK_REF3_FILES:%.xml=$(CHUNKSDIR)/%.chunk)
73
74ERL_CHUNK_FILES = $(patsubst $(APP_EBIN_DIR)/%.BEAM,$(CHUNKSDIR)/%.chunk,$(wildcard $(APP_EBIN_DIR)/*.beam))
75EMPTY_CHUNK_FILES = $(filter-out $(NO_CHUNKS:%.xml=$(CHUNKSDIR)/%.chunk) $(CHUNK_FILES), $(ERL_CHUNK_FILES))
76
77
78# ----------------------------------------------------
79# FLAGS
80# ----------------------------------------------------
81
82SPECS_FLAGS = -I$(ERL_TOP)/lib -I$(ERL_TOP)/lib/*/include -I$(ERL_TOP)/lib/*/src
83
84
85
86# ----------------------------------------------------
87# Targets
88# ----------------------------------------------------
89$(HTMLDIR)/%.gif: %.gif
90	$(INSTALL_DATA) $< $@
91$(HTMLDIR)/%.png: %.png
92	$(INSTALL_DATA) $< $@
93$(HTMLDIR)/%.jpg: %.jpg
94	$(INSTALL_DATA) $< $@
95
96DOC_TARGETS?=man pdf html chunks
97
98docs: $(INFO_FILE) $(DOC_TARGETS)
99
100$(TOP_PDF_FILE): $(XML_FILES)
101
102pdf: $(TOP_PDF_FILE)
103
104html: images $(HTML_REF_MAN_FILE) $(HTMLDIR)/$(APPLICATION).eix
105
106man: $(MAN1_FILES) $(MAN2_FILES) $(MAN3_FILES) $(MAN4_FILES) $(MAN5_FILES) $(MAN6_FILES) $(MAN7_FILES)
107
108chunks: $(CHUNK_FILES) $(EMPTY_CHUNK_FILES)
109
110images: $(IMAGE_FILES:%=$(HTMLDIR)/%)
111
112$(EDOC_REF3_FILES:%=$(XMLDIR)/%): $(APP_SRC_DIR)/$(@:$(XMLDIR)/%.xml=%.erl)
113	$(gen_verbose)escript $(DOCGEN)/priv/bin/xml_from_edoc.escript \
114	  -def vsn $(VSN) $(EDOC_FLAGS) -dir $(XMLDIR) $(APP_SRC_DIR)/$(@:$(XMLDIR)/%.xml=%.erl)
115$(XMLDIR)/$(EDOC_CHAPTER_FILE): ../overview.edoc
116	$(gen_verbose)escript $(DOCGEN)/priv/bin/xml_from_edoc.escript -def vsn $(VSN) \
117	-chapter -dir $(XMLDIR) $<
118
119info:
120	@echo "XML_APPLICATION_FILES: $(XML_APPLICATION_FILES)"
121	@echo "XML_REF1_FILES:        $(XML_REF1_FILES)"
122	@echo "XML_REF2_FILES:        $(XML_REF2_FILES)"
123	@echo "XML_REF3_FILES:        $(XML_ALL_REF3_FILES)"
124	@echo "XML_REF4_FILES:        $(XML_REF4_FILES)"
125	@echo "XML_REF5_FILES:        $(XML_REF5_FILES)"
126	@echo "XML_REF6_FILES:        $(XML_REF6_FILES)"
127	@echo "XML_REF7_FILES:        $(XML_REF7_FILES)"
128	@echo "XML_PART_FILES:        $(XML_PART_FILES)"
129	@echo "XML_CHAPTER_FILES:     $(XML_CHAPTER_FILES)"
130	@echo "BOOK_FILES:            $(BOOK_FILES)"
131
132debug opt lcnt:
133
134clean clean_docs: clean_xml clean_pdf clean_html clean_man clean_chunks
135	rm -rf $(EXTRA_FILES)
136	rm -f  errs core *~ *.eps
137
138clean_pdf:
139	rm -f $(PDFDIR)/*
140
141clean_man:
142	rm -f $(MAN1DIR)/* $(MAN3DIR)/* $(MAN4DIR)/* $(MAN6DIR)/*
143
144clean_xml:
145	rm -f  $(SPECDIR)/*
146	rm -rf $(XMLDIR)
147
148clean_html:
149	rm -rf $(HTMLDIR)/*
150
151clean_chunks:
152	rm -f  $(CHUNKSDIR)/*
153
154# ----------------------------------------------------
155# Release Target
156# ----------------------------------------------------
157include $(ERL_TOP)/make/otp_release_targets.mk
158
159$(RELSYSDIR) $(RELSYSDIR)/doc:
160	$(INSTALL_DIR) "$@"
161
162release_pdf_spec: pdf
163	$(INSTALL_DIR) "$(RELSYSDIR)/doc/pdf"
164	$(INSTALL_DATA) $(TOP_PDF_FILE) "$(RELSYSDIR)/doc/pdf"
165
166release_html_spec: html
167	$(INSTALL_DIR) "$(RELSYSDIR)/doc/html"
168	$(INSTALL_DIR_DATA) $(HTMLDIR) "$(RELSYSDIR)/doc/html"
169ifneq ($(HTML_EXTRA_FILES),)
170	$(INSTALL_DATA) $(HTML_EXTRA_FILES) "$(RELSYSDIR)/doc/html"
171endif
172
173release_chunks_spec: chunks
174ifneq ($(CHUNK_FILES),)
175	$(INSTALL_DIR) "$(RELCHUNKSDIR)/doc/chunks"
176	$(INSTALL_DATA) $(CHUNKSDIR)/* "$(RELCHUNKSDIR)/doc/chunks"
177endif
178
179release_man_spec: man
180ifneq ($(MAN1_FILES),)
181	$(INSTALL_DIR) "$(RELEASE_PATH)/man/man1"
182	$(INSTALL_DATA) $(MAN1DIR)/* "$(RELEASE_PATH)/man/man1"
183endif
184ifneq ($(MAN2_FILES),)
185	$(INSTALL_DIR) "$(RELEASE_PATH)/man/man2"
186	$(INSTALL_DATA) $(MAN2DIR)/* "$(RELEASE_PATH)/man/man2"
187endif
188ifneq ($(MAN3_FILES),)
189	$(INSTALL_DIR) "$(RELEASE_PATH)/man/man3"
190	$(INSTALL_DATA) $(MAN3DIR)/* "$(RELEASE_PATH)/man/man3"
191endif
192ifneq ($(MAN4_FILES),)
193	$(INSTALL_DIR) "$(RELEASE_PATH)/man/man4"
194	$(INSTALL_DATA) $(MAN4_FILES) "$(RELEASE_PATH)/man/man4"
195endif
196ifneq ($(MAN5_FILES),)
197	$(INSTALL_DIR) "$(RELEASE_PATH)/man/man5"
198	$(INSTALL_DATA) $(MAN5_FILES) "$(RELEASE_PATH)/man/man5"
199endif
200ifneq ($(MAN6_FILES),)
201	$(INSTALL_DIR) "$(RELEASE_PATH)/man/man6"
202	$(INSTALL_DATA) $(MAN6_FILES) "$(RELEASE_PATH)/man/man6"
203endif
204ifneq ($(MAN7_FILES),)
205	$(INSTALL_DIR) "$(RELEASE_PATH)/man/man7"
206	$(INSTALL_DATA) $(MAN7_FILES) "$(RELEASE_PATH)/man/man7"
207endif
208
209release_docs_spec: $(RELSYSDIR)/doc $(INFO_FILE) $(DOC_TARGETS:%=release_%_spec)
210	$(INSTALL_DATA) $(INFO_FILE) $(RELSYSDIR)
211ifneq ($(STANDARDS),)
212	$(INSTALL_DIR) "$(RELEASE_PATH)/doc/standard"
213	$(INSTALL_DATA) $(STANDARDS) "$(RELEASE_PATH)/doc/standard"
214endif
215
216release_spec:
217
218.PHONY: clean clean_xml clean_html clean_man clean_pdf \
219        debug opt info \
220        docs images html man pdf chunks \
221        release_docs_spec release_spec
222