make-lib.sh 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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
  42. LINK= # No need to rebuild service program yet.
  43. MODULES=
  44. # Get source list.
  45. sed -e ':begin' \
  46. -e '/\\$/{' \
  47. -e 's/\\$/ /' \
  48. -e 'N' \
  49. -e 'bbegin' \
  50. -e '}' \
  51. -e 's/\n//g' \
  52. -e 's/[[:space:]]*$//' \
  53. -e 's/^\([A-Za-z][A-Za-z0-9_]*\)[[:space:]]*=[[:space:]]*\(.*\)/\1="\2"/' \
  54. -e 's/\$(\([A-Za-z][A-Za-z0-9_]*\))/${\1}/g' \
  55. < Makefile.inc > tmpscript.sh
  56. . ./tmpscript.sh
  57. # Compile the sources into modules.
  58. INCLUDES="'`pwd`'"
  59. # Create a small C program to check ccsidcurl.c is up to date
  60. if action_needed "${LIBIFSNAME}/CHKSTRINGS.PGM" "${SCRIPTDIR}/chkstrings.c"
  61. then CMD="CRTBNDC PGM(${TARGETLIB}/CHKSTRINGS)"
  62. CMD="${CMD} SRCSTMF('${SCRIPTDIR}/chkstrings.c')"
  63. CMD="${CMD} INCDIR('${TOPDIR}/include/curl' '${TOPDIR}/include'"
  64. CMD="${CMD} '${SRCDIR}' ${INCLUDES})"
  65. CMD="${CMD} TGTCCSID(${TGTCCSID})"
  66. if CLcommand -i "${CMD}"
  67. then if "${LIBIFSNAME}/CHKSTRINGS.PGM"
  68. then :
  69. else echo "ERROR: CHKSTRINGS failed!"
  70. exit 2
  71. fi
  72. else echo "ERROR: Failed to build CHKSTRINGS *PGM object!"
  73. exit 2
  74. fi
  75. fi
  76. make_module OS400SYS "${SCRIPTDIR}/os400sys.c"
  77. make_module CCSIDCURL "${SCRIPTDIR}/ccsidcurl.c"
  78. for SRC in ${CSOURCES}
  79. do MODULE=`db2_name "${SRC}"`
  80. make_module "${MODULE}" "${SRC}"
  81. done
  82. # If needed, (re)create the static binding directory.
  83. if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
  84. then LINK=YES
  85. fi
  86. if [ "${LINK}" ]
  87. then rm -rf "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
  88. CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${STATBNDDIR})"
  89. CMD="${CMD} TEXT('LibCurl API static binding directory')"
  90. CLcommand "${CMD}"
  91. for MODULE in ${MODULES}
  92. do CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})"
  93. CMD="${CMD} OBJ((${TARGETLIB}/${MODULE} *MODULE))"
  94. CLcommand "${CMD}"
  95. done
  96. fi
  97. # The exportation file for service program creation must be in a DB2
  98. # source file, so make sure it exists.
  99. if action_needed "${LIBIFSNAME}/TOOLS.FILE"
  100. then CMD="CRTSRCPF FILE(${TARGETLIB}/TOOLS) RCDLEN(112)"
  101. CMD="${CMD} TEXT('curl: build tools')"
  102. CLcommand "${CMD}"
  103. fi
  104. # Gather the list of symbols to export.
  105. # First use awk to pull all CURL_EXTERN function prototypes from
  106. # the header files, pass through to sed to strip CURL_DEPRECATED(..)
  107. # then back to awk to pull the string immediately to the left of a
  108. # bracket stripping any spaces or *'s.
  109. EXPORTS=`awk '/^CURL_EXTERN/,/;/' \
  110. "${TOPDIR}"/include/curl/*.h \
  111. "${SCRIPTDIR}/ccsidcurl.h" |
  112. sed 's| CURL_DEPRECATED(.*)||g' |
  113. awk '{br=index($0,"("); \
  114. if (br) { \
  115. for(c=br-1; ;c--) { \
  116. if (c==1) { \
  117. print substr($0,c,br-1); break \
  118. } else if (match(substr($0, c, br-c), "[ *]") != 0) { \
  119. print substr($0, c+1, br-c-1); break \
  120. } \
  121. } \
  122. } \
  123. }'`
  124. # Create the service program exportation file in DB2 member if needed.
  125. BSF="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR"
  126. if action_needed "${BSF}" Makefile.am
  127. then LINK=YES
  128. fi
  129. if [ "${LINK}" ]
  130. then echo " STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('LIBCURL_${SONAME}')" \
  131. > "${BSF}"
  132. for EXPORT in ${EXPORTS}
  133. do echo ' EXPORT SYMBOL("'"${EXPORT}"'")' >> "${BSF}"
  134. done
  135. echo ' ENDPGMEXP' >> "${BSF}"
  136. fi
  137. # Build the service program if needed.
  138. if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM"
  139. then LINK=YES
  140. fi
  141. if [ "${LINK}" ]
  142. then CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})"
  143. CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(BNDSRC)"
  144. CMD="${CMD} MODULE(${TARGETLIB}/OS400)"
  145. CMD="${CMD} BNDDIR(${TARGETLIB}/${STATBNDDIR}"
  146. if [ "${WITH_ZLIB}" != 0 ]
  147. then CMD="${CMD} ${ZLIB_LIB}/${ZLIB_BNDDIR}"
  148. liblist -a "${ZLIB_LIB}"
  149. fi
  150. if [ "${WITH_LIBSSH2}" != 0 ]
  151. then CMD="${CMD} ${LIBSSH2_LIB}/${LIBSSH2_BNDDIR}"
  152. liblist -a "${LIBSSH2_LIB}"
  153. fi
  154. CMD="${CMD})"
  155. CMD="${CMD} BNDSRVPGM(QADRTTS QGLDCLNT QGLDBRDR)"
  156. CMD="${CMD} TEXT('curl API library')"
  157. CMD="${CMD} TGTRLS(${TGTRLS})"
  158. CLcommand "${CMD}"
  159. LINK=YES
  160. fi
  161. # If needed, (re)create the dynamic binding directory.
  162. if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
  163. then LINK=YES
  164. fi
  165. if [ "${LINK}" ]
  166. then rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
  167. CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
  168. CMD="${CMD} TEXT('LibCurl API dynamic binding directory')"
  169. CLcommand "${CMD}"
  170. CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
  171. CMD="${CMD} OBJ((*LIBL/${SRVPGM} *SRVPGM))"
  172. CLcommand "${CMD}"
  173. fi