1#!/bin/sh
2#
3#       libxml2 compilation script for the OS/400.
4#       This is a shell script since make is not a standard component of OS/400.
5#
6#       See Copyright for the status of this software.
7#
8#       Author: Patrick Monnerat <pm@datasphere.ch>, DATASPHERE S.A.
9#
10
11SCRIPTDIR=`dirname "${0}"`
12. "${SCRIPTDIR}/initscript.sh"
13cd "${TOPDIR}"
14
15
16#       Create the OS/400 library if it does not exist.
17
18if action_needed "${LIBIFSNAME}"
19then    CMD="CRTLIB LIB(${TARGETLIB})"
20        CMD="${CMD} TEXT('libxml2: XML parser and toolkit API')"
21        system "${CMD}"
22fi
23
24
25#       Create the DOCS source file if it does not exist.
26
27if action_needed "${LIBIFSNAME}/DOCS.FILE"
28then    CMD="CRTSRCPF FILE(${TARGETLIB}/DOCS) RCDLEN(112)"
29        CMD="${CMD} CCSID(${TGTCCSID}) TEXT('Documentation texts')"
30        system "${CMD}"
31fi
32
33
34#       Copy some documentation files if needed.
35
36for TEXT in "${TOPDIR}/AUTHORS" "${TOPDIR}/ChangeLog"                   \
37    "${TOPDIR}/Copyright" "${TOPDIR}/CONTRIBUTING" "${TOPDIR}/README"        \
38    "${TOPDIR}/MAINTAINERS" "${TOPDIR}/NEWS" "${TOPDIR}/TODO"           \
39    "${TOPDIR}/TODO_SCHEMAS" "${TOPDIR}/os400/README400"
40do      if [ -f "${TEXT}" ]
41        then    MEMBER="`basename \"${TEXT}\" .OS400`"
42                MEMBER="${LIBIFSNAME}/DOCS.FILE/`db2_name \"${MEMBER}\"`.MBR"
43
44                if action_needed "${MEMBER}" "${TEXT}"
45                then    # Sources are in UTF-8.
46                        rm -f "${TOPDIR}/tmpfile"[12]
47                        CMD="CPY OBJ('${TEXT}') TOOBJ('${TOPDIR}/tmpfile1')"
48                        CMD="${CMD} FROMCCSID(1208) TOCCSID(${TGTCCSID})"
49                        CMD="${CMD} DTAFMT(*TEXT) REPLACE(*YES)"
50                        system "${CMD}"
51                        # Make sure all lines are < 100 characters.
52                        sed -e 's/.\{99\}/&\
53/g' -e 's/\n$//' "${TOPDIR}/tmpfile1" > "${TOPDIR}/tmpfile2"
54                        CMD="CPY OBJ('${TOPDIR}/tmpfile2') TOOBJ('${MEMBER}')"
55                        CMD="${CMD} TOCCSID(${TGTCCSID})"
56                        CMD="${CMD} DTAFMT(*TEXT) REPLACE(*YES)"
57                        system "${CMD}"
58                fi
59        fi
60done
61
62
63#       Build files from template.
64
65configFile()
66
67{
68        args=`set | sed -e '/^[A-Za-z_][A-Za-z0-9_]*=/!d'               \
69                        -e 's/[\/\\\\&]/\\\\&/g'                        \
70                        -e "s/'/'\\\\\\''/g"                            \
71                        -e 's/^\([^=]*\)=\(.*\)$/-e '\''s\/@\1@\/\2\/g'\'/`
72        eval sed ${args} < "${1}".in > "${1}"
73}
74
75configFile include/libxml/xmlversion.h
76configFile os400/os400config.h
77mv os400/os400config.h config.h
78
79
80#       Build in each directory.
81
82for SUBDIR in include rpg src
83do      "${SCRIPTDIR}/make-${SUBDIR}.sh"
84done
85