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