make-lib.sh 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. # libcurl compilation script for the OS/400.
  27. #
  28. SCRIPTDIR=$(dirname "${0}")
  29. . "${SCRIPTDIR}/initscript.sh"
  30. cd "${TOPDIR}/lib" || exit 1
  31. # Need to have IFS access to the mih/cipher header file.
  32. if action_needed cipher.mih '/QSYS.LIB/QSYSINC.LIB/MIH.FILE/CIPHER.MBR'
  33. then rm -f cipher.mih
  34. ln -s '/QSYS.LIB/QSYSINC.LIB/MIH.FILE/CIPHER.MBR' cipher.mih
  35. fi
  36. # Create and compile the identification source file.
  37. {
  38. echo '#pragma comment(user, "libcurl version '"${LIBCURL_VERSION}"'")'
  39. echo '#pragma comment(user, __DATE__)'
  40. echo '#pragma comment(user, __TIME__)'
  41. echo '#pragma comment(copyright, "Copyright (C) Daniel Stenberg et al. OS/400 version by P. Monnerat")'
  42. } > os400.c
  43. make_module OS400 os400.c BUILDING_LIBCURL
  44. LINK= # No need to rebuild service program yet.
  45. MODULES=
  46. # Get source list (CSOURCES variable).
  47. get_make_vars Makefile.inc
  48. # Compile the sources into modules.
  49. # shellcheck disable=SC2034
  50. INCLUDES="'$(pwd)'"
  51. make_module OS400SYS "${SCRIPTDIR}/os400sys.c" BUILDING_LIBCURL
  52. make_module CCSIDCURL "${SCRIPTDIR}/ccsidcurl.c" BUILDING_LIBCURL
  53. for SRC in ${CSOURCES}
  54. do MODULE=$(db2_name "${SRC}")
  55. make_module "${MODULE}" "${SRC}" BUILDING_LIBCURL
  56. done
  57. # If needed, (re)create the static binding directory.
  58. if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
  59. then LINK=YES
  60. fi
  61. if [ -n "${LINK}" ]
  62. then rm -rf "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
  63. CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${STATBNDDIR})"
  64. CMD="${CMD} TEXT('LibCurl API static binding directory')"
  65. CLcommand "${CMD}"
  66. for MODULE in ${MODULES}
  67. do CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})"
  68. CMD="${CMD} OBJ((${TARGETLIB}/${MODULE} *MODULE))"
  69. CLcommand "${CMD}"
  70. done
  71. fi
  72. # The exportation file for service program creation must be in a DB2
  73. # source file, so make sure it exists.
  74. if action_needed "${LIBIFSNAME}/TOOLS.FILE"
  75. then CMD="CRTSRCPF FILE(${TARGETLIB}/TOOLS) RCDLEN(112)"
  76. CMD="${CMD} TEXT('curl: build tools')"
  77. CLcommand "${CMD}"
  78. fi
  79. # Gather the list of symbols to export.
  80. # - Unfold lines from the header files so that they contain a semicolon.
  81. # - Keep only CURL_EXTERN definitions.
  82. # - Remove the CURL_DEPRECATED and CURL_TEMP_PRINTF macro calls.
  83. # - Drop the parenthesized function arguments and what follows.
  84. # - Keep the trailing function name only.
  85. EXPORTS=$(cat "${TOPDIR}"/include/curl/*.h "${SCRIPTDIR}/ccsidcurl.h" |
  86. sed -e 'H;s/.*//;x;s/\n//;s/.*/& /' \
  87. -e '/^CURL_EXTERN[[:space:]]/!d' \
  88. -e '/\;/!{x;d;}' \
  89. -e 's/ CURL_DEPRECATED([^)]*)//g' \
  90. -e 's/ CURL_TEMP_PRINTF([^)]*)//g' \
  91. -e 's/[[:space:]]*(.*$//' \
  92. -e 's/^.*[^A-Za-z0-9_]\([A-Za-z0-9_]*\)$/\1/')
  93. # Create the service program exportation file in DB2 member if needed.
  94. BSF="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR"
  95. if action_needed "${BSF}" Makefile.am
  96. then LINK=YES
  97. fi
  98. if [ -n "${LINK}" ]
  99. then echo " STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('LIBCURL_${SONAME}')" \
  100. > "${BSF}"
  101. for EXPORT in ${EXPORTS}
  102. do echo ' EXPORT SYMBOL("'"${EXPORT}"'")' >> "${BSF}"
  103. done
  104. echo ' ENDPGMEXP' >> "${BSF}"
  105. fi
  106. # Build the service program if needed.
  107. if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM"
  108. then LINK=YES
  109. fi
  110. if [ -n "${LINK}" ]
  111. then CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})"
  112. CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(BNDSRC)"
  113. CMD="${CMD} MODULE(${TARGETLIB}/OS400)"
  114. CMD="${CMD} BNDDIR(${TARGETLIB}/${STATBNDDIR}"
  115. if [ "${WITH_ZLIB}" != 0 ]
  116. then CMD="${CMD} ${ZLIB_LIB}/${ZLIB_BNDDIR}"
  117. liblist -a "${ZLIB_LIB}"
  118. fi
  119. if [ "${WITH_LIBSSH2}" != 0 ]
  120. then CMD="${CMD} ${LIBSSH2_LIB}/${LIBSSH2_BNDDIR}"
  121. liblist -a "${LIBSSH2_LIB}"
  122. fi
  123. CMD="${CMD})"
  124. CMD="${CMD} BNDSRVPGM(QADRTTS QGLDCLNT QGLDBRDR)"
  125. CMD="${CMD} TEXT('curl API library')"
  126. CMD="${CMD} TGTRLS(${TGTRLS})"
  127. CLcommand "${CMD}"
  128. LINK=YES
  129. fi
  130. # If needed, (re)create the dynamic binding directory.
  131. if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
  132. then LINK=YES
  133. fi
  134. if [ -n "${LINK}" ]
  135. then rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
  136. CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
  137. CMD="${CMD} TEXT('LibCurl API dynamic binding directory')"
  138. CLcommand "${CMD}"
  139. CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
  140. CMD="${CMD} OBJ((*LIBL/${SRVPGM} *SRVPGM))"
  141. CLcommand "${CMD}"
  142. fi