Annotation of parser3/buildall, revision 1.43

1.1       moko        1: #!/bin/sh
1.43    ! moko        2: # $Id: buildall,v 1.42 2025/11/06 22:09:34 moko Exp $
1.1       moko        3: 
                      4: install_directory=$HOME/parser3install
                      5: sendmail_command="/usr/sbin/sendmail -i -t -f postmaster"
                      6: 
                      7: parser3_dir=`pwd`
                      8: cd ..
                      9: project_dir=`pwd`
                     10: 
                     11: build_xml="yes"
1.37      moko       12: build_pcre2="yes"
1.1       moko       13: build_gmime=""
                     14: build_apache=""
1.6       moko       15: build_stripped=""
1.26      moko       16: direct_download=""
1.1       moko       17: 
                     18: options="--with-included-ltdl"
                     19: options="$options --with-gc=$project_dir/gc/lib"
                     20: #options="$options --disable-stringstream"
                     21: 
1.24      moko       22: printf "Building statically linked parser3"
1.7       moko       23: for PARAM in "$@"; do
1.1       moko       24:     case "$PARAM" in
                     25:        "--without-xml")
1.24      moko       26:            printf ", without xml"
1.1       moko       27:            build_xml=""
                     28:            ;;
1.37      moko       29:        "--without-pcre2")
                     30:            printf ", without pcre2 library"
                     31:            build_pcre2=""
                     32:            ;;
1.1       moko       33:        "--with-apache")
1.24      moko       34:            printf ", with apache module"
1.1       moko       35:            options="$options --with-apache"
                     36:            build_apache="yes"
                     37:            ;;
                     38:        "--with-mailreceive")
1.24      moko       39:            printf ", with mail receiving"
1.41      moko       40:            options="$options --with-mailreceive=$project_dir/gmime"
1.1       moko       41:            build_gmime="yes"
                     42:            ;;
1.30      moko       43:        "--with-system-mailreceive")
                     44:            printf ", with mail receiving"
                     45:            options="$options --with-mailreceive"
                     46:            ;;
1.42      moko       47:        "--with-system-amqp")
                     48:            printf ", with amqp"
                     49:            options="$options --with-amqp"
                     50:            ;;
1.6       moko       51:        "--strip")
1.24      moko       52:            printf ", without debug information"
1.6       moko       53:            build_stripped="yes"
                     54:            ;;
1.26      moko       55:        "--direct-download")
                     56:            printf ", download sources from master"
                     57:            direct_download="yes"
                     58:            ;;
1.1       moko       59:        "--help")
1.2       moko       60:            echo
1.37      moko       61:            echo "Usage: buildall [--without-xml] [--without-pcre2] [--with-apache] [--with-mailreceive] [--with-system-mailreceive] [--strip] [--direct-download] [--disable-safe-mode] [other configure options ...]"
1.1       moko       62:            exit 1
                     63:            ;;
                     64:        *)
                     65:            options="$options $PARAM"
                     66:            ;;
                     67:     esac
                     68: done
                     69: 
                     70: if test "$build_xml" = "yes"; then
                     71:     options="$options --with-xml=$project_dir/gnome"
                     72: fi
                     73: 
                     74: bits=`getconf LONG_BIT`
1.9       moko       75: if test "$bits" = "64" -o "$build_apache" = "yes"; then
1.1       moko       76:     cflags="$cflags --with-pic"
                     77: else
                     78:     cflags="$cflags --without-pic"
                     79: fi
                     80: 
                     81: if test ! "$build_apache" = "yes"; then
                     82:     cflags="$cflags --disable-shared"
                     83: fi
                     84: 
                     85: download=`which fetch 2>/dev/null`
                     86: if test -f "$download"; then
                     87:     download="fetch -p"
                     88: else
                     89:     download="wget -c --passive-ftp"
                     90: fi
                     91: 
                     92: ############################### Support functions ################################
                     93: 
1.26      moko       94: prepare () {
1.1       moko       95:     cd $project_dir/src
                     96: 
1.29      moko       97:     if test ! -f "$1"; then
1.26      moko       98:        if test "$direct_download" = "yes"; then
                     99:            echo "Downloading $lib from $2..."
                    100:            $download $2$1
                    101:        else
                    102:            echo "Downloading $lib (master at $2)..."
                    103:            $download https://www.parser.ru/off-line/download/libs/$1
                    104:        fi
1.1       moko      105:     fi
                    106: 
1.8       moko      107:     echo "Unpacking $lib..."
1.1       moko      108:     rm -rf $lib
1.26      moko      109: }
                    110: 
                    111: prepare_gz () {
                    112:     prepare $1 $2
1.8       moko      113:     gunzip -c $1 | tar xf - >/dev/null
1.1       moko      114:     cd $lib
                    115: }
                    116: 
