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