1#
2# Makefile for Doc subdirectory
3#
4# Copyright (c) 1995-1997 Richard Coleman
5# All rights reserved.
6#
7# Permission is hereby granted, without written agreement and without
8# license or royalty fees, to use, copy, modify, and distribute this
9# software and to distribute modified versions of this software for any
10# purpose, provided that the above copyright notice and the following
11# two paragraphs appear in all copies of this software.
12#
13# In no event shall Richard Coleman or the Zsh Development Group be liable
14# to any party for direct, indirect, special, incidental, or consequential
15# damages arising out of the use of this software and its documentation,
16# even if Richard Coleman and the Zsh Development Group have been advised of
17# the possibility of such damage.
18#
19# Richard Coleman and the Zsh Development Group specifically disclaim any
20# warranties, including, but not limited to, the implied warranties of
21# merchantability and fitness for a particular purpose.  The software
22# provided hereunder is on an "as is" basis, and Richard Coleman and the
23# Zsh Development Group have no obligation to provide maintenance,
24# support, updates, enhancements, or modifications.
25#
26
27subdir = Doc
28dir_top = ..
29
30@VERSION_MK@
31
32# source/build directories
33VPATH           = @srcdir@
34sdir            = @srcdir@
35sdir_top        = @top_srcdir@
36INSTALL         = @INSTALL@
37LN_S            = @LN_S@
38
39@DEFS_MK@
40
41MAKEINFO = makeinfo
42TEXI2DVI = texi2dvi
43DVIPS = dvips
44TEXI2HTML = @TEXI2HTML@ --output . --ifinfo --split=chapter --node-files
45
46.SUFFIXES: .yo .1
47
48# man pages to install
49MAN = zsh.1 zshbuiltins.1 zshcompctl.1 zshcompwid.1 zshcompsys.1 \
50zshcontrib.1 zshexpn.1 zshmisc.1 zshmodules.1 \
51zshoptions.1 zshparam.1 zshroadmap.1 zshtcpsys.1 zshzftpsys.1 zshzle.1 \
52zshall.1
53
54# yodl documentation
55
56YODLDOC = $(MAN) texi
57
58MODDOCSRC = \
59Zsh/mod_attr.yo Zsh/mod_cap.yo Zsh/mod_clone.yo \
60Zsh/mod_compctl.yo Zsh/mod_complete.yo Zsh/mod_complist.yo \
61Zsh/mod_computil.yo Zsh/mod_curses.yo \
62Zsh/mod_datetime.yo Zsh/mod_deltochar.yo \
63Zsh/mod_example.yo Zsh/mod_files.yo Zsh/mod_langinfo.yo \
64Zsh/mod_mapfile.yo Zsh/mod_mathfunc.yo Zsh/mod_newuser.yo \
65Zsh/mod_parameter.yo Zsh/mod_pcre.yo Zsh/mod_regex.yo \
66Zsh/mod_sched.yo Zsh/mod_socket.yo \
67Zsh/mod_stat.yo  Zsh/mod_system.yo Zsh/mod_tcp.yo \
68Zsh/mod_termcap.yo Zsh/mod_terminfo.yo \
69Zsh/mod_zftp.yo Zsh/mod_zle.yo Zsh/mod_zleparameter.yo \
70Zsh/mod_zprof.yo Zsh/mod_zpty.yo Zsh/mod_zselect.yo \
71Zsh/mod_zutil.yo
72
73YODLSRC = zmacros.yo zman.yo ztexi.yo Zsh/arith.yo Zsh/builtins.yo \
74Zsh/compat.yo Zsh/compctl.yo Zsh/compsys.yo Zsh/compwid.yo Zsh/cond.yo \
75Zsh/contrib.yo Zsh/exec.yo Zsh/expn.yo \
76Zsh/filelist.yo Zsh/files.yo Zsh/ftp_sites.yo \
77Zsh/func.yo Zsh/grammar.yo Zsh/manual.yo \
78Zsh/index.yo Zsh/intro.yo Zsh/invoke.yo Zsh/jobs.yo Zsh/metafaq.yo \
79Zsh/modules.yo Zsh/modlist.yo Zsh/modmenu.yo Zsh/manmodmenu.yo $(MODDOCSRC) \
80Zsh/options.yo Zsh/params.yo Zsh/prompt.yo Zsh/redirect.yo Zsh/restricted.yo \
81Zsh/seealso.yo Zsh/tcpsys.yo Zsh/zftpsys.yo Zsh/zle.yo
82
83# ========== DEPENDENCIES FOR BUILDING ==========
84
85all: man $(runhelp) texi ../META-FAQ
86.PHONY: all
87
88everything: all dvi html pdf info
89.PHONY: everything
90
91dvi: zsh.dvi
92.PHONY: dvi
93
94zsh.dvi: $(sdir)/zsh.texi
95	$(TEXI2DVI) $(sdir)/zsh.texi
96
97pdf: zsh.pdf intro.a4.pdf intro.us.pdf
98.PHONY: pdf
99
100zsh.pdf: $(sdir)/zsh.texi
101	if [ x$(TEXI2PDF) != x ]; then \
102	  $(TEXI2PDF) $(sdir)/zsh.texi; \
103	else \
104	  PDFTEX=$(PDFETEX) $(TEXI2DVI) --pdf $(sdir)/zsh.texi; \
105	fi
106
107# Use roff2ps / ps2pdf because pdfroff produces doubled output.
108intro.a4.pdf: $(sdir)/intro.ms
109	roff2ps -ms -P-pa4 < $(sdir)/intro.ms > intro.a4.ps
110	ps2pdf intro.a4.ps
111
112intro.us.pdf: $(sdir)/intro.ms
113	roff2ps -ms -P-pletter < $(sdir)/intro.ms > intro.us.ps
114	ps2pdf intro.us.ps
115
116texi: $(sdir)/zsh.texi
117.PHONY: texi
118
119$(sdir)/zsh.texi: version.yo
120	$(YODL) -o $@ -I$(sdir) -w ztexi.yo version.yo zsh.yo; \
121	test -f $@
122
123info: zsh.info
124.PHONY: info
125
126zsh.info: $(sdir)/zsh.texi
127	$(MAKEINFO) $(sdir)/zsh.texi
128
129.yo.1:
130	@case $@ in \
131	  */*) target=$@ ;; \
132	  *) target=$(sdir)/$@ ;; \
133	esac; \
134	case '$(YODL)' in :*) touch $$target ;; *) \
135	    echo $(YODL) -o $$target -I$(sdir):. -w zman.yo version.yo $< ; \
136	    $(YODL) -I$(sdir):. -w zman.yo version.yo $< | \
137	      sed -e '1s/\\-/-/g' -e '/^\.'\''/d' -e 's/\(\\fB\)*'\''/\1\\\&'\''/' > $$target \
138	;; esac; \
139
140# These targets are no longer made by default, nor
141# distributed with the -doc.tar.gz, since the PDF
142# output is generally better.  However, they still work.
143ps: us_ps a4_ps
144.PHONY: ps
145
146us_ps: zsh_us.ps
147.PHONY: us_ps
148
149zsh_us.ps: zsh.dvi
150	$(DVIPS) -t letter -o $@ zsh.dvi
151
152a4_ps: zsh_a4.ps
153.PHONY: a4_ps
154
155zsh_a4.ps: zsh.dvi
156	$(DVIPS) -t a4 -o $@ zsh.dvi
157
158html: zsh_toc.html
159.PHONY: html
160
161zsh_toc.html: $(sdir)/zsh.texi
162	$(TEXI2HTML) $(sdir)/zsh.texi
163
164zshall.1: zsh.yo
165	@case $@ in \
166	  */*) target=$@ ;; \
167	  *) target=$(sdir)/$@ ;; \
168	esac; \
169	case '$(YODL)' in :*) touch $$target ;; *) \
170	    echo $(YODL) -o $$target -I$(sdir) -DZSHALL -w zman.yo version.yo zsh.yo; \
171	    $(YODL) -I$(sdir) -DZSHALL -w zman.yo version.yo zsh.yo | sed -e '1s/\\-/-/g' -e '/^\.'\''/d' > $$target \
172	;; esac; \
173
174../META-FAQ: META-FAQ.yo Zsh/metafaq.yo Zsh/ftp_sites.yo
175	case '$(YODL)' in :*) touch $(sdir_top)/META-FAQ ;; *) \
176	    $(YODL) -I$(sdir) META-FAQ.yo | sed -e '/NEXTLINE/N' -e '/DELLINE/d' -e '/^SECTHEAD$$/{N;s/^SECTHEAD.//;h;s/./-/g;H;g;}' -e 's/  *$$//' -e '/comment(.*)/d' > $(sdir_top)/META-FAQ \
177	;; esac
178
179$(YODLDOC): version.yo
180
181$(sdir)/zsh.texi: $(YODLSRC)
182
183man: $(MAN)
184.PHONY: man
185
186runhelp: help.txt
187.PHONY: runhelp
188
189help.txt: zshbuiltins.1
190	@-rm -f $(sdir)/help.txt $(sdir)/help/*
191	perl $(sdir_top)/Util/helpfiles \
192	    $(sdir)/zshbuiltins.1 $(sdir)/help $(sdir)/help.txt \
193	    || { rm -f $(sdir)/help.txt $(sdir)/help/*; false; }
194
195$(MAN): zmacros.yo zman.yo
196
197zsh.1 zshall.1: Zsh/intro.yo Zsh/metafaq.yo Zsh/invoke.yo Zsh/files.yo \
198                Zsh/filelist.yo Zsh/filelist.yo Zsh/seealso.yo \
199                Zsh/ftp_sites.yo Zsh/compat.yo Zsh/restricted.yo
200
201zshbuiltins.1: Zsh/builtins.yo
202
203zshcompctl.1: Zsh/compctl.yo
204
205zshcompwid.1: Zsh/compwid.yo
206
207zshcompsys.1: Zsh/compsys.yo
208
209zshcontrib.1: Zsh/contrib.yo
210
211zshexpn.1: Zsh/expn.yo
212
213zshmisc.1: Zsh/grammar.yo Zsh/redirect.yo Zsh/exec.yo Zsh/func.yo \
214           Zsh/jobs.yo Zsh/arith.yo Zsh/cond.yo Zsh/compat.yo \
215           Zsh/prompt.yo
216
217zshmodules.1: Zsh/modules.yo Zsh/modlist.yo Zsh/modmenu.yo $(MODDOCSRC)
218
219zshoptions.1: Zsh/options.yo
220
221zshparam.1: Zsh/params.yo
222
223zshroadmap.1: Zsh/roadmap.yo
224
225zshtcpsys.1: Zsh/tcpsys.yo
226
227zshzftpsys.1: Zsh/zftpsys.yo
228
229zshzle.1: Zsh/zle.yo
230
231# This should depend on config.status to get the /etc files right
232# but that would introduce a dependency on Yodl in shipped versions
233# of the shell that we want to avoid.
234version.yo: $(sdir_top)/Config/version.mk
235	( \
236	  echo 'IFDEF(INCWSLEVEL)(INCWSLEVEL())(STARTDEF())'; \
237	  echo 'def(version)(0)('$(VERSION)')'; \
238	  echo 'def(date)(0)('$(VERSION_DATE)')'; \
239	  echo 'def(zshenv)(0)(@zshenv@)'; \
240	  echo 'def(zprofile)(0)(@zprofile@)'; \
241	  echo 'def(zshrc)(0)(@zshrc@)'; \
242	  echo 'def(zlogin)(0)(@zlogin@)'; \
243	  echo 'def(zlogout)(0)(@zlogout@)'; \
244	  echo 'IFDEF(DECWSLEVEL)(DECWSLEVEL())(ENDDEF())#' | tr '#' '\\'; \
245	) > $(sdir)/version.yo
246
247Zsh/modlist.yo: $(MODDOCSRC)
248	( \
249	    echo "startitem()"; \
250	    for modfile in $(MODDOCSRC); do \
251		sed -n -e '1{s|^COMMENT(!MOD!\(.*\)$$|item(tt(\1))(|;p;d;}' \
252		    -e '/^!MOD!)$$/q;p' \
253		    < $(sdir)/$$modfile; \
254		echo ")"; \
255	    done; \
256	    echo "enditem()"; \
257	    echo "includefile(Zsh/modmenu.yo)"; \
258	    set '' $(MODDOCSRC); \
259	    mod1= mod2= mod3=; \
260	    test ".$$2" = . || \
261		mod2=`sed -n '1{s|^COMMENT(!MOD!||;p;q;}' < $(sdir)/$$2`; \
262	    while test ".$$2" != .; do \
263		mod3=; \
264		test ".$$3" = . || \
265		    mod3=`sed -n '1{s|^COMMENT(!MOD!||;p;q;}' < $(sdir)/$$3`; \
266		echo "texinode(The $$mod2 Module)($${mod3:+The $$mod3 Module})($${mod1:+The $$mod1 Module})(Zsh Modules)"; \
267		echo "sect(The $$mod2 Module)"; \
268		echo "includefile($${2})"; \
269		shift; \
270		mod1=$$mod2; \
271		mod2=$$mod3; \
272	    done \
273	) > $(sdir)/Zsh/modlist.yo
274
275Zsh/modmenu.yo: $(MODDOCSRC)
276	( \
277	    echo "startmenu()"; \
278	    for modfile in $(MODDOCSRC); do \
279		sed -n '1{s|^COMMENT(!MOD!\(.*\)$$|menu(The \1 Module)|;p;q;}' \
280		    < $(sdir)/$$modfile; \
281	    done; \
282	    echo "endmenu()" \
283	) > $(sdir)/Zsh/modmenu.yo
284
285Zsh/manmodmenu.yo: $(MODDOCSRC)
286	( \
287	    for modfile in $(MODDOCSRC); do \
288		sed -n '1{s|^COMMENT(!MOD!\(.*\)$$|menu(The \1 Module)|;p;q;}' \
289		    < $(sdir)/$$modfile; \
290	    done \
291	) > $(sdir)/Zsh/manmodmenu.yo
292
293# ========== DEPENDENCIES FOR INSTALLING ==========
294
295# install just installs the manual and runhelp pages
296install: install.man install.runhelp
297.PHONY: install
298
299# uninstall just uninstalls the manual and runhelp pages
300uninstall: uninstall.man uninstall.runhelp
301.PHONY: uninstall
302
303# install man pages, creating install directory if necessary
304install.man: man
305	${SHELL} $(sdir_top)/mkinstalldirs $(DESTDIR)$(mandir)/man1
306	for file in $(MAN); do \
307	    test -s $(sdir)/$$file || exit 1; \
308	    $(INSTALL_DATA) $(sdir)/$$file $(DESTDIR)$(mandir)/man1/`echo $$file | sed 's|zsh|$(tzsh)|'` || exit 1; \
309	done
310.PHONY: install.man
311
312# install runhelp pages, creating install directory if necessary
313install.runhelp: $(runhelp)
314	if test x"$(runhelpdir)" != x""; then \
315	    ${SHELL} $(sdir_top)/mkinstalldirs $(DESTDIR)$(runhelpdir); \
316	    $(INSTALL_DATA) $(sdir)/help/* $(DESTDIR)$(runhelpdir); \
317	    while read from to; do \
318	        rm -f $(DESTDIR)$(runhelpdir)/$$to || : ; \
319	        $(LN_S) $$from $(DESTDIR)$(runhelpdir)/$$to; \
320	    done < $(sdir)/help.txt; \
321	fi
322.PHONY: install.runhelp
323
324# install info pages, creating install directory if necessary
325install.info: texi
326	${SHELL} $(sdir_top)/mkinstalldirs $(DESTDIR)$(infodir)
327	rm -rf infodir
328	mkdir infodir
329	if ( \
330	    sed '/^@setfilename/s|zsh|$(tzsh)|' \
331		< $(sdir)/zsh.texi > infodir/tzsh.texi && \
332	    (cd infodir && $(MAKEINFO) tzsh.texi) && \
333	    for file in infodir/$(tzsh).info*; do \
334		$(INSTALL_DATA) $$file $(DESTDIR)$(infodir) || exit 1; \
335	    done \
336	); then \
337	    if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
338	      install-info --info-dir=$(DESTDIR)$(infodir) \
339	        $(DESTDIR)$(infodir)/$(tzsh).info; \
340	    else true; fi; \
341	    rm -rf infodir; \
342	    exit 0; \
343	else \
344	    rm -rf infodir; \
345	    exit 1; \
346	fi
347.PHONY: install.info
348
349# uninstall man pages
350uninstall.man:
351	for file in $(MAN); do \
352	    rm -f $(DESTDIR)$(mandir)/man1/`echo $$file | sed 's|zsh|$(tzsh)|'`; \
353	done
354.PHONY: uninstall.man
355
356# uninstall runhelp pages
357uninstall.runhelp:
358	test x"$(runhelpdir)" = x"" || rm -rf -- $(DESTDIR)$(runhelpdir)
359.PHONY: uninstall.runhelp
360
361# uninstall info pages
362uninstall.info:
363	rm -f $(DESTDIR)$(infodir)/$(tzsh).info
364	rm -f $(DESTDIR)$(infodir)/$(tzsh).info-[1-9]*
365.PHONY: uninstall.info
366
367# install HTML manual
368install.html: html
369	${SHELL} $(sdir_top)/mkinstalldirs $(DESTDIR)$(htmldir)
370	for file in *.html; do \
371	    $(INSTALL_DATA) $$file $(DESTDIR)$(htmldir) || exit 1; \
372	done
373.PHONY: install.html
374
375# uninstall HTML manual
376uninstall.html:
377	rm -f $(DESTDIR)$(htmldir)/*.html
378.PHONY: uninstall.html
379
380# ========== DEPENDENCIES FOR CLEANUP ==========
381
382clean-here:
383	rm -f *.html *.info* *.dvi *.ps *.pdf
384	rm -f *.aux *.cp *.cps *.fn *.fns *.ky *.log
385	rm -f *.pg *.pgs *.toc *.tp *.tps *.vr *.vrs
386	rm -rf infodir
387.PHONY: clean-here
388
389distclean-here: clean-here
390	rm -f Makefile
391.PHONY: distclean-here
392
393realclean-here: distclean-here
394	cd $(sdir) && rm -f Zsh/modlist.yo Zsh/modmenu.yo Zsh/manmodmenu.yo
395	cd $(sdir) && rm -f version.yo ../META-FAQ zsh.texi $(MAN)
396	cd $(sdir) && rm -f help.txt help/*
397.PHONY: realclean-here
398
399@CLEAN_MK@
400
401# ========== DEPENDENCIES FOR MAINTENANCE ==========
402
403@CONFIG_MK@
404