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