Annotation of parser3/buildall, revision 1.26

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

E-mail: