make-tests.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #!/bin/sh
  2. #
  3. # tests compilation script for the OS/400.
  4. #
  5. SCRIPTDIR=`dirname "${0}"`
  6. . "${SCRIPTDIR}/initscript.sh"
  7. cd "${TOPDIR}/tests"
  8. # tests directory not implemented yet.
  9. # Process the libtest subdirectory.
  10. cd libtest
  11. # Get definitions from the Makefile.inc file.
  12. # The `sed' statement works as follows:
  13. # _ Join \nl-separated lines.
  14. # _ Retain only lines that begins with "identifier =".
  15. # _ Turn these lines into shell variable assignments.
  16. eval "`sed -e ': begin' \
  17. -e '/\\\\$/{' \
  18. -e 'N' \
  19. -e 's/\\\\\\n/ /' \
  20. -e 'b begin' \
  21. -e '}' \
  22. -e '/^[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[=]/b keep' \
  23. -e 'd' \
  24. -e ': keep' \
  25. -e 's/[[:space:]]*=[[:space:]]*/=/' \
  26. -e 's/=\\(.*[^[:space:]]\\)[[:space:]]*$/=\\"\\1\\"/' \
  27. -e 's/\\$(\\([^)]*\\))/${\\1}/g' \
  28. < Makefile.inc`"
  29. # Special case: redefine chkhostname compilation parameters.
  30. chkhostname_SOURCES=chkhostname.c
  31. chkhostname_LDADD=curl_gethostname.o
  32. # Compile all programs.
  33. # The list is found in variable "noinst_PROGRAMS"
  34. INCLUDES="'${TOPDIR}/tests/libtest' '${TOPDIR}/lib'"
  35. for PGM in ${noinst_PROGRAMS}
  36. do DB2PGM=`db2_name "${PGM}"`
  37. PGMIFSNAME="${LIBIFSNAME}/${DB2PGM}.PGM"
  38. # Extract preprocessor symbol definitions from compilation
  39. # options for the program.
  40. PGMCFLAGS="`eval echo \"\\${${PGM}_CFLAGS}\"`"
  41. PGMDEFINES=
  42. for FLAG in ${PGMCFLAGS}
  43. do case "${FLAG}" in
  44. -D?*) DEFINE="`echo \"${FLAG}\" | sed 's/^..//'`"
  45. PGMDEFINES="${PGMDEFINES} '${DEFINE}'"
  46. ;;
  47. esac
  48. done
  49. # Compile all C sources for the program into modules.
  50. PGMSOURCES="`eval echo \"\\${${PGM}_SOURCES}\"`"
  51. LINK=
  52. MODULES=
  53. for SOURCE in ${PGMSOURCES}
  54. do case "${SOURCE}" in
  55. *.c) # Special processing for libxxx.c files: their
  56. # module name is determined by the target
  57. # PROGRAM name.
  58. case "${SOURCE}" in
  59. lib*.c) MODULE="${DB2PGM}"
  60. ;;
  61. *) MODULE=`db2_name "${SOURCE}"`
  62. ;;
  63. esac
  64. make_module "${MODULE}" "${SOURCE}" "${PGMDEFINES}"
  65. if action_needed "${PGMIFSNAME}" "${MODIFSNAME}"
  66. then LINK=yes
  67. fi
  68. ;;
  69. esac
  70. done
  71. # Link program if needed.
  72. if [ "${LINK}" ]
  73. then PGMLDADD="`eval echo \"\\${${PGM}_LDADD}\"`"
  74. for LDARG in ${PGMLDADD}
  75. do case "${LDARG}" in
  76. -*) ;; # Ignore non-module.
  77. *) MODULES="${MODULES} "`db2_name "${LDARG}"`
  78. ;;
  79. esac
  80. done
  81. MODULES="`echo \"${MODULES}\" |
  82. sed \"s/[^ ][^ ]*/${TARGETLIB}\/&/g\"`"
  83. CMD="CRTPGM PGM(${TARGETLIB}/${DB2PGM})"
  84. CMD="${CMD} ENTMOD(QADRT/QADRTMAIN2)"
  85. CMD="${CMD} MODULE(${MODULES})"
  86. CMD="${CMD} BNDSRVPGM(${TARGETLIB}/${SRVPGM} QADRTTS)"
  87. CMD="${CMD} TGTRLS(${TGTRLS})"
  88. system "${CMD}"
  89. fi
  90. done