Annotation of parser3/buildall, revision 1.38

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

E-mail: