113498266Sopenharmony_ci#!/bin/sh
213498266Sopenharmony_ci#***************************************************************************
313498266Sopenharmony_ci#                                  _   _ ____  _
413498266Sopenharmony_ci#  Project                     ___| | | |  _ \| |
513498266Sopenharmony_ci#                             / __| | | | |_) | |
613498266Sopenharmony_ci#                            | (__| |_| |  _ <| |___
713498266Sopenharmony_ci#                             \___|\___/|_| \_\_____|
813498266Sopenharmony_ci#
913498266Sopenharmony_ci# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
1013498266Sopenharmony_ci#
1113498266Sopenharmony_ci# This software is licensed as described in the file COPYING, which
1213498266Sopenharmony_ci# you should have received as part of this distribution. The terms
1313498266Sopenharmony_ci# are also available at https://curl.se/docs/copyright.html.
1413498266Sopenharmony_ci#
1513498266Sopenharmony_ci# You may opt to use, copy, modify, merge, publish, distribute and/or sell
1613498266Sopenharmony_ci# copies of the Software, and permit persons to whom the Software is
1713498266Sopenharmony_ci# furnished to do so, under the terms of the COPYING file.
1813498266Sopenharmony_ci#
1913498266Sopenharmony_ci# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
2013498266Sopenharmony_ci# KIND, either express or implied.
2113498266Sopenharmony_ci#
2213498266Sopenharmony_ci# SPDX-License-Identifier: curl
2313498266Sopenharmony_ci#
2413498266Sopenharmony_ci###########################################################################
2513498266Sopenharmony_ci#
2613498266Sopenharmony_ci#       tests compilation script for the OS/400.
2713498266Sopenharmony_ci#
2813498266Sopenharmony_ci
2913498266Sopenharmony_ci
3013498266Sopenharmony_ciSCRIPTDIR=`dirname "${0}"`
3113498266Sopenharmony_ci. "${SCRIPTDIR}/initscript.sh"
3213498266Sopenharmony_cicd "${TOPDIR}/tests"
3313498266Sopenharmony_ci
3413498266Sopenharmony_ci
3513498266Sopenharmony_ci#       Build programs in a directory.
3613498266Sopenharmony_ci
3713498266Sopenharmony_cibuild_all_programs()
3813498266Sopenharmony_ci
3913498266Sopenharmony_ci{
4013498266Sopenharmony_ci        #       Compile all programs.
4113498266Sopenharmony_ci        #       The list is found in variable "noinst_PROGRAMS"
4213498266Sopenharmony_ci
4313498266Sopenharmony_ci        INCLUDES="'`pwd`' '${TOPDIR}/lib' '${TOPDIR}/src'"
4413498266Sopenharmony_ci        MODS="${1}"
4513498266Sopenharmony_ci        SRVPGMS="${2}"
4613498266Sopenharmony_ci
4713498266Sopenharmony_ci        for PGM in ${noinst_PROGRAMS}
4813498266Sopenharmony_ci        do      DB2PGM=`db2_name "${PGM}"`
4913498266Sopenharmony_ci                PGMIFSNAME="${LIBIFSNAME}/${DB2PGM}.PGM"
5013498266Sopenharmony_ci
5113498266Sopenharmony_ci                #       Extract preprocessor symbol definitions from
5213498266Sopenharmony_ci                #               compilation options for the program.
5313498266Sopenharmony_ci
5413498266Sopenharmony_ci                PGMCFLAGS="`eval echo \"\\${${PGM}_CFLAGS}\"`"
5513498266Sopenharmony_ci                PGMDFNS=
5613498266Sopenharmony_ci
5713498266Sopenharmony_ci                for FLAG in ${PGMCFLAGS}
5813498266Sopenharmony_ci                do      case "${FLAG}" in
5913498266Sopenharmony_ci                        -D?*)   DEFINE="`echo \"${FLAG}\" | sed 's/^..//'`"
6013498266Sopenharmony_ci                                PGMDFNS="${PGMDFNS} '${DEFINE}'"
6113498266Sopenharmony_ci                                ;;
6213498266Sopenharmony_ci                        esac
6313498266Sopenharmony_ci                done
6413498266Sopenharmony_ci
6513498266Sopenharmony_ci                #        Compile all C sources for the program into modules.
6613498266Sopenharmony_ci
6713498266Sopenharmony_ci                PGMSOURCES="`eval echo \"\\${${PGM}_SOURCES}\"`"
6813498266Sopenharmony_ci                LINK=
6913498266Sopenharmony_ci                MODULES=
7013498266Sopenharmony_ci
7113498266Sopenharmony_ci                for SOURCE in ${PGMSOURCES}
7213498266Sopenharmony_ci                do      case "${SOURCE}" in
7313498266Sopenharmony_ci                        *.c)    #       Special processing for libxxx.c files:
7413498266Sopenharmony_ci                                #               their module name is determined
7513498266Sopenharmony_ci                                #               by the target PROGRAM name.
7613498266Sopenharmony_ci
7713498266Sopenharmony_ci                                case "${SOURCE}" in
7813498266Sopenharmony_ci                                lib*.c) MODULE="${DB2PGM}"
7913498266Sopenharmony_ci                                        ;;
8013498266Sopenharmony_ci                                *)      MODULE=`db2_name "${SOURCE}"`
8113498266Sopenharmony_ci                                        ;;
8213498266Sopenharmony_ci                                esac
8313498266Sopenharmony_ci
8413498266Sopenharmony_ci                                #       If source is in a sibling directory,
8513498266Sopenharmony_ci                                #               prefix module name with 'X'.
8613498266Sopenharmony_ci
8713498266Sopenharmony_ci                                case "${SOURCE}" in
8813498266Sopenharmony_ci                                ../*)   MODULE=`db2_name "X${MODULE}"`
8913498266Sopenharmony_ci                                            ;;
9013498266Sopenharmony_ci                                esac
9113498266Sopenharmony_ci
9213498266Sopenharmony_ci                                make_module "${MODULE}" "${SOURCE}" "${PGMDFNS}"
9313498266Sopenharmony_ci                                if action_needed "${PGMIFSNAME}" "${MODIFSNAME}"
9413498266Sopenharmony_ci                                then    LINK=yes
9513498266Sopenharmony_ci                                fi
9613498266Sopenharmony_ci                                ;;
9713498266Sopenharmony_ci                        esac
9813498266Sopenharmony_ci                done
9913498266Sopenharmony_ci
10013498266Sopenharmony_ci                #       Link program if needed.
10113498266Sopenharmony_ci
10213498266Sopenharmony_ci                if [ "${LINK}" ]
10313498266Sopenharmony_ci                then    PGMLDADD="`eval echo \"\\${${PGM}_LDADD}\"`"
10413498266Sopenharmony_ci                        for ARG in ${PGMLDADD}
10513498266Sopenharmony_ci                        do      case "${ARG}" in
10613498266Sopenharmony_ci                                -*)     ;;              # Ignore non-module.
10713498266Sopenharmony_ci                                *)      MODULES="${MODULES} "`db2_name "${ARG}"`
10813498266Sopenharmony_ci                                        ;;
10913498266Sopenharmony_ci                                esac
11013498266Sopenharmony_ci                        done
11113498266Sopenharmony_ci                        MODULES="`echo \"${MODULES}\" |
11213498266Sopenharmony_ci                            sed \"s/[^ ][^ ]*/${TARGETLIB}\/&/g\"`"
11313498266Sopenharmony_ci                        CMD="CRTPGM PGM(${TARGETLIB}/${DB2PGM})"
11413498266Sopenharmony_ci                        CMD="${CMD} ENTMOD(${TARGETLIB}/CURLMAIN)"
11513498266Sopenharmony_ci                        CMD="${CMD} MODULE(${MODULES} ${MODS})"
11613498266Sopenharmony_ci                        CMD="${CMD} BNDSRVPGM(${SRVPGMS} QADRTTS)"
11713498266Sopenharmony_ci                        CMD="${CMD} TGTRLS(${TGTRLS})"
11813498266Sopenharmony_ci                        CLcommand "${CMD}"
11913498266Sopenharmony_ci                fi
12013498266Sopenharmony_ci        done
12113498266Sopenharmony_ci}
12213498266Sopenharmony_ci
12313498266Sopenharmony_ci
12413498266Sopenharmony_ci#       Build programs in the server directory.
12513498266Sopenharmony_ci
12613498266Sopenharmony_ci(
12713498266Sopenharmony_ci        cd server
12813498266Sopenharmony_ci        get_make_vars Makefile.inc
12913498266Sopenharmony_ci        build_all_programs "${TARGETLIB}/OS400SYS"
13013498266Sopenharmony_ci)
13113498266Sopenharmony_ci
13213498266Sopenharmony_ci
13313498266Sopenharmony_ci#       Build all programs in the libtest subdirectory.
13413498266Sopenharmony_ci
13513498266Sopenharmony_ci(
13613498266Sopenharmony_ci        cd libtest
13713498266Sopenharmony_ci        get_make_vars Makefile.inc
13813498266Sopenharmony_ci
13913498266Sopenharmony_ci        #       Special case: redefine chkhostname compilation parameters.
14013498266Sopenharmony_ci
14113498266Sopenharmony_ci        chkhostname_SOURCES=chkhostname.c
14213498266Sopenharmony_ci        chkhostname_LDADD=curl_gethostname.o
14313498266Sopenharmony_ci
14413498266Sopenharmony_ci        build_all_programs "" "${TARGETLIB}/${SRVPGM}"
14513498266Sopenharmony_ci)
146