Blame os400/initscript.sh

Packit Service a31ea6
#!/bin/sh
Packit Service a31ea6
#
Packit Service a31ea6
#       Compilation scripts initialization for the OS/400 implementation.
Packit Service a31ea6
#
Packit Service a31ea6
#       See Copyright for the status of this software.
Packit Service a31ea6
#
Packit Service a31ea6
#       Author: Patrick Monnerat <pm@datasphere.ch>, DATASPHERE S.A.
Packit Service a31ea6
#
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
case "${SCRIPTDIR}" in
Packit Service a31ea6
/*)     ;;
Packit Service a31ea6
*)      SCRIPTDIR="`pwd`/${SCRIPTDIR}"
Packit Service a31ea6
esac
Packit Service a31ea6
Packit Service a31ea6
while true
Packit Service a31ea6
do      case "${SCRIPTDIR}" in
Packit Service a31ea6
        */.)    SCRIPTDIR="${SCRIPTDIR%/.}";;
Packit Service a31ea6
        *)      break;;
Packit Service a31ea6
        esac
Packit Service a31ea6
done
Packit Service a31ea6
Packit Service a31ea6
#  The script directory is supposed to be in $TOPDIR/os400.
Packit Service a31ea6
Packit Service a31ea6
TOPDIR=`dirname "${SCRIPTDIR}"`
Packit Service a31ea6
export SCRIPTDIR TOPDIR
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
setenv()
Packit Service a31ea6
Packit Service a31ea6
{
Packit Service a31ea6
        #       Define and export.
Packit Service a31ea6
Packit Service a31ea6
        eval ${1}="${2}"
Packit Service a31ea6
        export ${1}
Packit Service a31ea6
}
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
################################################################################
Packit Service a31ea6
#
Packit Service a31ea6
#                       Tunable configuration parameters.
Packit Service a31ea6
#
Packit Service a31ea6
################################################################################
Packit Service a31ea6
Packit Service a31ea6
setenv TARGETLIB        'LIBXML2'       # Target OS/400 program library.
Packit Service a31ea6
setenv STATBNDDIR       'LIBXML2_A'     # Static binding directory.
Packit Service a31ea6
setenv DYNBNDDIR        'LIBXML2'       # Dynamic binding directory.
Packit Service a31ea6
setenv SRVPGM           "LIBXML2"       # Service program.
Packit Service a31ea6
setenv TGTCCSID         '500'           # Target CCSID of objects.
Packit Service a31ea6
setenv DEBUG            '*ALL'          # Debug level.
Packit Service a31ea6
setenv OPTIMIZE         '10'            # Optimisation level.
Packit Service a31ea6
setenv OUTPUT           '*NONE'         # Compilation output option.
Packit Service a31ea6
setenv TGTRLS           'V6R1M0'        # Target OS release.
Packit Service a31ea6
setenv IFSDIR           '/libxml2'      # Installation IFS directory.
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
################################################################################
Packit Service a31ea6
#
Packit Service a31ea6
#                       Conditional compilation parameters.
Packit Service a31ea6
#
Packit Service a31ea6
################################################################################
Packit Service a31ea6
Packit Service a31ea6
setenv WITH_TRIO                1    # Configure trio support.
Packit Service a31ea6
setenv WITH_THREADS             1    # Configure thread support.
Packit Service a31ea6
setenv WITH_THREAD_ALLOC        1    # Whether allocation hooks are per-thread.
Packit Service a31ea6
setenv WITH_TREE                1    # Compile DOM tree API.
Packit Service a31ea6
setenv WITH_OUTPUT              1    # Compile serialization/saving support.
Packit Service a31ea6
setenv WITH_PUSH                1    # Compile push parser.
Packit Service a31ea6
setenv WITH_READER              1    # Compile parsing interface.
Packit Service a31ea6
setenv WITH_PATTERN             1    # Compile pattern node selection interface.
Packit Service a31ea6
setenv WITH_WRITER              1    # Compile saving interface.
Packit Service a31ea6
setenv WITH_SAX1                1    # Compile SAX version 1 interface.
Packit Service a31ea6
setenv WITH_FTP                 1    # Compile FTP support.
Packit Service a31ea6
setenv WITH_HTTP                1    # Compile HTTP support.
Packit Service a31ea6
setenv WITH_VALID               1    # Compile DTD validation support.
Packit Service a31ea6
setenv WITH_HTML                1    # Compile HTML support.
Packit Service a31ea6
setenv WITH_LEGACY              1    # Compile deprecated API.
Packit Service a31ea6
setenv WITH_C14N                1    # Compile canonicalization support.
Packit Service a31ea6
setenv WITH_CATALOG             1    # Compile catalog support.
Packit Service a31ea6
setenv WITH_DOCB                1    # Compile SGML Docbook support.
Packit Service a31ea6
setenv WITH_XPATH               1    # Compile XPath support.
Packit Service a31ea6
setenv WITH_XPTR                1    # Compile XPointer support.
Packit Service a31ea6
setenv WITH_XINCLUDE            1    # Compile XInclude support.
Packit Service a31ea6
setenv WITH_ICONV               1    # Whether iconv support is available.
Packit Service a31ea6
setenv WITH_ICU                 0    # Whether icu support is available.
Packit Service a31ea6
setenv WITH_ISO8859X            1    # Compile ISO-8859-* support if no iconv.
Packit Service a31ea6
setenv WITH_DEBUG               1    # Compile debugging module.
Packit Service a31ea6
setenv WITH_MEM_DEBUG           1    # Compile memory debugging module.
Packit Service a31ea6
setenv WITH_RUN_DEBUG           1    # Compile runtime debugging.
Packit Service a31ea6
setenv WITH_REGEXPS             1    # Compile regular expression interfaces.
Packit Service a31ea6
setenv WITH_SCHEMAS             1    # Compile schema validation interface.
Packit Service a31ea6
setenv WITH_SCHEMATRON          1    # Compile schematron validation interface.
Packit Service a31ea6
setenv WITH_MODULES             1    # Compile module interfaces.
Packit Service a31ea6
setenv WITH_ZLIB                0    # Whether zlib is available.
Packit Service a31ea6
setenv WITH_LZMA                0    # Whether LZMA is available.
Packit Service a31ea6
Packit Service a31ea6
#       Define ZLIB locations. This is ignored if WITH_ZLIB is 0.
Packit Service a31ea6
Packit Service a31ea6
setenv ZLIB_INCLUDE             '/zlib/include' # ZLIB include IFS directory.
Packit Service a31ea6
setenv ZLIB_LIB                 'ZLIB'          # ZLIB library.
Packit Service a31ea6
setenv ZLIB_BNDDIR              'ZLIB_A'        # ZLIB binding directory.
Packit Service a31ea6
Packit Service a31ea6
################################################################################
Packit Service a31ea6
#
Packit Service a31ea6
#                       OS/400 specific definitions.
Packit Service a31ea6
#
Packit Service a31ea6
################################################################################
Packit Service a31ea6
Packit Service a31ea6
setenv LIBIFSNAME               "/QSYS.LIB/${TARGETLIB}.LIB"
Packit Service a31ea6
setenv MODULE_EXTENSION         '.SRVPGM'
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
################################################################################
Packit Service a31ea6
#
Packit Service a31ea6
#                       Extract version information.
Packit Service a31ea6
#
Packit Service a31ea6
################################################################################
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
#       Transitional: get file name of configure script.
Packit Service a31ea6
Packit Service a31ea6
AUTOCONFSCRIPT="${TOPDIR}/configure.ac"
Packit Service a31ea6
Packit Service a31ea6
if [ ! -f "${AUTOCONFSCRIPT}" ]
Packit Service a31ea6
then    AUTOCONFSCRIPT="${TOPDIR}/configure.in"
Packit Service a31ea6
fi
Packit Service a31ea6
Packit Service a31ea6
#       Need to get the version definitions.
Packit Service a31ea6
Packit Service a31ea6
eval "`grep '^LIBXML_[A-Z]*_VERSION=' \"${AUTOCONFSCRIPT}\"`"
Packit Service a31ea6
eval "`grep '^LIBXML_MICRO_VERSION_SUFFIX=' \"${AUTOCONFSCRIPT}\"`"
Packit Service a31ea6
LIBXML_VERSION="${LIBXML_MAJOR_VERSION}.${LIBXML_MINOR_VERSION}"
Packit Service a31ea6
LIBXML_VERSION="${LIBXML_VERSION}.${LIBXML_MICRO_VERSION}"
Packit Service a31ea6
LIBXML_VERSION="${LIBXML_VERSION}${LIBXML_MICRO_VERSION_SUFFIX}"
Packit Service a31ea6
LIBXML_VERSION_NUMBER=`expr "${LIBXML_MAJOR_VERSION}" \* 10000 +        \
Packit Service a31ea6
                            "${LIBXML_MINOR_VERSION}" \* 100 +          \
Packit Service a31ea6
                            "${LIBXML_MICRO_VERSION}"`
