2
0

make-lib.sh 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. #!/bin/sh
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 1998 - 2020, 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. ###########################################################################
  23. #
  24. # libcurl compilation script for the OS/400.
  25. #
  26. SCRIPTDIR=`dirname "${0}"`
  27. . "${SCRIPTDIR}/initscript.sh"
  28. cd "${TOPDIR}/lib"
  29. # Need to have IFS access to the mih/cipher header file.
  30. if action_needed cipher.mih '/QSYS.LIB/QSYSINC.LIB/MIH.FILE/CIPHER.MBR'
  31. then rm -f cipher.mih
  32. ln -s '/QSYS.LIB/QSYSINC.LIB/MIH.FILE/CIPHER.MBR' cipher.mih
  33. fi
  34. # Create and compile the identification source file.
  35. echo '#pragma comment(user, "libcurl version '"${LIBCURL_VERSION}"'")' > os400.c
  36. echo '#pragma comment(user, __DATE__)' >> os400.c
  37. echo '#pragma comment(user, __TIME__)' >> os400.c
  38. echo '#pragma comment(copyright, "Copyright (C) 1998-2016 Daniel Stenberg et al. OS/400 version by P. Monnerat")' >> os400.c
  39. make_module OS400 os400.c
  40. LINK= # No need to rebuild service program yet.
  41. MODULES=
  42. # Get source list.
  43. sed -e ':begin' \
  44. -e '/\\$/{' \
  45. -e 's/\\$/ /' \
  46. -e 'N' \
  47. -e 'bbegin' \
  48. -e '}' \
  49. -e 's/\n//g' \
  50. -e 's/[[:space:]]*$//' \
  51. -e 's/^\([A-Za-z][A-Za-z0-9_]*\)[[:space:]]*=[[:space:]]*\(.*\)/\1="\2"/' \
  52. -e 's/\$(\([A-Za-z][A-Za-z0-9_]*\))/${\1}/g' \
  53. < Makefile.inc > tmpscript.sh
  54. . ./tmpscript.sh
  55. # Compile the sources into modules.
  56. INCLUDES="'`pwd`'"
  57. # Create a small C program to check ccsidcurl.c is up to date
  58. if action_needed "${LIBIFSNAME}/CHKSTRINGS.PGM"
  59. then
  60. CMD="CRTBNDC PGM(${TARGETLIB}/CHKSTRINGS) SRCSTMF('${SCRIPTDIR}/chkstrings.c')"
  61. CMD="${CMD} INCDIR('${TOPDIR}/include/curl' '${TOPDIR}/include' '${SRCDIR}' ${INCLUDES})"
  62. system -i "${CMD}"
  63. if [ $? -ne 0 ]
  64. then
  65. echo "ERROR: Failed to build CHKSTRINGS *PGM object!"
  66. exit 2
  67. else
  68. ${LIBIFSNAME}/CHKSTRINGS.PGM
  69. if [ $? -ne 0 ]
  70. then
  71. echo "ERROR: CHKSTRINGS failed!"
  72. exit 2
  73. fi
  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. system "${CMD}"
  91. for MODULE in ${MODULES}
  92. do CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})"
  93. CMD="${CMD} OBJ((${TARGETLIB}/${MODULE} *MODULE))"
  94. system "${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. system "${CMD}"
  103. fi
  104. # Gather the list of symbols to export.
  105. EXPORTS=`grep '^CURL_EXTERN[[:space:]]' \
  106. "${TOPDIR}"/include/curl/*.h \
  107. "${SCRIPTDIR}/ccsidcurl.h" |
  108. sed -e 's/^.*CURL_EXTERN[[:space:]]\(.*\)(.*$/\1/' \
  109. -e 's/[[:space:]]*$//' \
  110. -e 's/^.*[[:space:]][[:space:]]*//' \
  111. -e 's/^\*//' \
  112. -e 's/(\(.*\))/\1/'`
  113. # Create the service program exportation file in DB2 member if needed.
  114. BSF="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR"
  115. if action_needed "${BSF}" Makefile.am
  116. then LINK=YES
  117. fi
  118. if [ "${LINK}" ]
  119. then echo " STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('LIBCURL_${SONAME}')" \
  120. > "${BSF}"
  121. for EXPORT in ${EXPORTS}
  122. do echo ' EXPORT SYMBOL("'"${EXPORT}"'")' >> "${BSF}"
  123. done
  124. echo ' ENDPGMEXP' >> "${BSF}"
  125. fi
  126. # Build the service program if needed.
  127. if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM"
  128. then LINK=YES
  129. fi
  130. if [ "${LINK}" ]
  131. then CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})"
  132. CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(BNDSRC)"
  133. CMD="${CMD} MODULE(${TARGETLIB}/OS400)"
  134. CMD="${CMD} BNDDIR(${TARGETLIB}/${STATBNDDIR}"
  135. if [ "${WITH_ZLIB}" != 0 ]
  136. then CMD="${CMD} ${ZLIB_LIB}/${ZLIB_BNDDIR}"
  137. liblist -a "${ZLIB_LIB}"
  138. fi
  139. if [ "${WITH_LIBSSH2}" != 0 ]
  140. then CMD="${CMD} ${LIBSSH2_LIB}/${LIBSSH2_BNDDIR}"
  141. liblist -a "${LIBSSH2_LIB}"
  142. fi
  143. CMD="${CMD})"
  144. CMD="${CMD} BNDSRVPGM(QADRTTS QGLDCLNT QGLDBRDR)"
  145. CMD="${CMD} TEXT('curl API library')"
  146. CMD="${CMD} TGTRLS(${TGTRLS})"
  147. system "${CMD}"
  148. LINK=YES
  149. fi
  150. # If needed, (re)create the dynamic binding directory.
  151. if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
  152. then LINK=YES
  153. fi
  154. if [ "${LINK}" ]
  155. then rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
  156. CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
  157. CMD="${CMD} TEXT('LibCurl API dynamic binding directory')"
  158. system "${CMD}"
  159. CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
  160. CMD="${CMD} OBJ((*LIBL/${SRVPGM} *SRVPGM))"
  161. system "${CMD}"
  162. fi
  163. # Rebuild the formdata test if needed.
  164. if [ "${TEST_FORMDATA}" ]
  165. then MODULES=
  166. make_module TFORMDATA formdata.c "'_FORM_DEBUG' 'CURLDEBUG'"
  167. make_module TSTREQUAL strequal.c "'_FORM_DEBUG' 'CURLDEBUG'"
  168. make_module TMEMDEBUG memdebug.c "'_FORM_DEBUG' 'CURLDEBUG'"
  169. make_module TMPRINTF mprintf.c "'_FORM_DEBUG' 'CURLDEBUG'"
  170. make_module TSTRERROR strerror.c "'_FORM_DEBUG' 'CURLDEBUG'"
  171. # The following modules should not be needed (see comment in
  172. # formdata.c. However, there are some unsatisfied
  173. # external references leading in the following
  174. # modules to be (recursively) needed.
  175. MODULES="${MODULES} EASY STRDUP SSLGEN GSKIT HOSTIP HOSTIP4 HOSTIP6"
  176. MODULES="${MODULES} URL HASH TRANSFER GETINFO COOKIE SENDF SELECT"
  177. MODULES="${MODULES} INET_NTOP SHARE HOSTTHRE MULTI LLIST FTP HTTP"
  178. MODULES="${MODULES} HTTP_DIGES HTTP_CHUNK HTTP_NEGOT TIMEVAL HOSTSYN"
  179. MODULES="${MODULES} CONNECT SOCKS PROGRESS ESCAPE INET_PTON GETENV"
  180. MODULES="${MODULES} DICT LDAP TELNET FILE TFTP NETRC PARSEDATE"
  181. MODULES="${MODULES} SPEEDCHECK SPLAY BASE64 SECURITY IF2IP MD5"
  182. MODULES="${MODULES} KRB5 OS400SYS"
  183. PGMIFSNAME="${LIBIFSNAME}/TFORMDATA.PGM"
  184. if action_needed "${PGMIFSNAME}"
  185. then LINK=YES
  186. fi
  187. if [ "${LINK}" ]
  188. then CMD="CRTPGM PGM(${TARGETLIB}/TFORMDATA)"
  189. CMD="${CMD} ENTMOD(QADRT/QADRTMAIN2)"
  190. CMD="${CMD} MODULE("
  191. for MODULE in ${MODULES}
  192. do CMD="${CMD} ${TARGETLIB}/${MODULE}"
  193. done
  194. CMD="${CMD} ) BNDSRVPGM(QADRTTS)"
  195. CMD="${CMD} TGTRLS(${TGTRLS})"
  196. system "${CMD}"
  197. fi
  198. fi