xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | #*************************************************************************** |
| 3 | # _ _ ____ _ |
| 4 | # Project ___| | | | _ \| | |
| 5 | # / __| | | | |_) | | |
| 6 | # | (__| |_| | _ <| |___ |
| 7 | # \___|\___/|_| \_\_____| |
| 8 | # |
| 9 | # Copyright (C) 1998 - 2022, 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 | # tests compilation script for the OS/400. |
| 27 | # |
| 28 | |
| 29 | |
| 30 | SCRIPTDIR=`dirname "${0}"` |
| 31 | . "${SCRIPTDIR}/initscript.sh" |
| 32 | cd "${TOPDIR}/tests" |
| 33 | |
| 34 | |
| 35 | # tests directory not implemented yet. |
| 36 | |
| 37 | |
| 38 | # Process the libtest subdirectory. |
| 39 | |
| 40 | cd libtest |
| 41 | |
| 42 | # Get definitions from the Makefile.inc file. |
| 43 | # The `sed' statement works as follows: |
| 44 | # _ Join \nl-separated lines. |
| 45 | # _ Retain only lines that begins with "identifier =". |
| 46 | # _ Turn these lines into shell variable assignments. |
| 47 | |
| 48 | eval "`sed -e ': begin' \ |
| 49 | -e '/\\\\$/{' \ |
| 50 | -e 'N' \ |
| 51 | -e 's/\\\\\\n/ /' \ |
| 52 | -e 'b begin' \ |
| 53 | -e '}' \ |
| 54 | -e '/^[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[=]/b keep' \ |
| 55 | -e 'd' \ |
| 56 | -e ': keep' \ |
| 57 | -e 's/[[:space:]]*=[[:space:]]*/=/' \ |
| 58 | -e 's/=\\(.*[^[:space:]]\\)[[:space:]]*$/=\\"\\1\\"/' \ |
| 59 | -e 's/\\$(\\([^)]*\\))/${\\1}/g' \ |
| 60 | < Makefile.inc`" |
| 61 | |
| 62 | # Special case: redefine chkhostname compilation parameters. |
| 63 | |
| 64 | chkhostname_SOURCES=chkhostname.c |
| 65 | chkhostname_LDADD=curl_gethostname.o |
| 66 | |
| 67 | # Compile all programs. |
| 68 | # The list is found in variable "noinst_PROGRAMS" |
| 69 | |
| 70 | INCLUDES="'${TOPDIR}/tests/libtest' '${TOPDIR}/lib'" |
| 71 | |
| 72 | for PGM in ${noinst_PROGRAMS} |
| 73 | do DB2PGM=`db2_name "${PGM}"` |
| 74 | PGMIFSNAME="${LIBIFSNAME}/${DB2PGM}.PGM" |
| 75 | |
| 76 | # Extract preprocessor symbol definitions from compilation |
| 77 | # options for the program. |
| 78 | |
| 79 | PGMCFLAGS="`eval echo \"\\${${PGM}_CFLAGS}\"`" |
| 80 | PGMDEFINES= |
| 81 | |
| 82 | for FLAG in ${PGMCFLAGS} |
| 83 | do case "${FLAG}" in |
| 84 | -D?*) DEFINE="`echo \"${FLAG}\" | sed 's/^..//'`" |
| 85 | PGMDEFINES="${PGMDEFINES} '${DEFINE}'" |
| 86 | ;; |
| 87 | esac |
| 88 | done |
| 89 | |
| 90 | # Compile all C sources for the program into modules. |
| 91 | |
| 92 | PGMSOURCES="`eval echo \"\\${${PGM}_SOURCES}\"`" |
| 93 | LINK= |
| 94 | MODULES= |
| 95 | |
| 96 | for SOURCE in ${PGMSOURCES} |
| 97 | do case "${SOURCE}" in |
| 98 | *.c) # Special processing for libxxx.c files: their |
| 99 | # module name is determined by the target |
| 100 | # PROGRAM name. |
| 101 | |
| 102 | case "${SOURCE}" in |
| 103 | lib*.c) MODULE="${DB2PGM}" |
| 104 | ;; |
| 105 | *) MODULE=`db2_name "${SOURCE}"` |
| 106 | ;; |
| 107 | esac |
| 108 | |
| 109 | make_module "${MODULE}" "${SOURCE}" "${PGMDEFINES}" |
| 110 | if action_needed "${PGMIFSNAME}" "${MODIFSNAME}" |
| 111 | then LINK=yes |
| 112 | fi |
| 113 | ;; |
| 114 | esac |
| 115 | done |
| 116 | |
| 117 | # Link program if needed. |
| 118 | |
| 119 | if [ "${LINK}" ] |
| 120 | then PGMLDADD="`eval echo \"\\${${PGM}_LDADD}\"`" |
| 121 | for LDARG in ${PGMLDADD} |
| 122 | do case "${LDARG}" in |
| 123 | -*) ;; # Ignore non-module. |
| 124 | *) MODULES="${MODULES} "`db2_name "${LDARG}"` |
| 125 | ;; |
| 126 | esac |
| 127 | done |
| 128 | MODULES="`echo \"${MODULES}\" | |
| 129 | sed \"s/[^ ][^ ]*/${TARGETLIB}\/&/g\"`" |
| 130 | CMD="CRTPGM PGM(${TARGETLIB}/${DB2PGM})" |
| 131 | CMD="${CMD} ENTMOD(QADRT/QADRTMAIN2)" |
| 132 | CMD="${CMD} MODULE(${MODULES})" |
| 133 | CMD="${CMD} BNDSRVPGM(${TARGETLIB}/${SRVPGM} QADRTTS)" |
| 134 | CMD="${CMD} TGTRLS(${TGTRLS})" |
| 135 | system "${CMD}" |
| 136 | fi |
| 137 | done |