1#!/bin/sh 2#*************************************************************************** 3# _ _ ____ _ 4# Project ___| | | | _ \| | 5# / __| | | | |_) | | 6# | (__| |_| | _ <| |___ 7# \___|\___/|_| \_\_____| 8# 9# Copyright (C) Daniel Stenberg, <[email protected]>, 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# tests compilation script for the OS/400. 27# 28 29 30SCRIPTDIR=$(dirname "${0}") 31. "${SCRIPTDIR}/initscript.sh" 32cd "${TOPDIR}/tests" || exit 1 33 34 35# Build programs in a directory. 36 37build_all_programs() 38 39{ 40 # Compile all programs. 41 # The list is found in variable "noinst_PROGRAMS" 42 43 # shellcheck disable=SC2034 44 INCLUDES="'$(pwd)' '${TOPDIR}/lib' '${TOPDIR}/src'" 45 MODS="${1}" 46 SRVPGMS="${2}" 47 48 # shellcheck disable=SC2154 49 for PGM in ${noinst_PROGRAMS} 50 do DB2PGM=$(db2_name "${PGM}") 51 PGMIFSNAME="${LIBIFSNAME}/${DB2PGM}.PGM" 52 53 # Extract preprocessor symbol definitions from 54 # compilation options for the program. 55 56 PGMCFLAGS="$(eval echo "\${${PGM}_CFLAGS}")" 57 PGMDFNS= 58 59 for FLAG in ${PGMCFLAGS} 60 do case "${FLAG}" in 61 -D?*) # shellcheck disable=SC2001 62 DEFINE="$(echo "${FLAG}" | sed 's/^..//')" 63 PGMDFNS="${PGMDFNS} '${DEFINE}'" 64 ;; 65 esac 66 done 67 68 # Compile all C sources for the program into modules. 69 70 PGMSOURCES="$(eval echo "\${${PGM}_SOURCES}")" 71 LINK= 72 MODULES= 73 74 for SOURCE in ${PGMSOURCES} 75 do case "${SOURCE}" in 76 *.c) # Special processing for libxxx.c files: 77 # their module name is determined 78 # by the target PROGRAM name. 79 80 case "${SOURCE}" in 81 lib*.c) MODULE="${DB2PGM}" 82 ;; 83 *) MODULE=$(db2_name "${SOURCE}") 84 ;; 85 esac 86 87 # If source is in a sibling directory, 88 # prefix module name with 'X'. 89 90 case "${SOURCE}" in 91 ../*) MODULE=$(db2_name "X${MODULE}") 92 ;; 93 esac 94 95 make_module "${MODULE}" "${SOURCE}" "${PGMDFNS}" 96 if action_needed "${PGMIFSNAME}" "${MODIFSNAME}" 97 then LINK=yes 98 fi 99 ;; 100 esac 101 done 102 103 # Link program if needed. 104 105 if [ -n "${LINK}" ] 106 then PGMLDADD="$(eval echo "\${${PGM}_LDADD}")" 107 for M in ${PGMLDADD} 108 do case "${M}" in 109 -*) ;; # Ignore non-module. 110 *) MODULES="${MODULES} $(db2_name "${M}")" 111 ;; 112 esac 113 done 114 MODULES="$(echo "${MODULES}" | 115 sed "s/[^ ][^ ]*/${TARGETLIB}\/&/g")" 116 CMD="CRTPGM PGM(${TARGETLIB}/${DB2PGM})" 117 CMD="${CMD} ENTMOD(${TARGETLIB}/CURLMAIN)" 118 CMD="${CMD} MODULE(${MODULES} ${MODS})" 119 CMD="${CMD} BNDSRVPGM(${SRVPGMS} QADRTTS)" 120 CMD="${CMD} TGTRLS(${TGTRLS})" 121 CLcommand "${CMD}" 122 fi 123 done 124} 125 126 127# Build programs in the server directory. 128 129( 130 cd server || exit 1 131 get_make_vars Makefile.inc 132 build_all_programs "${TARGETLIB}/OS400SYS" 133) 134 135 136# Build all programs in the libtest subdirectory. 137 138( 139 cd libtest || exit 1 140 get_make_vars Makefile.inc 141 142 # shellcheck disable=SC2153 143 build_all_programs "" "${TARGETLIB}/${SRVPGM}" 144) 145