00001 # OVERALL_DOCUMENT_SOURCE, COMMON_TOP and DOCUTILS_TOP should have been 00002 # defined beforehand. 00003 00004 00005 00006 .PHONY: doc doc-recurse info info-doc-local full-doc create-doc regenerate-doc \ 00007 make-doc-repository view-doc to-print info-doc-local info-doc-tools \ 00008 clean clean-doc-repository clean-generated clean-dot clean-doc-logs clean-gnuplot \ 00009 clean-png clean-rst 00010 00011 00012 00013 00014 # Generic rules. 00015 00016 00017 00018 # Image section. 00019 00020 #IMG_VIEWER := `which xv` 00021 IMG_VIEWER := `which eog` 00022 00023 IMAGE_MAGICK := `which convert` 00024 00025 00026 # Not all python scripts generate images: 00027 PNG_FROM_PYTHON = $(patsubst %-png-generator.py,%.png,$(wildcard *-png-generator.py)) 00028 00029 PNG_FROM_PYTHON_NEGATED = $(patsubst %-png-generator.py,%-negated.png,$(wildcard *-png-generator.py)) 00030 00031 00032 NEGATED_PNG = $(patsubst %.png,%-negated.png,$(wildcard *.png)) 00033 00034 %-negated.png: %.png 00035 @echo " Generating $@ from $< with $(IMAGE_MAGICK)" 00036 @$(IMAGE_MAGICK) $< -negate $@ 00037 00038 00039 00040 ROTATED_PNG = $(patsubst %.png,%-rotated.png,$(wildcard *.png)) 00041 00042 # '-transpose' is not what we want: 00043 %-rotated.png: %.png 00044 @echo " Generating $@ from $< with $(IMAGE_MAGICK)" 00045 @$(IMAGE_MAGICK) $< -rotate -90 $@ 00046 00047 00048 00049 # Graph rendering section. 00050 00051 DOT_OPT := -Gcharset=latin1 00052 00053 # Dot must found directly from the environment, since it is needed by 00054 # both the Make system and the Erlang application. 00055 # DOT := `PATH=$(DOT_ROOT)/bin:$$PATH which dot` $(DOT_OPT) 00056 DOT := `which dot` $(DOT_OPT) 00057 00058 # To trigger the automatic rendering of a created graph, add 'VIEW_GRAPH=' 00059 # at the end of the command line (ex : 'make MyFSM.png VIEW_GRAPH=') 00060 VIEW_GRAPH := no 00061 #VIEW_GRAPH := 00062 00063 00064 00065 %.png: %.graph 00066 @echo " Generating $@ from graph $<" 00067 @$(DOT) -o$@ -Tpng $< 00068 @if [ "$(VIEW_GRAPH)" != "no" ] ; then $(IMG_VIEWER) $@ & fi 00069 00070 GRAPH_SRC = $(wildcard *.graph) 00071 GRAPH_PNG = $(GRAPH_SRC:%.graph=%.png) 00072 00073 00074 00075 # Plot rendering section. 00076 00077 %.dat: %.py 00078 @echo " Generating plot data $@ from $<" 00079 @$(PYTHON) $< 00080 00081 # To trigger the automatic rendering of a created plot, add 'VIEW_PLOT=' 00082 # at the end of the command line (ex : 'make MyData.png VIEW_PLOT=') 00083 #VIEW_PLOT := yes 00084 VIEW_PLOT := no 00085 00086 GNUPLOT := `which gnuplot` 00087 00088 %.png: %.plot %.dat 00089 @echo " Generating plot $@" 00090 @$(GNUPLOT) $< 00091 @if [ "$(VIEW_PLOT)" != "no" ] ; then $(IMG_VIEWER) $@ & fi 00092 00093 %.png: %.py 00094 @echo " Generating image $@ from $<" 00095 @$(PYTHON) $< 00096 @if [ "$(VIEW_PLOT)" != "no" ] ; then $(IMG_VIEWER) $@ & fi 00097 00098 00099 # Probably deprecated: 00100 %-generated.png: %.pdoc %.plotdoc 00101 @echo " Generating plot $@" 00102 @$(GNUPLOT) $< 00103 @if [ "$(VIEW_PLOT)" != "no" ] ; then $(IMG_VIEWER) $@ & fi 00104 00105 00106 00107 00108 # RST section. 00109 00110 GENERATOR_LOG_FILE := "rst.log" 00111 00112 TMP_RST_REPOSITORY := "tmp-rst" 00113 00114 00115 # OVERALL_DOCUMENT_SOURCE defined in per-project GNUmakefile: 00116 OVERALL_DOCUMENT_TARGET = $(patsubst %.rst,%.pdf,$(OVERALL_DOCUMENT_SOURCE)) 00117 00118 RST_FILES = $(wildcard *.rst) 00119 00120 AUX_GENERATED_FILES = $(patsubst %.rst,%.aux,$(RST_FILES)) 00121 TEX_GENERATED_FILES = $(patsubst %.rst,%.tex,$(RST_FILES)) 00122 OUT_GENERATED_FILES = $(patsubst %.rst,%.out,$(RST_FILES)) 00123 LOG_GENERATED_FILES = $(patsubst %.rst,%.log,$(RST_FILES)) 00124 HTML_GENERATED_FILES = $(patsubst %.rst,%.html,$(RST_FILES)) 00125 PDF_GENERATED_FILES = $(patsubst %.rst,%.pdf,$(RST_FILES)) 00126 00127 00128 RST_GENERATED_FILES = $(AUX_GENERATED_FILES) $(TEX_GENERATED_FILES) \ 00129 $(OUT_GENERATED_FILES) $(LOG_GENERATED_FILES) $(HTML_GENERATED_FILES) \ 00130 $(PDF_GENERATED_FILES) $(GENERATOR_LOG_FILE) 00131 00132 00133 #RST_GENERATOR = update-docutils.sh 00134 RST_GENERATOR = `PATH=$(COMMON_TOP)/src:$$PATH which generate-docutils.sh` 00135 00136 00137 PDF_VIEWER := `which evince` 00138 00139 00140 # To trigger the automatic rendering of a created PDF, add 'VIEW_PDF=' 00141 # at the end of the command line (ex : 'make MyDoc.pdf VIEW_PDF=') 00142 VIEW_PDF := yes 00143 #VIEW_PDF := no 00144 00145 00146 %.pdf: %.rst 00147 @echo " Generating PDF documentation $@" 00148 @if $(RST_GENERATOR) $< --pdf ; then if [ "$(VIEW_PDF)" != "no" ] ; then $(PDF_VIEWER) $@ & fi; fi 00149 00150 00151 %.html: %.rst 00152 @echo " Generating HTML documentation $@" 00153 @$(RST_GENERATOR) $< $(PROJECT_CSS) 00154 00155 00156 00157 00158 00159 # Basic rules. 00160 00161 00162 00163 doc: $(GRAPH_PNG) $(PNG_FROM_PYTHON) $(PNG_FROM_PYTHON_NEGATED) doc-recurse #$(PDF_GENERATED_FILES) 00164 00165 00166 00167 00168 info: info-doc-local info-doc-tools 00169 00170 00171 info-doc-local: 00172 @echo "OVERALL_DOCUMENT_SOURCE = $(OVERALL_DOCUMENT_SOURCE)" 00173 @echo "OVERALL_DOCUMENT_TARGET = $(OVERALL_DOCUMENT_TARGET)" 00174 @echo "PRINT_SERVER = $(PRINT_SERVER)" 00175 00176 00177 info-doc-tools: 00178 @echo "DOT = $(DOT)" 00179 @echo "GNUPLOT = $(GNUPLOT)" 00180 @echo "IMG_VIEWER = $(IMG_VIEWER)" 00181 @echo "IMAGE_MAGICK = $(IMAGE_MAGICK)" 00182 @echo "PDF_VIEWER = $(PDF_VIEWER)" 00183 @echo "RST_GENERATOR = $(RST_GENERATOR)" 00184 00185 00186 00187 00188 # Centralization of documentation sources is necessary, as the LateX generator 00189 # from docutils will not find images in directories otherwise. 00190 # Note: cannot use a 'doc' target, as it would induce in an infinite recursion. 00191 full-doc: create-doc 00192 00193 00194 create-doc: regenerate-doc clean-doc-repository make-doc-repository 00195 @echo " Generating full (PDF) documentation from \ 00196 $(OVERALL_DOCUMENT_SOURCE) in $(TMP_RST_REPOSITORY) \ 00197 (log in $(GENERATOR_LOG_FILE))" 00198 @$(MAKE) $(TMP_RST_REPOSITORY)/$(OVERALL_DOCUMENT_TARGET) 2>&1 | \ 00199 tee $(GENERATOR_LOG_FILE) 00200 00201 00202 regenerate-doc: 00203 @echo " Regenerating all documentation elements" 00204 @cd $(DOCUTILS_TOP) && $(MAKE) -s doc 00205 00206 00207 make-doc-repository: 00208 @echo " Copying documentation sources to $(TMP_RST_REPOSITORY)" 00209 @mkdir -p $(TMP_RST_REPOSITORY) 00210 @find $(DOCUTILS_TOP) -name $(TMP_RST_REPOSITORY) -prune -o \( -name '*.rst' -o -name '*.png' \) -exec cp -f '{}' $(TMP_RST_REPOSITORY) ';' 00211 00212 00213 view-doc: 00214 @[ ! -e "$(TMP_RST_REPOSITORY)/$(OVERALL_DOCUMENT_TARGET)" ] || \ 00215 $(PDF_VIEWER) $(TMP_RST_REPOSITORY)/$(OVERALL_DOCUMENT_TARGET) \ 00216 1>/dev/null 2>&1 00217 00218 00219 to-print: create-doc 00220 @echo " Transferring document $(OVERALL_DOCUMENT_TARGET) \ 00221 to $(PRINT_SERVER)" 00222 @scp $(TMP_RST_REPOSITORY)/$(OVERALL_DOCUMENT_TARGET) $(PRINT_LOCATION) 00223 00224 00225 clean: clean-doc-repository clean-generated clean-dot clean-doc-logs \ 00226 clean-gnuplot clean-png clean-rst 00227 00228 00229 00230 clean-doc-repository: 00231 @echo " Cleaning documentation repository in $(TMP_RST_REPOSITORY)" 00232 -@rm -rf $(TMP_RST_REPOSITORY) 00233 00234 00235 clean-generated: 00236 @echo " Cleaning generated files" 00237 -@rm -f $(RST_GENERATED_FILES) 00238 00239 00240 00241 00242 # Some .png must be kept (ex: dia-exported ones). 00243 clean-dot: 00244 -@if [ `basename $$PWD` != "doc" ]; then \ 00245 /bin/rm -f $(STATE_MACHINES_DIAGRAMS) *.map; fi 00246 00247 00248 clean-doc-logs: 00249 -@/bin/rm -f *.log 00250 00251 00252 clean-gnuplot: 00253 @# Let's hope we do not remove user files: 00254 -@if [ `basename $$PWD` != "doc" ]; then \ 00255 /bin/rm -f *robe*.dat *robe*.p; fi 00256 00257 00258 clean-png: 00259 -@rm -f $(GRAPH_PNG) $(PNG_FROM_PYTHON) $(PNG_FROM_PYTHON_NEGATED) \ 00260 $(NEGATED_PNG) $(ROTATED_PNG) 00261 00262 00263 clean-rst: 00264 -@rm -f $(RST_GENERATED_FILES) 00265 @if [ -d "$(TMP_RST_REPOSITORY)" ] ; then $(MAKE) clean-doc-repository; fi 00266