make-tests.sh 3.5 KB

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