1####################################################################### 2# # 3# Pph # 4# # 5# The Portable Project Handler # 6# # 7# projets Estime & Cristal, INRIA-Rocquencourt # 8# # 9# Copyright 2005-2008 INRIA. # 10# Institut National de Recherche en Informatique et en Automatique. # 11# All rights reserved. This file is distributed only by permission. # 12# # 13# Francois Clement <Francois.Clement@inria.fr> # 14# Pierre Weis <Pierre.Weis@inria.fr> # 15# # 16####################################################################### 17 18# $Id: Common.pph,v 1.1 2008/03/12 17:08:08 fclement Exp $ 19 20# Generic specific common makefile for Text compilation. 21# 22# This generic makefile provides generic rules and common generic mutable 23# targets specific to the compilation of Text files. Namely, all compilation 24# rules related to PIC, TEX, BIB, DVI, PS, PDF, HTML, and MAN files, a specific 25# add-on to the clean target. It includes the shared generic universal common 26# makefile ``user/Common.pph''. 27# 28# To use this generic makefile, the following variables should be defined: 29# 30# - MAKEFILES_DIR = a path to the present directory, 31# 32# and one of the variables: 33# 34# - ROOT_DIR = a path to the directory containing the main subdirectory 35# ``Include'' for HTMLC and/or HEVEA inclusions 36# 37# and issue the following line: 38# 39#include $(MAKEFILES_DIR)/text/Config.pph 40# 41# Then, the user has to provide the following variables (when suitable): 42# 43# - TEX_SOURCES = the list of LaTeX source files for LATEX 44# - BIB_SOURCES = the list of BibTeX source files for BIBTEX2HTML 45# - HTMLC_HTML_SOURCES = the list of HTML source files for HTMLC 46# - HTMLC_MAN_SOURCES = the list of MAN source files for HTMLC 47# - OTHER_FILES = the list of files to install unprocessed. 48# 49# And finally, the user should issue one of the following lines: 50# 51#include $(MAKEFILES_DIR)/text/Common.pph 52#include $(MAKEFILES_DIR)/<lang>/Documentation.pph 53#include $(MAKEFILES_DIR)/<lang>/Library.pph 54#include $(MAKEFILES_DIR)/<lang>/Application.pph 55# 56# Note: 57# There is no proposed extensions to handle locale for text files. 58# If you need to deal with various translations of the same set of files, 59# you should create a separate subdirectory for each language. 60# Otherwise, we would have to define locale versions for all the suffixes, 61# which is not an option. 62 63include $(PPH_USER_MAKEFILES_DIR)/Common.pph 64 65# Generic rules. 66.SUFFIXES: .man .htm .m .html .shtml .data 67.SUFFIXES: .pdf .ps8 .ps4 .ps2 .ps .advi .dvi .bbl .bib .tex .pic 68 69.pic.tex: 70 $(PIC) -t $< > $@ 71 72.tex.dvi: 73 $(LATEX) $< 74 75.dvi.advi: 76 $(DVICOPY) $< > $@ 77 78.tex.bbl: 79 $(LATEX) $< 80 $(BIBTEX) $* 81 82.tex.ps: 83 $(LATEX) $< 84 $(LATEX) '\def\driver{dvips}\input' $< 85 $(DVIPS) -o $@ $*.dvi 86 87.tex.pdf: 88 $(LATEX) $< 89 $(LATEX) '\def\driver{dvipdfm}\input' $< 90 $(DVIPDFM) -o $@ $*.dvi 91 92.ps.ps2: 93 $(PSNUPL2) $< > $@ 94 95.ps.ps4: 96 $(PSNUPL4) $< > $@ 97 98.ps.ps8: 99 $(PSNUPL8) $< > $@ 100 101.tex.htm: 102 $(HEVEA) -o $@ $< 103 104.bib.htm: 105 $(BIBTEX2HTML) $< 106 107.data.html: 108 $(HTMLC) -from $< -to $@ 109 110.shtml.html: 111 $(HTMLC) -from $< -to $@ 112 113.html.htm: 114 $(HTMLC) -from $< -to $@ 115 116.man.m: 117 $(HTMLC) -from $< -to $@ 118 119# Generic compilation targets. 120.PHONY: tex dvi ps ps2 ps4 ps8 pdf htm html man m 121 122tex: $(PIC_OBJS) 123 124dvi: $(TEX_OBJS) 125 126ps: $(DVIPS_OBJS) 127 if test -n "`echo $(DVIPS_OBJS) | $(STRIP_WHITES)`"; then \ 128 $(GZIP) $(DVIPS_OBJS); \ 129 fi 130 131ps2: $(DVIPS2_OBJS) 132 if test -n "`echo $(DVIPS2_OBJS) | $(STRIP_WHITES)`"; then \ 133 $(GZIP) $(DVIPS2_OBJS); \ 134 fi 135 136ps4: $(DVIPS4_OBJS) 137 if test -n "`echo $(DVIPS4_OBJS) | $(STRIP_WHITES)`"; then \ 138 $(GZIP) $(DVIPS4_OBJS); \ 139 fi 140 141ps8: $(DVIPS8_OBJS) 142 if test -n "`echo $(DVIPS8_OBJS) | $(STRIP_WHITES)`"; then \ 143 $(GZIP) $(DVIPS8_OBJS); \ 144 fi 145 146pdf: $(DVIPDF_OBJS) 147 148html htm: $(HEVEA_OBJS) $(BIBTEX2HTML_OBJS) $(HTMLC_HTM_OBJS) 149 150man m: $(HTMLC_M_OBJS) 151 152# Generic installation targets. 153.PHONY: install-local-first-dependency 154.PHONY: install-local-toplevel-dir uninstall-local-toplevel-dir 155.PHONY: install-local-files uninstall-local-files 156.PHONY: uninstall-all-versions-local-dirs 157 158install-local: install-local-first-dependency install-local-files 159 160install-local-first-dependency: 161 162uninstall-local: uninstall-local-files 163 164uninstall-all-versions-local: uninstall-all-versions-local-dirs 165 166# To install: 167# * Create the installation directory with the current full version number; 168# * Then, make a version-free symbolic link towards the previously created 169# directory. 170# 171# To uninstall: 172# * Remove the version-free symbolic link only if it is a link towards the 173# installation directory with the current full version number; 174# * Then, remove the latter. 175# 176# The Pph user must explicitely ask for the local targets, e.g. by adding the 177# following dependencies in the toplevel ``Makefile_user'' file: 178# 179#install-local-first-dependency: install-local-toplevel-dir 180#uninstall-local: uninstall-local-toplevel-dir 181 182install-local-toplevel-dir: 183 @if test -n "`echo $(TEXT_INSTALL_ROOT_DIR) | $(STRIP_WHITES)`"; then \ 184 $(MKDIR) $(TEXT_INSTALL_ROOT_DIR); \ 185 (cd $(TEXT_INSTALL_ROOT_DIR); \ 186 $(RM) $(TEXT_INSTALL_DIR_NAME); \ 187 $(MKDIR) $(TEXT_INSTALL_DIR_NAME); \ 188 $(RM) $(TEXT_INSTALL_DIR_SHORT_NAME); \ 189 $(LN) $(TEXT_INSTALL_DIR_NAME) $(TEXT_INSTALL_DIR_SHORT_NAME); \ 190 $(RM) $(TEXT_INSTALL_DIR_BASE_NAME); \ 191 $(LN) $(TEXT_INSTALL_DIR_SHORT_NAME) $(TEXT_INSTALL_DIR_BASE_NAME)); \ 192 else \ 193 echo "Error: empty TEXT_INSTALL_ROOT_DIR."; \ 194 exit $(EMPTY_VALUE_ERROR); \ 195 fi 196 197# To allow smooth uninstallation of old versions of the project, 198# TEXT_INSTALL_DIR_BASE_NAME is removed only if it is a link towards 199# TEXT_INSTALL_DIR_SHORT_NAME and the latter is a link towards 200# TEXT_INSTALL_DIR_NAME. 201uninstall-local-toplevel-dir: uninstall-local-files 202 @if test -n "`echo $(TEXT_INSTALL_ROOT_DIR) | $(STRIP_WHITES)`"; then \ 203 if test -d $(TEXT_INSTALL_ROOT_DIR); then \ 204 (cd $(TEXT_INSTALL_ROOT_DIR); \ 205 if test -h $(TEXT_INSTALL_DIR_SHORT_NAME); then \ 206 LNK=`$(LL) $(TEXT_INSTALL_DIR_SHORT_NAME) \ 207 | $(AWK) -F'->' '{print $$2}' | $(STRIP_WHITES)`; \ 208 if test "$$LNK" = $(TEXT_INSTALL_DIR_NAME); then \ 209 $(RM) $(TEXT_INSTALL_DIR_SHORT_NAME); \ 210 if test -h $(TEXT_INSTALL_DIR_BASE_NAME); then \ 211 LNK=`$(LL) $(TEXT_INSTALL_DIR_BASE_NAME) \ 212 | $(AWK) -F'->' '{print $$2}' | $(STRIP_WHITES)`; \ 213 if test "$$LNK" = $(TEXT_INSTALL_DIR_SHORT_NAME); then \ 214 $(RM) $(TEXT_INSTALL_DIR_BASE_NAME); \ 215 fi; \ 216 elif test -e $(TEXT_INSTALL_DIR_BASE_NAME); then \ 217 echo "Warning: in directory $(TEXT_INSTALL_ROOT_DIR), " \ 218 "$(TEXT_INSTALL_DIR_BASE_NAME) is not a link!"; \ 219 fi; \ 220 fi; \ 221 elif test -e $(TEXT_INSTALL_DIR_SHORT_NAME); then \ 222 echo "Warning: in directory $(TEXT_INSTALL_ROOT_DIR), " \ 223 "$(TEXT_INSTALL_DIR_SHORT_NAME) is not a link!"; \ 224 fi; \ 225 if test -d $(TEXT_INSTALL_DIR_NAME); then \ 226 $(RM) $(TEXT_INSTALL_DIR_NAME); \ 227 elif test -e $(TEXT_INSTALL_DIR_NAME); then \ 228 echo "Warning: in directory $(TEXT_INSTALL_ROOT_DIR), " \ 229 "$(TEXT_INSTALL_DIR_NAME) is not a subdirectory!"; \ 230 fi); \ 231 if test `$(LS) -a1 $(TEXT_INSTALL_ROOT_DIR) | $(WCL)` = 2; then \ 232 $(RMDIR) $(TEXT_INSTALL_ROOT_DIR); \ 233 fi; \ 234 fi; \ 235 else \ 236 echo "Error: empty TEXT_INSTALL_ROOT_DIR."; \ 237 exit $(EMPTY_VALUE_ERROR); \ 238 fi 239 240uninstall-all-versions-local-dirs: 241 @if test -n "`echo $(TEXT_INSTALL_ROOT_DIR) | $(STRIP_WHITES)`"; then \ 242 if test -d $(TEXT_INSTALL_ROOT_DIR); then \ 243 (cd $(TEXT_INSTALL_ROOT_DIR); \ 244 DIRS_TO_UNINSTALL="`$(LS) -d $(TEXT_INSTALL_DIR_BASE_NAME){,-*} \ 245 2> /dev/null`"; \ 246 if test -n "`echo $$DIRS_TO_UNINSTALL | $(STRIP_WHITES)`"; then \ 247 echo "You are about to remove the following directories:"; \ 248 echo "$$DIRS_TO_UNINSTALL"; \ 249 echo "Proceed? [y/N] " | $(STRIP_NEW_LINE); \ 250 read YN; \ 251 case $$YN in \ 252 ( y* | Y* | o* | O* ) $(RM) $$DIRS_TO_UNINSTALL;; \ 253 esac; \ 254 fi); \ 255 if test `$(LS) -a1 $(TEXT_INSTALL_ROOT_DIR) | $(WCL)` = 2; then \ 256 $(RMDIR) $(TEXT_INSTALL_ROOT_DIR); \ 257 fi; \ 258 fi; \ 259 else \ 260 echo "Error: empty TEXT_INSTALL_ROOT_DIR."; \ 261 exit $(EMPTY_VALUE_ERROR); \ 262 fi 263 264# If the list ALL_TEXT_FILES_TO_INSTALL is not reduced to blanks, and if the Text 265# installation directory is given, then all files listed are copied (with a 266# tar-pipe-tar command). 267# At the end, if a nonempty regular expression is given, the copied hierarchy 268# is cleaned up accordingly. 269# We need a specific target since the regular target install-local is defined 270# in Application.pph. 271install-local-files: $(ALL_TEXT_FILES_TO_INSTALL) 272 @if test -n "`echo $(ALL_TEXT_FILES_TO_INSTALL) | $(STRIP_WHITES)`"; \ 273 then \ 274 if test -n "`echo $(TEXT_INSTALL_DIR) | $(STRIP_WHITES)`"; then \ 275 $(MKDIR) $(TEXT_INSTALL_DIR); \ 276 if test -n "`echo $(ALL_READ_ONLY_TEXT_FILES_TO_INSTALL) \ 277 | $(STRIP_WHITES)`"; then \ 278 $(INSTALL_READ_ONLY) \ 279 $(ALL_READ_ONLY_TEXT_FILES_TO_INSTALL) $(TEXT_INSTALL_DIR); \ 280 fi; \ 281 if test -n "`echo $(ALL_EXECUTABLE_TEXT_FILES_TO_INSTALL) \ 282 | $(STRIP_WHITES)`"; then \ 283 $(INSTALL_EXECUTABLE) \ 284 $(ALL_EXECUTABLE_TEXT_FILES_TO_INSTALL) $(TEXT_INSTALL_DIR); \ 285 fi; \ 286 else \ 287 echo "Error: empty TEXT_INSTALL_DIR."; \ 288 exit $(EMPTY_VALUE_ERROR); \ 289 fi; \ 290 fi 291 292uninstall-local-files: 293 @if test -n "`echo $(ALL_TEXT_FILES_TO_INSTALL) | $(STRIP_WHITES)`"; \ 294 then \ 295 if test -n "`echo $(TEXT_INSTALL_DIR) | $(STRIP_WHITES)`"; then \ 296 if test -d $(TEXT_INSTALL_DIR); then \ 297 (cd $(TEXT_INSTALL_DIR); $(RM) $(ALL_TEXT_FILES_TO_INSTALL)); \ 298 if test `$(LS) -a1 $(TEXT_INSTALL_DIR) | $(WCL)` = 2; then \ 299 $(RMDIR) $(TEXT_INSTALL_DIR); \ 300 fi; \ 301 fi; \ 302 else \ 303 echo "Error: empty TEXT_INSTALL_DIR."; \ 304 exit $(EMPTY_VALUE_ERROR); \ 305 fi; \ 306 fi 307 308clean-local:: 309 $(RM) *.aux *.log *.idx *.advi *.out *.toc *.bbl *.blg 310 $(RM) *.hidx *.hind *.haux *.htoc *.image.tex 311 312clean-all-local:: 313 $(RM) $(ALL_TEXT_OBJS) 314