make-tests.sh 5.1 KB

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