#!/bin/sh1#***************************************************************************2# _ _ ____ _3# Project ___| | | | _ \| |4# / __| | | | |_) | |5# | (__| |_| | _ <| |___6# \___|\___/|_| \_\_____|7#8# Copyright (C) Daniel Stenberg, <[email protected]>, et al.9#10# This software is licensed as described in the file COPYING, which11# you should have received as part of this distribution. The terms12# are also available at https://curl.se/docs/copyright.html.13#14# You may opt to use, copy, modify, merge, publish, distribute and/or sell15# copies of the Software, and permit persons to whom the Software is16# furnished to do so, under the terms of the COPYING file.17#18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY19# KIND, either express or implied.20#21# SPDX-License-Identifier: curl22#23###########################################################################24#25# tests compilation script for the OS/400.26#272829SCRIPTDIR=$(dirname "${0}")30. "${SCRIPTDIR}/initscript.sh"31cd "${TOPDIR}/tests" || exit 1323334# Build programs in a directory.3536build_all_programs()3738{39# Compile all programs.40# The list is found in variable "noinst_PROGRAMS"4142# shellcheck disable=SC203443INCLUDES="'$(pwd)' '${TOPDIR}/lib' '${TOPDIR}/src'"44MODS="${1}"45SRVPGMS="${2}"4647# shellcheck disable=SC215448for PGM in ${noinst_PROGRAMS}49do DB2PGM=$(db2_name "${PGM}")50PGMIFSNAME="${LIBIFSNAME}/${DB2PGM}.PGM"5152# Extract preprocessor symbol definitions from53# compilation options for the program.5455PGMCFLAGS="$(eval echo "\${${PGM}_CFLAGS}")"56PGMDFNS=5758for FLAG in ${PGMCFLAGS}59do case "${FLAG}" in60-D?*) # shellcheck disable=SC200161DEFINE="$(echo "${FLAG}" | sed 's/^..//')"62PGMDFNS="${PGMDFNS} '${DEFINE}'"63;;64esac65done6667# Compile all C sources for the program into modules.6869PGMSOURCES="$(eval echo "\${${PGM}_SOURCES}")"70LINK=71MODULES=7273for SOURCE in ${PGMSOURCES}74do case "${SOURCE}" in75*.c) # Special processing for libxxx.c files:76# their module name is determined77# by the target PROGRAM name.7879case "${SOURCE}" in80lib*.c) MODULE="${DB2PGM}"81;;82*) MODULE=$(db2_name "${SOURCE}")83;;84esac8586# If source is in a sibling directory,87# prefix module name with 'X'.8889case "${SOURCE}" in90../*) MODULE=$(db2_name "X${MODULE}")91;;92esac9394make_module "${MODULE}" "${SOURCE}" "${PGMDFNS}"95if action_needed "${PGMIFSNAME}" "${MODIFSNAME}"96then LINK=yes97fi98;;99esac100done101102# Link program if needed.103104if [ -n "${LINK}" ]105then PGMLDADD="$(eval echo "\${${PGM}_LDADD}")"106for M in ${PGMLDADD}107do case "${M}" in108-*) ;; # Ignore non-module.109*) MODULES="${MODULES} $(db2_name "${M}")"110;;111esac112done113MODULES="$(echo "${MODULES}" |114sed "s/[^ ][^ ]*/${TARGETLIB}\/&/g")"115CMD="CRTPGM PGM(${TARGETLIB}/${DB2PGM})"116CMD="${CMD} ENTMOD(${TARGETLIB}/CURLMAIN)"117CMD="${CMD} MODULE(${MODULES} ${MODS})"118CMD="${CMD} BNDSRVPGM(${SRVPGMS} QADRTTS)"119CMD="${CMD} TGTRLS(${TGTRLS})"120CLcommand "${CMD}"121fi122done123}124125126# Build programs in the server directory.127128(129cd server || exit 1130get_make_vars Makefile.inc131build_all_programs "${TARGETLIB}/OS400SYS"132)133134135# Build all programs in the libtest subdirectory.136137(138cd libtest || exit 1139get_make_vars Makefile.inc140141# shellcheck disable=SC2153142build_all_programs "" "${TARGETLIB}/${SRVPGM}"143)144145146