Annotation of htdocs/share/mk/web.site.mk, Revision 1.59
1.59 ! rillig 1: # $NetBSD: web.site.mk,v 1.58 2006/08/01 03:38:41 rillig Exp $
1.2 grant 2: # FreeBSD: www/share/mk/web.site.mk,v 1.43 2002/08/07 03:17:10 trhodes Exp
1.1 grant 3:
4: #
5: # Build and install a web site.
6: #
1.48 rillig 7: # The following variables may be set by htdocs Makefiles:
1.1 grant 8: #
1.49 rillig 9: # SUBDIR:
10: # The list of subdirectories that will be processed.
11: #
1.55 rillig 12: # HTMLDOCS:
13: # The list of basenames of *.html files that will be installed
14: # directly.
15: #
1.56 rillig 16: # GENDOCS:
17: # This list of filenames that will be generated in this directory.
1.59 ! rillig 18: # They are generated in the "all" target, installed in the "install"
! 19: # target and removed in the "clean" target.
1.56 rillig 20: #
1.49 rillig 21: # LISTDOCS:
22: # The list of *.list files that will be converted to HTML.
23: #
24: # LISTCOLLECTION:
25: # The name of the collection of manual pages that should be used
26: # for linking to the appropriate pages. It has the form
27: # NetBSD-${version}.
28: #
29: # Example:
30: # LISTCOLLECTION= NetBSD-1.6
31: #
1.48 rillig 32: # XMLDOCS:
33: # (See web.xml.mk.)
34: #
1.49 rillig 35: # CLEANFILES:
36: # List of additional files that will be deleted when "make clean"
37: # is run.
1.48 rillig 38: #
39: #
1.57 rillig 40: # The following targets are provided by this file and are expected to be
41: # called by the user.
1.48 rillig 42: #
1.57 rillig 43: # all (default):
1.48 rillig 44: # performs batch mode processing necessary
45: #
1.57 rillig 46: # install:
1.54 rillig 47: # Installs the generated files into a destination directory.
1.57 rillig 48: # Support for installation is not yet complete.
1.48 rillig 49: #
1.57 rillig 50: # clean:
1.48 rillig 51: # Removes automatically generated files.
52: #
1.57 rillig 53: # cleandir:
1.48 rillig 54: # Really removes all automatically generated files.
1.1 grant 55: #
1.57 rillig 56: #
57: # The following targets may be overridden in htdocs Makefiles.
58: #
59: # pre-install:
60: # Does nothing by default and is called before do-install.
61: #
62: # do-install:
63: # Installs the usual files.
64: #
65: # post-install:
66: # Does nothing by default and is called after do-install.
67: #
1.1 grant 68:
1.47 rillig 69: .MAIN: all
70:
1.42 rillig 71: #
1.43 rillig 72: # include default settings and /etc/mk.conf first
1.42 rillig 73: #
1.43 rillig 74: .include "web.prefs.mk"
1.42 rillig 75:
1.9 grant 76: LOCALBASE?= /usr/pkg
77: PREFIX?= ${LOCALBASE}
78:
1.1 grant 79: WEBDIR?= ${.CURDIR:T}
80: CGIDIR?= ${.CURDIR:T}
81: DESTDIR?= ${HOME}/public_html
82:
83: WEBOWN?= ${USER}
84: WEBGRP?= www
85: WEBMODE?= 664
86:
87: CGIOWN?= ${USER}
88: CGIGRP?= www
89: CGIMODE?= 775
90:
1.52 rillig 91: AWK?= /usr/bin/awk
92: CAT?= /bin/cat
1.1 grant 93: CP?= /bin/cp
94: CVS?= /usr/bin/cvs
1.3 grant 95: ECHO?= echo
1.39 heinz 96: GREP?= /usr/bin/grep
1.1 grant 97: SETENV?= /usr/bin/env
98: LN?= /bin/ln
99: MKDIR?= /bin/mkdir
1.53 rillig 100: M4?= /usr/bin/m4
1.1 grant 101: MV?= /bin/mv
1.3 grant 102: PERL?= ${PREFIX}/bin/perl
1.47 rillig 103: PRINTF?= /usr/bin/printf
1.1 grant 104: RM?= /bin/rm
105: SED?= /usr/bin/sed
106: SH?= /bin/sh
107: SORT?= /usr/bin/sort
108: TOUCH?= /usr/bin/touch
1.10 grant 109: HTML2TXT?= ${PREFIX}/bin/lynx
110: HTML2TXTOPTS?= -force_html -dump -nolist ${HTML2TXTFLAGS}
1.1 grant 111: ISPELL?= ispell
112: ISPELLOPTS?= -l -p ${WEB_PREFIX}/en/share/dict/words ${ISPELLFLAGS}
1.4 grant 113:
1.13 grant 114: # Handle old .LIST files.
1.29 hrs 115: .if exists(${WEB_PREFIX}/${DOCLANG}/list2html.pl)
116: LIST2HTML?= ${PERL} ${WEB_PREFIX}/${DOCLANG}/list2html.pl
1.13 grant 117: .else
118: LIST2HTML?= ${PERL} ${WEB_PREFIX}/list2html.pl
119: .endif
1.14 grant 120:
1.15 grant 121: LIST2HTMLOPTS?= -q
1.14 grant 122: .if defined(LISTCOLLECTION)
123: LIST2HTMLOPTS+= -c ${LISTCOLLECTION}
124: .endif
1.13 grant 125:
1.31 hrs 126: #
1.47 rillig 127: # Include the transformation rules.
1.31 hrs 128: #
1.47 rillig 129: .include "${.PARSEDIR}/web.xml.mk"
1.31 hrs 130:
1.46 hrs 131: lint: ${VALIDATE_DOCS}
132:
1.31 hrs 133: XML_CATALOG_FILES= file://${WEB_PREFIX}/${DOCLANG}/share/xml/catalog.xml \
134: file://${WEB_PREFIX}/share/xml/catalog.xml \
135: file://${WEB_PREFIX}/share/xml/catalog-common.xml
136: .if defined(PKG_SYSCONFDIR.xmlcatmgr)
137: XML_CATALOG_FILES+= file://${PKG_SYSCONFDIR.xmlcatmgr}/xml/catalog
138: .elif defined(PKG_SYSCONFBASE)
139: XML_CATALOG_FILES+= file://${PKG_SYSCONFBASE}/xml/catalog
140: .else
141: XML_CATALOG_FILES+= file://${LOCALBASE}/etc/xml/catalog
142: .endif
143:
144: # for docbook-website DTD
145:
146: AUTOLAYOUTFILE?=${WEB_PREFIX}/autolayout.xml
147: LAYOUTFILE?= ${WEB_PREFIX}/layout.xml
148:
149: # backward compatibility
150:
151: XSLFILE?= ${WEB_PREFIX}/share/xsl/netbsd-webpage-${DOCLANG}.xsl
152: XMLDEPS+= ${AUTOLAYOUTFILE}
153: XMLDEPS+= ${XSLFILE}
154: XMLDEPS+= ${WEB_PREFIX}/share/xsl/webpage.xsl
155: XMLDEPS+= ${WEB_PREFIX}/share/xsl/global.xsl
1.1 grant 156:
157: #
158: # Install dirs derived from the above.
159: #
1.31 hrs 160:
1.54 rillig 161: DOCINSTALLDIR= ${DESTDIR}/${HTDOCS_SUBDIR}
162: CGIINSTALLDIR= ${DESTDIR}/${CGIDIR}
1.1 grant 163:
1.52 rillig 164: # A flag to the install(1) command.
165: COPY= -c
1.1 grant 166:
167: ##################################################################
168: # Transformation rules
169:
170: ###
1.3 grant 171: # file.xml --> file.html
172: #
173: # Generate HTML from Docbook Website XML
174:
1.4 grant 175: .xml.html: ${XMLDEPS}
176: @${ECHO} "[xsltproc] ${.IMPSRC} -> ${.TARGET}"
1.47 rillig 177: ${RUN} ulimit -d 800000 && ${XSLTPROC} ${XSLTPROCOPTS} --stringparam autolayout-file ${AUTOLAYOUTFILE} -o ${.TARGET} ${XSLFILE} ${.IMPSRC}
1.10 grant 178:
179: .html.txt:
180: @${ECHO} "[html2txt] ${.IMPSRC} -> ${.TARGET}"
1.47 rillig 181: ${RUN} ${HTML2TXT} ${HTML2TXTOPTS} ${.IMPSRC} > ${.TARGET}
1.3 grant 182:
1.13 grant 183: ###
184: # file.list --> file.html
185: #
186: # Generate HTML from old LIST format files
187:
1.52 rillig 188: LISTDOCS?= # none
189: .if ${LISTDOCS:N*.list} != ""
190: ERRORS+= "All LISTDOCS entries must be of the form \"*.list\"."
191: .endif
192: GENDOCS+= ${LISTDOCS:.list=.html}
1.13 grant 193:
1.48 rillig 194: .for list in ${LISTDOCS}
195: . for html in ${list:.list=.html}
196: ${html}: ${list}
197: @${ECHO} "[list2html] ${list} -> ${html}"
198: ${RUN} ${LIST2HTML} ${LIST2HTMLOPTS} ${list} ${html}
199: . endfor
200: .endfor
1.13 grant 201:
1.55 rillig 202: #
203: # HTML files are just copied.
204: #
205: DATA+= ${HTMLDOCS:=.html}
206:
1.1 grant 207: ##################################################################
208: # Targets
209:
210: #
211: # If no target is specified, .MAIN is made
212: #
213: .MAIN: all
214:
215: #
216: # Build most everything
217: #
1.48 rillig 218: all: check-errors pre-all ${COOKIE} ${GENDOCS} ${DATA} ${LOCAL} ${CGI} _PROGSUBDIR
1.4 grant 219:
220: #
221: # Make sure autolayout.xml is up-to-date first
222: #
1.31 hrs 223: pre-all: ${AUTOLAYOUTFILE} ${WEB_PREFIX}/gallery/sites.xml
1.21 jschauma 224:
1.32 hrs 225: .if defined(AUTOLAYOUTDIR)
226: autolayout.xml: ${AUTOLAYOUTFILE} ${LAYOUTFILE}
1.4 grant 227: .endif
1.39 heinz 228:
1.31 hrs 229: ${AUTOLAYOUTFILE}: ${LAYOUTFILE}
1.32 hrs 230: .if defined(AUTOLAYOUTDIR)
1.28 minskim 231: @(cd gallery && ${MAKE} sites.xml)
1.4 grant 232: @${ECHO} "[xsltproc] layout.xml -> autolayout.xml"
1.47 rillig 233: ${RUN} ${XSLTPROC} --nonet -o ${.TARGET}.tmp \
1.39 heinz 234: ${WEB_PREFIX}/share/xsl/autolayout.xsl \
235: ${LAYOUTFILE}
1.47 rillig 236: ${RUN} ${XMLLINT} --xinclude --nonet --noent --nsclean --noxincludenode \
1.39 heinz 237: ${.TARGET}.tmp \
238: | ${GREP} -v '!ENTITY' > ${.TARGET} \
239: || (${RM} -f ${.TARGET}.tmp && false)
1.45 rillig 240: . if !defined(DEBUG)
1.47 rillig 241: ${RUN} ${RM} -f ${.TARGET}.tmp
1.45 rillig 242: . endif
1.40 heinz 243:
244: CLEANFILES+= ${AUTOLAYOUTFILE} ${AUTOLAYOUTFILE}.tmp
1.4 grant 245: .else
1.27 jschauma 246: @${ECHO} "htdocs/layout.xml has changed - rebuilding htdocs/autolayout.xml..."
1.47 rillig 247: ${RUN} cd ${WEB_PREFIX} && ${MAKE} autolayout.xml
1.4 grant 248: .endif
1.9 grant 249:
250: spellcheck:
251: .for _entry in ${GENDOCS}
252: @echo "Spellcheck ${_entry}"
1.47 rillig 253: ${RUN} ${HTML2TXT} ${HTML2TXTOPTS} ${.CURDIR}/${_entry} | ${ISPELL} ${ISPELLOPTS}
1.9 grant 254: .endfor
1.1 grant 255:
256: #
257: # Clean things up
258: #
259: .if !target(clean)
260: clean: _PROGSUBDIR
1.45 rillig 261: . if defined(DIRS_TO_CLEAN) && !empty(DIRS_TO_CLEAN)
262: . for dir in ${DIRS_TO_CLEAN}
1.1 grant 263: cd ${.CURDIR}/${dir}; ${MAKE} clean
1.45 rillig 264: . endfor
265: . endif
1.1 grant 266: ${RM} -f Errs errs mklog ${GENDOCS} ${LOCAL} ${CLEANFILES}
267: .endif
268:
269: #
270: # Really clean things up
271: #
272: .if !target(cleandir)
273: cleandir: clean _PROGSUBDIR
274: ${RM} -f ${.CURDIR}/tags .depend
275: cd ${.CURDIR}; ${RM} -rf obj
276: .endif
277:
278: #
1.52 rillig 279: # Installing a website to another directory.
1.1 grant 280: #
281:
1.52 rillig 282: # Commands to install files.
1.1 grant 283: INSTALL_WEB?= \
284: ${INSTALL} ${COPY} ${INSTALLFLAGS} -o ${WEBOWN} -g ${WEBGRP} -m ${WEBMODE}
285: INSTALL_CGI?= \
286: ${INSTALL} ${COPY} ${INSTALLFLAGS} -o ${CGIOWN} -g ${CGIGRP} -m ${CGIMODE}
1.52 rillig 287:
1.1 grant 288: _ALLINSTALL+= ${GENDOCS} ${DATA} ${LOCAL}
289:
1.52 rillig 290: .if !target(pre-install)
291: pre-install:
292: .endif
293:
294: .if !target(do-install)
295: do-install:
1.45 rillig 296: . if !empty(_ALLINSTALL)
1.47 rillig 297: ${MKDIR} -p ${DOCINSTALLDIR}
1.45 rillig 298: . for entry in ${_ALLINSTALL}
299: . if exists(${.CURDIR}/${entry})
1.1 grant 300: ${INSTALL_WEB} ${.CURDIR}/${entry} ${DOCINSTALLDIR}
1.45 rillig 301: . else
1.1 grant 302: ${INSTALL_WEB} ${entry} ${DOCINSTALLDIR}
1.45 rillig 303: . endif
304: . endfor
305: . if defined(INDEXLINK) && !empty(INDEXLINK)
1.1 grant 306: cd ${DOCINSTALLDIR}; ${LN} -fs ${INDEXLINK} index.html
1.45 rillig 307: . endif
308: . endif
309: . if defined(CGI) && !empty(CGI)
1.47 rillig 310: ${MKDIR} -p ${CGIINSTALLDIR}
1.45 rillig 311: . for entry in ${CGI}
1.1 grant 312: ${INSTALL_CGI} ${.CURDIR}/${entry} ${CGIINSTALLDIR}
1.45 rillig 313: . endfor
314: . endif
1.1 grant 315:
1.52 rillig 316: .endif
317:
318: .if !target(post-install)
319: post-install:
320: .endif
321:
322: install: _PROGSUBDIR
323:
1.1 grant 324: # Set up install dependencies so they happen in the correct order.
1.52 rillig 325: install: post-install
326: post-install: do-install
327: do-install: pre-install
328: pre-install: ${COOKIE} ${_ALLINSTALL} ${CGI}
1.1 grant 329:
330: #
331: # This recursively calls make in subdirectories.
332: #
333: #SUBDIR+=${DOCSUBDIR}
334: _PROGSUBDIR: .USE
335: .if defined(SUBDIR) && !empty(SUBDIR)
1.45 rillig 336: . for entry in ${SUBDIR}
1.47 rillig 337: @${ECHO} "===> Making ${.TARGET} in ${DIRPRFX}${entry}"
338: ${RUN} cd ${.CURDIR}/${entry}; \
1.1 grant 339: ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/} \
340: DIRPRFX=${DIRPRFX}${entry}/
1.45 rillig 341: . endfor
1.1 grant 342: .endif
343: .if defined(DOCSUBDIR) && !empty(DOCSUBDIR)
1.45 rillig 344: . for entry in ${DOCSUBDIR}
1.7 grant 345: @${ECHO} "===> ${DIRPRFX}${entry}"
1.47 rillig 346: ${RUN} if [ \( "${WEBDIR}" = "data" -a "${entry}" = "handbook" \) -o "${entry}" = "docproj-primer" ]; then \
1.1 grant 347: cd ${.CURDIR}/${entry}; \
348: ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/} \
349: DIRPRFX=${DIRPRFX}${entry}/ ${PARAMS} \
350: FORMATS="txt html html-split"; \
351: elif [ "${WEBDIR}" = "data/ja" -a "${entry}" = "handbook" ]; then \
352: cd ${.CURDIR}/${entry}; \
353: ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/} \
354: DIRPRFX=${DIRPRFX}${entry}/ ${PARAMS} \
355: FORMATS="html html-split"; \
356: else \
357: cd ${.CURDIR}/${entry}; \
358: ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/} \
359: DIRPRFX=${DIRPRFX}${entry}/ ${PARAMS}; \
360: fi
1.45 rillig 361: . endfor
1.1 grant 362: .endif
363:
364: .include <bsd.obj.mk>
1.47 rillig 365:
366: ERRORS?= # none
367: WARNINGS?= # none
368: .PHONY: check-errors
369:
370: check-errors:
371: .if !empty(ERRORS:M*)
372: @${PRINTF} "ERROR: %s\\n" ${ERRORS}
373: .endif
374: .if !empty(WARNINGS:M*)
375: @${PRINTF} "WARNING: %s\\n" ${WARNINGS}
376: .endif
377: .if !empty(ERRORS:M*)
378: @false
379: .endif
1.51 rillig 380:
381: .PHONY: show-var
382: show-var:
383: @${ECHO} ${VARNAME}=${${VARNAME}:Q}
1.47 rillig 384:
1.1 grant 385: # THE END
CVSweb <webmaster@jp.NetBSD.org>