1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # libxml compilation script for the OS/400.
|
---|
4 | #
|
---|
5 | # See Copyright for the status of this software.
|
---|
6 | #
|
---|
7 | # Author: Patrick Monnerat <[email protected]>, DATASPHERE S.A.
|
---|
8 | #
|
---|
9 |
|
---|
10 | SCRIPTDIR=`dirname "${0}"`
|
---|
11 | . "${SCRIPTDIR}/initscript.sh"
|
---|
12 | cd "${TOPDIR}"
|
---|
13 |
|
---|
14 |
|
---|
15 | # Create and compile the identification source file.
|
---|
16 |
|
---|
17 | echo '#pragma comment(user, "libxml2 version '"${LIBXML_VERSION}"'")' > os400.c
|
---|
18 | echo '#pragma comment(user, __DATE__)' >> os400.c
|
---|
19 | echo '#pragma comment(user, __TIME__)' >> os400.c
|
---|
20 | echo '#pragma comment(copyright, "Copyright (C) 1998-2017 Daniel Veillard. OS/400 version by P. Monnerat.")' >> os400.c
|
---|
21 | make_module OS400 os400.c
|
---|
22 | LINK= # No need to rebuild service program yet.
|
---|
23 | MODULES=
|
---|
24 |
|
---|
25 |
|
---|
26 | # Get source list.
|
---|
27 |
|
---|
28 | foldlines()
|
---|
29 |
|
---|
30 | {
|
---|
31 | sed -e ':begin' \
|
---|
32 | -e '/\\$/{' \
|
---|
33 | -e 's/\\$/ /' \
|
---|
34 | -e 'N' \
|
---|
35 | -e 'bbegin' \
|
---|
36 | -e '}' \
|
---|
37 | -e 's/\n//g' \
|
---|
38 | -e 's/[[:space:]]*$//'
|
---|
39 | }
|
---|
40 |
|
---|
41 |
|
---|
42 | get_make_var()
|
---|
43 |
|
---|
44 | {
|
---|
45 | foldlines < Makefile.am |
|
---|
46 | sed -e "/^${1}[[:space:]]*=[[:space:]]*/{" \
|
---|
47 | -e 's///' \
|
---|
48 | -e 'q' \
|
---|
49 | -e '}' \
|
---|
50 | -e 'd'
|
---|
51 | }
|
---|
52 |
|
---|
53 |
|
---|
54 | docb_sources=`get_make_var docb_sources`
|
---|
55 | trio_sources=`get_make_var trio_sources`
|
---|
56 | CSOURCES=`eval echo "\`get_make_var libxml2_la_SOURCES | tr '()' '{}'\`"`
|
---|
57 |
|
---|
58 |
|
---|
59 | # Compile the sources into modules.
|
---|
60 |
|
---|
61 | INCLUDES="'`pwd`'"
|
---|
62 |
|
---|
63 | # OS/400 specific modules first.
|
---|
64 |
|
---|
65 | make_module --ebcdic DLFCN "${SCRIPTDIR}/dlfcn/dlfcn.c"
|
---|
66 | make_module --ebcdic ICONV "${SCRIPTDIR}/iconv/iconv.c"
|
---|
67 | make_module --ebcdic WRAPPERS "${SCRIPTDIR}/wrappers.c"
|
---|
68 | make_module TRANSCODE "${SCRIPTDIR}/transcode.c"
|
---|
69 | make_module RPGSUPPORT "${SCRIPTDIR}/rpgsupport.c"
|
---|
70 |
|
---|
71 | # Regular libxml2 modules.
|
---|
72 |
|
---|
73 | for SRC in ${CSOURCES}
|
---|
74 | do MODULE=`db2_name "${SRC}"`
|
---|
75 | make_module "${MODULE}" "${SRC}"
|
---|
76 | done
|
---|
77 |
|
---|
78 |
|
---|
79 | # If needed, (re)create the static binding directory.
|
---|
80 |
|
---|
81 | if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
|
---|
82 | then LINK=YES
|
---|
83 | fi
|
---|
84 |
|
---|
85 | if [ "${LINK}" ]
|
---|
86 | then rm -rf "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
|
---|
87 | CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${STATBNDDIR})"
|
---|
88 | CMD="${CMD} TEXT('libxml2 static binding directory')"
|
---|
89 | system "${CMD}"
|
---|
90 |
|
---|
91 | for MODULE in ${MODULES}
|
---|
92 | do CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})"
|
---|
93 | CMD="${CMD} OBJ((${TARGETLIB}/${MODULE} *MODULE))"
|
---|
94 | system "${CMD}"
|
---|
95 | done
|
---|
96 | fi
|
---|
97 |
|
---|
98 |
|
---|
99 | # The exportation file for service program creation must be in a DB2
|
---|
100 | # source file, so make sure it exists.
|
---|
101 |
|
---|
102 | if action_needed "${LIBIFSNAME}/TOOLS.FILE"
|
---|
103 | then CMD="CRTSRCPF FILE(${TARGETLIB}/TOOLS) RCDLEN(112)"
|
---|
104 | CMD="${CMD} CCSID(${TGTCCSID}) TEXT('libxml2: build tools')"
|
---|
105 | system "${CMD}"
|
---|
106 | fi
|
---|
107 |
|
---|
108 |
|
---|
109 | # Generate all exported symbol table versions in a binding source file.
|
---|
110 |
|
---|
111 | BSF="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR"
|
---|
112 | PGMEXPS=
|
---|
113 |
|
---|
114 | OS400SYMS=`cat os400/transcode.h os400/rpgsupport.h |
|
---|
115 | sed -e 'H' \
|
---|
116 | -e 'g' \
|
---|
117 | -e 's/\n/ /' \
|
---|
118 | -e 's/\\$/ /' \
|
---|
119 | -e 's/.*/& /' \
|
---|
120 | -e 's/\/\*.*\*\// /g' \
|
---|
121 | -e 'h' \
|
---|
122 | -e ':loop' \
|
---|
123 | -e 'g' \
|
---|
124 | -e '/\/\*/d' \
|
---|
125 | -e '/;/!d' \
|
---|
126 | -e 's/[^;]*;//' \
|
---|
127 | -e 'x' \
|
---|
128 | -e 's/[[:space:]]*;.*$//' \
|
---|
129 | -e '/XMLPUBFUN/{' \
|
---|
130 | -e 's/[[:space:]]*(.*$//' \
|
---|
131 | -e 's/.*[[:space:]*]//' \
|
---|
132 | -e 'p' \
|
---|
133 | -e 'bloop' \
|
---|
134 | -e '}' \
|
---|
135 | -e '/XMLPUBVAR/!bloop' \
|
---|
136 | -e ':loop2' \
|
---|
137 | -e '/\[[^][]*\]/{' \
|
---|
138 | -e 's///' \
|
---|
139 | -e 'bloop2' \
|
---|
140 | -e '}' \
|
---|
141 | -e 's/[[:space:]]*,[[:space:]]*/,/g' \
|
---|
142 | -e 's/[^,]*[[:space:]*]//' \
|
---|
143 | -e 's/[^[:alnum:]_,]//g' \
|
---|
144 | -e 's/,/\n/g' \
|
---|
145 | -e 'p' \
|
---|
146 | -e 'bloop'`
|
---|
147 |
|
---|
148 | sed -e 's/#.*//' \
|
---|
149 | -e 's/[[:space:]]*$//' \
|
---|
150 | -e 's/^[[:space:]]*//' \
|
---|
151 | -e '/^*global:$/d' \
|
---|
152 | -e '/^$/d' \
|
---|
153 | -e '/[[:space:]]*{$/{' \
|
---|
154 | -e 's///' \
|
---|
155 | -e 'h' \
|
---|
156 | -e 's/[^A-Za-z0-9]/_/g' \
|
---|
157 | -e 's/^[0-9]/_&/' \
|
---|
158 | -e 'x' \
|
---|
159 | -e 'G' \
|
---|
160 | -e 's/\(.*\)\n\(.*\)/\2_SIGNATURE="\1"/' \
|
---|
161 | -e 'p' \
|
---|
162 | -e 's/.*//' \
|
---|
163 | -e 'x' \
|
---|
164 | -e "s/.*/SONAME='&'/" \
|
---|
165 | -e 'b' \
|
---|
166 | -e '}' \
|
---|
167 | -e '/[[:space:]]*;$/!d' \
|
---|
168 | -e 's///' \
|
---|
169 | -e '/^xmlDllMain$/d' \
|
---|
170 | -e '/^}[[:space:]]*/!{' \
|
---|
171 | -e 'H' \
|
---|
172 | -e 'd' \
|
---|
173 | -e '}' \
|
---|
174 | -e 's///' \
|
---|
175 | -e '/^$/!{' \
|
---|
176 | -e 's/[^A-Za-z0-9]/_/g' \
|
---|
177 | -e 's/^[0-9]/_&/' \
|
---|
178 | -e 's/.*/${&}/' \
|
---|
179 | -e 'x' \
|
---|
180 | -e 'H' \
|
---|
181 | -e 's/.*//' \
|
---|
182 | -e '}' \
|
---|
183 | -e 'x' \
|
---|
184 | -e 's/\n/ /g' \
|
---|
185 | -e 's/^[[:space:]]*//' \
|
---|
186 | -e 's/.*/declare ${SONAME}="&"/' \
|
---|
187 | -e 's/.*/&; PGMEXPS="${SONAME} ${PGMEXPS}"/' \
|
---|
188 | < "${TOPDIR}/libxml2.syms" > bndvars
|
---|
189 | . ./bndvars
|
---|
190 |
|
---|
191 | PGMLVL=CURRENT
|
---|
192 | for PGMEXP in ${PGMEXPS}
|
---|
193 | do SIGNATURE=`echo "${PGMEXP}" | sed 's/^LIBXML2_//'`
|
---|
194 | eval ENTRIES=\"\${${PGMEXP}}\"
|
---|
195 | echo " STRPGMEXP PGMLVL(*${PGMLVL}) SIGNATURE('${SIGNATURE}')"
|
---|
196 | for ENTRY in ${ENTRIES} ${OS400SYMS}
|
---|
197 | do echo " EXPORT SYMBOL('${ENTRY}')"
|
---|
198 | done
|
---|
199 | echo ' ENDPGMEXP'
|
---|
200 | PGMLVL=PRV
|
---|
201 | done > "${BSF}"
|
---|
202 |
|
---|
203 |
|
---|
204 | # Build the service program if needed.
|
---|
205 |
|
---|
206 | if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM"
|
---|
207 | then LINK=YES
|
---|
208 | fi
|
---|
209 |
|
---|
210 | if [ "${LINK}" ]
|
---|
211 | then CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})"
|
---|
212 | CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(BNDSRC)"
|
---|
213 | CMD="${CMD} MODULE(${TARGETLIB}/OS400)"
|
---|
214 | CMD="${CMD} BNDDIR((${TARGETLIB}/${STATBNDDIR})"
|
---|
215 | if [ "${WITH_ZLIB}" -ne 0 ]
|
---|
216 | then CMD="${CMD} (${ZLIB_LIB}/${ZLIB_BNDDIR})"
|
---|
217 | fi
|
---|
218 | CMD="${CMD})"
|
---|
219 | CMD="${CMD} BNDSRVPGM(QADRTTS)"
|
---|
220 | CMD="${CMD} TEXT('libxml2 dynamic library')"
|
---|
221 | CMD="${CMD} TGTRLS(${TGTRLS})"
|
---|
222 | system "${CMD}"
|
---|
223 | LINK=YES
|
---|
224 | fi
|
---|
225 |
|
---|
226 |
|
---|
227 | # If needed, (re)create the dynamic binding directory.
|
---|
228 |
|
---|
229 | if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
|
---|
230 | then LINK=YES
|
---|
231 | fi
|
---|
232 |
|
---|
233 | if [ "${LINK}" ]
|
---|
234 | then rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
|
---|
235 | CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
|
---|
236 | CMD="${CMD} TEXT('libxml2 dynamic binding directory')"
|
---|
237 | system "${CMD}"
|
---|
238 | CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
|
---|
239 | CMD="${CMD} OBJ((*LIBL/${SRVPGM} *SRVPGM))"
|
---|
240 | system "${CMD}"
|
---|
241 | fi
|
---|
242 |
|
---|
243 |
|
---|
244 | # Compile the ASCII main() stub.
|
---|
245 |
|
---|
246 | make_module --ebcdic --sysiconv LIBXMLMAIN "${SCRIPTDIR}/libxmlmain.c"
|
---|
247 |
|
---|
248 |
|
---|
249 | # Compile and link program xmllint.
|
---|
250 |
|
---|
251 | if action_needed "${LIBIFSNAME}/XMLLINT.PGM" "xmllint.c" ||
|
---|
252 | action_needed "${LIBIFSNAME}/XMLLINT.PGM" "${LIBIFSNAME}/${SRVPGM}.SRVPGM" ||
|
---|
253 | action_needed "${LIBIFSNAME}/XMLLINT.PGM" "${LIBIFSNAME}/LIBXMLMAIN.MODULE"
|
---|
254 | then make_module XMLLINT xmllint.c
|
---|
255 | CMD="CRTPGM PGM(${TARGETLIB}/XMLLINT) MODULE(${TARGETLIB}/XMLLINT)"
|
---|
256 | CMD="${CMD} ENTMOD(${TARGETLIB}/LIBXMLMAIN)"
|
---|
257 | CMD="${CMD} BNDSRVPGM(QADRTTS) BNDDIR((${TARGETLIB}/${STATBNDDIR})"
|
---|
258 | if [ "${WITH_ZLIB}" -ne 0 ]
|
---|
259 | then CMD="${CMD} (${ZLIB_LIB}/${ZLIB_BNDDIR})"
|
---|
260 | fi
|
---|
261 | CMD="${CMD}) ACTGRP(*NEW) TEXT('XML tool')"
|
---|
262 | CMD="${CMD} TGTRLS(${TGTRLS})"
|
---|
263 | system "${CMD}"
|
---|
264 | rm -f "${LIBIFSNAME}/XMLLINT.MODULE"
|
---|
265 | fi
|
---|
266 |
|
---|
267 | # Install xmllint in IFS.
|
---|
268 |
|
---|
269 | if [ ! -d "${IFSDIR}/bin" ]
|
---|
270 | then mkdir -p "${IFSDIR}/bin"
|
---|
271 | fi
|
---|
272 | rm -f "${IFSDIR}/bin/xmllint"
|
---|
273 | ln -s "${LIBIFSNAME}/XMLLINT.PGM" "${IFSDIR}/bin/xmllint"
|
---|
274 |
|
---|
275 | # Prepare the XMLLINT command and its response program.
|
---|
276 |
|
---|
277 | if action_needed "${LIBIFSNAME}/XMLLINTCL.PGM" "${SCRIPTDIR}/xmllintcl.c"
|
---|
278 | then make_module --ebcdic XMLLINTCL "${SCRIPTDIR}/xmllintcl.c"
|
---|
279 | CMD="CRTPGM PGM(${TARGETLIB}/XMLLINTCL) MODULE(${TARGETLIB}/XMLLINTCL)"
|
---|
280 | CMD="${CMD} ACTGRP(*NEW) TEXT('XMLLINT command response')"
|
---|
281 | CMD="${CMD} TGTRLS(${TGTRLS})"
|
---|
282 | system "${CMD}"
|
---|
283 | rm -f "${LIBIFSNAME}/XMLLINTCL.MODULE"
|
---|
284 | fi
|
---|
285 |
|
---|
286 | if action_needed "${LIBIFSNAME}/TOOLS.FILE/XMLLINT.MBR" \
|
---|
287 | "${SCRIPTDIR}/xmllint.cmd"
|
---|
288 | then CMD="CPY OBJ('${SCRIPTDIR}/xmllint.cmd')"
|
---|
289 | CMD="${CMD} TOOBJ('${LIBIFSNAME}/TOOLS.FILE/XMLLINT.MBR')"
|
---|
290 | CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
|
---|
291 | system "${CMD}"
|
---|
292 | fi
|
---|
293 |
|
---|
294 | if action_needed "${LIBIFSNAME}/XMLLINT.CMD" \
|
---|
295 | "${LIBIFSNAME}/TOOLS.FILE/XMLLINT.MBR"
|
---|
296 | then CMD="CRTCMD CMD(${TARGETLIB}/XMLLINT) PGM(${TARGETLIB}/XMLLINTCL)"
|
---|
297 | CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(XMLLINT) THDSAFE(*YES)"
|
---|
298 | CMD="${CMD} TEXT('XML tool') REPLACE(*YES)"
|
---|
299 | system "${CMD}"
|
---|
300 | fi
|
---|
301 |
|
---|
302 |
|
---|
303 | # Compile and link program xmlcatalog.
|
---|
304 |
|
---|
305 | if action_needed "${LIBIFSNAME}/XMLCATALOG.PGM" "xmlcatalog.c" ||
|
---|
306 | action_needed "${LIBIFSNAME}/XMLCATALOG.PGM" \
|
---|
307 | "${LIBIFSNAME}/${SRVPGM}.SRVPGM" ||
|
---|
308 | action_needed "${LIBIFSNAME}/XMLCATALOG.PGM" \
|
---|
309 | "${LIBIFSNAME}/LIBXMLMAIN.MODULE"
|
---|
310 | then make_module XMLCATALOG xmlcatalog.c
|
---|
311 | CMD="CRTPGM PGM(${TARGETLIB}/XMLCATALOG)"
|
---|
312 | CMD="${CMD} MODULE(${TARGETLIB}/XMLCATALOG)"
|
---|
313 | CMD="${CMD} ENTMOD(${TARGETLIB}/LIBXMLMAIN)"
|
---|
314 | CMD="${CMD} BNDSRVPGM(QADRTTS) BNDDIR((${TARGETLIB}/${STATBNDDIR})"
|
---|
315 | if [ "${WITH_ZLIB}" -ne 0 ]
|
---|
316 | then CMD="${CMD} (${ZLIB_LIB}/${ZLIB_BNDDIR})"
|
---|
317 | fi
|
---|
318 | CMD="${CMD}) ACTGRP(*NEW) TEXT('XML/SGML catalog tool')"
|
---|
319 | CMD="${CMD} TGTRLS(${TGTRLS})"
|
---|
320 | system "${CMD}"
|
---|
321 | rm -f "${LIBIFSNAME}/XMLCATALOG.MODULE"
|
---|
322 | fi
|
---|
323 |
|
---|
324 | # Install xmlcatalog in IFS.
|
---|
325 |
|
---|
326 | rm -f "${IFSDIR}/bin/xmlcatalog"
|
---|
327 | ln -s "${LIBIFSNAME}/XMLCATALOG.PGM" "${IFSDIR}/bin/xmlcatalog"
|
---|
328 |
|
---|
329 | # Prepare the XMLCATALOG command and its response program.
|
---|
330 |
|
---|
331 | if action_needed "${LIBIFSNAME}/XMLCATLGCL.PGM" "${SCRIPTDIR}/xmlcatlgcl.c"
|
---|
332 | then make_module --ebcdic XMLCATLGCL "${SCRIPTDIR}/xmlcatlgcl.c"
|
---|
333 | CMD="CRTPGM PGM(${TARGETLIB}/XMLCATLGCL)"
|
---|
334 | CMD="${CMD} MODULE(${TARGETLIB}/XMLCATLGCL)"
|
---|
335 | CMD="${CMD} ACTGRP(*NEW) TEXT('XMLCATALOG command response')"
|
---|
336 | CMD="${CMD} TGTRLS(${TGTRLS})"
|
---|
337 | system "${CMD}"
|
---|
338 | rm -f "${LIBIFSNAME}/XMLCATLGCL.MODULE"
|
---|
339 | fi
|
---|
340 |
|
---|
341 | if action_needed "${LIBIFSNAME}/TOOLS.FILE/XMLCATALOG.MBR" \
|
---|
342 | "${SCRIPTDIR}/xmlcatalog.cmd"
|
---|
343 | then CMD="CPY OBJ('${SCRIPTDIR}/xmlcatalog.cmd')"
|
---|
344 | CMD="${CMD} TOOBJ('${LIBIFSNAME}/TOOLS.FILE/XMLCATALOG.MBR')"
|
---|
345 | CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
|
---|
346 | system "${CMD}"
|
---|
347 | fi
|
---|
348 |
|
---|
349 | if action_needed "${LIBIFSNAME}/XMLCATALOG.CMD" \
|
---|
350 | "${LIBIFSNAME}/TOOLS.FILE/XMLCATALOG.MBR"
|
---|
351 | then CMD="CRTCMD CMD(${TARGETLIB}/XMLCATALOG) PGM(${TARGETLIB}/XMLCATLGCL)"
|
---|
352 | CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(XMLCATALOG)"
|
---|
353 | CMD="${CMD} THDSAFE(*YES) TEXT('XML/SGML catalog tool') REPLACE(*YES)"
|
---|
354 | system "${CMD}"
|
---|
355 | fi
|
---|