~ubuntu-branches/ubuntu/edgy/lasso/edgy

1 by Frederic Peters
Import upstream version 0.4.1
1
TOP=$(top_srcdir)
2
DOC_MAIN_SGML_FILE=lasso.sgml
3
SOURCE_DIR=$(TOP)/lasso
4
INCLUDE_DIR=$(TOP)/lasso
5
6
EXTRA_DIST = \
7
	lasso-sections.txt \
8
	lasso.sgml \
9
	lasso.types 
10
11
# Extra options to pass to gtkdoc-scangobj.
12
SCANOBJ_OPTIONS=
13
14
#
15
# We need to pre-process original source files
16
# because gtkdoc does not understand some C features
17
#
18
DOC_SOURCE_DIR=./code
19
DOC_SOURCE_FILES=\
20
	$(shell find $(SOURCE_DIR) -name '*.c' -print ) \
21
	$(shell find $(INCLUDE_DIR) -name '*.h' -print )
22
23
# do nothing for all
24
all: docs
25
26
docs: sgml html clean-sources
27
28
html: sgml $(DOC_MAIN_SGML_FILE) lasso-index
29
	@echo '*** Building HTML ***'
30
	test -d html || mkdir html
31
	cd html && gtkdoc-mkhtml lasso ../build/$(DOC_MAIN_SGML_FILE)
32
33
SCANOBJ_FILES = lasso.hierarchy	lasso.signals lasso.interfaces lasso.prerequisites lasso.args
34
35
#
36
# Prepeare sgml files from sources for each library. We are also
37
# doing some "magic" here by automatically adding links to XML DSig and 
38
# XML Enc specification, we also remove "Ptr" from the end of the link
39
# targets to make more references
40
#
41
sgml: templates
42
	@echo '*** Building SGML ***'
43
	cd build && gtkdoc-mkdb --module=lasso \
44
		    --main-sgml-file=$(DOC_MAIN_SGML_FILE) \
45
		    --tmpl-dir=../tmpl/ \
46
		    --source-dir=../$(DOC_SOURCE_DIR)/lasso \
47
		    --output-dir=../sgml/
48
	cp $(srcdir)/lasso.sgml build/
49
	(for i in `find sgml -name "*.sgml" -print` ; do \
50
	    cat $$i | \
51
		sed 's!\(&lt;dsig:\)\([^/]*\)\(\/&gt;\)!<ulink URL=\"http://www.w3.org/TR/xmldsig-core/#sec-\2\">\1\2\3</ulink>!g' | \
52
		sed 's!\(&lt;enc:\)\([^/]*\)\(\/&gt;\)!<ulink URL=\"http://www.w3.org/TR/xmlenc-core/#sec-\2\">\1\2\3</ulink>!g' | \
53
		sed 's!linkend=\"\(.*\)Ptr\"!linkend=\"\1\"!g' > \
54
		$$i.tmp; \
55
		mv -f $$i.tmp $$i; \
56
	done);
57
	rm -f build/sgml && $(LN_S) ../sgml build/sgml
58
59
templates: scan
60
	@echo '*** Building TMPL ***'
61
	cd build && gtkdoc-mktmpl --module=lasso --output-dir=../tmpl/
62
63
# CFLAGS and LDFLAGS for compiling scan program.
64
GTKDOC_CFLAGS = 		\
65
	$(LASSO_CFLAGS) 	\
66
	-I$(top_srcdir)
67
68
GTKDOC_LIBS = 	\
69
	$(LASSO_LIBS) \
70
	$(top_builddir)/lasso/liblasso.la
71
72
GTKDOC_CC=$(LIBTOOL) --mode=compile $(CC)
73
GTKDOC_LD=$(LIBTOOL) --mode=link $(CC)
74
75
scan: doc_sources
76
	test -d build || mkdir build
77
	@echo '*** Scan sources ***'
78
	cp $(srcdir)/lasso-sections.txt build/
79
	if grep -l '^..*$$' $(srcdir)/lasso.types > /dev/null ; then \
80
		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/ ; \
81
	else \
82
		cd $(srcdir) ; \
83
		for i in $(SCANOBJ_FILES) ; do \
84
			test -f $$i || touch $$i ; \
85
		done \
86
	fi
87
	gtkdoc-scan --module=lasso --source-dir=$(DOC_SOURCE_DIR)/lasso/ --output-dir=build/
88
89
90
#
91
# Prepare source files by coping them to "code" folder and 
92
# removing LASSO_EXPORT* stuff that makes gtkdoc crazy
93
#
94
doc_sources: $(DOC_SOURCE_FILES)
95
	@echo '*** Prepare sources ***'
96
	(for i in $(DOC_SOURCE_FILES) ; do \
97
	    folder_name=`echo $$i | sed 's#$(TOP)/##' | sed 's#/[^/]*$$##'`; \
98
	    file_name=`echo $$i | sed 's#.*/##'`; \
99
	    test -d $(DOC_SOURCE_DIR)/$$folder_name || mkdir -p $(DOC_SOURCE_DIR)/$$folder_name; \
100
	    cat $$i | \
101
		sed 's/#if.*//' | \
102
		sed 's/#el.*//' | \
103
		sed 's/#end.*//' | \
104
		sed 's/LASSO_EXPORT_VAR//' | \
105
		sed 's/LASSO_EXPORT//' > \
106
		$(DOC_SOURCE_DIR)/$$folder_name/$$file_name; \
107
	done);
108
109
#
110
# Create index for all functions. For macros and defines need to add -CAPS suffix
111
#
112
lasso-index: scan 
113
	@echo '*** Create functions index ***'
114
	grep -h '<NAME>.*</NAME>' build/lasso-*decl.txt | \
115
		grep -v '<NAME>extern</NAME>' | \
116
		sort -u | \
117
		sed 's#_#-#g' | \
118
		sed 's#<NAME>\([^-]*\)-\([^<]*\)</NAME>#<listitem><para><link linkend=\"\1-\2-CAPS\">\1-\2</link></para></listitem>#g' | \
119
		sed 's#<NAME>\([^<]*\)</NAME>#<listitem><para><link linkend=\"\1\">\1</link></para></listitem>#g' > \
120
		sgml/lasso-index.sgml
121
122
#dist-hook:
123
#	@cp -p $(srcdir)/html/*.html $(srcdir)/images/*.png $(srcdir)/*.sgml $(distdir)
124
125
clean-local: clean-sources
126
	-rm -rf $(DOC_SOURCE_DIR)
127
	-rm -rf .libs
128
	-rm -rf tmpl
129
	-rm -rf sgml
130
	-rm -rf html
131
	-rm -rf build
132
	-rm -f $(SCANOBJ_FILES) index.sgml lasso-index.sgml
133
	-rm -rf  $(SCANOBJ_FILES) *.o *~ *.bak *.stamp
134
135
clean-sources:
136
	-rm -rf code
137
138
maintainer-clean-local: clean
139
	-rm -rf `find sgml -name "*.sgml" -print`
140