summaryrefslogtreecommitdiffstats
path: root/docs/reference/Makefile.am
blob: 030fd1b8831d31e7e34c8bb38d57c78e4b182b05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
EXTRA_DIST = \
	lasso-sections.txt \
	lasso.sgml \
	lasso.types \
	version.xml.in

# We need to pre-process original source files
# because gtkdoc does not understand some C features
#
DOC_SOURCE_DIR = ./code
DOC_SOURCE_FILES = \
	$(shell find $(top_srcdir)/lasso -name '*.c' -print ) \
	$(shell find $(top_srcdir)/lasso -name '*.h' -print | grep -v private)

IGNORE_HFILES = lasso_config.h

# do nothing for all
all: docs

docs: sgml html clean-sources

html: sgml lasso.sgml lasso-index
	@echo '*** Building HTML ***'
	test -d html || mkdir html
	cd html && gtkdoc-mkhtml lasso ../build/lasso.sgml

SCANOBJ_FILES = lasso.hierarchy	lasso.signals lasso.interfaces lasso.prerequisites lasso.args

#
# Prepeare sgml files from sources for each library. We are also
# doing some "magic" here by automatically adding links to XML DSig and 
# XML Enc specification, we also remove "Ptr" from the end of the link
# targets to make more references
#
sgml: templates
	@echo '*** Building SGML ***'
	cp $(srcdir)/*.sgml version.xml build/
	cd build && gtkdoc-mkdb --module=lasso \
		    --main-sgml-file=lasso.sgml \
		    --sgml-mode \
		    --output-format=xml \
		    --tmpl-dir=../tmpl/ \
		    --source-dir=../$(DOC_SOURCE_DIR)/lasso \
		    --output-dir=../sgml/
	(for i in `find sgml -name "*.sgml" -print` ; do \
	    cat $$i | \
		sed 's!\(&lt;dsig:\)\([^/]*\)\(\/&gt;\)!<ulink URL=\"http://www.w3.org/TR/xmldsig-core/#sec-\2\">\1\2\3</ulink>!g' | \
		sed 's!\(&lt;enc:\)\([^/]*\)\(\/&gt;\)!<ulink URL=\"http://www.w3.org/TR/xmlenc-core/#sec-\2\">\1\2\3</ulink>!g' | \
		sed 's!linkend=\"\(.*\)Ptr\"!linkend=\"\1\"!g' > \
		$$i.tmp; \
		mv -f $$i.tmp $$i; \
	done);
	rm -f build/sgml && $(LN_S) ../sgml build/sgml


# don't rebuild templates if tmpl is not in srcdir
templates: scan
	@echo '*** Building TMPL ***'
	if test $(top_builddir) != $(top_srcdir); then \
		cp -R $(srcdir)/tmpl/ . ; \
		chmod +w tmpl/ ; \
		chmod +w tmpl/*.sgml ; \
	else \
		(cd build && gtkdoc-mktmpl --module=lasso --output-dir=../tmpl/) ; \
	fi

# CFLAGS and LDFLAGS for compiling scan program.
GTKDOC_CFLAGS = 		\
	$(LASSO_CFLAGS) 	\
	-I$(top_srcdir)

GTKDOC_LIBS = 	\
	$(LASSO_LIBS) \
	$(top_builddir)/lasso/liblasso.la

GTKDOC_CC = $(LIBTOOL) --mode=compile $(CC)
GTKDOC_LD = $(LIBTOOL) --mode=link $(CC)

scan: doc_sources
	test -d build || mkdir build
	@echo '*** Scan sources ***'
	cp $(srcdir)/lasso-sections.txt build/
	if grep -l '^..*$$' $(srcdir)/lasso.types > /dev/null ; then \
		CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)" CFLAGS="$(GTKDOC_CFLAGS)" LDFLAGS="$(GTKDOC_LIBS)" gtkdoc-scangobj $(SCANOBJ_OPTIONS) --module=lasso --types=$(srcdir)/lasso.types --output-dir=build/ ; \
	else \
		cd $(srcdir) ; \
		for i in $(SCANOBJ_FILES) ; do \
			test -f $$i || touch $$i ; \
		done \
	fi
	gtkdoc-scan --module=lasso \
		--source-dir=$(DOC_SOURCE_DIR)/lasso/ \
		--output-dir=build/ \
		--ignore-headers="$(IGNORE_HFILES)"

#
# Prepare source files by coping them to "code" folder and 
# removing LASSO_EXPORT* stuff that makes gtkdoc crazy
#
doc_sources: $(DOC_SOURCE_FILES)
	@echo '*** Prepare sources ***'
	(for i in $(DOC_SOURCE_FILES) ; do \
	    folder_name=`echo $$i | sed 's#$(top_srcdir)/##' | sed 's#/[^/]*$$##'`; \
	    file_name=`echo $$i | sed 's#.*/##'`; \
	    test -d $(DOC_SOURCE_DIR)/$$folder_name || mkdir -p $(DOC_SOURCE_DIR)/$$folder_name; \
	    cat $$i | \
		sed 's/#if.*//' | \
		sed 's/#el.*//' | \
		sed 's/#end.*//' | \
		sed 's/LASSO_EXPORT_VAR//' | \
		sed 's/LASSO_EXPORT//' > \
		$(DOC_SOURCE_DIR)/$$folder_name/$$file_name; \
	done);

#
# Create index for all functions. For macros and defines need to add -CAPS suffix
#
lasso-index: scan 
	@echo '*** Create functions index ***'
	grep -h '<NAME>.*</NAME>' build/lasso-*decl.txt | \
		grep -v '<NAME>extern</NAME>' | \
		sort -u | \
		sed 's#_#-#g' | \
		sed 's#<NAME>\([^-]*\)-\([^<]*\)</NAME>#<listitem><para><link linkend=\"\1-\2-CAPS\">\1-\2</link></para></listitem>#g' | \
		sed 's#<NAME>\([^<]*\)</NAME>#<listitem><para><link linkend=\"\1\">\1</link></para></listitem>#g' > \
		sgml/lasso-index.sgml

clean-local: clean-sources
	-rm -rf $(DOC_SOURCE_DIR)
	-rm -rf .libs
	-if test $(top_builddir) != $(top_srcdir); then rm -f tmpl/*.sgml ; fi
	-rm -rf sgml
	-rm -rf html
	-rm -rf build
	-rm -f $(SCANOBJ_FILES) index.sgml lasso-index.sgml
	-rm -rf  $(SCANOBJ_FILES) *.o *~ *.bak *.stamp

clean-sources:
	-rm -rf code

maintainer-clean-local: clean
	-rm -rf `find sgml -name "*.sgml" -print`

if GTK_DOC_ENABLED
dist-check-gtkdoc:
else
dist-check-gtkdoc:
	@echo "*** gtk-doc must be installed and enabled in order to make dist"
	@false
endif

dist-hook: dist-check-gtkdoc dist-hook-local
	mkdir $(distdir)/tmpl
	mkdir $(distdir)/html
	-cp $(srcdir)/tmpl/*.sgml $(distdir)/tmpl
	-cp $(srcdir)/html/* $(distdir)/html

.PHONY : dist-hook-local