blob: 664b47bf2d26d7cbf4f3fd3328558936cd881814 [file] [log] [blame]
Patrick Monnerate72b4e72014-03-04 17:26:13 +01001#!/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
Patrick Monnerate72b4e72014-03-04 17:26:13 +010028for 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
Patrick Monnerate72b4e72014-03-04 17:26:13 +010037 eval "VAR_${VAR}=\"${VAL}\""
Patrick Monnerat22b04152015-04-16 16:04:06 +080038 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
Patrick Monnerate72b4e72014-03-04 17:26:13 +010045
46
47change_include()
48
49{
50 sed -e '\#^....../include *"libxmlrpg/#{' \
51 -e 's///' \
52 -e 's/".*//' \
Patrick Monnerat22b04152015-04-16 16:04:06 +080053 -f tmpsubstfile2 \
Patrick Monnerate72b4e72014-03-04 17:26:13 +010054 -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