&_cleanfiles: +"*.l[oa]T"
[macros.git] / Makefile-gtk-doc.am
1 # $Id$
2 # automake include file for gtk-doc, define your '#%' lines
3 # from gtk-doc-0.9-5/usr/share/doc/gtk-doc-0.9/examples/Makefile.am
4 # Copyright (C) 2002 Jan Kratochvil <project-macros@jankratochvil.net>
5
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; exactly version 2 of June 1991 is required
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
19
20 # local diff:
21 # s/EXTRA_DIST =/EXTRA_DIST +=/
22 # s/tmpl-build.stamp:/tmpl-build.stamp $(srcdir)/tmpl/*.sgml:/
23 #       Prevent: No rule to make target `tmpl/*.sgml', needed by `sgml-build.stamp'.  Stop.
24 #       Fixes gtk-doc-0.9/setting-up.txt/:
25 #               (Note that due to make being awkward the build
26 #               may fail the first time, but if you run make again it should work.)
27 # s/gtkdoc-scanobj/gtkdoc-scangobj/
28 #       Note that if your project is targeted at GTK+ 2.0 rather
29 #       than GTK+ 1.2.x, then you will have to change it so it
30 #       runs gtkdoc-scangobj rather than gtkdoc-scanobj.
31 # s/: scan-build.stamp/ $(DOC_MODULE)-sections.txt &/
32 #       Prevent: No rule to make target `$(DOC_MODULE)-sections.txt', needed by `distdir'.  Stop.
33 # s/gtkdoc-scan --module=/rm -f $(SCANOBJ_FILES) \&\& &/
34 #       Do not forget to rebuild some files.
35
36
37 # Create sgml/sgml/ to satisfy sgml/-based includes from sgml/MODULE-doc.top
38 # Prevent: sgml.stamp defined both conditionally and unconditionally
39 if ENABLE_GTK_DOC
40 sgml.stamp: sgml/sgml
41 sgml/sgml:
42         @$(LN_S) ./ $@
43 endif
44
45
46 #% ## Process this file with automake to produce Makefile.in
47 #% 
48 #% # This is a blank Makefile.am for using gtk-doc.
49 #% # Copy this to your project's API docs directory and modify the variables to
50 #% # suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples
51 #% # of using the various options.
52 #% 
53 #% # The name of the module, e.g. 'glib'.
54 #% DOC_MODULE=
55 #% 
56 #% # The top-level SGML file. Change it if you want.
57 #% DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
58 #% 
59 #% # The directory containing the source code. Relative to $(srcdir).
60 #% # gtk-doc will search all .c & .h files beneath here for inline comments
61 #% # documenting functions and macros.
62 #% DOC_SOURCE_DIR=
63 #% 
64 #% # Extra options to pass to gtkdoc-scangobj or gtkdoc-scangobj.
65 #% SCANOBJ_OPTIONS=
66 #% 
67 #% # Extra options to supply to gtkdoc-scan.
68 #% SCAN_OPTIONS=
69 #% 
70 #% # Extra options to supply to gtkdoc-mkdb.
71 #% MKDB_OPTIONS=
72 #% 
73 #% # Extra options to supply to gtkdoc-fixref.
74 #% FIXXREF_OPTIONS=
75 #% 
76 #% # Used for dependencies.
77 #% HFILE_GLOB=
78 #% CFILE_GLOB=
79 #% 
80 #% # Header files to ignore when scanning.
81 #% IGNORE_HFILES=
82 #% 
83 #% # Images to copy into HTML directory.
84 #% HTML_IMAGES =
85 #% 
86 #% # Extra SGML files that are included by $(DOC_MAIN_SGML_FILE).
87 #% content_files =
88 #% 
89 #% # Other files to distribute.
90 #% extra_files =
91 #% 
92 #% # CFLAGS and LDFLAGS for compiling scan program. Only needed if your app/lib
93 #% # contains GtkObjects/GObjects and you want to document signals and properties.
94 #% GTKDOC_CFLAGS =
95 #% GTKDOC_LIBS =
96 #% 
97 #% GTKDOC_CC=$(LIBTOOL) --mode=compile $(CC)
98 #% GTKDOC_LD=$(LIBTOOL) --mode=link $(CC)
99 #% 
100 #% # If you need to override some of the declarations, place them in the
101 #% # $(DOC_MODULE)-overrides.txt file and uncomment the second line here.
102 #% DOC_OVERRIDES =
103 #% #DOC_OVERRIDES = $(DOC_MODULE)-overrides.txt
104
105
106
107 ###########################################################################
108 # Everything below here is generic and you shouldn't need to change it.
109 ###########################################################################
110
111 TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)
112
113 EXTRA_DIST +=                           \
114         $(content_files)                \
115         $(extra_files)                  \
116         $(HTML_IMAGES)                  \
117         $(DOC_MAIN_SGML_FILE)           \
118         $(DOC_MODULE).types             \
119         $(DOC_MODULE)-sections.txt      \
120         $(DOC_OVERRIDES)
121
122 DOC_STAMPS=scan-build.stamp tmpl-build.stamp sgml-build.stamp html-build.stamp \
123            $(srcdir)/tmpl.stamp $(srcdir)/sgml.stamp $(srcdir)/html.stamp
124
125 SCANOBJ_FILES =                 \
126         $(DOC_MODULE).args      \
127         $(DOC_MODULE).hierarchy \
128         $(DOC_MODULE).signals
129
130 if ENABLE_GTK_DOC
131 all-local: html-build.stamp
132
133 #### scan ####
134
135 scan-build.stamp: $(HFILE_GLOB)
136         @echo '*** Scanning header files ***'
137         if grep -l '^..*$$' $(srcdir)/$(DOC_MODULE).types > /dev/null ; then \
138             CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)" CFLAGS="$(GTKDOC_CFLAGS)" LDFLAGS="$(GTKDOC_LIBS)" gtkdoc-scangobj $(SCANOBJ_OPTIONS) --module=$(DOC_MODULE) --output-dir=$(srcdir) ; \
139         else \
140             cd $(srcdir) ; \
141             for i in $(SCANOBJ_FILES) ; do \
142                test -f $$i || touch $$i ; \
143             done \
144         fi
145         cd $(srcdir) && \
146           rm -f $(SCANOBJ_FILES) && gtkdoc-scan --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR) --ignore-headers="$(IGNORE_HFILES)" $(SCAN_OPTIONS) $(EXTRA_HFILES)
147         touch scan-build.stamp
148
149 $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt : scan-build.stamp
150         @true
151
152 #### templates ####
153
154 tmpl-build.stamp $(srcdir)/tmpl/*.sgml: $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_OVERRIDES)
155         @echo '*** Rebuilding template files ***'
156         cd $(srcdir) && gtkdoc-mktmpl --module=$(DOC_MODULE)
157         touch tmpl-build.stamp
158
159 tmpl.stamp: tmpl-build.stamp
160         @true
161
162 #### sgml ####
163
164 sgml-build.stamp: tmpl.stamp $(CFILE_GLOB) $(srcdir)/tmpl/*.sgml
165         @echo '*** Building SGML ***'
166         cd $(srcdir) && \
167         gtkdoc-mkdb --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR) --main-sgml-file=$(DOC_MAIN_SGML_FILE) $(MKDB_OPTIONS)
168         touch sgml-build.stamp
169
170 sgml.stamp: sgml-build.stamp
171         @true
172
173 #### html ####
174
175 html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
176         @echo '*** Building HTML ***'
177         test -d $(srcdir)/html || mkdir $(srcdir)/html
178         cd $(srcdir)/html && gtkdoc-mkhtml $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE)
179         test "x$(HTML_IMAGES)" = "x" || ( cd $(srcdir) && cp $(HTML_IMAGES) html )
180         @echo '-- Fixing Crossreferences' 
181         cd $(srcdir) && gtkdoc-fixxref --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
182         touch html-build.stamp
183 endif
184
185 ##############
186
187 clean-local:
188         rm -f *~ *.bak $(SCANOBJ_FILES) *-unused.txt $(DOC_STAMPS)
189
190 maintainer-clean-local: clean
191         cd $(srcdir) && rm -rf sgml html $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
192
193 install-data-local:
194         $(mkinstalldirs) $(DESTDIR)$(TARGET_DIR)
195         (installfiles=`echo $(srcdir)/html/*.html`; \
196         if test "$$installfiles" = '$(srcdir)/html/*.html'; \
197         then echo '-- Nothing to install' ; \
198         else \
199           for i in $$installfiles; do \
200             echo '-- Installing '$$i ; \
201             $(INSTALL_DATA) $$i $(DESTDIR)$(TARGET_DIR); \
202           done; \
203           echo '-- Installing $(srcdir)/html/index.sgml' ; \
204           $(INSTALL_DATA) $(srcdir)/html/index.sgml $(DESTDIR)$(TARGET_DIR); \
205         fi)
206
207 #
208 # Require gtk-doc when making dist
209 #
210 if ENABLE_GTK_DOC
211 dist-check-gtkdoc:
212 else
213 dist-check-gtkdoc:
214         @echo "*** gtk-doc must be installed and enabled in order to make dist"
215         @false
216 endif
217
218 dist-hook: dist-check-gtkdoc dist-hook-local
219         mkdir $(distdir)/tmpl
220         mkdir $(distdir)/sgml
221         mkdir $(distdir)/html
222         -cp $(srcdir)/tmpl/*.sgml $(distdir)/tmpl
223         -cp $(srcdir)/sgml/*.sgml $(distdir)/sgml
224         -cp $(srcdir)/html/index.sgml $(distdir)/html
225         -cp $(srcdir)/html/*.html $(srcdir)/html/*.css $(distdir)/html
226
227         images=$(HTML_IMAGES) ;               \
228         for i in $$images ; do                \
229           cp $(srcdir)/$$i $(distdir)/html ;  \
230         done
231
232 .PHONY : dist-hook-local