1#!/bin/sh 2# 3# Installation of the ILE/RPG header files in the OS/400 library. 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}/os400/libxmlrpg" 13 14 15# Create the OS/400 source program file for the ILE/RPG header files. 16 17SRCPF="${LIBIFSNAME}/LIBXMLRPG.FILE" 18 19if action_needed "${SRCPF}" 20then CMD="CRTSRCPF FILE(${TARGETLIB}/LIBXMLRPG) RCDLEN(112)" 21 CMD="${CMD} CCSID(${TGTCCSID}) TEXT('libxml2: ILE/RPG header files')" 22 system "${CMD}" 23fi 24 25 26# Map file names to DB2 name syntax. 27 28for HFILE in *.rpgle *.rpgle.in 29do NAME="`basename \"${HFILE}\" .in`" 30 VAR="`basename \"${NAME}\" .rpgle`" 31 VAL="`db2_name \"${NAME}\" nomangle`" 32 33 if [ "${VAR}" = 'xmlschemastypes' ] 34 then VAL=SCHMTYPES 35 fi 36 37 eval "VAR_${VAR}=\"${VAL}\"" 38 echo "${VAR} s/${VAR}/${VAL}/g" 39done > tmpsubstfile1 40 41# Order substitution commands so that a prefix appears after all 42# file names beginning with the prefix. 43 44sort -r tmpsubstfile1 | sed 's/^[^ ]*[ ]*//' > tmpsubstfile2 45 46 47change_include() 48 49{ 50 sed -e '\#^....../include *"libxmlrpg/#{' \ 51 -e 's///' \ 52 -e 's/".*//' \ 53 -f tmpsubstfile2 \ 54 -e 's#.*# /include libxmlrpg,&#' \ 55 -e '}' 56} 57 58 59# Create the IFS directory for the ILE/RPG header files. 60 61RPGIFSDIR="${IFSDIR}/include/libxmlrpg" 62 63if action_needed "${RPGIFSDIR}" 64then mkdir -p "${RPGIFSDIR}" 65fi 66 67# Copy the header files to IFS ILE/RPG include directory. 68# Copy them with include path editing to the DB2 library. 69 70for HFILE in *.rpgle *.rpgle.in 71do IFSCMD="cat \"${HFILE}\"" 72 DB2CMD="change_include < \"${HFILE}\"" 73 IFSFILE="`basename \"${HFILE}\" .in`" 74 75 case "${HFILE}" in 76 77 *.in) IFSCMD="${IFSCMD} | versioned_copy" 78 DB2CMD="${DB2CMD} | versioned_copy" 79 ;; 80 esac 81 82 IFSDEST="${RPGIFSDIR}/${IFSFILE}" 83 84 if action_needed "${IFSDEST}" "${HFILE}" 85 then eval "${IFSCMD}" > "${IFSDEST}" 86 fi 87 88 eval DB2MBR="\"\${VAR_`basename \"${IFSDEST}\" .rpgle`}\"" 89 DB2DEST="${SRCPF}/${DB2MBR}.MBR" 90 91 if action_needed "${DB2DEST}" "${HFILE}" 92 then eval "${DB2CMD}" | change_include > tmphdrfile 93 94 # Need to translate to target CCSID. 95 96 CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DB2DEST}')" 97 CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)" 98 system "${CMD}" 99 fi 100done 101