1#/bin/sh 2 3# Script to prepare the files for building a PCRE2 release. It does some 4# processing of the documentation, detrails files, and creates pcre2.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 PCRE2 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# README & NON-AUTOTOOLS-BUILD 29# These files are copied into the doc/html directory, with .txt 30# extensions so that they can by hyperlinked from the HTML 31# documentation, because some people just go to the HTML without 32# looking for text files. 33 34 35# First, sort out the documentation. Remove pcre2demo.3 first because it won't 36# pass the markup check (it is created below, using markup that none of the 37# other pages use). 38 39cd doc 40echo Processing documentation 41 42/bin/rm -f pcre2demo.3 43 44# Check the remaining man pages 45 46perl ../CheckMan *.1 *.3 47if [ $? != 0 ] ; then exit 1; fi 48 49# Make Text form of the documentation. It needs some mangling to make it 50# tidy for online reading. Concatenate all the .3 stuff, but omit the 51# individual function pages. 52 53cat <<End >pcre2.txt 54----------------------------------------------------------------------------- 55This file contains a concatenation of the PCRE2 man pages, converted to plain 56text format for ease of searching with a text editor, or for use on systems 57that do not have a man page processor. The small individual files that give 58synopses of each function in the library have not been included. Neither has 59the pcre2demo program. There are separate text files for the pcre2grep and 60pcre2test commands. 61----------------------------------------------------------------------------- 62 63 64End 65 66echo "Making pcre2.txt" 67for file in pcre2 pcre2api pcre2build pcre2callout pcre2compat pcre2jit \ 68 pcre2limits pcre2matching pcre2partial pcre2pattern pcre2perform \ 69 pcre2posix pcre2sample pcre2serialize pcre2syntax \ 70 pcre2unicode ; do 71 echo " Processing $file.3" 72 nroff -c -man $file.3 >$file.rawtxt 73 perl ../CleanTxt <$file.rawtxt >>pcre2.txt 74 /bin/rm $file.rawtxt 75 echo "------------------------------------------------------------------------------" >>pcre2.txt 76 if [ "$file" != "pcre2sample" ] ; then 77 echo " " >>pcre2.txt 78 echo " " >>pcre2.txt 79 fi 80done 81 82# The three commands 83for file in pcre2test pcre2grep pcre2-config ; do 84 echo Making $file.txt 85 nroff -c -man $file.1 >$file.rawtxt 86 perl ../CleanTxt <$file.rawtxt >$file.txt 87 /bin/rm $file.rawtxt 88done 89 90 91# Make pcre2demo.3 from the pcre2demo.c source file 92 93echo "Making pcre2demo.3" 94perl <<"END" >pcre2demo.3 95 use Time::Piece; 96 open(VH, "<", "../src/config.h.generic") || die "Failed to open src/config.h.generic\n"; 97 open(IN, "../src/pcre2demo.c") || die "Failed to open src/pcre2demo.c\n"; 98 open(OUT, ">pcre2demo.3") || die "Failed to open pcre2demo.3\n"; 99 my $version; 100 while (<VH>) 101 { 102 chomp; 103 if ( /^#define PACKAGE_STRING "([^"]+)"/ ) { $version = $1 ; last } 104 } 105 my $t = localtime; 106 print OUT ".TH PCRE2DEMO 3 \"", $t->strftime('%e %B %Y'), '" "', $version, "\"\n" . 107 ".\\\"AUTOMATICALLY GENERATED BY PrepareRelease - do not EDIT!\n" . 108 ".SH NAME\n" . 109 "PCRE2DEMO - A demonstration C program for PCRE2\n" . 110 ".SH \"SOURCE CODE\"\n" . 111 ".rs\n" . 112 ".sp\n" . 113 ".\\\" Start example.\n" . 114 ".de EX\n" . 115 ". do ds mF \\\\n[.fam]\n" . 116 ". nr mE \\\\n(.f\n" . 117 ". nf\n" . 118 ". nh\n" . 119 ". do fam C\n" . 120 ". ft CW\n" . 121 "..\n" . 122 ".\n" . 123 ".\n" . 124 ".\\\" End example.\n" . 125 ".de EE\n" . 126 ". do fam \\\\*(mF\n" . 127 ". ft \\\\n(mE\n" . 128 ". fi\n" . 129 ". hy \\\\n(HY\n" . 130 "..\n" . 131 ".\n" . 132 ".RS -7\n" . 133 ".EX\n" ; 134 while (<IN>) 135 { 136 s/\\/\\e/g; 137 print OUT; 138 } 139 print OUT ".EE\n"; 140 close(IN); 141 close(OUT); 142END 143if [ $? != 0 ] ; then exit 1; fi 144 145 146# Make HTML form of the documentation. 147 148echo "Making HTML documentation" 149/bin/rm html/* 150cp index.html.src html/index.html 151cp ../README html/README.txt 152cp ../NON-AUTOTOOLS-BUILD html/NON-AUTOTOOLS-BUILD.txt 153 154for file in *.1 ; do 155 base=`basename $file .1` 156 echo " Making $base.html" 157 perl ../132html -toc $base <$file >html/$base.html 158done 159 160# Exclude table of contents for function summaries. It seems that expr 161# forces an anchored regex. Also exclude them for small pages that have 162# only one section. 163 164for file in *.3 ; do 165 base=`basename $file .3` 166 toc=-toc 167 if [ `expr $base : '.*_'` -ne 0 ] ; then toc="" ; fi 168 if [ "$base" = "pcre2sample" ] || \ 169 [ "$base" = "pcre2compat" ] || \ 170 [ "$base" = "pcre2demo" ] || \ 171 [ "$base" = "pcre2limits" ] || \ 172 [ "$base" = "pcre2unicode" ] ; then 173 toc="" 174 fi 175 echo " Making $base.html" 176 perl ../132html $toc $base <$file >html/$base.html 177 if [ $? != 0 ] ; then exit 1; fi 178done 179 180# End of documentation processing; stop if only documentation required. 181 182cd .. 183echo Documentation done 184if [ "$1" = "doc" ] ; then exit; fi 185 186# These files are detrailed; do not detrail the test data because there may be 187# significant trailing spaces. Do not detrail RunTest.bat, because it has CRLF 188# line endings and the detrail script removes all trailing white space. The 189# configure files are also omitted from the detrailing. 190 191files="\ 192 Makefile.am \ 193 configure.ac \ 194 README \ 195 LICENCE \ 196 COPYING \ 197 AUTHORS \ 198 NEWS \ 199 NON-AUTOTOOLS-BUILD \ 200 INSTALL \ 201 132html \ 202 CleanTxt \ 203 Detrail \ 204 ChangeLog \ 205 CMakeLists.txt \ 206 RunGrepTest \ 207 RunTest \ 208 pcre2-config.in \ 209 perltest.sh \ 210 libpcre2-8.pc.in \ 211 libpcre2-16.pc.in \ 212 libpcre2-32.pc.in \ 213 libpcre2-posix.pc.in \ 214 src/pcre2_dftables.c \ 215 src/pcre2.h.in \ 216 src/pcre2_auto_possess.c \ 217 src/pcre2_compile.c \ 218 src/pcre2_config.c \ 219 src/pcre2_context.c \ 220 src/pcre2_convert.c \ 221 src/pcre2_dfa_match.c \ 222 src/pcre2_error.c \ 223 src/pcre2_extuni.c \ 224 src/pcre2_find_bracket.c \ 225 src/pcre2_internal.h \ 226 src/pcre2_intmodedep.h \ 227 src/pcre2_jit_compile.c \ 228 src/pcre2_jit_match.c \ 229 src/pcre2_jit_misc.c \ 230 src/pcre2_jit_test.c \ 231 src/pcre2_maketables.c \ 232 src/pcre2_match.c \ 233 src/pcre2_match_data.c \ 234 src/pcre2_newline.c \ 235 src/pcre2_ord2utf.c \ 236 src/pcre2_pattern_info.c \ 237 src/pcre2_printint.c \ 238 src/pcre2_string_utils.c \ 239 src/pcre2_study.c \ 240 src/pcre2_substring.c \ 241 src/pcre2_tables.c \ 242 src/pcre2_ucd.c \ 243 src/pcre2_ucp.h \ 244 src/pcre2_valid_utf.c \ 245 src/pcre2_xclass.c \ 246 src/pcre2demo.c \ 247 src/pcre2grep.c \ 248 src/pcre2posix.c \ 249 src/pcre2posix.h \ 250 src/pcre2test.c" 251 252echo Detrailing 253perl ./Detrail $files doc/p* doc/html/* 254 255echo Done 256 257#End 258