first version.
[build-srcpkg.git] / res / builder / build-srcpkg / shlib / doc / tex.shlib
bloba303acf2a9c83ff67dfd57fcd2d42a4bf0d56404
1 #!/bin/bash
2 ############################################################
3 # source: flex.shlib
4 # author: devenkong(18151155@qq.com)
5 # date: 2023-10-17
6 ############################################################
7 # note:
8 # use flex to generate lexer proc srcfile.
9 ############################################################
12 # todo£º
13 # @
14 # @
17 . shlibinc
19 include gplib.shlib
21 include stdio.shlib
22 #include term.shlib
25 ##############################
26 # section: public comment info
27 ##############################
31 ##############################
32 # section: variable define
33 ##############################
35 # bad style
36 RL_LIBDIR = $(topdir)/lib/readline
38 # unused
39 TEXINDEX = texindex
40 TEX = tex
42 TEXINPUTDIR = $(RL_LIBDIR)/doc
43 SET_TEXINPUTS = TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS
45 HSUSER = $(RL_LIBDIR)/doc/hsuser.texi
46 RLUSER = $(RL_LIBDIR)/doc/rluser.texi
50 MAKEINFO=makeinfo
51 TEXI2DVI=${SUPPORT_SRCDIR}/texi2dvi
52 TEXI2HTML=${SUPPORT_SRCDIR}/texi2html
53 MAN2HTML=${BUILD_DIR}/support/man2html
54 HTMLPOST=${srcdir}/htmlpost.sh
55 INFOPOST=${srcdir}/infopost.sh
57 QUIETPS=#set this to -q to shut up dvips
58 PAPERSIZE=letter # change to a4 for A4-size paper
59 PSDPI=600 # could be 300 if you like
61 DVIPS=dvips -D ${PSDPI} $(QUIETPS) -t ${PAPERSIZE} -o $@ # tricky
62 # experimental; uses external texi2dvi for now; this needs pdftex to be present
63 TEXI2PDF=texi2dvi --pdf
65 # These tools might not be available; they're not required
66 DVIPDF=dvipdfm -o $@ -p ${PAPERSIZE}
67 PSPDF="gs -sPAPERSIZE=${PAPERSIZE} -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -sOutputFile=$@"
69 MKDIRS=${SUPPORT_SRCDIR}/mkdirs
71 # This should be a program that converts troff to an ascii-readable format
72 # added the -P -c for benefit of Mac OS X, which insists on adding colors if
73 # it's not present
74 NROFF=groff -Tascii -P -c
76 # This should be a program that converts troff to postscript
77 GROFF=groff
83 TEXI2DVI=texi2dvi
84 TEXI2PDF="${TEXI2DVI} --pdf --batch"
85 MAKEINFO="${SHELL} /mnt/hgfs/workspace/tmp/src-pkgs/hello-2.11.tar/hello-2.11/build-aux/missing makeinfo"
86 MAKEINFOHTML="${MAKEINFO} --html"
88 DVIPS=dvips
92 ##############################
93 # section: private function
94 ##############################
97 #############################################################################
101 ############################################################################
104 .ms.ps:
105 ${GROFF} -ms $< > $@
107 .3.ps:
108 .1.ps:
109 ${GROFF} -man $< > $@
111 .3.0:
112 .1.0:
113 ${NROFF} -man $< > $@
115 .3.html:
116 ${MAN2HTML} $< > $@
118 .1.html:
119 ${MAN2HTML} $< | ${HTMLPOST} > $@
121 .ms.txt:
122 ${NROFF} -ms $< > $@
124 ${NROFF} -man $< > $@
126 .ps.pdf:
127 ${PSPDF} $<
129 .dvi.pdf:
130 ${DVIPDF} $<
132 .dvi.ps:
133 ${DVIPS} $<
135 .texi.pdf:
136 ${TEXI2PDF} $<
139 ##############################
140 # section: public function
141 ##############################
147 # fsyntax: tex2man
148 # fdesc: translate tex file to man file.
150 tex2man ()
152 # TBD:
157 # fsyntax: tex2info
158 # fdesc: translate tex file to info file.
160 tex2info ()
162 local cmd="$SETLANG $MAKEINFO -o $PACKAGE.info $commonarg $infoarg \"$srcfile\""
163 echo "Generating info... ($cmd)"
164 rm -f $PACKAGE.info* # get rid of any strays
165 eval "$cmd"
167 # $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \
168 # -o $@ $(srcdir)/doc/hello.texi
172 # fsyntax: tex2txt
173 # fdesc: translate tex file to text file.
175 tex2txt ()
177 opt="-o $PACKAGE.txt --no-split --no-headers $commonarg"
178 cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
179 printf "\nGenerating ascii... ($cmd)\n"
180 eval "$cmd"
184 # fsyntax: tex2dvi
185 # fdesc: translate tex file to dvi file.
187 tex2dvi ()
189 cmd="$SETLANG $TEXI2DVI $dirargs $texarg \"$srcfile\""
190 printf "\nGenerating dvi... ($cmd)\n"
191 eval "$cmd"
193 # TBD:
194 # MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc'
195 # $(TEXI2DVI) $(AM_V_texinfo) --build-dir=$(@:.dvi=.t2d) -o $@ $(AM_V_texidevnull)
199 # fsyntax: tex2pdf
200 # fdesc: translate tex file to pdf file.
202 tex2pdf ()
204 cmd="$SETLANG $TEXI2DVI --pdf $dirargs $texarg \"$srcfile\""
205 printf "\nGenerating pdf... ($cmd)\n"
206 eval "$cmd"
208 # TBD:
209 # MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc'
210 # $(TEXI2PDF) $(AM_V_texinfo) --build-dir=$(@:.pdf=.t2p) -o $@ $(AM_V_texidevnull)
214 # fsyntax: tex2html
215 # fdesc: translate tex file to html file.
217 tex2html ()
219 opt="--split=$1 --node-files $commonarg $htmlarg"
220 cmd="$SETLANG $TEXI2HTML --output $PACKAGE.html $opt \"$srcfile\""
221 printf "\nGenerating html by $1... ($cmd)\n"
222 eval "$cmd"
224 #opt="--no-split --html -o $PACKAGE.html $commonarg $htmlarg"
225 #cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
226 #printf "\nGenerating monolithic html... ($cmd)\n"
227 #rm -rf $PACKAGE.html # in case a directory is left over
228 #eval "$cmd"
231 ## split texi2html
232 #opt="--html -o $PACKAGE.html $split_arg $commonarg $htmlarg"
233 #cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
234 #printf "\nGenerating html by $split... ($cmd)\n"
235 #eval "$cmd"
237 ## use texi2html
238 #opt="--output $PACKAGE.html $commonarg $htmlarg"
239 #cmd="$SETLANG $TEXI2HTML $opt \"$srcfile\""
240 #printf "\nGenerating monolithic html with texi2html... ($cmd)\n"
241 #rm -rf $PACKAGE.html # in case a directory is left over
242 #eval "$cmd"
244 # html_split node
245 # html_split chapter
246 # html_split section
249 # TBD:
250 # $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc -o $(@:.html=.htp) `test -f 'doc/hello.texi'`
254 # fsyntax: tex2docbook
255 # fdesc: translate tex file to docbook file.
257 tex2docbook ()
259 opt="-o - --docbook $commonarg"
260 cmd="$SETLANG $MAKEINFO $opt \"$srcfile\" >${srcdir}/$PACKAGE-db.xml"
261 printf "\nGenerating docbook XML... ($cmd)\n"
262 eval "$cmd"
266 ##############################
267 # section: file tail
268 ##############################