summaryrefslogtreecommitdiffstats
path: root/libxml2/os400/make-src.sh
blob: 6094de8e1731c1e5288998c56b8cc0ae946136fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
#!/bin/sh
#
#       libxml compilation script for the OS/400.
#
#       See Copyright for the status of this software.
#
#       Author: Patrick Monnerat <pm@datasphere.ch>, DATASPHERE S.A.
#

SCRIPTDIR=`dirname "${0}"`
. "${SCRIPTDIR}/initscript.sh"
cd "${TOPDIR}"


#      Create and compile the identification source file.

echo '#pragma comment(user, "libxml2 version '"${LIBXML_VERSION}"'")' > os400.c
echo '#pragma comment(user, __DATE__)' >> os400.c
echo '#pragma comment(user, __TIME__)' >> os400.c
echo '#pragma comment(copyright, "Copyright (C) 1998-2015 Daniel Veillard. OS/400 version by P. Monnerat.")' >> os400.c
make_module     OS400           os400.c
LINK=                           # No need to rebuild service program yet.
MODULES=


#       Get source list.

foldlines()

{
        sed -e ':begin'                                                 \
            -e '/\\$/{'                                                 \
            -e 's/\\$/ /'                                               \
            -e 'N'                                                      \
            -e 'bbegin'                                                 \
            -e '}'                                                      \
            -e 's/\n//g'                                                \
            -e 's/[[:space:]]*$//'
}


get_make_var()

{
        foldlines < Makefile.am                                         |
        sed -e "/^${1}[[:space:]]*=[[:space:]]*/{"                      \
            -e 's///'                                                   \
            -e 'q'                                                      \
            -e '}'                                                      \
            -e 'd'
}


docb_sources=`get_make_var docb_sources`
trio_sources=`get_make_var trio_sources`
CSOURCES=`eval echo "\`get_make_var libxml2_la_SOURCES | tr '()' '{}'\`"`


#       Compile the sources into modules.

INCLUDES="'`pwd`'"

#       OS/400 specific modules first.

make_module     --ebcdic        DLFCN           "${SCRIPTDIR}/dlfcn/dlfcn.c"
make_module     --ebcdic        ICONV           "${SCRIPTDIR}/iconv/iconv.c"
make_module     --ebcdic        WRAPPERS        "${SCRIPTDIR}/wrappers.c"
make_module                     TRANSCODE       "${SCRIPTDIR}/transcode.c"
make_module                     RPGSUPPORT      "${SCRIPTDIR}/rpgsupport.c"

#       Regular libxml2 modules.

for SRC in ${CSOURCES}
do      MODULE=`db2_name "${SRC}"`
        make_module "${MODULE}" "${SRC}"
done


#       If needed, (re)create the static binding directory.

if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
then    LINK=YES
fi

if [ "${LINK}" ]
then    rm -rf "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
        CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${STATBNDDIR})"
        CMD="${CMD} TEXT('libxml2 static binding directory')"
        system "${CMD}"

        for MODULE in ${MODULES}
        do      CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})"
                CMD="${CMD} OBJ((${TARGETLIB}/${MODULE} *MODULE))"
                system "${CMD}"
        done
fi


#       The exportation file for service program creation must be in a DB2
#               source file, so make sure it exists.

if action_needed "${LIBIFSNAME}/TOOLS.FILE"
then    CMD="CRTSRCPF FILE(${TARGETLIB}/TOOLS) RCDLEN(112)"
        CMD="${CMD} CCSID(${TGTCCSID}) TEXT('libxml2: build tools')"
        system "${CMD}"
fi


#       Generate all exported symbol table versions in a binding source file.

BSF="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR"
PGMEXPS=

