2024-04-15 07:10:10 +08:00
|
|
|
#!/bin/sh
|
2020-03-23 21:44:29 +08:00
|
|
|
#***************************************************************************
|
|
|
|
# _ _ ____ _
|
|
|
|
# Project ___| | | | _ \| |
|
|
|
|
# / __| | | | |_) | |
|
|
|
|
# | (__| |_| | _ <| |___
|
|
|
|
# \___|\___/|_| \_\_____|
|
|
|
|
#
|
2023-01-02 20:51:48 +08:00
|
|
|
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
2020-03-23 21:44:29 +08:00
|
|
|
#
|
|
|
|
# This software is licensed as described in the file COPYING, which
|
|
|
|
# you should have received as part of this distribution. The terms
|
2020-11-04 21:02:01 +08:00
|
|
|
# are also available at https://curl.se/docs/copyright.html.
|
2020-03-23 21:44:29 +08:00
|
|
|
#
|
|
|
|
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
# copies of the Software, and permit persons to whom the Software is
|
|
|
|
# furnished to do so, under the terms of the COPYING file.
|
|
|
|
#
|
|
|
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
# KIND, either express or implied.
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: curl
|
2022-05-17 17:16:50 +08:00
|
|
|
#
|
2020-03-23 21:44:29 +08:00
|
|
|
###########################################################################
|
2007-08-23 22:30:24 +08:00
|
|
|
|
2023-04-18 22:27:35 +08:00
|
|
|
CLcommand()
|
2022-01-25 06:45:48 +08:00
|
|
|
{
|
2023-04-18 22:27:35 +08:00
|
|
|
/usr/bin/system "${@}" || exit 1
|
2022-01-25 06:45:48 +08:00
|
|
|
}
|
2007-08-23 22:30:24 +08:00
|
|
|
|
2013-10-26 00:37:37 +08:00
|
|
|
setenv()
|
|
|
|
|
|
|
|
{
|
|
|
|
# Define and export.
|
|
|
|
|
2024-04-07 20:39:59 +08:00
|
|
|
eval "${1}=${2}"
|
|
|
|
export "${1?}"
|
2013-10-26 00:37:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-23 22:30:24 +08:00
|
|
|
case "${SCRIPTDIR}" in
|
|
|
|
/*) ;;
|
2024-04-07 20:39:59 +08:00
|
|
|
*) SCRIPTDIR="$(pwd)/${SCRIPTDIR}"
|
2007-08-23 22:30:24 +08:00
|
|
|
esac
|
|
|
|
|
|
|
|
while true
|
|
|
|
do case "${SCRIPTDIR}" in
|
|
|
|
*/.) SCRIPTDIR="${SCRIPTDIR%/.}";;
|
|
|
|
*) break;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# The script directory is supposed to be in $TOPDIR/packages/os400.
|
|
|
|
|
2024-04-07 20:39:59 +08:00
|
|
|
TOPDIR=$(dirname "${SCRIPTDIR}")
|
|
|
|
TOPDIR=$(dirname "${TOPDIR}")
|
2007-08-23 22:30:24 +08:00
|
|
|
export SCRIPTDIR TOPDIR
|
|
|
|
|
2008-01-17 00:04:47 +08:00
|
|
|
# Extract the SONAME from the library makefile.
|
|
|
|
|
2024-04-07 20:39:59 +08:00
|
|
|
SONAME="$(sed -e '/^VERSIONCHANGE=/!d;s/^.*=\([0-9]*\).*/\1/' \
|
|
|
|
< "${TOPDIR}/lib/Makefile.soname")"
|
2008-01-17 00:04:47 +08:00
|
|
|
export SONAME
|
|
|
|
|
2023-07-31 02:04:25 +08:00
|
|
|
# Get OS/400 configuration parameters.
|
2007-08-23 22:30:24 +08:00
|
|
|
|
2023-07-31 00:04:09 +08:00
|
|
|
. "${SCRIPTDIR}/config400.default"
|
|
|
|
if [ -f "${SCRIPTDIR}/config400.override" ]
|
2023-07-31 02:04:25 +08:00
|
|
|
then . "${SCRIPTDIR}/config400.override"
|
2023-07-31 00:04:09 +08:00
|
|
|
fi
|
2007-08-23 22:30:24 +08:00
|
|
|
|
2024-07-28 06:36:09 +08:00
|
|
|
# Check if perl available.
|
|
|
|
{ [ -n "${PASEPERL}" ] && [ -x "${PASEPERL}" ]; } || PASEPERL=
|
|
|
|
|
2007-08-23 22:30:24 +08:00
|
|
|
# Need to get the version definitions.
|
|
|
|
|
2024-04-07 20:39:59 +08:00
|
|
|
LIBCURL_VERSION=$(grep '^#define *LIBCURL_VERSION ' \
|
2007-08-23 22:30:24 +08:00
|
|
|
"${TOPDIR}/include/curl/curlver.h" |
|
2024-04-07 20:39:59 +08:00
|
|
|
sed 's/.*"\(.*\)".*/\1/')
|
|
|
|
LIBCURL_VERSION_MAJOR=$(grep '^#define *LIBCURL_VERSION_MAJOR ' \
|
2007-08-23 22:30:24 +08:00
|
|
|
"${TOPDIR}/include/curl/curlver.h" |
|
2024-04-07 20:39:59 +08:00
|
|
|
sed 's/^#define *LIBCURL_VERSION_MAJOR *\([^ ]*\).*/\1/')
|
|
|
|
LIBCURL_VERSION_MINOR=$(grep '^#define *LIBCURL_VERSION_MINOR ' \
|
2007-08-23 22:30:24 +08:00
|
|
|
"${TOPDIR}/include/curl/curlver.h" |
|
2024-04-07 20:39:59 +08:00
|
|
|
sed 's/^#define *LIBCURL_VERSION_MINOR *\([^ ]*\).*/\1/')
|
|
|
|
LIBCURL_VERSION_PATCH=$(grep '^#define *LIBCURL_VERSION_PATCH ' \
|
2007-08-23 22:30:24 +08:00
|
|
|
"${TOPDIR}/include/curl/curlver.h" |
|
2024-04-07 20:39:59 +08:00
|
|
|
sed 's/^#define *LIBCURL_VERSION_PATCH *\([^ ]*\).*/\1/')
|
|
|
|
LIBCURL_VERSION_NUM=$(grep '^#define *LIBCURL_VERSION_NUM ' \
|
2007-08-23 22:30:24 +08:00
|
|
|
"${TOPDIR}/include/curl/curlver.h" |
|
2024-04-07 20:39:59 +08:00
|
|
|
sed 's/^#define *LIBCURL_VERSION_NUM *0x\([^ ]*\).*/\1/')
|
|
|
|
LIBCURL_TIMESTAMP=$(grep '^#define *LIBCURL_TIMESTAMP ' \
|
2007-08-23 22:30:24 +08:00
|
|
|
"${TOPDIR}/include/curl/curlver.h" |
|
2024-04-07 20:39:59 +08:00
|
|
|
sed 's/.*"\(.*\)".*/\1/')
|
2007-08-23 22:30:24 +08:00
|
|
|
export LIBCURL_VERSION
|
|
|
|
export LIBCURL_VERSION_MAJOR LIBCURL_VERSION_MINOR LIBCURL_VERSION_PATCH
|
|
|
|
export LIBCURL_VERSION_NUM LIBCURL_TIMESTAMP
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# OS/400 specific definitions.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
LIBIFSNAME="/QSYS.LIB/${TARGETLIB}.LIB"
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# Procedures.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# action_needed dest [src]
|
|
|
|
#
|
|
|
|
# dest is an object to build
|
|
|
|
# if specified, src is an object on which dest depends.
|
|
|
|
#
|
|
|
|
# exit 0 (succeeds) if some action has to be taken, else 1.
|
|
|
|
|
|
|
|
action_needed()
|
|
|
|
|
|
|
|
{
|
|
|
|
[ ! -e "${1}" ] && return 0
|
2024-04-07 20:39:59 +08:00
|
|
|
[ -n "${2}" ] || return 1
|
2024-04-15 07:10:10 +08:00
|
|
|
# shellcheck disable=SC3013
|
2007-08-23 22:30:24 +08:00
|
|
|
[ "${1}" -ot "${2}" ] && return 0
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-19 02:22:44 +08:00
|
|
|
# canonicalize_path path
|
|
|
|
#
|
|
|
|
# Return canonicalized path as:
|
|
|
|
# - Absolute
|
|
|
|
# - No . or .. component.
|
|
|
|
|
|
|
|
canonicalize_path()
|
|
|
|
|
|
|
|
{
|
|
|
|
if expr "${1}" : '^/' > /dev/null
|
|
|
|
then P="${1}"
|
2024-04-07 20:39:59 +08:00
|
|
|
else P="$(pwd)/${1}"
|
2014-06-19 02:22:44 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
R=
|
|
|
|
IFSSAVE="${IFS}"
|
|
|
|
IFS="/"
|
|
|
|
|
|
|
|
for C in ${P}
|
|
|
|
do IFS="${IFSSAVE}"
|
|
|
|
case "${C}" in
|
|
|
|
.) ;;
|
2024-04-14 03:57:04 +08:00
|
|
|
..) R="$(expr "${R}" : '^\(.*/\)..*')"
|
2014-06-19 02:22:44 +08:00
|
|
|
;;
|
|
|
|
?*) R="${R}${C}/"
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
IFS="${IFSSAVE}"
|
2024-04-07 20:39:59 +08:00
|
|
|
echo "/$(expr "${R}" : '^\(.*\)/')"
|
2014-06-19 02:22:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-23 22:30:24 +08:00
|
|
|
# make_module module_name source_name [additional_definitions]
|
|
|
|
#
|
|
|
|
# Compile source name into ASCII module if needed.
|
|
|
|
# As side effect, append the module name to variable MODULES.
|
|
|
|
# Set LINK to "YES" if the module has been compiled.
|
|
|
|
|
|
|
|
make_module()
|
|
|
|
|
|
|
|
{
|
|
|
|
MODULES="${MODULES} ${1}"
|
|
|
|
MODIFSNAME="${LIBIFSNAME}/${1}.MODULE"
|
|
|
|
action_needed "${MODIFSNAME}" "${2}" || return 0;
|
2024-04-14 03:57:04 +08:00
|
|
|
SRCDIR="$(dirname "$(canonicalize_path "${2}")")"
|
2007-08-23 22:30:24 +08:00
|
|
|
|
|
|
|
# #pragma convert has to be in the source file itself, i.e.
|
|
|
|
# putting it in an include file makes it only active
|
|
|
|
# for that include file.
|
|
|
|
# Thus we build a temporary file with the pragma prepended to
|
2023-05-22 05:27:43 +08:00
|
|
|
# the source file and we compile that temporary file.
|
2007-08-23 22:30:24 +08:00
|
|
|
|
2024-04-07 20:39:59 +08:00
|
|
|
{
|
|
|
|
echo "#line 1 \"${2}\""
|
|
|
|
echo "#pragma convert(819)"
|
|
|
|
echo "#line 1"
|
|
|
|
cat "${2}"
|
|
|
|
} > __tmpsrcf.c
|
2007-08-23 22:30:24 +08:00
|
|
|
CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('__tmpsrcf.c')"
|
2023-08-19 14:28:39 +08:00
|
|
|
CMD="${CMD} SYSIFCOPT(*IFS64IO *ASYNCSIGNAL)"
|
|
|
|
# CMD="${CMD} OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)"
|
|
|
|
CMD="${CMD} OPTION(*INCDIRFIRST)"
|
2016-07-26 00:58:23 +08:00
|
|
|
CMD="${CMD} LOCALETYPE(*LOCALE) FLAG(10)"
|
2023-04-18 22:27:35 +08:00
|
|
|
CMD="${CMD} INCDIR('${QADRTDIR}/include'"
|
2014-06-19 02:22:44 +08:00
|
|
|
CMD="${CMD} '${TOPDIR}/include/curl' '${TOPDIR}/include' '${SRCDIR}'"
|
2013-10-26 00:37:37 +08:00
|
|
|
CMD="${CMD} '${TOPDIR}/packages/OS400'"
|
|
|
|
|
|
|
|
if [ "${WITH_ZLIB}" != "0" ]
|
|
|
|
then CMD="${CMD} '${ZLIB_INCLUDE}'"
|
|
|
|
fi
|
|
|
|
|
2015-11-19 20:35:29 +08:00
|
|
|
if [ "${WITH_LIBSSH2}" != "0" ]
|
|
|
|
then CMD="${CMD} '${LIBSSH2_INCLUDE}'"
|
|
|
|
fi
|
|
|
|
|
2013-10-26 00:37:37 +08:00
|
|
|
CMD="${CMD} ${INCLUDES})"
|
2007-08-23 22:30:24 +08:00
|
|
|
CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
|
|
|
|
CMD="${CMD} OUTPUT(${OUTPUT})"
|
|
|
|
CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
|
|
|
|
CMD="${CMD} DBGVIEW(${DEBUG})"
|
|
|
|
|
2023-08-29 19:32:39 +08:00
|
|
|
DEFINES="${3} 'qadrt_use_inline'"
|
2013-10-26 00:37:37 +08:00
|
|
|
|
|
|
|
if [ "${WITH_ZLIB}" != "0" ]
|
tidy-up: delete parallel/unused feature flags
Detecting headers and lib separately makes sense when headers come in
variations or with extra ones, but this wasn't the case here. These were
duplicate/parallel macros that we had to keep in sync with each other
for a working build. This patch leaves a single macro for each of these
dependencies:
- Rely on `HAVE_LIBZ`, delete parallel `HAVE_ZLIB_H`.
Also delete CMake logic making sure these two were in sync, along with
a toggle to turn off that logic, called `CURL_SPECIAL_LIBZ`.
Also delete stray `HAVE_ZLIB` defines.
There is also a `USE_ZLIB` variant in `lib/config-dos.h`. This patch
retains it for compatibility and deprecates it.
- Rely on `USE_LIBSSH2`, delete parallel `HAVE_LIBSSH2_H`.
Also delete `LIBSSH2_WIN32`, `LIBSSH2_LIBRARY` from
`winbuild/MakefileBuild.vc`, these have a role when building libssh2
itself. And `CURL_USE_LIBSSH`, which had no use at all.
Also delete stray `HAVE_LIBSSH2` defines.
- Rely on `USE_LIBSSH`, delete parallel `HAVE_LIBSSH_LIBSSH_H`.
Also delete `LIBSSH_WIN32`, `LIBSSH_LIBRARY` and `HAVE_LIBSSH` from
`winbuild/MakefileBuild.vc`, these were the result of copy-pasting the
libssh2 line, and were not having any use.
- Delete unused `HAVE_LIBPSL_H` and `HAVE_LIBPSL`.
Reviewed-by: Daniel Stenberg
Closes #9652
2022-10-06 23:30:13 +08:00
|
|
|
then DEFINES="${DEFINES} HAVE_LIBZ"
|
2013-10-26 00:37:37 +08:00
|
|
|
fi
|
|
|
|
|
2015-11-19 20:35:29 +08:00
|
|
|
if [ "${WITH_LIBSSH2}" != "0" ]
|
tidy-up: delete parallel/unused feature flags
Detecting headers and lib separately makes sense when headers come in
variations or with extra ones, but this wasn't the case here. These were
duplicate/parallel macros that we had to keep in sync with each other
for a working build. This patch leaves a single macro for each of these
dependencies:
- Rely on `HAVE_LIBZ`, delete parallel `HAVE_ZLIB_H`.
Also delete CMake logic making sure these two were in sync, along with
a toggle to turn off that logic, called `CURL_SPECIAL_LIBZ`.
Also delete stray `HAVE_ZLIB` defines.
There is also a `USE_ZLIB` variant in `lib/config-dos.h`. This patch
retains it for compatibility and deprecates it.
- Rely on `USE_LIBSSH2`, delete parallel `HAVE_LIBSSH2_H`.
Also delete `LIBSSH2_WIN32`, `LIBSSH2_LIBRARY` from
`winbuild/MakefileBuild.vc`, these have a role when building libssh2
itself. And `CURL_USE_LIBSSH`, which had no use at all.
Also delete stray `HAVE_LIBSSH2` defines.
- Rely on `USE_LIBSSH`, delete parallel `HAVE_LIBSSH_LIBSSH_H`.
Also delete `LIBSSH_WIN32`, `LIBSSH_LIBRARY` and `HAVE_LIBSSH` from
`winbuild/MakefileBuild.vc`, these were the result of copy-pasting the
libssh2 line, and were not having any use.
- Delete unused `HAVE_LIBPSL_H` and `HAVE_LIBPSL`.
Reviewed-by: Daniel Stenberg
Closes #9652
2022-10-06 23:30:13 +08:00
|
|
|
then DEFINES="${DEFINES} USE_LIBSSH2"
|
2015-11-19 20:35:29 +08:00
|
|
|
fi
|
|
|
|
|
2024-04-07 20:39:59 +08:00
|
|
|
if [ -n "${DEFINES}" ]
|
2013-10-26 00:37:37 +08:00
|
|
|
then CMD="${CMD} DEFINE(${DEFINES})"
|
2007-08-23 22:30:24 +08:00
|
|
|
fi
|
|
|
|
|
2023-04-18 22:27:35 +08:00
|
|
|
CLcommand "${CMD}"
|
2007-08-23 22:30:24 +08:00
|
|
|
rm -f __tmpsrcf.c
|
2024-04-07 20:39:59 +08:00
|
|
|
# shellcheck disable=SC2034
|
2007-08-23 22:30:24 +08:00
|
|
|
LINK=YES
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Determine DB2 object name from IFS name.
|
|
|
|
|
|
|
|
db2_name()
|
|
|
|
|
|
|
|
{
|
2013-10-26 00:37:37 +08:00
|
|
|
if [ "${2}" = 'nomangle' ]
|
|
|
|
then basename "${1}" |
|
|
|
|
tr 'a-z-' 'A-Z_' |
|
|
|
|
sed -e 's/\..*//' \
|
|
|
|
-e 's/^\(.\).*\(.........\)$/\1\2/'
|
|
|
|
else basename "${1}" |
|
|
|
|
tr 'a-z-' 'A-Z_' |
|
|
|
|
sed -e 's/\..*//' \
|
|
|
|
-e 's/^CURL_*/C/' \
|
2023-08-29 19:32:39 +08:00
|
|
|
-e 's/^TOOL_*/T/' \
|
2013-10-26 00:37:37 +08:00
|
|
|
-e 's/^\(.\).*\(.........\)$/\1\2/'
|
|
|
|
fi
|
2007-08-23 22:30:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Copy IFS file replacing version info.
|
|
|
|
|
|
|
|
versioned_copy()
|
|
|
|
|
|
|
|
{
|
|
|
|
sed -e "s/@LIBCURL_VERSION@/${LIBCURL_VERSION}/g" \
|
|
|
|
-e "s/@LIBCURL_VERSION_MAJOR@/${LIBCURL_VERSION_MAJOR}/g" \
|
|
|
|
-e "s/@LIBCURL_VERSION_MINOR@/${LIBCURL_VERSION_MINOR}/g" \
|
|
|
|
-e "s/@LIBCURL_VERSION_PATCH@/${LIBCURL_VERSION_PATCH}/g" \
|
|
|
|
-e "s/@LIBCURL_VERSION_NUM@/${LIBCURL_VERSION_NUM}/g" \
|
|
|
|
-e "s/@LIBCURL_TIMESTAMP@/${LIBCURL_TIMESTAMP}/g" \
|
|
|
|
< "${1}" > "${2}"
|
|
|
|
}
|
2023-08-29 19:32:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
# Get definitions from a make file.
|
|
|
|
# The `sed' statement works as follows:
|
|
|
|
# - Join \nl-separated lines.
|
|
|
|
# - Retain only lines that begins with "identifier =".
|
2023-08-31 21:28:49 +08:00
|
|
|
# - Replace @...@ substitutions by shell variable references.
|
2023-08-29 19:32:39 +08:00
|
|
|
# - Turn these lines into shell variable assignments.
|
|
|
|
|
|
|
|
get_make_vars()
|
|
|
|
|
|
|
|
{
|
2024-04-07 20:39:59 +08:00
|
|
|
eval "$(sed -e ': begin' \
|
2024-04-15 07:10:10 +08:00
|
|
|
-e '/\\$/{' \
|
2023-08-29 19:32:39 +08:00
|
|
|
-e 'N' \
|
2024-04-15 07:10:10 +08:00
|
|
|
-e 's/\\\n/ /' \
|
2023-08-29 19:32:39 +08:00
|
|
|
-e 'b begin' \
|
|
|
|
-e '}' \
|
2024-04-15 07:10:10 +08:00
|
|
|
-e 's/[[:space:]][[:space:]]*/ /g' \
|
|
|
|
-e '/^[A-Za-z_][A-Za-z0-9_]* *=/!d' \
|
|
|
|
-e 's/@\([A-Za-z0-9_]*\)@/${\1}/g' \
|
|
|
|
-e 's/ *= */=/' \
|
|
|
|
-e 's/=\(.*[^ ]\) *$/="\1"/' \
|
|
|
|
-e 's/\$(\([^)]*\))/${\1}/g' \
|
|
|
|
< "${1}")"
|
2023-08-29 19:32:39 +08:00
|
|
|
}
|