• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2#
3#       Compilation scripts initialization for the OS/400 implementation.
4#
5#       See Copyright for the status of this software.
6#
7#       Author: Patrick Monnerat <pm@datasphere.ch>, DATASPHERE S.A.
8#
9
10
11case "${SCRIPTDIR}" in
12/*)     ;;
13*)      SCRIPTDIR="`pwd`/${SCRIPTDIR}"
14esac
15
16while true
17do      case "${SCRIPTDIR}" in
18        */.)    SCRIPTDIR="${SCRIPTDIR%/.}";;
19        *)      break;;
20        esac
21done
22
23#  The script directory is supposed to be in $TOPDIR/os400.
24
25TOPDIR=`dirname "${SCRIPTDIR}"`
26export SCRIPTDIR TOPDIR
27
28
29setenv()
30
31{
32        #       Define and export.
33
34        eval ${1}="${2}"
35        export ${1}
36}
37
38
39################################################################################
40#
41#                       Tunable configuration parameters.
42#
43################################################################################
44
45setenv TARGETLIB        'LIBXML2'       # Target OS/400 program library.
46setenv STATBNDDIR       'LIBXML2_A'     # Static binding directory.
47setenv DYNBNDDIR        'LIBXML2'       # Dynamic binding directory.
48setenv SRVPGM           "LIBXML2"       # Service program.
49setenv TGTCCSID         '500'           # Target CCSID of objects.
50setenv DEBUG            '*ALL'          # Debug level.
51setenv OPTIMIZE         '10'            # Optimisation level.
52setenv OUTPUT           '*NONE'         # Compilation output option.
53setenv TGTRLS           'V5R3M0'        # Target OS release.
54setenv IFSDIR           '/libxml2'      # Installation IFS directory.
55
56
57################################################################################
58#
59#                       Conditional compilation parameters.
60#
61################################################################################
62
63setenv WITH_TRIO                1    # Configure trio support.
64setenv WITH_THREADS             1    # Configure thread support.
65setenv WITH_THREAD_ALLOC        1    # Whether allocation hooks are per-thread.
66setenv WITH_TREE                1    # Compile DOM tree API.
67setenv WITH_OUTPUT              1    # Compile serialization/saving support.
68setenv WITH_PUSH                1    # Compile push parser.
69setenv WITH_READER              1    # Compile parsing interface.
70setenv WITH_PATTERN             1    # Compile pattern node selection interface.
71setenv WITH_WRITER              1    # Compile saving interface.
72setenv WITH_SAX1                1    # Compile SAX version 1 interface.
73setenv WITH_FTP                 1    # Compile FTP support.
74setenv WITH_HTTP                1    # Compile HTTP support.
75setenv WITH_VALID               1    # Compile DTD validation support.
76setenv WITH_HTML                1    # Compile HTML support.
77setenv WITH_LEGACY              1    # Compile deprecated API.
78setenv WITH_C14N                1    # Compile canonicalization support.
79setenv WITH_CATALOG             1    # Compile catalog support.
80setenv WITH_DOCB                1    # Compile SGML Docbook support.
81setenv WITH_XPATH               1    # Compile XPath support.
82setenv WITH_XPTR                1    # Compile XPointer support.
83setenv WITH_XINCLUDE            1    # Compile XInclude support.
84setenv WITH_ICONV               1    # Whether iconv support is available.
85setenv WITH_ICU                 0    # Whether icu support is available.
86setenv WITH_ISO8859X            1    # Compile ISO-8859-* support if no iconv.
87setenv WITH_DEBUG               1    # Compile debugging module.
88setenv WITH_MEM_DEBUG           1    # Compile memory debugging module.
89setenv WITH_RUN_DEBUG           1    # Compile runtime debugging.
90setenv WITH_REGEXPS             1    # Compile regular expression interfaces.
91setenv WITH_SCHEMAS             1    # Compile schema validation interface.
92setenv WITH_SCHEMATRON          1    # Compile schematron validation interface.
93setenv WITH_MODULES             1    # Compile module interfaces.
94setenv WITH_ZLIB                0    # Whether zlib is available.
95setenv WITH_LZMA                0    # Whether LZMA is available.
96
97#       Define ZLIB locations. This is ignored if WITH_ZLIB is 0.
98
99setenv ZLIB_INCLUDE             '/zlib/include' # ZLIB include IFS directory.
100setenv ZLIB_LIB                 'ZLIB'          # ZLIB library.
101setenv ZLIB_BNDDIR              'ZLIB_A'        # ZLIB binding directory.
102
103################################################################################
104#
105#                       OS/400 specific definitions.
106#
107################################################################################
108
109setenv LIBIFSNAME               "/QSYS.LIB/${TARGETLIB}.LIB"
110setenv MODULE_EXTENSION         '.SRVPGM'
111
112
113################################################################################
114#
115#                       Extract version information.
116#
117################################################################################
118
119
120#       Transitional: get file name of configure script.
121
122AUTOCONFSCRIPT="${TOPDIR}/configure.ac"
123
124if [ ! -f "${AUTOCONFSCRIPT}" ]
125then    AUTOCONFSCRIPT="${TOPDIR}/configure.in"
126fi
127
128#       Need to get the version definitions.
129
130eval "`grep '^LIBXML_[A-Z]*_VERSION=' \"${AUTOCONFSCRIPT}\"`"
131eval "`grep '^LIBXML_MICRO_VERSION_SUFFIX=' \"${AUTOCONFSCRIPT}\"`"
132LIBXML_VERSION="${LIBXML_MAJOR_VERSION}.${LIBXML_MINOR_VERSION}"
133LIBXML_VERSION="${LIBXML_VERSION}.${LIBXML_MICRO_VERSION}"
134LIBXML_VERSION="${LIBXML_VERSION}${LIBXML_MICRO_VERSION_SUFFIX}"
135LIBXML_VERSION_NUMBER=`expr "${LIBXML_MAJOR_VERSION}" \* 10000 +        \
136                            "${LIBXML_MINOR_VERSION}" \* 100 +          \
137                            "${LIBXML_MICRO_VERSION}"`
138export LIBXML_MAJOR_VERSION LIBXML_MINOR_VERSION
139export LIBXML_MICRO_VERSION LIBXML_MICROVERSION_SUFFIX
140export LIBXML_VERSION LIBXML_VERSION_NUMBER
141setenv LIBXML_VERSION_EXTRA ''
142setenv VERSION  "${LIBXML_VERSION}"
143
144
145################################################################################
146#
147#                               Procedures.
148#
149################################################################################
150
151#       action_needed dest [src]
152#
153#       dest is an object to build
154#       if specified, src is an object on which dest depends.
155#
156#       exit 0 (succeeds) if some action has to be taken, else 1.
157
158action_needed()
159
160{
161        [ ! -e "${1}" ] && return 0
162        [ "${2}" ] || return 1
163        [ "${1}" -ot "${2}" ] && return 0
164        return 1
165}
166
167
168#       make_module module_name source_name [additional_definitions]
169#
170#       Compile source name into ASCII module if needed.
171#       As side effect, append the module name to variable MODULES.
172#       Set LINK to "YES" if the module has been compiled.
173
174make_module()
175
176{
177        MODULES="${MODULES} ${1}"
178        MODIFSNAME="${LIBIFSNAME}/${1}.MODULE"
179        action_needed "${MODIFSNAME}" "${2}" || return 0;
180
181        #       #pragma convert has to be in the source file itself, i.e.
182        #               putting it in an include file makes it only active
183        #               for that include file.
184        #       Thus we build a temporary file with the pragma prepended to
185        #               the source file and we compile that temporary file.
186
187        rm -f __tmpsrcf.c
188        if [ "${4}" != 'ebcdic' ]
189        then    echo "#line 1 \"${2}\"" >> __tmpsrcf.c
190                echo "#pragma convert(819)" >> __tmpsrcf.c
191                echo '#include "wrappers.h"' >> __tmpsrcf.c
192        fi
193        echo "#line 1 \"${2}\"" >> __tmpsrcf.c
194        cat "${2}" >> __tmpsrcf.c
195        CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('__tmpsrcf.c')"
196#       CMD="${CMD} OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)"
197        CMD="${CMD} OPTION(*INCDIRFIRST)"
198        CMD="${CMD} SYSIFCOPT(*IFS64IO) LANGLVL(*EXTENDED) LOCALETYPE(*LOCALE)"
199        CMD="${CMD} INCDIR("
200        CMD="${CMD} '${TOPDIR}/os400/iconv'"
201        if [ "${4}" != 'ebcdic' ]
202        then    CMD="${CMD} '/qibm/proddata/qadrt/include'"
203        fi
204        CMD="${CMD} '${TOPDIR}/os400' '${TOPDIR}/os400/dlfcn'"
205        CMD="${CMD} '${IFSDIR}/include/libxml' '${IFSDIR}/include'"
206        if [ "${ZLIB_INCLUDE}" ]
207        then    CMD="${CMD} '${ZLIB_INCLUDE}'"
208        fi
209        CMD="${CMD} '${TOPDIR}' ${INCLUDES})"
210        CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
211        CMD="${CMD} OUTPUT(${OUTPUT})"
212        CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
213        CMD="${CMD} DBGVIEW(${DEBUG})"
214        CMD="${CMD} DEFINE('_REENTRANT' 'TRIO_HAVE_CONFIG_H' 'NDEBUG' ${3})"
215
216        system "${CMD}"
217        rm -f __tmpsrcf.c
218        LINK=YES
219}
220
221
222#       Determine DB2 object name from IFS name.
223
224db2_name()
225
226{
227        if [ "${2}" = 'nomangle' ]
228        then    basename "${1}"                                         |
229                tr 'a-z-' 'A-Z_'                                        |
230                sed -e 's/\..*//'                                       \
231                    -e 's/^\(..........\).*$/\1/'
232        else    basename "${1}"                                         |
233                tr 'a-z-' 'A-Z_'                                        |
234                sed -e 's/\..*//'                                       \
235                    -e 's/^TEST/T/'                                     \
236                    -e 's/^XML/X/'                                      \
237                    -e 's/^\(.\).*\(.........\)$/\1\2/'
238        fi
239}
240
241
242#       Copy IFS file replacing version & configuration info.
243
244versioned_copy()
245
246{
247    sed -e "s/@LIBXML_VERSION@/${LIBXML_VERSION}/g"                     \
248                                                                        \
249        -e "s#@LIBXML_MAJOR_VERSION@#${LIBXML_MAJOR_VERSION}#g"         \
250        -e "s#@LIBXML_MINOR_VERSION@#${LIBXML_MINOR_VERSION}#g"         \
251        -e "s#@LIBXML_MICRO_VERSION@#${LIBXML_MICRO_VERSION}#g"         \
252        -e "s#@LIBXML_MICRO_VERSION_SUFFIX@#${LIBXML_MICRO_VERSION_SUFFIX}#g" \
253        -e "s#@LIBXML_VERSION@#${LIBXML_VERSION}#g"                     \
254        -e "s#@LIBXML_VERSION_NUMBER@#${LIBXML_VERSION_NUMBER}#g"       \
255        -e "s#@LIBXML_VERSION_EXTRA@#${LIBXML_VERSION_EXTRA}#g"         \
256        -e "s#@VERSION@#${VERSION}#g"                                   \
257        -e "s#@WITH_TRIO@#${WITH_TRIO}#g"                               \
258        -e "s#@WITH_THREADS@#${WITH_THREADS}#g"                         \
259        -e "s#@WITH_THREAD_ALLOC@#${WITH_THREAD_ALLOC}#g"               \
260        -e "s#@WITH_TREE@#${WITH_TREE}#g"                               \
261        -e "s#@WITH_OUTPUT@#${WITH_OUTPUT}#g"                           \
262        -e "s#@WITH_PUSH@#${WITH_PUSH}#g"                               \
263        -e "s#@WITH_READER@#${WITH_READER}#g"                           \
264        -e "s#@WITH_PATTERN@#${WITH_PATTERN}#g"                         \
265        -e "s#@WITH_WRITER@#${WITH_WRITER}#g"                           \
266        -e "s#@WITH_SAX1@#${WITH_SAX1}#g"                               \
267        -e "s#@WITH_FTP@#${WITH_FTP}#g"                                 \
268        -e "s#@WITH_HTTP@#${WITH_HTTP}#g"                               \
269        -e "s#@WITH_VALID@#${WITH_VALID}#g"                             \
270        -e "s#@WITH_HTML@#${WITH_HTML}#g"                               \
271        -e "s#@WITH_LEGACY@#${WITH_LEGACY}#g"                           \
272        -e "s#@WITH_C14N@#${WITH_C14N}#g"                               \
273        -e "s#@WITH_CATALOG@#${WITH_CATALOG}#g"                         \
274        -e "s#@WITH_DOCB@#${WITH_DOCB}#g"                               \
275        -e "s#@WITH_XPATH@#${WITH_XPATH}#g"                             \
276        -e "s#@WITH_XPTR@#${WITH_XPTR}#g"                               \
277        -e "s#@WITH_XINCLUDE@#${WITH_XINCLUDE}#g"                       \
278        -e "s#@WITH_ICONV@#${WITH_ICONV}#g"                             \
279        -e "s#@WITH_ICU@#${WITH_ICU}#g"                                 \
280        -e "s#@WITH_ISO8859X@#${WITH_ISO8859X}#g"                       \
281        -e "s#@WITH_DEBUG@#${WITH_DEBUG}#g"                             \
282        -e "s#@WITH_MEM_DEBUG@#${WITH_MEM_DEBUG}#g"                     \
283        -e "s#@WITH_RUN_DEBUG@#${WITH_RUN_DEBUG}#g"                     \
284        -e "s#@WITH_REGEXPS@#${WITH_REGEXPS}#g"                         \
285        -e "s#@WITH_SCHEMAS@#${WITH_SCHEMAS}#g"                         \
286        -e "s#@WITH_SCHEMATRON@#${WITH_SCHEMATRON}#g"                   \
287        -e "s#@WITH_MODULES@#${WITH_MODULES}#g"                         \
288        -e "s#@WITH_ZLIB@#${WITH_ZLIB}#g"                               \
289        -e "s#@WITH_LZMA@#${WITH_LZMA}#g"
290}
291