14 case "${SCRIPTDIR}" in
16 *) SCRIPTDIR="`pwd`/${SCRIPTDIR}"
20 do case "${SCRIPTDIR}" in
21 */.) SCRIPTDIR="${SCRIPTDIR%/.}";;
26 # The script directory is supposed to be in $TOPDIR/packages/os400.
28 TOPDIR=`dirname "${SCRIPTDIR}"`
29 TOPDIR=`dirname "${TOPDIR}"`
30 export SCRIPTDIR TOPDIR
32 # Extract the SONAME from the library makefile.
34 SONAME=`sed -e '/^VERSIONINFO=/!d' -e 's/^.* \([0-9]*\):.*$/\1/' -e 'q' \
35 < "${TOPDIR}/lib/Makefile.am"`
39 ################################################################################
41 # Tunable configuration parameters.
43 ################################################################################
45 setenv TARGETLIB 'CURL' # Target OS/400 program library.
46 setenv STATBNDDIR 'CURL_A' # Static binding directory.
47 setenv DYNBNDDIR 'CURL' # Dynamic binding directory.
48 setenv SRVPGM "CURL.${SONAME}" # Service program.
49 setenv TGTCCSID '500' # Target CCSID of objects.
50 setenv DEBUG '*ALL' # Debug level.
51 setenv OPTIMIZE '10' # Optimisation level
52 setenv OUTPUT '*NONE' # Compilation output option.
53 setenv TGTRLS 'V6R1M0' # Target OS release.
54 setenv IFSDIR '/curl' # Installation IFS directory.
56 # Define ZLIB availability and locations.
58 setenv WITH_ZLIB 0 # Define to 1 to enable.
59 setenv ZLIB_INCLUDE '/zlib/include' # ZLIB include IFS directory.
60 setenv ZLIB_LIB 'ZLIB' # ZLIB library.
61 setenv ZLIB_BNDDIR 'ZLIB_A' # ZLIB binding directory.
63 # Define LIBSSH2 availability and locations.
65 setenv WITH_LIBSSH2 0 # Define to 1 to enable.
66 setenv LIBSSH2_INCLUDE '/libssh2/include' # LIBSSH2 include IFS directory.
67 setenv LIBSSH2_LIB 'LIBSSH2' # LIBSSH2 library.
68 setenv LIBSSH2_BNDDIR 'LIBSSH2_A' # LIBSSH2 binding directory.
71 ################################################################################
73 # Need to get the version definitions.
75 LIBCURL_VERSION=`grep '^#define *LIBCURL_VERSION ' \
76 "${TOPDIR}/include/curl/curlver.h" |
77 sed 's/.*"\(.*\)".*/\1/'`
78 LIBCURL_VERSION_MAJOR=`grep '^#define *LIBCURL_VERSION_MAJOR ' \
79 "${TOPDIR}/include/curl/curlver.h" |
80 sed 's/^#define *LIBCURL_VERSION_MAJOR *\([^ ]*\).*/\1/'`
81 LIBCURL_VERSION_MINOR=`grep '^#define *LIBCURL_VERSION_MINOR ' \
82 "${TOPDIR}/include/curl/curlver.h" |
83 sed 's/^#define *LIBCURL_VERSION_MINOR *\([^ ]*\).*/\1/'`
84 LIBCURL_VERSION_PATCH=`grep '^#define *LIBCURL_VERSION_PATCH ' \
85 "${TOPDIR}/include/curl/curlver.h" |
86 sed 's/^#define *LIBCURL_VERSION_PATCH *\([^ ]*\).*/\1/'`
87 LIBCURL_VERSION_NUM=`grep '^#define *LIBCURL_VERSION_NUM ' \
88 "${TOPDIR}/include/curl/curlver.h" |
89 sed 's/^#define *LIBCURL_VERSION_NUM *0x\([^ ]*\).*/\1/'`
90 LIBCURL_TIMESTAMP=`grep '^#define *LIBCURL_TIMESTAMP ' \
91 "${TOPDIR}/include/curl/curlver.h" |
92 sed 's/.*"\(.*\)".*/\1/'`
93 export LIBCURL_VERSION
94 export LIBCURL_VERSION_MAJOR LIBCURL_VERSION_MINOR LIBCURL_VERSION_PATCH
95 export LIBCURL_VERSION_NUM LIBCURL_TIMESTAMP
97 ################################################################################
99 # OS/400 specific definitions.
101 ################################################################################
103 LIBIFSNAME="/QSYS.LIB/${TARGETLIB}.LIB"
106 ################################################################################
110 ################################################################################
112 # action_needed dest [src]
114 # dest is an object to build
115 # if specified, src is an object on which dest depends.
117 # exit 0 (succeeds) if some action has to be taken, else 1.
122 [ ! -e "${1}" ] && return 0
123 [ "${2}" ] || return 1
124 [ "${1}" -ot "${2}" ] && return 0
129 # canonicalize_path path
131 # Return canonicalized path as:
133 # - No . or .. component.
138 if expr "${1}" : '^/' > /dev/null
151 ..) R=`expr "${R}" : '^\(.*/\)..*'`
160 echo "/`expr "${R}" : '^\(.*\)/'`"
164 # make_module module_name source_name [additional_definitions]
166 # Compile source name into ASCII module if needed.
167 # As side effect, append the module name to variable MODULES.
168 # Set LINK to "YES" if the module has been compiled.
173 MODULES="${MODULES} ${1}"
174 MODIFSNAME="${LIBIFSNAME}/${1}.MODULE"
175 action_needed "${MODIFSNAME}" "${2}" || return 0;
176 SRCDIR=`dirname \`canonicalize_path "${2}"\``
178 # #pragma convert has to be in the source file itself, i.e.
179 # putting it in an include file makes it only active
180 # for that include file.
181 # Thus we build a temporary file with the pragma prepended to
182 # the source file and we compile that themporary file.
184 echo "#line 1 \"${2}\"" > __tmpsrcf.c
185 echo "#pragma convert(819)" >> __tmpsrcf.c
186 echo "#line 1" >> __tmpsrcf.c
187 cat "${2}" >> __tmpsrcf.c
188 CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('__tmpsrcf.c')"
189 # CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)"
190 CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST)"
191 CMD="${CMD} LOCALETYPE(*LOCALE) FLAG(10)"
192 CMD="${CMD} INCDIR('/qibm/proddata/qadrt/include'"
193 CMD="${CMD} '${TOPDIR}/include/curl' '${TOPDIR}/include' '${SRCDIR}'"
194 CMD="${CMD} '${TOPDIR}/packages/OS400'"
196 if [ "${WITH_ZLIB}" != "0" ]
197 then CMD="${CMD} '${ZLIB_INCLUDE}'"
200 if [ "${WITH_LIBSSH2}" != "0" ]
201 then CMD="${CMD} '${LIBSSH2_INCLUDE}'"
204 CMD="${CMD} ${INCLUDES})"
205 CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
206 CMD="${CMD} OUTPUT(${OUTPUT})"
207 CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
208 CMD="${CMD} DBGVIEW(${DEBUG})"
210 DEFINES="${3} BUILDING_LIBCURL"
212 if [ "${WITH_ZLIB}" != "0" ]
213 then DEFINES="${DEFINES} HAVE_LIBZ HAVE_ZLIB_H"
216 if [ "${WITH_LIBSSH2}" != "0" ]
217 then DEFINES="${DEFINES} USE_LIBSSH2 HAVE_LIBSSH2_H"
221 then CMD="${CMD} DEFINE(${DEFINES})"
230 # Determine DB2 object name from IFS name.
235 if [ "${2}" = 'nomangle' ]
236 then basename "${1}" |
239 -e 's/^\(.\).*\(.........\)$/\1\2/'
240 else basename "${1}" |
244 -e 's/^\(.\).*\(.........\)$/\1\2/'
249 # Copy IFS file replacing version info.
254 sed -e "s/@LIBCURL_VERSION@/${LIBCURL_VERSION}/g" \
255 -e "s/@LIBCURL_VERSION_MAJOR@/${LIBCURL_VERSION_MAJOR}/g" \
256 -e "s/@LIBCURL_VERSION_MINOR@/${LIBCURL_VERSION_MINOR}/g" \
257 -e "s/@LIBCURL_VERSION_PATCH@/${LIBCURL_VERSION_PATCH}/g" \
258 -e "s/@LIBCURL_VERSION_NUM@/${LIBCURL_VERSION_NUM}/g" \
259 -e "s/@LIBCURL_TIMESTAMP@/${LIBCURL_TIMESTAMP}/g" \