Packit Service a31ea6
export LIBXML_MAJOR_VERSION LIBXML_MINOR_VERSION
Packit Service a31ea6
export LIBXML_MICRO_VERSION LIBXML_MICROVERSION_SUFFIX
Packit Service a31ea6
export LIBXML_VERSION LIBXML_VERSION_NUMBER
Packit Service a31ea6
setenv LIBXML_VERSION_EXTRA ''
Packit Service a31ea6
setenv VERSION  "${LIBXML_VERSION}"
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
################################################################################
Packit Service a31ea6
#
Packit Service a31ea6
#                               Procedures.
Packit Service a31ea6
#
Packit Service a31ea6
################################################################################
Packit Service a31ea6
Packit Service a31ea6
#       action_needed dest [src]
Packit Service a31ea6
#
Packit Service a31ea6
#       dest is an object to build
Packit Service a31ea6
#       if specified, src is an object on which dest depends.
Packit Service a31ea6
#
Packit Service a31ea6
#       exit 0 (succeeds) if some action has to be taken, else 1.
Packit Service a31ea6
Packit Service a31ea6
action_needed()
Packit Service a31ea6
Packit Service a31ea6
{
Packit Service a31ea6
        [ ! -e "${1}" ] && return 0
Packit Service a31ea6
        [ "${2}" ] || return 1
Packit Service a31ea6
        [ "${1}" -ot "${2}" ] && return 0
Packit Service a31ea6
        return 1
Packit Service a31ea6
}
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
#       make_module [option] module_name source_name
Packit Service a31ea6
#
Packit Service a31ea6
#       Compile source name into ASCII module if needed.
Packit Service a31ea6
#       As side effect, append the module name to variable MODULES.
Packit Service a31ea6
#       Set LINK to "YES" if the module has been compiled.
Packit Service a31ea6
#       Options are:
Packit Service a31ea6
#         --define <additional definitions>
Packit Service a31ea6
#         --ebcdic
Packit Service a31ea6
#         --sysiconv
Packit Service a31ea6
Packit Service a31ea6
make_module()
Packit Service a31ea6
Packit Service a31ea6
{
Packit Service a31ea6
        DEFN=
Packit Service a31ea6
        EBCDIC=
Packit Service a31ea6
        SYSICONV=
Packit Service a31ea6
        while true
Packit Service a31ea6
        do      case "${1}" in
Packit Service a31ea6
                --define)
