make-lib.sh 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. #!/bin/sh
  2. #
  3. # libcurl compilation script for the OS/400.
  4. #
  5. SCRIPTDIR=`dirname "${0}"`
  6. . "${SCRIPTDIR}/initscript.sh"
  7. cd "${TOPDIR}/lib"
  8. # Need to have IFS access to the mih/cipher header file.
  9. if action_needed cipher.mih '/QSYS.LIB/QSYSINC.LIB/MIH.FILE/CIPHER.MBR'
  10. then rm -f cipher.mih
  11. ln -s '/QSYS.LIB/QSYSINC.LIB/MIH.FILE/CIPHER.MBR' cipher.mih
  12. fi
  13. # Create and compile the identification source file.
  14. echo '#pragma comment(user, "libcurl version '"${LIBCURL_VERSION}"'")' > os400.c
  15. echo '#pragma comment(user, __DATE__)' >> os400.c
  16. echo '#pragma comment(user, __TIME__)' >> os400.c
  17. echo '#pragma comment(copyright, "Copyright (C) 1998-2014 Daniel Stenberg et al. OS/400 version by P. Monnerat")' >> os400.c
  18. make_module OS400 os400.c
  19. LINK= # No need to rebuild service program yet.
  20. MODULES=
  21. # Get source list.
  22. sed -e ':begin' \
  23. -e '/\\$/{' \
  24. -e 's/\\$/ /' \
  25. -e 'N' \
  26. -e 'bbegin' \
  27. -e '}' \
  28. -e 's/\n//g' \
  29. -e 's/[[:space:]]*$//' \
  30. -e 's/^\([A-Za-z][A-Za-z0-9_]*\)[[:space:]]*=[[:space:]]*\(.*\)/\1="\2"/' \
  31. -e 's/\$(\([A-Za-z][A-Za-z0-9_]*\))/${\1}/g' \
  32. < Makefile.inc > tmpscript.sh
  33. . ./tmpscript.sh
  34. # Compile the sources into modules.
  35. INCLUDES="'`pwd`'"
  36. make_module OS400SYS "${SCRIPTDIR}/os400sys.c"
  37. make_module CCSIDCURL "${SCRIPTDIR}/ccsidcurl.c"
  38. for SRC in ${CSOURCES}
  39. do MODULE=`db2_name "${SRC}"`
  40. make_module "${MODULE}" "${SRC}"
  41. done
  42. # If needed, (re)create the static binding directory.
  43. if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
  44. then LINK=YES
  45. fi
  46. if [ "${LINK}" ]
  47. then rm -rf "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
  48. CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${STATBNDDIR})"
  49. CMD="${CMD} TEXT('LibCurl API static binding directory')"
  50. system "${CMD}"
  51. for MODULE in ${MODULES}
  52. do CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})"
  53. CMD="${CMD} OBJ((${TARGETLIB}/${MODULE} *MODULE))"
  54. system "${CMD}"
  55. done
  56. fi
  57. # The exportation file for service program creation must be in a DB2
  58. # source file, so make sure it exists.
  59. if action_needed "${LIBIFSNAME}/TOOLS.FILE"
  60. then CMD="CRTSRCPF FILE(${TARGETLIB}/TOOLS) RCDLEN(112)"
  61. CMD="${CMD} TEXT('curl: build tools')"
  62. system "${CMD}"
  63. fi
  64. # Gather the list of symbols to export.
  65. EXPORTS=`grep '^CURL_EXTERN[[:space:]]' \
  66. "${TOPDIR}"/include/curl/*.h \
  67. "${SCRIPTDIR}/ccsidcurl.h" |
  68. sed -e 's/^.*CURL_EXTERN[[:space:]]\(.*\)(.*$/\1/' \
  69. -e 's/[[:space:]]*$//' \
  70. -e 's/^.*[[:space:]][[:space:]]*//' \
  71. -e 's/^\*//' \
  72. -e 's/(\(.*\))/\1/'`
  73. # Create the service program exportation file in DB2 member if needed.
  74. BSF="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR"
  75. if action_needed "${BSF}" Makefile.am
  76. then LINK=YES
  77. fi
  78. if [ "${LINK}" ]
  79. then echo " STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('LIBCURL_${SONAME}')" \
  80. > "${BSF}"
  81. for EXPORT in ${EXPORTS}
  82. do echo ' EXPORT SYMBOL("'"${EXPORT}"'")' >> "${BSF}"
  83. done
  84. echo ' ENDPGMEXP' >> "${BSF}"
  85. fi
  86. # Build the service program if needed.
  87. if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM"
  88. then LINK=YES
  89. fi
  90. if [ "${LINK}" ]
  91. then CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})"
  92. CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(BNDSRC)"
  93. CMD="${CMD} MODULE(${TARGETLIB}/OS400)"
  94. CMD="${CMD} BNDDIR(${TARGETLIB}/${STATBNDDIR}"
  95. if [ "${WITH_ZLIB}" != 0 ]
  96. then CMD="${CMD} ${ZLIB_LIB}/${ZLIB_BNDDIR}"
  97. liblist -a "${ZLIB_LIB}"
  98. fi
  99. if [ "${WITH_LIBSSH2}" != 0 ]
  100. then CMD="${CMD} ${LIBSSH2_LIB}/${LIBSSH2_BNDDIR}"
  101. liblist -a "${LIBSSH2_LIB}"
  102. fi
  103. CMD="${CMD})"
  104. CMD="${CMD} BNDSRVPGM(QADRTTS QGLDCLNT QGLDBRDR)"
  105. CMD="${CMD} TEXT('curl API library')"
  106. CMD="${CMD} TGTRLS(${TGTRLS})"
  107. system "${CMD}"
  108. LINK=YES
  109. fi
  110. # If needed, (re)create the dynamic binding directory.
  111. if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
  112. then LINK=YES
  113. fi
  114. if [ "${LINK}" ]
  115. then rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
  116. CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
  117. CMD="${CMD} TEXT('LibCurl API dynamic binding directory')"
  118. system "${CMD}"
  119. CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
  120. CMD="${CMD} OBJ((*LIBL/${SRVPGM} *SRVPGM))"
  121. system "${CMD}"
  122. fi
  123. # Rebuild the formdata test if needed.
  124. if [ "${TEST_FORMDATA}" ]
  125. then MODULES=
  126. make_module TFORMDATA formdata.c "'_FORM_DEBUG' 'CURLDEBUG'"
  127. make_module TSTREQUAL strequal.c "'_FORM_DEBUG' 'CURLDEBUG'"
  128. make_module TMEMDEBUG memdebug.c "'_FORM_DEBUG' 'CURLDEBUG'"
  129. make_module TMPRINTF mprintf.c "'_FORM_DEBUG' 'CURLDEBUG'"
  130. make_module TSTRERROR strerror.c "'_FORM_DEBUG' 'CURLDEBUG'"
  131. # The following modules should not be needed (see comment in
  132. # formdata.c. However, there are some unsatisfied
  133. # external references leading in the following
  134. # modules to be (recursively) needed.
  135. MODULES="${MODULES} EASY STRDUP SSLGEN GSKIT HOSTIP HOSTIP4 HOSTIP6"
  136. MODULES="${MODULES} URL HASH TRANSFER GETINFO COOKIE SENDF SELECT"
  137. MODULES="${MODULES} INET_NTOP SHARE HOSTTHRE MULTI LLIST FTP HTTP"
  138. MODULES="${MODULES} HTTP_DIGES HTTP_CHUNK HTTP_NEGOT TIMEVAL HOSTSYN"
  139. MODULES="${MODULES} CONNECT SOCKS PROGRESS ESCAPE INET_PTON GETENV"
  140. MODULES="${MODULES} DICT LDAP TELNET FILE TFTP NETRC PARSEDATE"
  141. MODULES="${MODULES} SPEEDCHECK SPLAY BASE64 SECURITY IF2IP MD5"
  142. MODULES="${MODULES} KRB5 OS400SYS"
  143. PGMIFSNAME="${LIBIFSNAME}/TFORMDATA.PGM"
  144. if action_needed "${PGMIFSNAME}"
  145. then LINK=YES
  146. fi
  147. if [ "${LINK}" ]
  148. then CMD="CRTPGM PGM(${TARGETLIB}/TFORMDATA)"
  149. CMD="${CMD} ENTMOD(QADRT/QADRTMAIN2)"
  150. CMD="${CMD} MODULE("
  151. for MODULE in ${MODULES}
  152. do CMD="${CMD} ${TARGETLIB}/${MODULE}"
  153. done
  154. CMD="${CMD} ) BNDSRVPGM(QADRTTS)"
  155. CMD="${CMD} TGTRLS(${TGTRLS})"
  156. system "${CMD}"
  157. fi
  158. fi