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