make-lib.sh 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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"
  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. echo '#pragma comment(user, "libcurl version '"${LIBCURL_VERSION}"'")' > os400.c
  38. echo '#pragma comment(user, __DATE__)' >> os400.c
  39. echo '#pragma comment(user, __TIME__)' >> os400.c
  40. echo '#pragma comment(copyright, "Copyright (C) Daniel Stenberg et al. OS/400 version by P. Monnerat")' >> os400.c
  41. make_module OS400 os400.c BUILDING_LIBCURL
  42. LINK= # No need to rebuild service program yet.
  43. MODULES=
  44. # Get source list (CSOURCES variable).
  45. get_make_vars Makefile.inc
  46. # Compile the sources into modules.
  47. INCLUDES="'`pwd`'"
  48. make_module OS400SYS "${SCRIPTDIR}/os400sys.c" BUILDING_LIBCURL
  49. make_module CCSIDCURL "${SCRIPTDIR}/ccsidcurl.c" BUILDING_LIBCURL
  50. for SRC in ${CSOURCES}
  51. do MODULE=`db2_name "${SRC}"`
  52. make_module "${MODULE}" "${SRC}" BUILDING_LIBCURL
  53. done
  54. # If needed, (re)create the static binding directory.
  55. if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
  56. then LINK=YES
  57. fi
  58. if [ "${LINK}" ]
  59. then rm -rf "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
  60. CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${STATBNDDIR})"
  61. CMD="${CMD} TEXT('LibCurl API static binding directory')"
  62. CLcommand "${CMD}"
  63. for MODULE in ${MODULES}
  64. do CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})"
  65. CMD="${CMD} OBJ((${TARGETLIB}/${MODULE} *MODULE))"
  66. CLcommand "${CMD}"
  67. done
  68. fi
  69. # The exportation file for service program creation must be in a DB2
  70. # source file, so make sure it exists.
  71. if action_needed "${LIBIFSNAME}/TOOLS.FILE"
  72. then CMD="CRTSRCPF FILE(${TARGETLIB}/TOOLS) RCDLEN(112)"
  73. CMD="${CMD} TEXT('curl: build tools')"
  74. CLcommand "${CMD}"
  75. fi
  76. # Gather the list of symbols to export.
  77. # First use awk to pull all CURL_EXTERN function prototypes from
  78. # the header files, pass through to sed to strip CURL_DEPRECATED(..)
  79. # then back to awk to pull the string immediately to the left of a
  80. # bracket stripping any spaces or *'s.
  81. EXPORTS=`awk '/^CURL_EXTERN/,/;/' \
  82. "${TOPDIR}"/include/curl/*.h \
  83. "${SCRIPTDIR}/ccsidcurl.h" |
  84. sed 's| CURL_DEPRECATED(.*)||g' |
  85. awk '{br=index($0,"("); \
  86. if (br) { \
  87. for(c=br-1; ;c--) { \
  88. if (c==1) { \
  89. print substr($0,c,br-1); break \
  90. } else if (match(substr($0, c, br-c), "[ *]") != 0) { \
  91. print substr($0, c+1, br-c-1); break \
  92. } \
  93. } \
  94. } \
  95. }'`
  96. # Create the service program exportation file in DB2 member if needed.
  97. BSF="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR"
  98. if action_needed "${BSF}" Makefile.am
  99. then LINK=YES
  100. fi
  101. if [ "${LINK}" ]
  102. then echo " STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('LIBCURL_${SONAME}')" \
  103. > "${BSF}"
  104. for EXPORT in ${EXPORTS}
  105. do echo ' EXPORT SYMBOL("'"${EXPORT}"'")' >> "${BSF}"
  106. done
  107. echo ' ENDPGMEXP' >> "${BSF}"
  108. fi
  109. # Build the service program if needed.
  110. if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM"
  111. then LINK=YES
  112. fi
  113. if [ "${LINK}" ]
  114. then CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})"
  115. CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(BNDSRC)"
  116. CMD="${CMD} MODULE(${TARGETLIB}/OS400)"
  117. CMD="${CMD} BNDDIR(${TARGETLIB}/${STATBNDDIR}"
  118. if [ "${WITH_ZLIB}" != 0 ]
  119. then CMD="${CMD} ${ZLIB_LIB}/${ZLIB_BNDDIR}"
  120. liblist -a "${ZLIB_LIB}"
  121. fi
  122. if [ "${WITH_LIBSSH2}" != 0 ]
  123. then CMD="${CMD} ${LIBSSH2_LIB}/${LIBSSH2_BNDDIR}"
  124. liblist -a "${LIBSSH2_LIB}"
  125. fi
  126. CMD="${CMD})"
  127. CMD="${CMD} BNDSRVPGM(QADRTTS QGLDCLNT QGLDBRDR)"
  128. CMD="${CMD} TEXT('curl API library')"
  129. CMD="${CMD} TGTRLS(${TGTRLS})"
  130. CLcommand "${CMD}"
  131. LINK=YES
  132. fi
  133. # If needed, (re)create the dynamic binding directory.
  134. if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
  135. then LINK=YES
  136. fi
  137. if [ "${LINK}" ]
  138. then rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
  139. CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
  140. CMD="${CMD} TEXT('LibCurl API dynamic binding directory')"
  141. CLcommand "${CMD}"
  142. CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
  143. CMD="${CMD} OBJ((*LIBL/${SRVPGM} *SRVPGM))"
  144. CLcommand "${CMD}"
  145. fi