2
0

makefile.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. # curl compilation script for the OS/400.
  27. #
  28. #
  29. # This is a shell script since make is not a standard component of OS/400.
  30. SCRIPTDIR=$(dirname "${0}")
  31. . "${SCRIPTDIR}/initscript.sh"
  32. cd "${TOPDIR}" || exit 1
  33. # Make sure all files are UTF8-encoded.
  34. # shellcheck disable=SC2038
  35. find "${TOPDIR}" -type f -print | xargs ls -S | while read -r CCSID FILE
  36. do if [ "${CCSID}" != 1208 ]
  37. then CMD="CPY OBJ('${FILE}') TOOBJ('${FILE}') FROMCCSID(*OBJ)"
  38. CMD="${CMD} TOCCSID(1208) DTAFMT(*TEXT) REPLACE(*YES)"
  39. (CLcommand "${CMD}")
  40. fi
  41. done
  42. # Create the OS/400 library if it does not exist.
  43. if action_needed "${LIBIFSNAME}"
  44. then CMD="CRTLIB LIB(${TARGETLIB}) TEXT('curl: multiprotocol support API')"
  45. CLcommand "${CMD}"
  46. fi
  47. # Create the DOCS source file if it does not exist.
  48. if action_needed "${LIBIFSNAME}/DOCS.FILE"
  49. then CMD="CRTSRCPF FILE(${TARGETLIB}/DOCS) RCDLEN(240)"
  50. CMD="${CMD} CCSID(${TGTCCSID}) TEXT('Documentation texts')"
  51. CLcommand "${CMD}"
  52. fi
  53. # Copy some documentation files if needed.
  54. for TEXT in "${TOPDIR}/COPYING" "${SCRIPTDIR}/README.OS400" \
  55. "${TOPDIR}/CHANGES.md" "${TOPDIR}/docs/THANKS" "${TOPDIR}/docs/FAQ" \
  56. "${TOPDIR}/docs/FEATURES" "${TOPDIR}/docs/SSLCERTS.md" \
  57. "${TOPDIR}/docs/RESOURCES" "${TOPDIR}/docs/VERSIONS.md" \
  58. "${TOPDIR}/docs/HISTORY.md"
  59. do MEMBER="$(basename "${TEXT}" .OS400)"
  60. MEMBER="$(basename "${MEMBER}" .md)"
  61. MEMBER="${LIBIFSNAME}/DOCS.FILE/$(db2_name "${MEMBER}").MBR"
  62. [ -e "${TEXT}" ] || continue
  63. if action_needed "${MEMBER}" "${TEXT}"
  64. then CMD="CPY OBJ('${TEXT}') TOOBJ('${MEMBER}') TOCCSID(${TGTCCSID})"
  65. CMD="${CMD} DTAFMT(*TEXT) REPLACE(*YES)"
  66. CLcommand "${CMD}"
  67. fi
  68. done
  69. # Create the RPGXAMPLES source file if it does not exist.
  70. if action_needed "${LIBIFSNAME}/RPGXAMPLES.FILE"
  71. then CMD="CRTSRCPF FILE(${TARGETLIB}/RPGXAMPLES) RCDLEN(240)"
  72. CMD="${CMD} CCSID(${TGTCCSID}) TEXT('ILE/RPG examples')"
  73. CLcommand "${CMD}"
  74. fi
  75. # Copy RPG examples if needed.
  76. for EXAMPLE in "${SCRIPTDIR}/rpg-examples"/*
  77. do MEMBER="$(basename "${EXAMPLE}")"
  78. IFSMEMBER="${LIBIFSNAME}/RPGXAMPLES.FILE/$(db2_name "${MEMBER}").MBR"
  79. [ -e "${EXAMPLE}" ] || continue
  80. if action_needed "${IFSMEMBER}" "${EXAMPLE}"
  81. then CMD="CPY OBJ('${EXAMPLE}') TOOBJ('${IFSMEMBER}')"
  82. CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
  83. CLcommand "${CMD}"
  84. MBRTEXT=$(sed -e '1!d;/^ \*/!d;s/^ *\* *//' \
  85. -e 's/ *$//;s/'"'"'/&&/g' < "${EXAMPLE}")
  86. CMD="CHGPFM FILE(${TARGETLIB}/RPGXAMPLES) MBR(${MEMBER})"
  87. CMD="${CMD} SRCTYPE(RPGLE) TEXT('${MBRTEXT}')"
  88. CLcommand "${CMD}"
  89. fi
  90. done
  91. # Compile the QADRTMAIN2 replacement module.
  92. if action_needed "${LIBIFSNAME}/CURLMAIN.MODULE" "${SCRIPTDIR}/curlmain.c"
  93. then CMD="CRTCMOD MODULE(${TARGETLIB}/CURLMAIN)"
  94. CMD="${CMD} SRCSTMF('${SCRIPTDIR}/curlmain.c')"
  95. CMD="${CMD} SYSIFCOPT(*IFS64IO) LOCALETYPE(*LOCALE) FLAG(10)"
  96. CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
  97. CMD="${CMD} OUTPUT(${OUTPUT})"
  98. CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
  99. CMD="${CMD} DBGVIEW(${DEBUG})"
  100. CLcommand "${CMD}"
  101. fi
  102. # Build in each directory.
  103. # for SUBDIR in include lib docs src tests
  104. for SUBDIR in include lib docs src
  105. do "${SCRIPTDIR}/make-${SUBDIR}.sh"
  106. done