• 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           'V6R1M0'        # 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 [option] module_name source_name
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#       Options are:
174#         --define <additional definitions>
175#         --ebcdic
176#         --sysiconv
177
178make_module()
179
180{
181        DEFN=
182        EBCDIC=
183        SYSICONV=
184        while true
185        do      case "${1}" in
186                --define)
187                        DEFN="${2}"
188                        shift
189                        ;;
190                --ebcdic)
191                        EBCDIC=yes
192                        ;;
193                --sysiconv)
194                        SYSICONV=yes
195                        ;;
196                *)      break
197                esac
198                shift
199        done
200        MODULES="${MODULES} ${1}"
201        MODIFSNAME="${LIBIFSNAME}/${1}.MODULE"
202        action_needed "${MODIFSNAME}" "${2}" || return 0;
203
204        #       #pragma convert has to be in the source file itself, i.e.
205        #               putting it in an include file makes it only active
206        #               for that include file.
207        #       Thus we build a temporary file with the pragma prepended to
208        #               the source file and we compile that temporary file.
209
210        rm -f __tmpsrcf.c
211        if [ -z "${EBCDIC}" ]
212        then    echo "#line 1 \"${2}\"" >> __tmpsrcf.c
213                echo "#pragma convert(819)" >> __tmpsrcf.c
214                echo '#include "wrappers.h"' >> __tmpsrcf.c
215        fi
216        echo "#line 1 \"${2}\"" >> __tmpsrcf.c
217        cat "${2}" >> __tmpsrcf.c
218        CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('__tmpsrcf.c')"
219#       CMD="${CMD} OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)"
220        CMD="${CMD} OPTION(*INCDIRFIRST) FLAG(10)"
221        CMD="${CMD} SYSIFCOPT(*IFS64IO) LANGLVL(*EXTENDED) LOCALETYPE(*LOCALE)"
222        CMD="${CMD} INCDIR("
223        if [  -z "${SYSICONV}" ]
224        then    CMD="${CMD} '${TOPDIR}/os400/iconv'"
225        fi
226        if [ -z "${EBCDIC}" ]
227        then    CMD="${CMD} '/qibm/proddata/qadrt/include'"
228        fi
229        CMD="${CMD} '${TOPDIR}/os400' '${TOPDIR}/os400/dlfcn'"
230        CMD="${CMD} '${IFSDIR}/include/libxml' '${IFSDIR}/include'"
231        if [ "${ZLIB_INCLUDE}" ]
232        then    CMD="${CMD} '${ZLIB_INCLUDE}'"
233        fi
234        CMD="${CMD} '${TOPDIR}' ${INCLUDES})"
235        CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
236        CMD="${CMD} OUTPUT(${OUTPUT})"
237        CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
238        CMD="${CMD} DBGVIEW(${DEBUG})"
239        CMD="${CMD} DEFINE('_REENTRANT' 'TRIO_HAVE_CONFIG_H' 'NDEBUG' ${DEFN})"
240
241        system "${CMD}"
242        rm -f __tmpsrcf.c
243        LINK=YES
244}
245
246
247#       Determine DB2 object name from IFS name.
248
249db2_name()
250
251{
252        if [ "${2}" = 'nomangle' ]
253        then    basename "${1}"                                         |
254                tr 'a-z-' 'A-Z_'                                        |
255                sed -e 's/\..*//'                                       \
256                    -e 's/^\(..........\).*$/\1/'
257        else    basename "${1}"                                         |
258                tr 'a-z-' 'A-Z_'                                        |
259                sed -e 's/\..*//'                                       \
260                    -e 's/^TEST/T/'                                     \
261                    -e 's/^XML/X/'                                      \
262                    -e 's/^\(.\).*\(.........\)$/\1\2/'
263        fi
264}
265
266
267#       Copy IFS file replacing version & configuration info.
268
269versioned_copy()
270
271{
272    sed -e "s/@LIBXML_VERSION@/${LIBXML_VERSION}/g"                     \
273                                                                        \
274        -e "s#@LIBXML_MAJOR_VERSION@#${LIBXML_MAJOR_VERSION}#g"         \
275        -e "s#@LIBXML_MINOR_VERSION@#${LIBXML_MINOR_VERSION}#g"         \
276        -e "s#@LIBXML_MICRO_VERSION@#${LIBXML_MICRO_VERSION}#g"         \
277        -e "s#@LIBXML_MICRO_VERSION_SUFFIX@#${LIBXML_MICRO_VERSION_SUFFIX}#g" \
278        -e "s#@LIBXML_VERSION@#${LIBXML_VERSION}#g"                     \
279        -e "s#@LIBXML_VERSION_NUMBER@#${LIBXML_VERSION_NUMBER}#g"       \
280        -e "s#@LIBXML_VERSION_EXTRA@#${LIBXML_VERSION_EXTRA}#g"         \
281        -e "s#@VERSION@#${VERSION}#g"                                   \
282        -e "s#@WITH_TRIO@#${WITH_TRIO}#g"                               \
283        -e "s#@WITH_THREADS@#${WITH_THREADS}#g"                         \
284        -e "s#@WITH_THREAD_ALLOC@#${WITH_THREAD_ALLOC}#g"               \
285        -e "s#@WITH_TREE@#${WITH_TREE}#g"                               \
286        -e "s#@WITH_OUTPUT@#${WITH_OUTPUT}#g"                           \
287        -e "s#@WITH_PUSH@#${WITH_PUSH}#g"                               \
288        -e "s#@WITH_READER@#${WITH_READER}#g"                           \
289        -e "s#@WITH_PATTERN@#${WITH_PATTERN}#g"                         \
290        -e "s#@WITH_WRITER@#${WITH_WRITER}#g"                           \
291        -e "s#@WITH_SAX1@#${WITH_SAX1}#g"                               \
292        -e "s#@WITH_FTP@#${WITH_FTP}#g"                                 \
293        -e "s#@WITH_HTTP@#${WITH_HTTP}#g"                               \
294        -e "s#@WITH_VALID@#${WITH_VALID}#g"                             \
295        -e "s#@WITH_HTML@#${WITH_HTML}#g"                               \
296        -e "s#@WITH_LEGACY@#${WITH_LEGACY}#g"                           \
297        -e "s#@WITH_C14N@#${WITH_C14N}#g"                               \
298        -e "s#@WITH_CATALOG@#${WITH_CATALOG}#g"                         \
299        -e "s#@WITH_DOCB@#${WITH_DOCB}#g"                               \
300        -e "s#@WITH_XPATH@#${WITH_XPATH}#g"                             \
301        -e "s#@WITH_XPTR@#${WITH_XPTR}#g"                               \
302        -e "s#@WITH_XINCLUDE@#${WITH_XINCLUDE}#g"                       \
303        -e "s#@WITH_ICONV@#${WITH_ICONV}#g"                             \
304        -e "s#@WITH_ICU@#${WITH_ICU}#g"                                 \
305        -e "s#@WITH_ISO8859X@#${WITH_ISO8859X}#g"                       \
306        -e "s#@WITH_DEBUG@#${WITH_DEBUG}#g"                             \
307        -e "s#@WITH_MEM_DEBUG@#${WITH_MEM_DEBUG}#g"                     \
308        -e "s#@WITH_RUN_DEBUG@#${WITH_RUN_DEBUG}#g"                     \
309        -e "s#@WITH_REGEXPS@#${WITH_REGEXPS}#g"                         \
310        -e "s#@WITH_SCHEMAS@#${WITH_SCHEMAS}#g"                         \
311        -e "s#@WITH_SCHEMATRON@#${WITH_SCHEMATRON}#g"                   \
312        -e "s#@WITH_MODULES@#${WITH_MODULES}#g"                         \
313        -e "s#@WITH_ZLIB@#${WITH_ZLIB}#g"                               \
314        -e "s#@WITH_LZMA@#${WITH_LZMA}#g"
315}
316