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