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