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 <pm@datasphere.ch>, DATASPHERE S.A. 8# 9 10SCRIPTDIR=`dirname "${0}"` 11. "${SCRIPTDIR}/initscript.sh" 12cd "${TOPDIR}" 13 14 15# Create and compile the identification source file. 16 17echo '#pragma comment(user, "libxml2 version '"${LIBXML_VERSION}"'")' > os400.c 18echo '#pragma comment(user, __DATE__)' >> os400.c 19echo '#pragma comment(user, __TIME__)' >> os400.c 20echo '#pragma comment(copyright, "Copyright (C) 1998-2017 Daniel Veillard. OS/400 version by P. Monnerat.")' >> os400.c 21make_module OS400 os400.c 22LINK= # No need to rebuild service program yet. 23MODULES= 24 25 26# Get source list. 27 28foldlines() 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 42get_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 54docb_sources=`get_make_var docb_sources` 55trio_sources=`get_make_var trio_sources` 56CSOURCES=`eval echo "\`get_make_var libxml2_la_SOURCES | tr '()' '{}'\`"` 57 58 59# Compile the sources into modules. 60 61INCLUDES="'`pwd`'" 62 63# OS/400 specific modules first. 64 65make_module --ebcdic DLFCN "${SCRIPTDIR}/dlfcn/dlfcn.c" 66make_module --ebcdic ICONV "${SCRIPTDIR}/iconv/iconv.c" 67make_module --ebcdic WRAPPERS "${SCRIPTDIR}/wrappers.c" 68make_module TRANSCODE "${SCRIPTDIR}/transcode.c" 69make_module RPGSUPPORT "${SCRIPTDIR}/rpgsupport.c" 70 71# Regular libxml2 modules. 72 73for SRC in ${CSOURCES} 74do MODULE=`db2_name "${SRC}"` 75 make_module "${MODULE}" "${SRC}" 76done 77 78 79# If needed, (re)create the static binding directory. 80 81if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR" 82then LINK=YES 83fi 84 85if [ "${LINK}" ] 86then 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 96fi 97 98 99# The exportation file for service program creation must be in a DB2 100# source file, so make sure it exists. 101 102if action_needed "${LIBIFSNAME}/TOOLS.FILE" 103then CMD="CRTSRCPF FILE(${TARGETLIB}/TOOLS) RCDLEN(112)" 104 CMD="${CMD} CCSID(${TGTCCSID}) TEXT('libxml2: build tools')" 105 system "${CMD}" 106fi 107 108 109# Generate all exported symbol table versions in a binding source file. 110 111BSF="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR" 112PGMEXPS= 113 114OS400SYMS=`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 148sed -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 191PGMLVL=CURRENT 192for PGMEXP in ${PGMEXPS} 193do 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 201done > "${BSF}" 202 203 204# Build the service program if needed. 205 206if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM" 207then LINK=YES 208fi 209 210if [ "${LINK}" ] 211then 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 224fi 225 226 227# If needed, (re)create the dynamic binding directory. 228 229if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR" 230then LINK=YES 231fi 232 233if [ "${LINK}" ] 234then 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}" 241fi 242 243 244# Compile the ASCII main() stub. 245 246make_module --ebcdic --sysiconv LIBXMLMAIN "${SCRIPTDIR}/libxmlmain.c" 247 248 249# Compile and link program xmllint. 250 251if 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" 254then 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" 265fi 266 267# Install xmllint in IFS. 268 269if [ ! -d "${IFSDIR}/bin" ] 270then mkdir -p "${IFSDIR}/bin" 271fi 272rm -f "${IFSDIR}/bin/xmllint" 273ln -s "${LIBIFSNAME}/XMLLINT.PGM" "${IFSDIR}/bin/xmllint" 274 275# Prepare the XMLLINT command and its response program. 276 277if action_needed "${LIBIFSNAME}/XMLLINTCL.PGM" "${SCRIPTDIR}/xmllintcl.c" 278then 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" 284fi 285 286if action_needed "${LIBIFSNAME}/TOOLS.FILE/XMLLINT.MBR" \ 287 "${SCRIPTDIR}/xmllint.cmd" 288then 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}" 292fi 293 294if action_needed "${LIBIFSNAME}/XMLLINT.CMD" \ 295 "${LIBIFSNAME}/TOOLS.FILE/XMLLINT.MBR" 296then 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}" 300fi 301 302 303# Compile and link program xmlcatalog. 304 305if 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" 310then 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" 322fi 323 324# Install xmlcatalog in IFS. 325 326rm -f "${IFSDIR}/bin/xmlcatalog" 327ln -s "${LIBIFSNAME}/XMLCATALOG.PGM" "${IFSDIR}/bin/xmlcatalog" 328 329# Prepare the XMLCATALOG command and its response program. 330 331if action_needed "${LIBIFSNAME}/XMLCATLGCL.PGM" "${SCRIPTDIR}/xmlcatlgcl.c" 332then 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" 339fi 340 341if action_needed "${LIBIFSNAME}/TOOLS.FILE/XMLCATALOG.MBR" \ 342 "${SCRIPTDIR}/xmlcatalog.cmd" 343then 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}" 347fi 348 349if action_needed "${LIBIFSNAME}/XMLCATALOG.CMD" \ 350 "${LIBIFSNAME}/TOOLS.FILE/XMLCATALOG.MBR" 351then 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}" 355fi 356