OS400SYMS=`cat os400/transcode.h os400/rpgsupport.h                     |
           sed -e 'H'                                                   \
               -e 'g'                                                   \
               -e 's/\n/ /'                                             \
               -e 's/\\$/ /'                                            \
               -e 's/.*/& /'                                            \
               -e 's/\/\*.*\*\// /g'                                    \
               -e 'h'                                                   \
               -e ':loop'                                               \
               -e 'g'                                                   \
               -e '/\/\*/d'                                             \
               -e '/;/!d'                                               \
               -e 's/[^;]*;//'                                          \
               -e 'x'                                                   \
               -e 's/[[:space:]]*;.*$//'                                \
               -e '/XMLPUBFUN/{'                                        \
               -e 's/[[:space:]]*(.*$//'                                \
               -e 's/.*[[:space:]*]//'                                  \
               -e 'p'                                                   \
               -e 'bloop'                                               \
               -e '}'                                                   \
               -e '/XMLPUBVAR/!bloop'                                   \
               -e ':loop2'                                              \
               -e '/\[[^][]*\]/{'                                       \
               -e 's///'                                                \
               -e 'bloop2'                                              \
               -e '}'                                                   \
               -e 's/[[:space:]]*,[[:space:]]*/,/g'                     \
               -e 's/[^,]*[[:space:]*]//'                               \
               -e 's/[^[:alnum:]_,]//g'                                 \
               -e 's/,/\n/g'                                            \
               -e 'p'                                                   \
               -e 'bloop'`

sed -e 's/#.*//'                                                        \
    -e 's/[[:space:]]*$//'                                              \
    -e 's/^[[:space:]]*//'                                              \
    -e '/^*global:$/d'                                                  \
    -e '/^$/d'                                                          \
    -e '/[[:space:]]*{$/{'                                              \
    -e   's///'                                                         \
    -e   'h'                                                            \
    -e   's/[^A-Za-z0-9]/_/g'                                           \
    -e   's/^[0-9]/_&/'                                                 \
    -e   'x'                                                            \
    -e   'G'                                                            \
    -e   's/\(.*\)\n\(.*\)/\2_SIGNATURE="\1"/'                          \
    -e   'p'                                                            \
    -e   's/.*//'                                                       \
    -e   'x'                                                            \
    -e   "s/.*/SONAME='&'/"                                             \
    -e   'b'                                                            \
    -e '}'                                                              \
    -e '/[[:space:]]*;$/!d'                                             \
    -e 's///'                                                           \
    -e '/^xmlDllMain$/d'                                                \
    -e '/^}[[:space:]]*/!{'                                             \
    -e   'H'                                                            \
    -e   'd'                                                            \
    -e '}'                                                              \
    -e 's///'                                                           \
    -e '/^$/!{'                                                         \
    -e   's/[^A-Za-z0-9]/_/g'                                           \
    -e   's/^[0-9]/_&/'                                                 \
    -e   's/.*/${&}/'                                                   \
    -e   'x'                                                            \
    -e   'H'                                                            \
    -e   's/.*//'                                                       \
    -e '}'                                                              \
    -e 'x'                                                              \
    -e 's/\n/ /g'                                                       \
    -e 's/^[[:space:]]*//'                                              \
    -e 's/.*/declare ${SONAME}="&"/'                                    \
    -e 's/.*/&; PGMEXPS="${SONAME} ${PGMEXPS}"/'                        \
        < "${TOPDIR}/libxml2.syms"    > bndvars
. ./bndvars

PGMLVL=CURRENT
for PGMEXP in ${PGMEXPS}
do      SIGNATURE=`echo "${PGMEXP}" | sed 's/^LIBXML2_//'`
        eval ENTRIES=\"\${${PGMEXP}}\"
        echo " STRPGMEXP PGMLVL(*${PGMLVL}) SIGNATURE('${SIGNATURE}')"
        for ENTRY in ${ENTRIES} ${OS400SYMS}
        do      echo " EXPORT    SYMBOL('${ENTRY}')"
        done
        echo ' ENDPGMEXP'
        PGMLVL=PRV
done            > "${BSF}"


#       Build the service program if needed.

if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM"
then    LINK=YES
fi