Packit Service a31ea6
                        DEFN="${2}"
Packit Service a31ea6
                        shift
Packit Service a31ea6
                        ;;
Packit Service a31ea6
                --ebcdic)
Packit Service a31ea6
                        EBCDIC=yes
Packit Service a31ea6
                        ;;
Packit Service a31ea6
                --sysiconv)
Packit Service a31ea6
                        SYSICONV=yes
Packit Service a31ea6
                        ;;
Packit Service a31ea6
                *)      break
Packit Service a31ea6
                esac
Packit Service a31ea6
                shift
Packit Service a31ea6
        done
Packit Service a31ea6
        MODULES="${MODULES} ${1}"
Packit Service a31ea6
        MODIFSNAME="${LIBIFSNAME}/${1}.MODULE"
Packit Service a31ea6
        action_needed "${MODIFSNAME}" "${2}" || return 0;
Packit Service a31ea6
Packit Service a31ea6
        #       #pragma convert has to be in the source file itself, i.e.
Packit Service a31ea6
        #               putting it in an include file makes it only active
Packit Service a31ea6
        #               for that include file.
Packit Service a31ea6
        #       Thus we build a temporary file with the pragma prepended to
Packit Service a31ea6
        #               the source file and we compile that temporary file.
Packit Service a31ea6
Packit Service a31ea6
        rm -f __tmpsrcf.c
Packit Service a31ea6
        if [ -z "${EBCDIC}" ]
Packit Service a31ea6
        then    echo "#line 1 \"${2}\"" >> __tmpsrcf.c
Packit Service a31ea6
                echo "#pragma convert(819)" >> __tmpsrcf.c
Packit Service a31ea6
                echo '#include "wrappers.h"' >> __tmpsrcf.c
Packit Service a31ea6
        fi
Packit Service a31ea6
        echo "#line 1 \"${2}\"" >> __tmpsrcf.c