1.4       moko      117: prepare_xz () {
1.26      moko      118:     prepare $1 $2
1.8       moko      119:     xzcat $1 | tar xf - >/dev/null
1.1       moko      120:     cd $lib
                    121: }
                    122: 
                    123: cleanup () {
                    124:     cd ..
1.27      moko      125:     rm -rf $lib
1.1       moko      126: }
                    127: 
                    128: #################################### Building ####################################
                    129: 
                    130: echo
                    131: mkdir src >/dev/null 2>&1
                    132: 
                    133: if test ! -f "$project_dir/gc/lib/libgc.a"; then
1.34      moko      134:     lib="libatomic_ops-7.6.2"
                    135:     prepare_gz ${lib}.tar.gz http://www.hboehm.info/gc/gc_source/
                    136: 
1.26      moko      137:     lib="gc-8.0.4"
1.19      moko      138:     prepare_gz ${lib}.tar.gz http://www.hboehm.info/gc/gc_source/
                    139: 
1.34      moko      140:     mv ../libatomic_ops-7.6.2 libatomic_ops
                    141: 
1.8       moko      142:     echo "Configuring $lib..."
1.22      moko      143:     CPPFLAGS="-DUSE_MMAP -DDONT_ADD_BYTE_AT_END" \
1.1       moko      144:     ./configure --prefix=$project_dir/gc \
                    145:        --disable-shared \
1.35      moko      146:        --disable-parallel-mark \
1.1       moko      147:        --silent $cflags
1.8       moko      148:     echo "Building $lib..."
1.1       moko      149:     make install
                    150:     cleanup
                    151: fi
                    152: 
1.37      moko      153: if test "$build_pcre2" = "yes"; then
                    154: 
                    155: options="$options --with-pcre=$project_dir/pcre2"
                    156: 
                    157: if test ! -f "$project_dir/pcre2/lib/libpcre2-8.a"; then
1.39      moko      158:     lib="pcre2-10.44"
                    159:     prepare_gz $lib.tar.gz https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.44/
1.37      moko      160:     echo "Configuring $lib..."
                    161:     ./configure --prefix="$project_dir/pcre2" \
                    162:        --enable-jit \
                    163:        --with-match-limit-depth=10000 \
                    164:        --disable-shared \
                    165:        --silent $cflags
                    166:     echo "Building $lib..."
                    167:     make install
                    168:     cleanup
                    169: fi
                    170: 
                    171: else
                    172: 
                    173: options="$options --with-pcre=$project_dir/pcre"
                    174: 
1.1       moko      175: if test ! -f "$project_dir/pcre/lib/libpcre.a"; then
1.37      moko      176:     lib="pcre-8.45"
1.38      moko      177:     prepare_gz $lib.tar.gz https://sourceforge.net/projects/pcre/files/pcre/8.45/
1.8       moko      178:     echo "Configuring $lib..."
1.1       moko      179:     ./configure --prefix="$project_dir/pcre" \
                    180:        --with-match-limit-recursion=10000 \
                    181:        --enable-utf8 \
                    182:        --enable-unicode-properties \
                    183:        --disable-shared \
                    184:        --disable-cpp \
                    185:        --disable-pcregrep-libz \
                    186:        --disable-pcregrep-libbz2 \
                    187:        --silent $cflags
1.8       moko      188:     echo "Building $lib..."
1.1       moko      189:     make install
                    190:     cleanup
                    191: fi
                    192: 
1.37      moko      193: fi
                    194: 
1.1       moko      195: if test "$build_xml" = "yes" -a ! -f "$project_dir/gnome/lib/libxml2.a"; then
1.27      moko      196:     lib="libxml2-2.9.9"
1.38      moko      197:     prepare_gz $lib.tar.gz http://xmlsoft.org/download/
1.1       moko      198:     #sax1, output, tree, xinclude[in libxslt], html[in libxslt, mode=html?], xptr[xinclude], pattern -- needed!
1.8       moko      199:     echo "Configuring $lib..."
1.1       moko      200:     ./configure --prefix=$project_dir/gnome \
                    201:        --without-catalog \
                    202:        --without-iconv \
                    203:        --without-debug \
                    204:        --without-iso8859x \
                    205:        --without-legacy \
                    206:        --without-push \
                    207:        --without-python \
                    208:        --without-writer \
                    209:        --without-readline \
                    210:        --without-regexps \
                    211:        --without-schemas \
                    212:        --without-schematron \
                    213:        --without-modules \
                    214:        --without-ftp \
                    215:        --without-http \
                    216:        --without-docbook \
                    217:        --without-zlib \
                    218:        --without-lzma \
                    219:        --disable-shared \
                    220:        --silent $cflags
1.8       moko      221:     echo "Building $lib..."
1.1       moko      222:     make install
                    223:     cleanup
                    224: fi
                    225: 
                    226: if test "$build_xml" = "yes" -a ! -f "$project_dir/gnome/lib/libxslt.a"; then
