1# This is an include file specifically tuned for building documentation
2# for GStreamer plug-ins
3
4help:
5	@echo
6	@echo "If you are a doc maintainer, run 'make update' to update"
7	@echo "the documentation files maintained in git"
8	@echo
9	@echo Other useful make targets:
10	@echo
11	@echo  check-inspected-versions: make sure the inspected plugin info
12	@echo                            is up to date before a release
13	@echo
14
15# update the stuff maintained by doc maintainers
16update: scanobj-update
17	$(MAKE) check-outdated-docs
18
19if GTK_DOC_USE_LIBTOOL
20GTKDOC_CC = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(INCLUDES) $(GTKDOC_DEPS_CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
21GTKDOC_LD = $(LIBTOOL) --tag=CC --mode=link $(CC) $(GTKDOC_DEPS_LIBS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS)
22GTKDOC_RUN = $(LIBTOOL) --mode=execute
23else
24GTKDOC_CC = $(CC) $(INCLUDES) $(GTKDOC_DEPS_CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
25GTKDOC_LD = $(CC) $(GTKDOC_DEPS_LIBS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS)
26GTKDOC_RUN =
27endif
28
29# We set GPATH here; this gives us semantics for GNU make
30# which are more like other make's VPATH, when it comes to
31# whether a source that is a target of one rule is then
32# searched for in VPATH/GPATH.
33#
34GPATH = $(srcdir)
35
36# thomas: make docs parallel installable
37TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)-@GST_API_VERSION@
38
39MAINTAINER_DOC_STAMPS =			\
40	scanobj-build.stamp
41
42EXTRA_DIST = 				\
43	$(MAINTAINER_DOC_STAMPS)		\
44	$(srcdir)/inspect/*.xml		\
45	$(SCANOBJ_FILES)		\
46	$(content_files)		\
47	$(extra_files)			\
48	$(HTML_IMAGES)			\
49	$(DOC_MAIN_SGML_FILE)	\
50	$(DOC_OVERRIDES)		\
51	$(DOC_MODULE)-sections.txt
52
53# we don't add scanobj-build.stamp here since they are built manually by docs
54# maintainers and result is commited to git
55DOC_STAMPS =				\
56	scan-build.stamp		\
57	sgml-build.stamp		\
58	html-build.stamp		\
59	scan.stamp			\
60	sgml.stamp			\
61	html.stamp
62
63# files generated/updated by gtkdoc-scangobj
64SCANOBJ_FILES =				\
65	$(DOC_MODULE).args              \
66	$(DOC_MODULE).hierarchy         \
67	$(DOC_MODULE).interfaces        \
68	$(DOC_MODULE).prerequisites     \
69	$(DOC_MODULE).signals           \
70	$(DOC_MODULE).types
71
72SCANOBJ_FILES_O =			\
73	.libs/$(DOC_MODULE)-scan.o
74
75# files generated/updated by gtkdoc-scan
76SCAN_FILES =				\
77	$(DOC_MODULE)-sections.txt	\
78	$(DOC_MODULE)-overrides.txt	\
79	$(DOC_MODULE)-decl.txt		\
80	$(DOC_MODULE)-decl-list.txt
81
82
83REPORT_FILES = \
84	$(DOC_MODULE)-undocumented.txt \
85	$(DOC_MODULE)-undeclared.txt \
86	$(DOC_MODULE)-unused.txt
87
88CLEANFILES = \
89	$(SCANOBJ_FILES_O) \
90	$(REPORT_FILES) \
91	$(DOC_STAMPS) \
92	inspect-registry.xml
93
94INSPECT_DIR = inspect
95
96if ENABLE_GTK_DOC
97all-local: html-build.stamp
98
99### inspect GStreamer plug-ins; done by documentation maintainer ###
100
101# only look at the plugins in this module when building inspect .xml stuff
102INSPECT_REGISTRY=$(top_builddir)/docs/plugins/inspect-registry.xml
103INSPECT_ENVIRONMENT=\
104	LC_ALL=C \
105	GST_PLUGIN_SYSTEM_PATH_1_0= \
106	GST_PLUGIN_PATH_1_0=$(top_builddir)/gst:$(top_builddir)/sys:$(top_builddir)/ext:$(top_builddir)/plugins:$(top_builddir)/src:$(top_builddir)/gnl \
107	GST_REGISTRY_1_0=$(INSPECT_REGISTRY) \
108	PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" \
109	$(INSPECT_EXTRA_ENVIRONMENT)
110
111#### scan gobjects; done by documentation maintainer ####
112scanobj-update:
113	-rm scanobj-build.stamp
114	$(MAKE) scanobj-build.stamp
115
116# gstdoc-scanobj produces 5 output files (.new)
117# scangobj-merge.py merges them into the file which we commit later
118# TODO: also merge the hierarchy
119scanobj-build.stamp: $(SCANOBJ_DEPS) $(basefiles)
120	@echo "  DOC   Introspecting gobjects"
121	@if test x"$(srcdir)" != x. ; then				\
122	    for f in $(SCANOBJ_FILES) $(SCAN_FILES);			\
123	    do								\
124	        if test -e $(srcdir)/$$f; then				\
125	            cp -u $(srcdir)/$$f . || cp $(srcdir)/$$f . ;	\
126	        fi;							\
127	    done;							\
128	fi;								\
129	mkdir -p $(INSPECT_DIR); \
130	scanobj_options=""; \
131	if test "x$(V)" = "x1"; then \
132	    scanobj_options="--verbose"; \
133	fi; \
134	$(INSPECT_ENVIRONMENT) 					\
135	CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)" RUN="$(GTKDOC_RUN)"	\
136	CFLAGS="$(GTKDOC_CFLAGS) $(CFLAGS) $(WARNING_CFLAGS)"	\
137	LDFLAGS="$(GTKDOC_LIBS) $(LDFLAGS)"				\
138	$(GST_DOC_SCANOBJ) $$scanobj_options --type-init-func="gst_init(NULL,NULL)"	\
139	    --module=$(DOC_MODULE) --source=$(PACKAGE) --inspect-dir=$(INSPECT_DIR) &&		\
140	    echo "  DOC   Merging introspection data" && \
141	    $(PYTHON)						\
142	    $(top_srcdir)/common/scangobj-merge.py $(DOC_MODULE) || exit 1;	\
143	if test x"$(srcdir)" != x. ; then				\
144	    for f in $(SCANOBJ_FILES);					\
145	    do								\
146	        cmp -s ./$$f $(srcdir)/$$f || cp ./$$f $(srcdir)/ ;		\
147	    done;							\
148	fi;								\
149	touch scanobj-build.stamp
150
151$(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(SCANOBJ_FILES_O): scan-build.stamp
152	@true
153
154### scan headers; done on every build ###
155scan-build.stamp: $(HFILE_GLOB) $(EXTRA_HFILES) $(basefiles) scanobj-build.stamp
156	@echo '  DOC   Scanning header files'
157	@if test x"$(srcdir)" != x. ; then				\
158	    for f in $(SCANOBJ_FILES) $(SCAN_FILES);			\
159	    do								\
160	        if test -e $(srcdir)/$$f; then				\
161	            cp -u $(srcdir)/$$f . || cp $(srcdir)/$$f .;	\
162	        fi;							\
163	    done;							\
164	fi
165	@_source_dir='' ;						\
166	for i in $(DOC_SOURCE_DIR) ; do					\
167	    _source_dir="$${_source_dir} --source-dir=$$i" ;	        \
168	done ;							        \
169	gtkdoc-scan							\
170	    $(SCAN_OPTIONS) $(EXTRA_HFILES)				\
171	    --module=$(DOC_MODULE)					\
172	    $${_source_dir}             				\
173	    --ignore-headers="$(IGNORE_HFILES)";			\
174	touch scan-build.stamp
175
176#### xml ####
177
178sgml-build.stamp: scan-build.stamp $(CFILE_GLOB) $(top_srcdir)/common/plugins.xsl $(expand_content_files)
179	@echo '  DOC   Building XML'
180	@-mkdir -p xml
181	@for a in $(inspect_files); do \
182	    xsltproc --stringparam module $(MODULE) \
183		$(top_srcdir)/common/plugins.xsl $$a > xml/`basename $$a`; done
184	@for f in $(EXAMPLE_CFILES); do \
185		$(PYTHON) $(top_srcdir)/common/c-to-xml.py $$f > xml/element-`basename $$f .c`.xml; done
186	@_source_dir='' ;						\
187	for i in $(DOC_SOURCE_DIR) ; do					\
188	    _source_dir="$${_source_dir} --source-dir=$$i" ;	        \
189	done ;								\
190	gtkdoc-mkdb \
191		--module=$(DOC_MODULE) \
192		$${_source_dir} \
193		 --expand-content-files="$(expand_content_files)" \
194		--main-sgml-file=$(srcdir)/$(DOC_MAIN_SGML_FILE) \
195		--output-format=xml \
196		--ignore-files="$(IGNORE_HFILES) $(IGNORE_CFILES)" \
197		$(MKDB_OPTIONS)
198	@$(PYTHON) $(top_srcdir)/common/mangle-db.py xml
199	@cp ../version.entities xml
200	@touch sgml-build.stamp
201
202sgml.stamp: sgml-build.stamp
203	@true
204
205#### html ####
206
207html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
208	@echo '  DOC   Building HTML'
209	@rm -rf html
210	@mkdir html
211	@cp $(srcdir)/$(DOC_MAIN_SGML_FILE) html
212	@for f in $(content_files); do cp $(srcdir)/$$f html; done
213	@cp -pr xml html
214	@cp ../version.entities html
215	@mkhtml_options=""; \
216	gtkdoc-mkhtml 2>&1 --help | grep  >/dev/null "\-\-verbose"; \
217	if test "$(?)" = "0"; then \
218	  if test "x$(V)" = "x1"; then \
219	    mkhtml_options="$$mkhtml_options --verbose"; \
220	  fi; \
221	fi; \
222	cd html && gtkdoc-mkhtml $$mkhtml_options $(DOC_MODULE)-@GST_API_VERSION@ $(DOC_MAIN_SGML_FILE)
223	@rm -f html/$(DOC_MAIN_SGML_FILE)
224	@rm -rf html/xml
225	@rm -f html/version.entities
226	@test "x$(HTML_IMAGES)" = "x" || for i in "" $(HTML_IMAGES) ; do \
227	    if test "$$i" != ""; then cp $(srcdir)/$$i html ; fi; done
228	@echo '  DOC   Fixing cross-references'
229	@gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
230	@touch html-build.stamp
231
232clean-local-gtkdoc:
233	@rm -rf xml tmpl html
234# clean files copied for nonsrcdir templates build
235	@if test x"$(srcdir)" != x. ; then \
236	    rm -rf $(SCANOBJ_FILES) $(SCAN_FILES) $(REPORT_FILES) \
237	        $(MAINTAINER_DOC_STAMPS); \
238	fi
239else
240all-local:
241clean-local-gtkdoc:
242endif
243
244clean-local: clean-local-gtkdoc
245	@rm -f *~ *.bak
246	@rm -rf .libs
247
248distclean-local:
249	@rm -f $(REPORT_FILES) \
250	        $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
251	@rm -rf tmpl/*.sgml.bak
252	@rm -f $(DOC_MODULE).hierarchy
253	@rm -f *.stamp || true
254	@if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
255	    rm -f $(DOC_MODULE)-docs.sgml ; \
256	    rm -f $(DOC_MODULE).types ; \
257	    rm -f $(DOC_MODULE).interfaces ; \
258	    rm -f $(DOC_MODULE)-overrides.txt ; \
259	    rm -f $(DOC_MODULE).prerequisites ; \
260	    rm -f $(DOC_MODULE)-sections.txt ; \
261	    rm -rf tmpl/*.sgml ; \
262	    rm -rf $(INSPECT_DIR); \
263	fi
264	@rm -rf *.o
265
266MAINTAINERCLEANFILES = $(MAINTAINER_DOC_STAMPS)
267
268# thomas: make docs parallel installable; devhelp requires majorminor too
269install-data-local:
270	(installfiles=`echo $(builddir)/html/*.sgml $(builddir)/html/*.html $(builddir)/html/*.png $(builddir)/html/*.css`; \
271	if test "$$installfiles" = '$(builddir)/html/*.sgml $(builddir)/html/*.html $(builddir)/html/*.png $(builddir)/html/*.css'; \
272	then echo '-- Nothing to install' ; \
273	else \
274	  $(mkinstalldirs) $(DESTDIR)$(TARGET_DIR); \
275	  for i in $$installfiles; do \
276	    echo '-- Installing '$$i ; \
277	    $(INSTALL_DATA) $$i $(DESTDIR)$(TARGET_DIR); \
278	  done; \
279	  pngfiles=`echo ./html/*.png`; \
280	  if test "$$pngfiles" != './html/*.png'; then \
281	    for i in $$pngfiles; do \
282	      echo '-- Installing '$$i ; \
283	      $(INSTALL_DATA) $$i $(DESTDIR)$(TARGET_DIR); \
284	    done; \
285	  fi; \
286	  echo '-- Installing $(builddir)/html/$(DOC_MODULE)-@GST_API_VERSION@.devhelp2' ; \
287	  if test -e $(builddir)/html/$(DOC_MODULE)-@GST_API_VERSION@.devhelp2; then \
288	            $(INSTALL_DATA) $(builddir)/html/$(DOC_MODULE)-@GST_API_VERSION@.devhelp2 \
289	            $(DESTDIR)$(TARGET_DIR)/$(DOC_MODULE)-@GST_API_VERSION@.devhelp2; \
290	  fi; \
291	  $(GTKDOC_REBASE) --relative --dest-dir=$(DESTDIR) --html-dir=$(DESTDIR)$(TARGET_DIR) || true ; \
292	fi)
293uninstall-local:
294	if test -d $(DESTDIR)$(TARGET_DIR); then \
295	  rm -rf $(DESTDIR)$(TARGET_DIR)/*; \
296	  rmdir -p $(DESTDIR)$(TARGET_DIR) 2>/dev/null || true; \
297	else \
298	  echo '-- Nothing to uninstall' ; \
299	fi;
300
301#
302# Checks
303#
304if ENABLE_GTK_DOC
305check-hierarchy: $(DOC_MODULE).hierarchy
306	@if grep '	' $(DOC_MODULE).hierarchy; then \
307	    echo "$(DOC_MODULE).hierarchy contains tabs, please fix"; \
308	    /bin/false; \
309	fi
310
311check: check-hierarchy
312endif
313
314# wildcard is apparently not portable to other makes, hence the use of find
315inspect_files = $(sort $(shell find $(srcdir)/$(INSPECT_DIR) -name '*.xml'))
316
317check-inspected-versions:
318	@echo Checking plugin versions of inspected plugin data ...; \
319	fail=0 ; \
320	for each in $(inspect_files) ; do \
321	  if (grep -H '<version>' $$each | grep -v '<version>$(VERSION)'); then \
322	    echo $$each should be fixed to say version $(VERSION) or be removed ; \
323	    echo "sed -i -e 's/<version.*version>/<version>$(VERSION)<\/version>/'" $$each; \
324	    echo ; \
325	    fail=1; \
326	  fi ; \
327	done ; \
328	exit $$fail
329
330check-outdated-docs:
331	$(AM_V_GEN)echo Checking for outdated plugin inspect data ...; \
332	fail=0 ; \
333	if [ -d $(top_srcdir)/.git/ ]; then \
334	  files=`find $(srcdir)/inspect/ -name '*xml'`; \
335	  for f in $$files; do \
336	    ver=`grep '<version>$(PACKAGE_VERSION)</version>' $$f`; \
337	    if test "x$$ver" = "x"; then \
338	      plugin=`echo $$f | sed -e 's/^.*plugin-//' -e 's/.xml//'`; \
339	      # echo "Checking $$plugin $$f"; \
340	      pushd "$(top_srcdir)" >/dev/null; \
341	      pinit=`git grep -A3 GST_PLUGIN_DEFINE -- ext/ gst/ sys/ | grep "\"$$plugin\""`; \
342	      popd >/dev/null; \
343	      # echo "[$$pinit]"; \
344	      if test "x$$pinit" = "x"; then \
345	        printf " **** outdated docs for plugin %-15s: %s\n" $$plugin $$f; \
346	        fail=1; \
347	      fi; \
348	    fi; \
349	  done; \
350	fi ; \
351	exit $$fail
352
353#
354# Require gtk-doc when making dist
355#
356if ENABLE_GTK_DOC
357dist-check-gtkdoc:
358else
359dist-check-gtkdoc:
360	@echo "*** gtk-doc must be installed and enabled in order to make dist"
361	@false
362endif
363
364# FIXME: decide whether we want to dist generated html or not
365# also this only works, if the project has been build before
366# we could dist html only if its there, but that might lead to missing html in
367# tarballs
368dist-hook: dist-check-gtkdoc dist-hook-local
369	mkdir $(distdir)/html
370	cp html/* $(distdir)/html
371	-cp $(srcdir)/$(DOC_MODULE).types $(distdir)/
372	-cp $(srcdir)/$(DOC_MODULE)-sections.txt $(distdir)/
373	cd $(distdir) && rm -f $(DISTCLEANFILES)
374	-gtkdoc-rebase --online --relative --html-dir=$(distdir)/html
375
376.PHONY : dist-hook-local docs check-outdated-docs inspect
377
378# avoid spurious build errors when distchecking with -jN
379.NOTPARALLEL:
380