Packit Service a31ea6
        cat "${2}" >> __tmpsrcf.c
Packit Service a31ea6
        CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('__tmpsrcf.c')"
Packit Service a31ea6
#       CMD="${CMD} OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)"
Packit Service a31ea6
        CMD="${CMD} OPTION(*INCDIRFIRST) FLAG(10)"
Packit Service a31ea6
        CMD="${CMD} SYSIFCOPT(*IFS64IO) LANGLVL(*EXTENDED) LOCALETYPE(*LOCALE)"
Packit Service a31ea6
        CMD="${CMD} INCDIR("
Packit Service a31ea6
        if [  -z "${SYSICONV}" ]
Packit Service a31ea6
        then    CMD="${CMD} '${TOPDIR}/os400/iconv'"
Packit Service a31ea6
        fi
Packit Service a31ea6
        if [ -z "${EBCDIC}" ]
Packit Service a31ea6
        then    CMD="${CMD} '/qibm/proddata/qadrt/include'"
Packit Service a31ea6
        fi
Packit Service a31ea6
        CMD="${CMD} '${TOPDIR}/os400' '${TOPDIR}/os400/dlfcn'"
Packit Service a31ea6
        CMD="${CMD} '${IFSDIR}/include/libxml' '${IFSDIR}/include'"
Packit Service a31ea6
        if [ "${ZLIB_INCLUDE}" ]
Packit Service a31ea6
        then    CMD="${CMD} '${ZLIB_INCLUDE}'"
Packit Service a31ea6
        fi
Packit Service a31ea6
        CMD="${CMD} '${TOPDIR}' ${INCLUDES})"
Packit Service a31ea6
        CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
Packit Service a31ea6
        CMD="${CMD} OUTPUT(${OUTPUT})"
Packit Service a31ea6
        CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
Packit Service a31ea6
        CMD="${CMD} DBGVIEW(${DEBUG})"
Packit Service a31ea6
        CMD="${CMD} DEFINE('_REENTRANT' 'TRIO_HAVE_CONFIG_H' 'NDEBUG' ${DEFN})"
Packit Service a31ea6
Packit Service a31ea6
        system "${CMD}"
Packit Service a31ea6
        rm -f __tmpsrcf.c
Packit Service a31ea6
        LINK=YES
