geom_gate userland utility improvements
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

209 lines
7.7 KiB

  1. #!/bin/sh
  2. #
  3. # libssh2 compilation script for the OS/400.
  4. #
  5. SCRIPTDIR=`dirname "${0}"`
  6. . "${SCRIPTDIR}/initscript.sh"
  7. cd "${TOPDIR}/src"
  8. # Function to extract external prototypes from header files.
  9. # Input: concatenated header files.
  10. # Output: external prototypes, one per (long) line.
  11. extproto()
  12. {
  13. sed -e 'x;G;s/^\n//;s/\n/ /g' \
  14. -e 's#[[:space:]]*/\*[^*]*\(\*\([^/*][^*]*\)\{0,1\}\)*\*/[[:space:]]*##g' \
  15. -e 'h' \
  16. -e '/\/\*/!{' \
  17. -e '/^#/{s/^.*[^\\]$//;h;d' \
  18. -e '}' \
  19. -e 's/[{}]/;/g;s/\\$//' \
  20. -e ':loop1' \
  21. -e '/;/{' \
  22. -e 's/^[^;]*;//;x;s/;.*//' \
  23. -e '/^[[:space:]]*LIBSSH2_API[[:space:]].*(/{' \
  24. -e 's/^[[:space:]]*LIBSSH2_API[[:space:]]*//' \
  25. -e 's/[[:space:]]*$//' \
  26. -e 's/[[:space:]][[:space:]]*/ /g' \
  27. -e 'p' \
  28. -e '}' \
  29. -e 'g;bloop1' \
  30. -e '}' \
  31. -e '}' \
  32. -n
  33. }
  34. # Need to have IFS access to the mih/modasa header file.
  35. if action_needed modasa.mih '/QSYS.LIB/QSYSINC.LIB/MIH.FILE/MODASA.MBR'
  36. then rm -f modasa.mih
  37. ln -s '/QSYS.LIB/QSYSINC.LIB/MIH.FILE/MODASA.MBR' modasa.mih
  38. fi
  39. # Create and compile the identification source file.
  40. echo '#pragma comment(user, "libssh2 version '"${LIBSSH2_VERSION}"'")' > os400.c
  41. echo '#pragma comment(user, __DATE__)' >> os400.c
  42. echo '#pragma comment(user, __TIME__)' >> os400.c
  43. echo '#pragma comment(copyright, "See COPYING file. OS/400 version by P. Monnerat")' >> os400.c
  44. make_module OS400 os400.c
  45. LINK= # No need to rebuild service program yet.
  46. MODULES=
  47. # Generate the procedures implementing macros.
  48. if action_needed macros.c "${TOPDIR}/os400/macros.h"
  49. then (
  50. echo '#include "libssh2_publickey.h"'
  51. echo '#include "libssh2_sftp.h"'
  52. extproto < "${TOPDIR}/os400/macros.h" |
  53. sed -e 'h;s/^[^(]*[ *]\([^ (]*\) *(.*/\1/' \
  54. -e 's/.*/#pragma map(_&, "&")/;p' \
  55. -e 'g;s/^\([^(]*[ *]\)\([^ (]*\)\( *(.*\)/\1_\2\3 {/;p' \
  56. -e 'g;s/^[^(]*(\(.*\))$/,\1,/;s/[^A-Za-z0-9_,]/ /g' \
  57. -e 's/ *,/,/g;s/,[^,]* \([^ ,]*\)/,\1/g' \
  58. -e 's/ //g;s/^,void,$/,,/' \
  59. -e 's/^,\(.*\),$/(\1); }/;s/,/, /g' \
  60. -e 'x;s/(.*//;s/ *$//;G;s/\n//g' \
  61. -e 's/^void\([ *]\)/\1/;s/^ *//' \
  62. -e 's/^[^(]*[ *]\([A-Za-z][A-Za-z0-9_]* *(\)/return \1/' \
  63. -e 's/.*/ &/'
  64. ) > macros.c
  65. fi
  66. # Get source list.
  67. cat ../Makefile.inc ../Makefile.os400qc3.inc |
  68. sed -e ':begin' \
  69. -e '/\\$/{' \
  70. -e 's/\\$/ /' \
  71. -e 'N' \
  72. -e 'bbegin' \
  73. -e '}' \
  74. -e 's/\n//g' \
  75. -e 's/[[:space:]]*$//' \
  76. -e 's/^\([A-Za-z][A-Za-z0-9_]*\)[[:space:]]*=[[:space:]]*\(.*\)/\1="\2"/' \
  77. -e 's/\$(\([A-Za-z][A-Za-z0-9_]*\))/${\1}/g' \
  78. > tmpscript.sh
  79. . ./tmpscript.sh
  80. # Compile the sources into modules.
  81. INCLUDES="'`pwd`'"
  82. for SRC in "${TOPDIR}/os400/os400sys.c" "${TOPDIR}/os400/ccsid.c" \
  83. ${CSOURCES} ${CRYPTO_CSOURCES} macros.c
  84. do MODULE=`db2_name "${SRC}"`
  85. make_module "${MODULE}" "${SRC}"
  86. done
  87. # If needed, (re)create the static binding directory.
  88. if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
  89. then LINK=YES
  90. fi
  91. if [ "${LINK}" ]
  92. then rm -rf "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
  93. CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${STATBNDDIR})"
  94. CMD="${CMD} TEXT('libssh2 API static binding directory')"
  95. system "${CMD}"
  96. for MODULE in ${MODULES}
  97. do CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})"
  98. CMD="${CMD} OBJ((${TARGETLIB}/${MODULE} *MODULE))"
  99. system "${CMD}"
  100. done
  101. # V6R1M0 does not list system service program QC3PBEXT in the
  102. # implicit binding directory: thus we add it here in ours.
  103. CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})"
  104. CMD="${CMD} OBJ((QSYS/QC3PBEXT *SRVPGM))"
  105. system "${CMD}"
  106. fi
  107. # The exportation file for service program creation must be in a DB2
  108. # source file, so make sure it exists.
  109. if action_needed "${LIBIFSNAME}/TOOLS.FILE"
  110. then CMD="CRTSRCPF FILE(${TARGETLIB}/TOOLS) RCDLEN(112)"
  111. CMD="${CMD} TEXT('libssh2: build tools')"
  112. system "${CMD}"
  113. fi
  114. # Gather the list of symbols to export.
  115. EXPORTS=`cat "${TOPDIR}"/include/*.h "${TOPDIR}/os400/macros.h" \
  116. "${TOPDIR}/os400/libssh2_ccsid.h" |
  117. extproto |
  118. sed -e 's/(.*//;s/[^A-Za-z0-9_]/ /g;s/ *$//;s/^.* //'`
  119. # Create the service program exportation file in DB2 member if needed.
  120. BSF="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR"
  121. if action_needed "${BSF}" Makefile.am
  122. then LINK=YES
  123. fi
  124. if [ "${LINK}" ]
  125. then echo " STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('LIBSSH2_${SONAME}')" \
  126. > "${BSF}"
  127. for EXPORT in ${EXPORTS}
  128. do echo ' EXPORT SYMBOL("'"${EXPORT}"'")' >> "${BSF}"
  129. done
  130. echo ' ENDPGMEXP' >> "${BSF}"
  131. fi
  132. # Build the service program if needed.
  133. if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM"
  134. then LINK=YES
  135. fi
  136. if [ "${LINK}" ]
  137. then CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})"
  138. CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(BNDSRC)"
  139. CMD="${CMD} MODULE(${TARGETLIB}/OS400)"
  140. CMD="${CMD} BNDDIR(${TARGETLIB}/${STATBNDDIR}"
  141. if [ "${WITH_ZLIB}" != 0 ]
  142. then CMD="${CMD} ${ZLIB_LIB}/${ZLIB_BNDDIR}"
  143. liblist -a "${ZLIB_LIB}"
  144. fi
  145. CMD="${CMD})"
  146. CMD="${CMD} BNDSRVPGM(QADRTTS)"
  147. CMD="${CMD} TEXT('libssh2 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('libssh2 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