xref: /curl/packages/OS400/makefile.sh (revision 5e46c290)
1#!/bin/sh
2#***************************************************************************
3#                                  _   _ ____  _
4#  Project                     ___| | | |  _ \| |
5#                             / __| | | | |_) | |
6#                            | (__| |_| |  _ <| |___
7#                             \___|\___/|_| \_\_____|
8#
9# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
10#
11# This software is licensed as described in the file COPYING, which
12# you should have received as part of this distribution. The terms
13# are also available at https://curl.se/docs/copyright.html.
14#
15# You may opt to use, copy, modify, merge, publish, distribute and/or sell
16# copies of the Software, and permit persons to whom the Software is
17# furnished to do so, under the terms of the COPYING file.
18#
19# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20# KIND, either express or implied.
21#
22# SPDX-License-Identifier: curl
23#
24###########################################################################
25#
26#       curl compilation script for the OS/400.
27#
28#
29#       This is a shell script since make is not a standard component of OS/400.
30
31SCRIPTDIR=$(dirname "${0}")
32. "${SCRIPTDIR}/initscript.sh"
33cd "${TOPDIR}" || exit 1
34
35
36#       Create the OS/400 library if it does not exist.
37
38if action_needed "${LIBIFSNAME}"
39then    CMD="CRTLIB LIB(${TARGETLIB}) TEXT('curl: multiprotocol support API')"
40        CLcommand "${CMD}"
41fi
42
43
44#       Create the DOCS source file if it does not exist.
45
46if action_needed "${LIBIFSNAME}/DOCS.FILE"
47then    CMD="CRTSRCPF FILE(${TARGETLIB}/DOCS) RCDLEN(240)"
48        CMD="${CMD} CCSID(${TGTCCSID}) TEXT('Documentation texts')"
49        CLcommand "${CMD}"
50fi
51
52
53#       Copy some documentation files if needed.
54
55for TEXT in "${TOPDIR}/COPYING" "${SCRIPTDIR}/README.OS400"             \
56    "${TOPDIR}/CHANGES" "${TOPDIR}/docs/THANKS" "${TOPDIR}/docs/FAQ"    \
57    "${TOPDIR}/docs/FEATURES" "${TOPDIR}/docs/SSLCERTS.md"              \
58    "${TOPDIR}/docs/RESOURCES" "${TOPDIR}/docs/VERSIONS.md"             \
59    "${TOPDIR}/docs/HISTORY.md"
60do      MEMBER="$(basename "${TEXT}" .OS400)"
61        MEMBER="$(basename "${MEMBER}" .md)"
62        MEMBER="${LIBIFSNAME}/DOCS.FILE/$(db2_name "${MEMBER}").MBR"
63
64        [ -e "${TEXT}" ] || continue
65
66        if action_needed "${MEMBER}" "${TEXT}"
67        then    CMD="CPY OBJ('${TEXT}') TOOBJ('${MEMBER}') TOCCSID(${TGTCCSID})"
68                CMD="${CMD} DTAFMT(*TEXT) REPLACE(*YES)"
69                CLcommand "${CMD}"
70        fi
71done
72
73
74#       Create the RPGXAMPLES source file if it does not exist.
75
76if action_needed "${LIBIFSNAME}/RPGXAMPLES.FILE"
77then    CMD="CRTSRCPF FILE(${TARGETLIB}/RPGXAMPLES) RCDLEN(240)"
78        CMD="${CMD} CCSID(${TGTCCSID}) TEXT('ILE/RPG examples')"
79        CLcommand "${CMD}"
80fi
81
82
83#       Copy RPG examples if needed.
84
85for EXAMPLE in "${SCRIPTDIR}/rpg-examples"/*
86do      MEMBER="$(basename "${EXAMPLE}")"
87        IFSMEMBER="${LIBIFSNAME}/RPGXAMPLES.FILE/$(db2_name "${MEMBER}").MBR"
88
89        [ -e "${EXAMPLE}" ] || continue
90
91        if action_needed "${IFSMEMBER}" "${EXAMPLE}"
92        then    CMD="CPY OBJ('${EXAMPLE}') TOOBJ('${IFSMEMBER}')"
93                CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
94                CLcommand "${CMD}"
95                MBRTEXT=$(sed -e '1!d;/^      \*/!d;s/^ *\* *//'        \
96                              -e 's/ *$//;s/'"'"'/&&/g' < "${EXAMPLE}")
97                CMD="CHGPFM FILE(${TARGETLIB}/RPGXAMPLES) MBR(${MEMBER})"
98                CMD="${CMD} SRCTYPE(RPGLE) TEXT('${MBRTEXT}')"
99                CLcommand "${CMD}"
100        fi
101done
102
103
104#       Compile the QADRTMAIN2 replacement module.
105
106if action_needed "${LIBIFSNAME}/CURLMAIN.MODULE" "${SCRIPTDIR}/curlmain.c"
107then    CMD="CRTCMOD MODULE(${TARGETLIB}/CURLMAIN)"
108        CMD="${CMD} SRCSTMF('${SCRIPTDIR}/curlmain.c')"
109        CMD="${CMD} SYSIFCOPT(*IFS64IO) LOCALETYPE(*LOCALE) FLAG(10)"
110        CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
111        CMD="${CMD} OUTPUT(${OUTPUT})"
112        CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
113        CMD="${CMD} DBGVIEW(${DEBUG})"
114        CLcommand "${CMD}"
115fi
116
117
118#       Build in each directory.
119
120# for SUBDIR in include lib src tests
121for SUBDIR in include lib src
122do      "${SCRIPTDIR}/make-${SUBDIR}.sh"
123done
124