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.
 
 
 
 

244 lines
8.0 KiB

  1. #!/bin/sh
  2. setenv()
  3. {
  4. # Define and export.
  5. eval ${1}="${2}"
  6. export ${1}
  7. }
  8. case "${SCRIPTDIR}" in
  9. /*) ;;
  10. *) SCRIPTDIR="`pwd`/${SCRIPTDIR}"
  11. esac
  12. while true
  13. do case "${SCRIPTDIR}" in
  14. */.) SCRIPTDIR="${SCRIPTDIR%/.}";;
  15. *) break;;
  16. esac
  17. done
  18. # The script directory is supposed to be in $TOPDIR/os400.
  19. TOPDIR=`dirname "${SCRIPTDIR}"`
  20. export SCRIPTDIR TOPDIR
  21. # Extract the SONAME from the library makefile.
  22. SONAME=`sed -e '/^VERSION=/!d' -e 's/^.* \([0-9]*\):.*$/\1/' -e 'q' \
  23. < "${TOPDIR}/src/Makefile.am"`
  24. export SONAME
  25. ################################################################################
  26. #
  27. # Tunable configuration parameters.
  28. #
  29. ################################################################################
  30. setenv TARGETLIB 'LIBSSH2' # Target OS/400 program library.
  31. setenv STATBNDDIR 'LIBSSH2_A' # Static binding directory.
  32. setenv DYNBNDDIR 'LIBSSH2' # Dynamic binding directory.
  33. setenv SRVPGM "LIBSSH2.${SONAME}" # Service program.
  34. setenv TGTCCSID '500' # Target CCSID of objects.
  35. setenv DEBUG '*ALL' # Debug level.
  36. setenv OPTIMIZE '10' # Optimisation level
  37. setenv OUTPUT '*NONE' # Compilation output option.
  38. setenv TGTRLS 'V6R1M0' # Target OS release.
  39. setenv IFSDIR '/libssh2' # Installation IFS directory.
  40. # Define ZLIB availability and locations.
  41. setenv WITH_ZLIB 0 # Define to 1 to enable.
  42. setenv ZLIB_INCLUDE '/zlib/include' # ZLIB include IFS directory.
  43. setenv ZLIB_LIB 'ZLIB' # ZLIB library.
  44. setenv ZLIB_BNDDIR 'ZLIB_A' # ZLIB binding directory.
  45. ################################################################################
  46. # Need to get the version definitions.
  47. LIBSSH2_VERSION=`grep '^#define *LIBSSH2_VERSION ' \
  48. "${TOPDIR}/include/libssh2.h" |
  49. sed 's/.*"\(.*\)".*/\1/'`
  50. LIBSSH2_VERSION_MAJOR=`grep '^#define *LIBSSH2_VERSION_MAJOR ' \
  51. "${TOPDIR}/include/libssh2.h" |
  52. sed 's/^#define *LIBSSH2_VERSION_MAJOR *\([^ ]*\).*/\1/'`
  53. LIBSSH2_VERSION_MINOR=`grep '^#define *LIBSSH2_VERSION_MINOR ' \
  54. "${TOPDIR}/include/libssh2.h" |
  55. sed 's/^#define *LIBSSH2_VERSION_MINOR *\([^ ]*\).*/\1/'`
  56. LIBSSH2_VERSION_PATCH=`grep '^#define *LIBSSH2_VERSION_PATCH ' \
  57. "${TOPDIR}/include/libssh2.h" |
  58. sed 's/^#define *LIBSSH2_VERSION_PATCH *\([^ ]*\).*/\1/'`
  59. LIBSSH2_VERSION_NUM=`grep '^#define *LIBSSH2_VERSION_NUM ' \
  60. "${TOPDIR}/include/libssh2.h" |
  61. sed 's/^#define *LIBSSH2_VERSION_NUM *0x\([^ ]*\).*/\1/'`
  62. LIBSSH2_TIMESTAMP=`grep '^#define *LIBSSH2_TIMESTAMP ' \
  63. "${TOPDIR}/include/libssh2.h" |
  64. sed 's/.*"\(.*\)".*/\1/'`
  65. export LIBSSH2_VERSION
  66. export LIBSSH2_VERSION_MAJOR LIBSSH2_VERSION_MINOR LIBSSH2_VERSION_PATCH
  67. export LIBSSH2_VERSION_NUM LIBSSH2_TIMESTAMP
  68. ################################################################################
  69. #
  70. # OS/400 specific definitions.
  71. #
  72. ################################################################################
  73. LIBIFSNAME="/QSYS.LIB/${TARGETLIB}.LIB"
  74. ################################################################################
  75. #
  76. # Procedures.
  77. #
  78. ################################################################################
  79. # action_needed dest [src]
  80. #
  81. # dest is an object to build
  82. # if specified, src is an object on which dest depends.
  83. #
  84. # exit 0 (succeeds) if some action has to be taken, else 1.
  85. action_needed()
  86. {
  87. [ ! -e "${1}" ] && return 0
  88. [ "${2}" ] || return 1
  89. [ "${1}" -ot "${2}" ] && return 0
  90. return 1
  91. }
  92. # canonicalize_path path
  93. #
  94. # Return canonicalized path as:
  95. # - Absolute
  96. # - No . or .. component.
  97. canonicalize_path()
  98. {
  99. if expr "${1}" : '^/' > /dev/null
  100. then P="${1}"
  101. else P="`pwd`/${1}"
  102. fi
  103. R=
  104. IFSSAVE="${IFS}"
  105. IFS="/"
  106. for C in ${P}
  107. do IFS="${IFSSAVE}"
  108. case "${C}" in
  109. .) ;;
  110. ..) R=`expr "${R}" : '^\(.*/\)..*'`
  111. ;;
  112. ?*) R="${R}${C}/"
  113. ;;
  114. *) ;;
  115. esac
  116. done
  117. IFS="${IFSSAVE}"
  118. echo "/`expr "${R}" : '^\(.*\)/'`"
  119. }
  120. # make_module module_name source_name [additional_definitions]
  121. #
  122. # Compile source name into ASCII module if needed.
  123. # As side effect, append the module name to variable MODULES.
  124. # Set LINK to "YES" if the module has been compiled.
  125. make_module()
  126. {
  127. MODULES="${MODULES} ${1}"
  128. MODIFSNAME="${LIBIFSNAME}/${1}.MODULE"
  129. action_needed "${MODIFSNAME}" "${2}" || return 0;
  130. SRCDIR=`dirname \`canonicalize_path "${2}"\``
  131. # #pragma convert has to be in the source file itself, i.e.
  132. # putting it in an include file makes it only active
  133. # for that include file.
  134. # Thus we build a temporary file with the pragma prepended to
  135. # the source file and we compile that temporary file.
  136. echo "#line 1 \"${2}\"" > __tmpsrcf.c
  137. echo "#pragma convert(819)" >> __tmpsrcf.c
  138. echo "#line 1" >> __tmpsrcf.c
  139. cat "${2}" >> __tmpsrcf.c
  140. CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('__tmpsrcf.c')"
  141. # CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)"
  142. CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST)"
  143. CMD="${CMD} LOCALETYPE(*LOCALE) FLAG(10)"
  144. CMD="${CMD} INCDIR('${TOPDIR}/os400/include'"
  145. CMD="${CMD} '/QIBM/ProdData/qadrt/include' '${TOPDIR}/include'"
  146. CMD="${CMD} '${TOPDIR}/os400' '${SRCDIR}'"
  147. if [ "${WITH_ZLIB}" != "0" ]
  148. then CMD="${CMD} '${ZLIB_INCLUDE}'"
  149. fi
  150. CMD="${CMD} ${INCLUDES})"
  151. CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
  152. CMD="${CMD} OUTPUT(${OUTPUT})"
  153. CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
  154. CMD="${CMD} DBGVIEW(${DEBUG})"
  155. DEFINES="${3}"
  156. if [ "${WITH_ZLIB}" != "0" ]
  157. then DEFINES="${DEFINES} HAVE_LIBZ LIBSSH2_HAVE_ZLIB"
  158. fi
  159. if [ "${DEFINES}" ]
  160. then CMD="${CMD} DEFINE(${DEFINES})"
  161. fi
  162. system "${CMD}"
  163. rm -f __tmpsrcf.c
  164. LINK=YES
  165. }
  166. # Determine DB2 object name from IFS name.
  167. db2_name()
  168. {
  169. if [ "${2}" = 'nomangle' ]
  170. then basename "${1}" |
  171. tr 'a-z-' 'A-Z_' |
  172. sed -e 's/\..*//;s/^\(.\).*\(.........\)$/\1\2/'
  173. else basename "${1}" |
  174. tr 'a-z-' 'A-Z_' |
  175. sed -e 's/\..*//;s/^LIBSSH2_/SSH2_/' \
  176. -e 's/^\(.\).*\(.........\)$/\1\2/' \
  177. -e 's/^SPUBLICKEY$/SSH2_PKEY/'
  178. fi
  179. }
  180. # Copy stream replacing version info.
  181. versioned_copy()
  182. {
  183. sed -e "s/@LIBSSH2_VERSION@/${LIBSSH2_VERSION}/g" \
  184. -e "s/@LIBSSH2_VERSION_MAJOR@/${LIBSSH2_VERSION_MAJOR}/g" \
  185. -e "s/@LIBSSH2_VERSION_MINOR@/${LIBSSH2_VERSION_MINOR}/g" \
  186. -e "s/@LIBSSH2_VERSION_PATCH@/${LIBSSH2_VERSION_PATCH}/g" \
  187. -e "s/@LIBSSH2_VERSION_NUM@/${LIBSSH2_VERSION_NUM}/g" \
  188. -e "s/@LIBSSH2_TIMESTAMP@/${LIBSSH2_TIMESTAMP}/g"
  189. }