1#!/bin/sh
2#
3#       Installation of the header files in the OS/400 library.
4#
5
6SCRIPTDIR=`dirname "${0}"`
7. "${SCRIPTDIR}/initscript.sh"
8cd "${TOPDIR}/include"
9
10
11#       Create the OS/400 source program file for the header files.
12
13SRCPF="${LIBIFSNAME}/H.FILE"
14
15if action_needed "${SRCPF}"
16then    CMD="CRTSRCPF FILE(${TARGETLIB}/H) RCDLEN(112)"
17        CMD="${CMD} CCSID(${TGTCCSID}) TEXT('libssh2: Header files')"
18        system "${CMD}"
19fi
20
21
22#       Create the IFS directory for the header files.
23
24IFSINCLUDE="${IFSDIR}/include"
25
26if action_needed "${IFSINCLUDE}"
27then    mkdir -p "${IFSINCLUDE}"
28fi
29
30
31copy_hfile()
32
33{
34        destfile="${1}"
35        srcfile="${2}"
36        shift
37        shift
38        sed -e '1i\
39#pragma datamodel(P128)\
40' "${@}" -e '$a\
41#pragma datamodel(pop)\
42' < "${srcfile}" > "${destfile}"
43}
44
45#       Copy the header files.
46
47for HFILE in *.h "${TOPDIR}/os400/libssh2_ccsid.h"
48do      DEST="${SRCPF}/`db2_name \"${HFILE}\"`.MBR"
49
50        if action_needed "${DEST}" "${HFILE}"
51        then    copy_hfile "${DEST}" "${HFILE}"
52                IFSDEST="${IFSINCLUDE}/`basename \"${HFILE}\"`"
53                rm -f "${IFSDEST}"
54                ln -s "${DEST}" "${IFSDEST}"
55        fi
56done
57