Packit Service a31ea6
}
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
#       Determine DB2 object name from IFS name.
Packit Service a31ea6
Packit Service a31ea6
db2_name()
Packit Service a31ea6
Packit Service a31ea6
{
Packit Service a31ea6
        if [ "${2}" = 'nomangle' ]
Packit Service a31ea6
        then    basename "${1}"                                         |
Packit Service a31ea6
                tr 'a-z-' 'A-Z_'                                        |
Packit Service a31ea6
                sed -e 's/\..*//'                                       \
Packit Service a31ea6
                    -e 's/^\(..........\).*$/\1/'
Packit Service a31ea6
        else    basename "${1}"                                         |
Packit Service a31ea6
                tr 'a-z-' 'A-Z_'                                        |
Packit Service a31ea6
                sed -e 's/\..*//'                                       \
Packit Service a31ea6
                    -e 's/^TEST/T/'                                     \
Packit Service a31ea6
                    -e 's/^XML/X/'                                      \
Packit Service a31ea6
                    -e 's/^\(.\).*\(.........\)$/\1\2/'
Packit Service a31ea6
        fi
Packit Service a31ea6
}
Packit Service a31ea6
Packit Service a31ea6
Packit Service a31ea6
#       Copy IFS file replacing version & configuration info.
Packit Service a31ea6
Packit Service a31ea6
versioned_copy()
Packit Service a31ea6
Packit Service a31ea6
{
Packit Service a31ea6
    sed -e "s/@LIBXML_VERSION@/${LIBXML_VERSION}/g"                     \
Packit Service a31ea6
                                                                        \
Packit Service a31ea6
        -e "s#@LIBXML_MAJOR_VERSION@#${LIBXML_MAJOR_VERSION}#g"         \
Packit Service a31ea6
        -e "s#@LIBXML_MINOR_VERSION@#${LIBXML_MINOR_VERSION}#g"         \
Packit Service a31ea6
        -e "s#@LIBXML_MICRO_VERSION@#${LIBXML_MICRO_VERSION}#g"         \
Packit Service a31ea6
        -e "s#@LIBXML_MICRO_VERSION_SUFFIX@#${LIBXML_MICRO_VERSION_SUFFIX}#g" \
Packit Service a31ea6
        -e "s#@LIBXML_VERSION@#${LIBXML_VERSION}#g"                     \
Packit Service a31ea6
        -e "s#@LIBXML_VERSION_NUMBER@#${LIBXML_VERSION_NUMBER}#g"       \
Packit Service a31ea6
        -e "s#@LIBXML_VERSION_EXTRA@#${LIBXML_VERSION_EXTRA}#g"         \
Packit Service a31ea6
        -e "s#@VERSION@#${VERSION}#g"                                   \
Packit Service a31ea6
        -e "s#@WITH_TRIO@#${WITH_TRIO}#g"                               \
Packit Service a31ea6
        -e "s#@WITH_THREADS@#${WITH_THREADS}#g"                         \
Packit Service a31ea6
        -e "s#@WITH_THREAD_ALLOC@#${WITH_THREAD_ALLOC}#g"               \
Packit Service a31ea6
        -e "s#@WITH_TREE@#${WITH_TREE}#g"                               \
Packit Service a31ea6
        -e "s#@WITH_OUTPUT@#${WITH_OUTPUT}#g"                           \
Packit Service a31ea6
        -e "s#@WITH_PUSH@#${WITH_PUSH}#g"                               \
Packit Service a31ea6
        -e "s#@WITH_READER@#${WITH_READER}#g"                           \
Packit Service a31ea6
        -e "s#@WITH_PATTERN@#${WITH_PATTERN}#g"                         \
Packit Service a31ea6
        -e "s#@WITH_WRITER@#${WITH_WRITER}#g"                           \
Packit Service a31ea6
        -e "s#@WITH_SAX1@#${WITH_SAX1}#g"                               \
Packit Service a31ea6
        -e "s#@WITH_FTP@#${WITH_FTP}#g"                                 \
Packit Service a31ea6
        -e "s#@WITH_HTTP@#${WITH_HTTP}#g"                               \
Packit Service a31ea6
        -e "s#@WITH_VALID@#${WITH_VALID}#g"                             \
Packit Service a31ea6
        -e "s#@WITH_HTML@#${WITH_HTML}#g"                               \
Packit Service a31ea6
        -e "s#@WITH_LEGACY@#${WITH_LEGACY}#g"                           \
Packit Service a31ea6
        -e "s#@WITH_C14N@#${WITH_C14N}#g"                               \
Packit Service a31ea6
        -e "s#@WITH_CATALOG@#${WITH_CATALOG}#g"                         \
Packit Service a31ea6
        -e "s#@WITH_DOCB@#${WITH_DOCB}#g"                               \
Packit Service a31ea6
        -e "s#@WITH_XPATH@#${WITH_XPATH}#g"                             \
Packit Service a31ea6
        -e "s#@WITH_XPTR@#${WITH_XPTR}#g"                               \
Packit Service a31ea6
        -e "s#@WITH_XINCLUDE@#${WITH_XINCLUDE}#g"                       \
Packit Service a31ea6
        -e "s#@WITH_ICONV@#${WITH_ICONV}#g"                             \
Packit Service a31ea6
        -e "s#@WITH_ICU@#${WITH_ICU}#g"                                 \
Packit Service a31ea6
        -e "s#@WITH_ISO8859X@#${WITH_ISO8859X}#g"                       \
Packit Service a31ea6
        -e "s#@WITH_DEBUG@#${WITH_DEBUG}#g"                             \
Packit Service a31ea6
        -e "s#@WITH_MEM_DEBUG@#${WITH_MEM_DEBUG}#g"                     \
Packit Service a31ea6
        -e "s#@WITH_RUN_DEBUG@#${WITH_RUN_DEBUG}#g"                     \
Packit Service a31ea6
        -e "s#@WITH_REGEXPS@#${WITH_REGEXPS}#g"                         \
Packit Service a31ea6
        -e "s#@WITH_SCHEMAS@#${WITH_SCHEMAS}#g"                         \
Packit Service a31ea6
        -e "s#@WITH_SCHEMATRON@#${WITH_SCHEMATRON}#g"                   \
Packit Service a31ea6
        -e "s#@WITH_MODULES@#${WITH_MODULES}#g"                         \
Packit Service a31ea6
        -e "s#@WITH_ZLIB@#${WITH_ZLIB}#g"                               \
Packit Service a31ea6
        -e "s#@WITH_LZMA@#${WITH_LZMA}#g"
Packit Service a31ea6
}