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