1.27      moko      227:     lib="libxslt-1.1.34"
1.38      moko      228:     prepare_gz $lib.tar.gz http://xmlsoft.org/download/
1.8       moko      229:     echo "Configuring $lib..."
1.21      moko      230:     CFLAGS="$CFLAGS -D__stub_clock_gettime -Dclock_gettime=choke_me" \
1.1       moko      231:     ./configure --prefix=$project_dir/gnome \
                    232:        --with-libxml-prefix=$project_dir/gnome \
                    233:        --without-debug \
                    234:        --without-debugger \
                    235:        --without-crypto \
                    236:        --without-plugins \
                    237:        --disable-shared \
                    238:        --silent $cflags
1.8       moko      239:     echo "Building $lib..."
1.1       moko      240:     make install
                    241:     cleanup
                    242: fi
                    243: 
                    244: if test "$build_gmime" = "yes"; then
                    245: 
                    246: glib_ldflags=""
                    247: gmime_cflags=""
1.40      moko      248: gmime_ldflags="-L$project_dir/gmime/lib/"
1.1       moko      249: 
                    250: os=`uname`
                    251: if test "$os" = "FreeBSD"; then
                    252:     gmime_cflags="CFLAGS=-I/usr/local/include CXXFLAGS=-I/usr/local/include"
                    253:     glib_ldflags="LDFLAGS=-L/usr/local/lib"
                    254:     gmime_ldflags="$gmime_ldflags -L/usr/local/lib"
                    255: fi
                    256: 
1.40      moko      257: if test ! -f "$project_dir/gmime/lib/libglib-2.0.a"; then
1.1       moko      258:     lib="glib-2.28.8"
1.8       moko      259:     prepare_xz $lib.tar.xz ftp://ftp.gnome.org/pub/GNOME/sources/glib/2.28/
                    260:     echo "Configuring $lib..."
1.40      moko      261:     ./configure --prefix=$project_dir/gmime \
1.1       moko      262:        --enable-dtrace=no \
                    263:        --enable-debug=no \
                    264:        --enable-iconv-cache=no \
                    265:        --disable-fam \
                    266:        --disable-selinux \
                    267:        --disable-xattr \
                    268:        --disable-shared \
                    269:        --enable-static \
                    270:        --silent $cflags $gmime_cflags $glib_ldflags
1.8       moko      271:     echo "Building $lib..."
1.1       moko      272:     make install
                    273:     cleanup
                    274: fi
                    275: 
1.40      moko      276: if test ! -f "$project_dir/gmime/lib/libgmime-2.4.a"; then
1.1       moko      277:     lib="gmime-2.4.32"
1.8       moko      278:     prepare_xz $lib.tar.xz ftp://ftp.gnome.org/pub/GNOME/sources/gmime/2.4/
                    279:     echo "Configuring $lib..."
1.40      moko      280:     ./configure --prefix=$project_dir/gmime \
1.1       moko      281:        --disable-glibtest \
                    282:        --disable-mono \
                    283:        --disable-shared \
                    284:        --enable-static \
1.40      moko      285:        --silent $cflags $gmime_cflags LDFLAGS="$gmime_ldflags" PKG_CONFIG_PATH="$project_dir/gmime/lib/pkgconfig"
1.8       moko      286:     echo "Building $lib..."
1.1       moko      287:     make install
                    288:     cleanup
                    289: fi
                    290: 
                    291: fi
                    292: 
                    293: cd $parser3_dir
1.3       moko      294: if test ! -f "Makefile"; then
1.1       moko      295:     echo "Configuring parser3..."
1.32      moko      296:     ./configure --prefix=$install_directory \
                    297:        --sysconfdir=$install_directory/bin \
                    298:        --datadir=$install_directory/bin \
1.36      moko      299:        --datarootdir="\$confdir" \
                    300:        --libdir="\$confdir/lib" \
1.32      moko      301:        --with-sendmail="$sendmail_command" \
                    302:        $options $cflags $gmime_cflags
1.3       moko      303: fi
1.1       moko      304: 
                    305: echo "Building parser3..."
                    306: make install
                    307: if test $? -ne 0; then exit 1; fi
                    308: 
1.6       moko      309: if test "$build_stripped" = "yes"; then
                    310:     strip ${install_directory}/bin/parser3
                    311: fi
1.1       moko      312: 
                    313: echo "DONE"
                    314: echo
                    315: echo "********************************************************************************************************"
                    316: echo "Now you can copy $install_directory/bin to your cgi-bin directory"
                    317: echo "Read more about installing Parser here:"
1.43    ! moko      318: echo "  https://www.parser.ru/en/docs/lang/install4apachecgi.htm in English"
        !           319: echo "  https://www.parser.ru/docs/lang/install4apachecgi.htm in Russian"
1.1       moko      320: echo "********************************************************************************************************"
                    321: 

E-mail: