1#!/bin/sh 2#*************************************************************************** 3# _ _ ____ _ 4# Project ___| | | | _ \| | 5# / __| | | | |_) | | 6# | (__| |_| | _ <| |___ 7# \___|\___/|_| \_\_____| 8# 9# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 10# 11# This software is licensed as described in the file COPYING, which 12# you should have received as part of this distribution. The terms 13# are also available at https://curl.se/docs/copyright.html. 14# 15# You may opt to use, copy, modify, merge, publish, distribute and/or sell 16# copies of the Software, and permit persons to whom the Software is 17# furnished to do so, under the terms of the COPYING file. 18# 19# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 20# KIND, either express or implied. 21# 22# SPDX-License-Identifier: curl 23# 24########################################################################### 25# 26# libcurl compilation script for the OS/400. 27# 28 29SCRIPTDIR=`dirname "${0}"` 30. "${SCRIPTDIR}/initscript.sh" 31cd "${TOPDIR}/lib" 32 33# Need to have IFS access to the mih/cipher header file. 34 35if action_needed cipher.mih '/QSYS.LIB/QSYSINC.LIB/MIH.FILE/CIPHER.MBR' 36then rm -f cipher.mih 37 ln -s '/QSYS.LIB/QSYSINC.LIB/MIH.FILE/CIPHER.MBR' cipher.mih 38fi 39 40 41# Create and compile the identification source file. 42 43echo '#pragma comment(user, "libcurl version '"${LIBCURL_VERSION}"'")' > os400.c 44echo '#pragma comment(user, __DATE__)' >> os400.c 45echo '#pragma comment(user, __TIME__)' >> os400.c 46echo '#pragma comment(copyright, "Copyright (C) Daniel Stenberg et al. OS/400 version by P. Monnerat")' >> os400.c 47make_module OS400 os400.c BUILDING_LIBCURL 48LINK= # No need to rebuild service program yet. 49MODULES= 50 51 52# Get source list (CSOURCES variable). 53 54get_make_vars Makefile.inc 55 56 57# Compile the sources into modules. 58 59INCLUDES="'`pwd`'" 60 61make_module OS400SYS "${SCRIPTDIR}/os400sys.c" BUILDING_LIBCURL 62make_module CCSIDCURL "${SCRIPTDIR}/ccsidcurl.c" BUILDING_LIBCURL 63 64for SRC in ${CSOURCES} 65do MODULE=`db2_name "${SRC}"` 66 make_module "${MODULE}" "${SRC}" BUILDING_LIBCURL 67done 68 69 70# If needed, (re)create the static binding directory. 71 72if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR" 73then LINK=YES 74fi 75 76if [ "${LINK}" ] 77then rm -rf "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR" 78 CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${STATBNDDIR})" 79 CMD="${CMD} TEXT('LibCurl API static binding directory')" 80 CLcommand "${CMD}" 81 82 for MODULE in ${MODULES} 83 do CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})" 84 CMD="${CMD} OBJ((${TARGETLIB}/${MODULE} *MODULE))" 85 CLcommand "${CMD}" 86 done 87fi 88 89 90# The exportation file for service program creation must be in a DB2 91# source file, so make sure it exists. 92 93if action_needed "${LIBIFSNAME}/TOOLS.FILE" 94then CMD="CRTSRCPF FILE(${TARGETLIB}/TOOLS) RCDLEN(112)" 95 CMD="${CMD} TEXT('curl: build tools')" 96 CLcommand "${CMD}" 97fi 98 99 100# Gather the list of symbols to export. 101# First use awk to pull all CURL_EXTERN function prototypes from 102# the header files, pass through to sed to strip CURL_DEPRECATED(..) 103# and CURL_TEMP_PRINTF(..) then back to awk to pull the string 104# immediately to the left of a bracket stripping any spaces or *'s. 105 106EXPORTS=`awk '/^CURL_EXTERN/,/;/' \ 107 "${TOPDIR}"/include/curl/*.h \ 108 "${SCRIPTDIR}/ccsidcurl.h" | 109 sed 's/ CURL_DEPRECATED(.*)//g;s/ CURL_TEMP_PRINTF(.*)//g' | 110 awk '{br=index($0,"("); \ 111 if (br) { \ 112 for(c=br-1; ;c--) { \ 113 if (c==1) { \ 114 print substr($0,c,br-1); break \ 115 } else if (match(substr($0, c, br-c), "[ *]") != 0) { \ 116 print substr($0, c+1, br-c-1); break \ 117 } \ 118 } \ 119 } \ 120 }'` 121 122# Create the service program exportation file in DB2 member if needed. 123 124BSF="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR" 125 126if action_needed "${BSF}" Makefile.am 127then LINK=YES 128fi 129 130if [ "${LINK}" ] 131then echo " STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('LIBCURL_${SONAME}')" \ 132 > "${BSF}" 133 for EXPORT in ${EXPORTS} 134 do echo ' EXPORT SYMBOL("'"${EXPORT}"'")' >> "${BSF}" 135 done 136 137 echo ' ENDPGMEXP' >> "${BSF}" 138fi 139 140 141# Build the service program if needed. 142 143if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM" 144then LINK=YES 145fi 146 147if [ "${LINK}" ] 148then CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})" 149 CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(BNDSRC)" 150 CMD="${CMD} MODULE(${TARGETLIB}/OS400)" 151 CMD="${CMD} BNDDIR(${TARGETLIB}/${STATBNDDIR}" 152 if [ "${WITH_ZLIB}" != 0 ] 153 then CMD="${CMD} ${ZLIB_LIB}/${ZLIB_BNDDIR}" 154 liblist -a "${ZLIB_LIB}" 155 fi 156 if [ "${WITH_LIBSSH2}" != 0 ] 157 then CMD="${CMD} ${LIBSSH2_LIB}/${LIBSSH2_BNDDIR}" 158 liblist -a "${LIBSSH2_LIB}" 159 fi 160 CMD="${CMD})" 161 CMD="${CMD} BNDSRVPGM(QADRTTS QGLDCLNT QGLDBRDR)" 162 CMD="${CMD} TEXT('curl API library')" 163 CMD="${CMD} TGTRLS(${TGTRLS})" 164 CLcommand "${CMD}" 165 LINK=YES 166fi 167 168 169# If needed, (re)create the dynamic binding directory. 170 171if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR" 172then LINK=YES 173fi 174 175if [ "${LINK}" ] 176then rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR" 177 CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})" 178 CMD="${CMD} TEXT('LibCurl API dynamic binding directory')" 179 CLcommand "${CMD}" 180 CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})" 181 CMD="${CMD} OBJ((*LIBL/${SRVPGM} *SRVPGM))" 182 CLcommand "${CMD}" 183fi 184