1 |
#/bin/sh
|
2 |
|
3 |
# Script to prepare the files for building a PCRE release. It does some
|
4 |
# processing of the documentation, detrails files, and creates pcre.h.generic
|
5 |
# and config.h.generic (for use by builders who can't run ./configure).
|
6 |
|
7 |
# You must run this script before runnning "make dist". If its first argument
|
8 |
# is "doc", it stops after preparing the documentation. There are no other
|
9 |
# arguments. The script makes use of the following files:
|
10 |
|
11 |
# 132html A Perl script that converts a .1 or .3 man page into HTML. It
|
12 |
# "knows" the relevant troff constructs that are used in the PCRE
|
13 |
# man pages.
|
14 |
|
15 |
# CheckMan A Perl script that checks man pages for typos in the mark up.
|
16 |
|
17 |
# CleanTxt A Perl script that cleans up the output of "nroff -man" by
|
18 |
# removing backspaces and other redundant text so as to produce
|
19 |
# a readable .txt file.
|
20 |
|
21 |
# Detrail A Perl script that removes trailing spaces from files.
|
22 |
|
23 |
# doc/index.html.src
|
24 |
# A file that is copied as index.html into the doc/html directory
|
25 |
# when the HTML documentation is built. It works like this so that
|
26 |
# doc/html can be deleted and re-created from scratch.
|
27 |
|
28 |
|
29 |
# First, sort out the documentation. Remove pcredemo.3 first because it won't
|
30 |
# pass the markup check (it is created below, using markup that none of the
|
31 |
# other pages use).
|
32 |
|
33 |
cd doc
|
34 |
echo Processing documentation
|
35 |
|
36 |
/bin/rm -f pcredemo.3
|
37 |
|
38 |
# Check the remaining man pages
|
39 |
|
40 |
../CheckMan *.1 *.3
|
41 |
if [ $? != 0 ] ; then exit 1; fi
|
42 |
|
43 |
# Make Text form of the documentation. It needs some mangling to make it
|
44 |
# tidy for online reading. Concatenate all the .3 stuff, but omit the
|
45 |
# individual function pages.
|
46 |
|
47 |
cat <<End >pcre.txt
|
48 |
-----------------------------------------------------------------------------
|
49 |
This file contains a concatenation of the PCRE man pages, converted to plain
|
50 |
text format for ease of searching with a text editor, or for use on systems
|
51 |
that do not have a man page processor. The small individual files that give
|
52 |
synopses of each function in the library have not been included. Neither has
|
53 |
the pcredemo program. There are separate text files for the pcregrep and
|
54 |
pcretest commands.
|
55 |
-----------------------------------------------------------------------------
|
56 |
|
57 |
|
58 |
End
|
59 |
|
60 |
echo "Making pcre.txt"
|
61 |
for file in pcre pcrebuild pcrematching pcreapi pcrecallout pcrecompat \
|
62 |
pcrepattern pcresyntax pcrepartial pcreprecompile \
|
63 |
pcreperform pcreposix pcrecpp pcresample pcrestack ; do
|
64 |
echo " Processing $file.3"
|
65 |
nroff -c -man $file.3 >$file.rawtxt
|
66 |
../CleanTxt <$file.rawtxt >>pcre.txt
|
67 |
/bin/rm $file.rawtxt
|
68 |
echo "------------------------------------------------------------------------------" >>pcre.txt
|
69 |
if [ "$file" != "pcresample" ] ; then
|
70 |
echo " " >>pcre.txt
|
71 |
echo " " >>pcre.txt
|
72 |
fi
|
73 |
done
|
74 |
|
75 |
# The three commands
|
76 |
for file in pcretest pcregrep pcre-config ; do
|
77 |
echo Making $file.txt
|
78 |
nroff -c -man $file.1 >$file.rawtxt
|
79 |
../CleanTxt <$file.rawtxt >$file.txt
|
80 |
/bin/rm $file.rawtxt
|
81 |
done
|
82 |
|
83 |
|
84 |
# Make pcredemo.3 from the pcredemo.c source file
|
85 |
|
86 |
echo "Making pcredemo.3"
|
87 |
perl <<"END" >pcredemo.3
|
88 |
open(IN, "../pcredemo.c") || die "Failed to open pcredemo.c\n";
|
89 |
open(OUT, ">pcredemo.3") || die "Failed to open pcredemo.3\n";
|
90 |
print OUT ".\\\" Start example.\n" .
|
91 |
".de EX\n" .
|
92 |
". nr mE \\\\n(.f\n" .
|
93 |
". nf\n" .
|
94 |
". nh\n" .
|
95 |
". ft CW\n" .
|
96 |
"..\n" .
|
97 |
".\n" .
|
98 |
".\n" .
|
99 |
".\\\" End example.\n" .
|
100 |
".de EE\n" .
|
101 |
". ft \\\\n(mE\n" .
|
102 |
". fi\n" .
|
103 |
". hy \\\\n(HY\n" .
|
104 |
"..\n" .
|
105 |
".\n" .
|
106 |
".EX\n" ;
|
107 |
while (<IN>)
|
108 |
{
|
109 |
s/\\/\\e/g;
|
110 |
print OUT;
|
111 |
}
|
112 |
print OUT ".EE\n";
|
113 |
close(IN);
|
114 |
close(OUT);
|
115 |
END
|
116 |
if [ $? != 0 ] ; then exit 1; fi
|
117 |
|
118 |
|
119 |
# Make HTML form of the documentation.
|
120 |
|
121 |
echo "Making HTML documentation"
|
122 |
/bin/rm html/*
|
123 |
cp index.html.src html/index.html
|
124 |
|
125 |
for file in *.1 ; do
|
126 |
base=`basename $file .1`
|
127 |
echo " Making $base.html"
|
128 |
../132html -toc $base <$file >html/$base.html
|
129 |
done
|
130 |
|
131 |
# Exclude table of contents for function summaries. It seems that expr
|
132 |
# forces an anchored regex. Also exclude them for small pages that have
|
133 |
# only one section.
|
134 |
|
135 |
for file in *.3 ; do
|
136 |
base=`basename $file .3`
|
137 |
toc=-toc
|
138 |
if [ `expr $base : '.*_'` -ne 0 ] ; then toc="" ; fi
|
139 |
if [ "$base" = "pcresample" ] || \
|
140 |
[ "$base" = "pcrestack" ] || \
|
141 |
[ "$base" = "pcrecompat" ] || \
|
142 |
[ "$base" = "pcreperform" ] ; then
|
143 |
toc=""
|
144 |
fi
|
145 |
echo " Making $base.html"
|
146 |
../132html $toc $base <$file >html/$base.html
|
147 |
if [ $? != 0 ] ; then exit 1; fi
|
148 |
done
|
149 |
|
150 |
# End of documentation processing; stop if only documentation required.
|
151 |
|
152 |
cd ..
|
153 |
echo Documentation done
|
154 |
if [ "$1" = "doc" ] ; then exit; fi
|
155 |
|
156 |
# These files are detrailed; do not detrail the test data because there may be
|
157 |
# significant trailing spaces. The configure files are also omitted from the
|
158 |
# detrailing.
|
159 |
|
160 |
files="\
|
161 |
Makefile.am \
|
162 |
Makefile.in \
|
163 |
configure.ac \
|
164 |
README \
|
165 |
LICENCE \
|
166 |
COPYING \
|
167 |
AUTHORS \
|
168 |
NEWS \
|
169 |
NON-UNIX-USE \
|
170 |
INSTALL \
|
171 |
132html \
|
172 |
CleanTxt \
|
173 |
Detrail \
|
174 |
ChangeLog \
|
175 |
CMakeLists.txt \
|
176 |
RunGrepTest \
|
177 |
RunTest \
|
178 |
RunTest.bat \
|
179 |
pcre-config.in \
|
180 |
libpcre.pc.in \
|
181 |
libpcreposix.pc.in \
|
182 |
libpcrecpp.pc.in \
|
183 |
config.h.in \
|
184 |
pcre_printint.src \
|
185 |
pcre_chartables.c.dist \
|
186 |
pcredemo.c \
|
187 |
pcregrep.c \
|
188 |
pcretest.c \
|
189 |
dftables.c \
|
190 |
pcreposix.c \
|
191 |
pcreposix.h \
|
192 |
pcre.h.in \
|
193 |
pcre_internal.h
|
194 |
pcre_compile.c \
|
195 |
pcre_config.c \
|
196 |
pcre_dfa_exec.c \
|
197 |
pcre_exec.c \
|
198 |
pcre_fullinfo.c \
|
199 |
pcre_get.c \
|
200 |
pcre_globals.c \
|
201 |
pcre_info.c \
|
202 |
pcre_maketables.c \
|
203 |
pcre_newline.c \
|
204 |
pcre_ord2utf8.c \
|
205 |
pcre_refcount.c \
|
206 |
pcre_study.c \
|
207 |
pcre_tables.c \
|
208 |
pcre_try_flipped.c \
|
209 |
pcre_ucp_searchfuncs.c \
|
210 |
pcre_valid_utf8.c \
|
211 |
pcre_version.c \
|
212 |
pcre_xclass.c \
|
213 |
pcre_scanner.cc \
|
214 |
pcre_scanner.h \
|
215 |
pcre_scanner_unittest.cc \
|
216 |
pcrecpp.cc \
|
217 |
pcrecpp.h \
|
218 |
pcrecpparg.h.in \
|
219 |
pcrecpp_unittest.cc \
|
220 |
pcre_stringpiece.cc \
|
221 |
pcre_stringpiece.h.in \
|
222 |
pcre_stringpiece_unittest.cc \
|
223 |
perltest.pl \
|
224 |
ucp.h \
|
225 |
ucpinternal.h \
|
226 |
ucptable.h \
|
227 |
makevp.bat \
|
228 |
pcre.def \
|
229 |
libpcre.def \
|
230 |
libpcreposix.def"
|
231 |
|
232 |
echo Detrailing
|
233 |
./Detrail $files doc/p* doc/html/*
|
234 |
|
235 |
echo Doing basic configure to get default pcre.h and config.h
|
236 |
# This is in case the caller has set aliases (as I do - PH)
|
237 |
unset cp ls mv rm
|
238 |
./configure >/dev/null
|
239 |
|
240 |
echo Converting pcre.h and config.h to generic forms
|
241 |
cp -f pcre.h pcre.h.generic
|
242 |
|
243 |
perl <<'END'
|
244 |
open(IN, "<config.h") || die "Can't open config.h: $!\n";
|
245 |
open(OUT, ">config.h.generic") || die "Can't open config.h.generic: $!\n";
|
246 |
while (<IN>)
|
247 |
{
|
248 |
if (/^#define\s(?!PACKAGE)(\w+)/)
|
249 |
{
|
250 |
print OUT "#ifndef $1\n";
|
251 |
print OUT;
|
252 |
print OUT "#endif\n";
|
253 |
}
|
254 |
else
|
255 |
{
|
256 |
print OUT;
|
257 |
}
|
258 |
}
|
259 |
close IN;
|
260 |
close OUT;
|
261 |
END
|
262 |
|
263 |
echo Done
|
264 |
|
265 |
#End
|