make-tests.sh 5.0 KB

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