huangcm
2025-02-24 69ed55dec4b2116a19e4cca4393cbc014fce5fb2
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
#!/bin/sh
#
#       Installation of the ILE/RPG header files in the OS/400 library.
#
#       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}/os400/libxmlrpg"
 
 
#       Create the OS/400 source program file for the ILE/RPG header files.
 
SRCPF="${LIBIFSNAME}/LIBXMLRPG.FILE"
 
if action_needed "${SRCPF}"
then    CMD="CRTSRCPF FILE(${TARGETLIB}/LIBXMLRPG) RCDLEN(112)"
        CMD="${CMD} CCSID(${TGTCCSID}) TEXT('libxml2: ILE/RPG header files')"
        system "${CMD}"
fi
 
 
#       Map file names to DB2 name syntax.
 
for HFILE in *.rpgle *.rpgle.in
do      NAME="`basename \"${HFILE}\" .in`"
        VAR="`basename \"${NAME}\" .rpgle`"
        VAL="`db2_name \"${NAME}\" nomangle`"
 
        if [ "${VAR}" = 'xmlschemastypes' ]
        then    VAL=SCHMTYPES
        fi
 
        eval "VAR_${VAR}=\"${VAL}\""
        echo "${VAR} s/${VAR}/${VAL}/g"
done > tmpsubstfile1
 
#       Order substitution commands so that a prefix appears after all
#               file names beginning with the prefix.
 
sort -r tmpsubstfile1 | sed 's/^[^ ]*[ ]*//' > tmpsubstfile2
 
 
change_include()
 
{
        sed -e '\#^....../include  *"libxmlrpg/#{'                      \
            -e 's///'                                                   \
            -e 's/".*//'                                                \
            -f tmpsubstfile2                                            \
            -e 's#.*#      /include libxmlrpg,&#'                       \
            -e '}'
}
 
 
#       Create the IFS directory for the ILE/RPG header files.
 
RPGIFSDIR="${IFSDIR}/include/libxmlrpg"
 
if action_needed "${RPGIFSDIR}"
then    mkdir -p "${RPGIFSDIR}"
fi
 
#       Copy the header files to IFS ILE/RPG include directory.
#       Copy them with include path editing to the DB2 library.
 
for HFILE in *.rpgle *.rpgle.in
do      IFSCMD="cat \"${HFILE}\""
        DB2CMD="change_include < \"${HFILE}\""
        IFSFILE="`basename \"${HFILE}\" .in`"
 
        case "${HFILE}" in
 
        *.in)   IFSCMD="${IFSCMD} | versioned_copy"
                DB2CMD="${DB2CMD} | versioned_copy"
                ;;
        esac
 
        IFSDEST="${RPGIFSDIR}/${IFSFILE}"
 
        if action_needed "${IFSDEST}" "${HFILE}"
        then    eval "${IFSCMD}" > "${IFSDEST}"
        fi
 
        eval DB2MBR="\"\${VAR_`basename \"${IFSDEST}\" .rpgle`}\""
        DB2DEST="${SRCPF}/${DB2MBR}.MBR"
 
        if action_needed "${DB2DEST}" "${HFILE}"
        then    eval "${DB2CMD}" | change_include > tmphdrfile
 
                #       Need to translate to target CCSID.
 
                CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DB2DEST}')"
                CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
                system "${CMD}"
        fi
done