make-lib.sh 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. #!/bin/sh
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 1998 - 2022, 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) 1998-2016 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"
  61. then
  62. CMD="CRTBNDC PGM(${TARGETLIB}/CHKSTRINGS) SRCSTMF('${SCRIPTDIR}/chkstrings.c')"
  63. CMD="${CMD} INCDIR('${TOPDIR}/include/curl' '${TOPDIR}/include' '${SRCDIR}' ${INCLUDES})"
  64. system -i "${CMD}"
  65. if [ $? -ne 0 ]
  66. then
  67. echo "ERROR: Failed to build CHKSTRINGS *PGM object!"
  68. exit 2
  69. else
  70. ${LIBIFSNAME}/CHKSTRINGS.PGM
  71. if [ $? -ne 0 ]
  72. then
  73. echo "ERROR: CHKSTRINGS failed!"
  74. exit 2
  75. fi
  76. fi
  77. fi
  78. make_module OS400SYS "${SCRIPTDIR}/os400sys.c"
  79. make_module CCSIDCURL "${SCRIPTDIR}/ccsidcurl.c"
  80. for SRC in ${CSOURCES}
  81. do MODULE=`db2_name "${SRC}"`
  82. make_module "${MODULE}" "${SRC}"
  83. done
  84. # If needed, (re)create the static binding directory.
  85. if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
  86. then LINK=YES
  87. fi
  88. if [ "${LINK}" ]
  89. then rm -rf "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
  90. CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${STATBNDDIR})"
  91. CMD="${CMD} TEXT('LibCurl API static binding directory')"
  92. system "${CMD}"
  93. for MODULE in ${MODULES}
  94. do CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})"
  95. CMD="${CMD} OBJ((${TARGETLIB}/${MODULE} *MODULE))"
  96. system "${CMD}"
  97. done
  98. fi
  99. # The exportation file for service program creation must be in a DB2
  100. # source file, so make sure it exists.
  101. if action_needed "${LIBIFSNAME}/TOOLS.FILE"
  102. then CMD="CRTSRCPF FILE(${TARGETLIB}/TOOLS) RCDLEN(112)"
  103. CMD="${CMD} TEXT('curl: build tools')"
  104. system "${CMD}"
  105. fi
  106. # Gather the list of symbols to export.
  107. EXPORTS=`grep '^CURL_EXTERN[[:space:]]' \
  108. "${TOPDIR}"/include/curl/*.h \
  109. "${SCRIPTDIR}/ccsidcurl.h" |
  110. sed -e 's/^.*CURL_EXTERN[[:space:]]\(.*\)(.*$/\1/' \
  111. -e 's/[[:space:]]*$//' \
  112. -e 's/^.*[[:space:]][[:space:]]*//' \
  113. -e 's/^\*//' \
  114. -e 's/(\(.*\))/\1/'`
  115. # Create the service program exportation file in DB2 member if needed.
  116. BSF="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR"
  117. if action_needed "${BSF}" Makefile.am
  118. then LINK=YES
  119. fi
  120. if [ "${LINK}" ]
  121. then echo " STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('LIBCURL_${SONAME}')" \
  122. > "${BSF}"
  123. for EXPORT in ${EXPORTS}
  124. do echo ' EXPORT SYMBOL("'"${EXPORT}"'")' >> "${BSF}"
  125. done
  126. echo ' ENDPGMEXP' >> "${BSF}"
  127. fi
  128. # Build the service program if needed.
  129. if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM"
  130. then LINK=YES
  131. fi
  132. if [ "${LINK}" ]
  133. then CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})"
  134. CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(BNDSRC)"
  135. CMD="${CMD} MODULE(${TARGETLIB}/OS400)"
  136. CMD="${CMD} BNDDIR(${TARGETLIB}/${STATBNDDIR}"
  137. if [ "${WITH_ZLIB}" != 0 ]
  138. then CMD="${CMD} ${ZLIB_LIB}/${ZLIB_BNDDIR}"
  139. liblist -a "${ZLIB_LIB}"
  140. fi
  141. if [ "${WITH_LIBSSH2}" != 0 ]
  142. then CMD="${CMD} ${LIBSSH2_LIB}/${LIBSSH2_BNDDIR}"
  143. liblist -a "${LIBSSH2_LIB}"
  144. fi
  145. CMD="${CMD})"
  146. CMD="${CMD} BNDSRVPGM(QADRTTS QGLDCLNT QGLDBRDR)"
  147. CMD="${CMD} TEXT('curl API library')"
  148. CMD="${CMD} TGTRLS(${TGTRLS})"
  149. system "${CMD}"
  150. LINK=YES
  151. fi
  152. # If needed, (re)create the dynamic binding directory.
  153. if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
  154. then LINK=YES
  155. fi
  156. if [ "${LINK}" ]
  157. then rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
  158. CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
  159. CMD="${CMD} TEXT('LibCurl API dynamic binding directory')"
  160. system "${CMD}"
  161. CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
  162. CMD="${CMD} OBJ((*LIBL/${SRVPGM} *SRVPGM))"
  163. system "${CMD}"
  164. fi
  165. # Rebuild the formdata test if needed.
  166. if [ "${TEST_FORMDATA}" ]
  167. then MODULES=
  168. make_module TFORMDATA formdata.c "'_FORM_DEBUG' 'CURLDEBUG'"
  169. make_module TSTREQUAL strequal.c "'_FORM_DEBUG' 'CURLDEBUG'"
  170. make_module TMEMDEBUG memdebug.c "'_FORM_DEBUG' 'CURLDEBUG'"
  171. make_module TMPRINTF mprintf.c "'_FORM_DEBUG' 'CURLDEBUG'"
  172. make_module TSTRERROR strerror.c "'_FORM_DEBUG' 'CURLDEBUG'"
  173. # The following modules should not be needed (see comment in
  174. # formdata.c. However, there are some unsatisfied
  175. # external references leading in the following
  176. # modules to be (recursively) needed.
  177. MODULES="${MODULES} EASY STRDUP SSLGEN GSKIT HOSTIP HOSTIP4 HOSTIP6"
  178. MODULES="${MODULES} URL HASH TRANSFER GETINFO COOKIE SENDF SELECT"
  179. MODULES="${MODULES} INET_NTOP SHARE HOSTTHRE MULTI LLIST FTP HTTP"
  180. MODULES="${MODULES} HTTP_DIGES HTTP_CHUNK HTTP_NEGOT TIMEVAL HOSTSYN"
  181. MODULES="${MODULES} CONNECT SOCKS PROGRESS ESCAPE INET_PTON GETENV"
  182. MODULES="${MODULES} DICT LDAP TELNET FILE TFTP NETRC PARSEDATE"
  183. MODULES="${MODULES} SPEEDCHECK SPLAY BASE64 SECURITY IF2IP MD5"
  184. MODULES="${MODULES} KRB5 OS400SYS"
  185. PGMIFSNAME="${LIBIFSNAME}/TFORMDATA.PGM"
  186. if action_needed "${PGMIFSNAME}"
  187. then LINK=YES
  188. fi
  189. if [ "${LINK}" ]
  190. then CMD="CRTPGM PGM(${TARGETLIB}/TFORMDATA)"
  191. CMD="${CMD} ENTMOD(QADRT/QADRTMAIN2)"
  192. CMD="${CMD} MODULE("
  193. for MODULE in ${MODULES}
  194. do CMD="${CMD} ${TARGETLIB}/${MODULE}"
  195. done
  196. CMD="${CMD} ) BNDSRVPGM(QADRTTS)"
  197. CMD="${CMD} TGTRLS(${TGTRLS})"
  198. system "${CMD}"
  199. fi
  200. fi