if [ "${LINK}" ]
then    CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})"
        CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(BNDSRC)"
        CMD="${CMD} MODULE(${TARGETLIB}/OS400)"
        CMD="${CMD} BNDDIR((${TARGETLIB}/${STATBNDDIR})"
        if [ "${WITH_ZLIB}" -ne 0 ]
        then    CMD="${CMD} (${ZLIB_LIB}/${ZLIB_BNDDIR})"
        fi
        CMD="${CMD})"
        CMD="${CMD} BNDSRVPGM(QADRTTS)"
        CMD="${CMD} TEXT('libxml2 dynamic library')"
        CMD="${CMD} TGTRLS(${TGTRLS})"
        system "${CMD}"
        LINK=YES
fi


#       If needed, (re)create the dynamic binding directory.

if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
then    LINK=YES
fi

if [ "${LINK}" ]
then    rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
        CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
        CMD="${CMD} TEXT('libxml2 dynamic binding directory')"
        system "${CMD}"
        CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
        CMD="${CMD} OBJ((*LIBL/${SRVPGM} *SRVPGM))"
        system "${CMD}"
fi


#       Compile the ASCII main() stub.

make_module     --ebcdic --sysiconv     LIBXMLMAIN  "${SCRIPTDIR}/libxmlmain.c"


#       Compile and link program xmllint.

if action_needed "${LIBIFSNAME}/XMLLINT.PGM" "xmllint.c" ||
   action_needed "${LIBIFSNAME}/XMLLINT.PGM" "${LIBIFSNAME}/${SRVPGM}.SRVPGM" ||
   action_needed "${LIBIFSNAME}/XMLLINT.PGM" "${LIBIFSNAME}/LIBXMLMAIN.MODULE"
then    make_module XMLLINT xmllint.c
        CMD="CRTPGM PGM(${TARGETLIB}/XMLLINT) MODULE(${TARGETLIB}/XMLLINT)"
        CMD="${CMD} ENTMOD(${TARGETLIB}/LIBXMLMAIN)"
        CMD="${CMD} BNDSRVPGM(QADRTTS) BNDDIR((${TARGETLIB}/${STATBNDDIR})"
        if [ "${WITH_ZLIB}" -ne 0 ]
        then    CMD="${CMD} (${ZLIB_LIB}/${ZLIB_BNDDIR})"
        fi
        CMD="${CMD}) ACTGRP(*NEW) TEXT('XML tool')"
        CMD="${CMD} TGTRLS(${TGTRLS})"
        system "${CMD}"
        rm -f "${LIBIFSNAME}/XMLLINT.MODULE"
fi

#       Install xmllint in IFS.

if [ ! -d "${IFSDIR}/bin" ]
then    mkdir -p "${IFSDIR}/bin"
fi
rm -f "${IFSDIR}/bin/xmllint"
ln -s "${LIBIFSNAME}/XMLLINT.PGM" "${IFSDIR}/bin/xmllint"

#       Prepare the XMLLINT command and its response program.

if action_needed "${LIBIFSNAME}/XMLLINTCL.PGM" "${SCRIPTDIR}/xmllintcl.c"
then    make_module --ebcdic XMLLINTCL "${SCRIPTDIR}/xmllintcl.c"
        CMD="CRTPGM PGM(${TARGETLIB}/XMLLINTCL) MODULE(${TARGETLIB}/XMLLINTCL)"
        CMD="${CMD} ACTGRP(*NEW) TEXT('XMLLINT command response')"
        CMD="${CMD} TGTRLS(${TGTRLS})"
        system "${CMD}"
        rm -f "${LIBIFSNAME}/XMLLINTCL.MODULE"
fi

if action_needed "${LIBIFSNAME}/TOOLS.FILE/XMLLINT.MBR"                 \
                 "${SCRIPTDIR}/xmllint.cmd"
then    CMD="CPY OBJ('${SCRIPTDIR}/xmllint.cmd')"
        CMD="${CMD} TOOBJ('${LIBIFSNAME}/TOOLS.FILE/XMLLINT.MBR')"
        CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
        system "${CMD}"
