xref: /aosp_15_r20/external/libxml2/os400/make-include.sh (revision 7c5688314b92172186c154356a6374bf7684c3ca)
1#!/bin/sh
2#
3#       Installation of the C header files in the OS/400 library.
4#
5#       See Copyright for the status of this software.
6#
7#       Author: Patrick Monnerat <[email protected]>, DATASPHERE S.A.
8#
9
10SCRIPTDIR=`dirname "${0}"`
11. "${SCRIPTDIR}/initscript.sh"
12cd "${TOPDIR}/include"
13
14
15#       Create the OS/400 source program file for the C header files.
16
17SRCPF="${LIBIFSNAME}/LIBXML.FILE"
18
19if action_needed "${SRCPF}"
20then    CMD="CRTSRCPF FILE(${TARGETLIB}/LIBXML) RCDLEN(112)"
21        CMD="${CMD} CCSID(${TGTCCSID}) TEXT('libxml2: C/C++ header files')"
22        system "${CMD}"
23fi
24
25
26#       Create the IFS directory for the C header files.
27
28if action_needed "${IFSDIR}/include/libxml"
29then    mkdir -p "${IFSDIR}/include/libxml"
30fi
31
32
33
34#       Enumeration values may be used as va_arg tagfields, so they MUST be
35#               integers.
36
37copy_hfile()
38
39{
40        sed -e '1i\
41#pragma enum(int)\
42' "${@}" -e '$a\
43#pragma enum(pop)\
44'
45}
46
47#       Copy the header files to DB2 library. Link from IFS include directory.
48
49for HFILE in "${TOPDIR}/os400/transcode.h" libxml/*.h libxml/*.h.in
50do      CMD="cat \"${HFILE}\""
51        DEST="${SRCPF}/`db2_name \"${HFILE}\" nomangle`.MBR"
52
53        case "`basename \"${HFILE}\"`" in
54
55        *.in)   CMD="${CMD} | versioned_copy";;
56
57        xmlschemastypes.h)      #       Special case: rename colliding file.
58                DEST="${SRCPF}/SCHMTYPES.MBR";;
59
60        esac
61
62        if action_needed "${DEST}" "${HFILE}"
63        then    eval "${CMD}" | copy_hfile > tmphdrfile
64
65                #       Need to translate to target CCSID.
66
67                CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DEST}')"
68                CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
69                system "${CMD}"
70        fi
71
72        IFSFILE="${IFSDIR}/include/libxml/`basename \"${HFILE}\" .in`"
73
74        if action_needed "${IFSFILE}" "${DEST}"
75        then    rm -f "${IFSFILE}"
76                ln -s "${DEST}" "${IFSFILE}"
77        fi
78done
79