fi

if action_needed "${LIBIFSNAME}/XMLLINT.CMD"                            \
                 "${LIBIFSNAME}/TOOLS.FILE/XMLLINT.MBR"
then    CMD="CRTCMD CMD(${TARGETLIB}/XMLLINT) PGM(${TARGETLIB}/XMLLINTCL)"
        CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(XMLLINT) THDSAFE(*YES)"
        CMD="${CMD} TEXT('XML tool') REPLACE(*YES)"
        system "${CMD}"
fi


#       Compile and link program xmlcatalog.

if action_needed "${LIBIFSNAME}/XMLCATALOG.PGM" "xmlcatalog.c" ||
   action_needed "${LIBIFSNAME}/XMLCATALOG.PGM"                         \
                 "${LIBIFSNAME}/${SRVPGM}.SRVPGM" ||
   action_needed "${LIBIFSNAME}/XMLCATALOG.PGM"                         \
                 "${LIBIFSNAME}/LIBXMLMAIN.MODULE"
then    make_module XMLCATALOG xmlcatalog.c
        CMD="CRTPGM PGM(${TARGETLIB}/XMLCATALOG)"
        CMD="${CMD}  MODULE(${TARGETLIB}/XMLCATALOG)"
        CMD="${CMD} ENTMOD(${TARGETLIB}/LIBXMLMAIN)"
        CMD="${CMD} BNDSRVPGM(QADRTTS) BNDDIR((${TARGETLIB}/${STATBNDDIR})"
        if [ "${WITH_ZLIB}" -ne 0 ]
        then    CMD="${CMD} (${ZLIB_LIB}/${ZLIB_BNDDIR})"
        fi
        CMD="${CMD}) ACTGRP(*NEW) TEXT('XML/SGML catalog tool')"
        CMD="${CMD} TGTRLS(${TGTRLS})"
        system "${CMD}"
        rm -f "${LIBIFSNAME}/XMLCATALOG.MODULE"
fi

#       Install xmlcatalog in IFS.

rm -f "${IFSDIR}/bin/xmlcatalog"
ln -s "${LIBIFSNAME}/XMLCATALOG.PGM" "${IFSDIR}/bin/xmlcatalog"

#       Prepare the XMLCATALOG command and its response program.

if action_needed "${LIBIFSNAME}/XMLCATLGCL.PGM" "${SCRIPTDIR}/xmlcatlgcl.c"
then    make_module --ebcdic XMLCATLGCL "${SCRIPTDIR}/xmlcatlgcl.c"
        CMD="CRTPGM PGM(${TARGETLIB}/XMLCATLGCL)"
        CMD="${CMD} MODULE(${TARGETLIB}/XMLCATLGCL)"
        CMD="${CMD} ACTGRP(*NEW) TEXT('XMLCATALOG command response')"
        CMD="${CMD} TGTRLS(${TGTRLS})"
        system "${CMD}"
        rm -f "${LIBIFSNAME}/XMLCATLGCL.MODULE"
fi

if action_needed "${LIBIFSNAME}/TOOLS.FILE/XMLCATALOG.MBR"              \
                 "${SCRIPTDIR}/xmlcatalog.cmd"
then    CMD="CPY OBJ('${SCRIPTDIR}/xmlcatalog.cmd')"
        CMD="${CMD} TOOBJ('${LIBIFSNAME}/TOOLS.FILE/XMLCATALOG.MBR')"
        CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
        system "${CMD}"
fi

if action_needed "${LIBIFSNAME}/XMLCATALOG.CMD"                         \
                 "${LIBIFSNAME}/TOOLS.FILE/XMLCATALOG.MBR"
then    CMD="CRTCMD CMD(${TARGETLIB}/XMLCATALOG) PGM(${TARGETLIB}/XMLCATLGCL)"
        CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(XMLCATALOG)"
        CMD="${CMD} THDSAFE(*YES) TEXT('XML/SGML catalog tool') REPLACE(*YES)"
        system "${CMD}"
fi