Annotation of embedaddon/curl/packages/OS400/initscript.sh, revision 1.1.1.1
1.1 misho 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:
25: setenv()
26:
27: {
28: # Define and export.
29:
30: eval ${1}="${2}"
31: export ${1}
32: }
33:
34:
35: case "${SCRIPTDIR}" in
36: /*) ;;
37: *) SCRIPTDIR="`pwd`/${SCRIPTDIR}"
38: esac
39:
40: while true
41: do case "${SCRIPTDIR}" in
42: */.) SCRIPTDIR="${SCRIPTDIR%/.}";;
43: *) break;;
44: esac
45: done
46:
47: # The script directory is supposed to be in $TOPDIR/packages/os400.
48:
49: TOPDIR=`dirname "${SCRIPTDIR}"`
50: TOPDIR=`dirname "${TOPDIR}"`
51: export SCRIPTDIR TOPDIR
52:
53: # Extract the SONAME from the library makefile.
54:
55: SONAME=`sed -e '/^VERSIONINFO=/!d' -e 's/^.* \([0-9]*\):.*$/\1/' -e 'q' \
56: < "${TOPDIR}/lib/Makefile.am"`
57: export SONAME
58:
59:
60: ################################################################################
61: #
62: # Tunable configuration parameters.
63: #
64: ################################################################################
65:
66: setenv TARGETLIB 'CURL' # Target OS/400 program library.
67: setenv STATBNDDIR 'CURL_A' # Static binding directory.
68: setenv DYNBNDDIR 'CURL' # Dynamic binding directory.
69: setenv SRVPGM "CURL.${SONAME}" # Service program.
70: setenv TGTCCSID '500' # Target CCSID of objects.
71: setenv DEBUG '*ALL' # Debug level.
72: setenv OPTIMIZE '10' # Optimisation level
73: setenv OUTPUT '*NONE' # Compilation output option.
74: setenv TGTRLS 'V6R1M0' # Target OS release.
75: setenv IFSDIR '/curl' # Installation IFS directory.
76:
77: # Define ZLIB availability and locations.
78:
79: setenv WITH_ZLIB 0 # Define to 1 to enable.
80: setenv ZLIB_INCLUDE '/zlib/include' # ZLIB include IFS directory.
81: setenv ZLIB_LIB 'ZLIB' # ZLIB library.
82: setenv ZLIB_BNDDIR 'ZLIB_A' # ZLIB binding directory.
83:
84: # Define LIBSSH2 availability and locations.
85:
86: setenv WITH_LIBSSH2 0 # Define to 1 to enable.
87: setenv LIBSSH2_INCLUDE '/libssh2/include' # LIBSSH2 include IFS directory.
88: setenv LIBSSH2_LIB 'LIBSSH2' # LIBSSH2 library.
89: setenv LIBSSH2_BNDDIR 'LIBSSH2_A' # LIBSSH2 binding directory.
90:
91:
92: ################################################################################
93:
94: # Need to get the version definitions.
95:
96: LIBCURL_VERSION=`grep '^#define *LIBCURL_VERSION ' \
97: "${TOPDIR}/include/curl/curlver.h" |
98: sed 's/.*"\(.*\)".*/\1/'`
99: LIBCURL_VERSION_MAJOR=`grep '^#define *LIBCURL_VERSION_MAJOR ' \
100: "${TOPDIR}/include/curl/curlver.h" |
101: sed 's/^#define *LIBCURL_VERSION_MAJOR *\([^ ]*\).*/\1/'`
102: LIBCURL_VERSION_MINOR=`grep '^#define *LIBCURL_VERSION_MINOR ' \
103: "${TOPDIR}/include/curl/curlver.h" |
104: sed 's/^#define *LIBCURL_VERSION_MINOR *\([^ ]*\).*/\1/'`
105: LIBCURL_VERSION_PATCH=`grep '^#define *LIBCURL_VERSION_PATCH ' \
106: "${TOPDIR}/include/curl/curlver.h" |
107: sed 's/^#define *LIBCURL_VERSION_PATCH *\([^ ]*\).*/\1/'`
108: LIBCURL_VERSION_NUM=`grep '^#define *LIBCURL_VERSION_NUM ' \
109: "${TOPDIR}/include/curl/curlver.h" |
110: sed 's/^#define *LIBCURL_VERSION_NUM *0x\([^ ]*\).*/\1/'`
111: LIBCURL_TIMESTAMP=`grep '^#define *LIBCURL_TIMESTAMP ' \
112: "${TOPDIR}/include/curl/curlver.h" |
113: sed 's/.*"\(.*\)".*/\1/'`
114: export LIBCURL_VERSION
115: export LIBCURL_VERSION_MAJOR LIBCURL_VERSION_MINOR LIBCURL_VERSION_PATCH
116: export LIBCURL_VERSION_NUM LIBCURL_TIMESTAMP
117:
118: ################################################################################
119: #
120: # OS/400 specific definitions.
121: #
122: ################################################################################
123:
124: LIBIFSNAME="/QSYS.LIB/${TARGETLIB}.LIB"
125:
126:
127: ################################################################################
128: #
129: # Procedures.
130: #
131: ################################################################################
132:
133: # action_needed dest [src]
134: #
135: # dest is an object to build
136: # if specified, src is an object on which dest depends.
137: #
138: # exit 0 (succeeds) if some action has to be taken, else 1.
139:
140: action_needed()
141:
142: {
143: [ ! -e "${1}" ] && return 0
144: [ "${2}" ] || return 1
145: [ "${1}" -ot "${2}" ] && return 0
146: return 1
147: }
148:
149:
150: # canonicalize_path path
151: #
152: # Return canonicalized path as:
153: # - Absolute
154: # - No . or .. component.
155:
156: canonicalize_path()
157:
158: {
159: if expr "${1}" : '^/' > /dev/null
160: then P="${1}"
161: else P="`pwd`/${1}"
162: fi
163:
164: R=
165: IFSSAVE="${IFS}"
166: IFS="/"
167:
168: for C in ${P}
169: do IFS="${IFSSAVE}"
170: case "${C}" in
171: .) ;;
172: ..) R=`expr "${R}" : '^\(.*/\)..*'`
173: ;;
174: ?*) R="${R}${C}/"
175: ;;
176: *) ;;
177: esac
178: done
179:
180: IFS="${IFSSAVE}"
181: echo "/`expr "${R}" : '^\(.*\)/'`"
182: }
183:
184:
185: # make_module module_name source_name [additional_definitions]
186: #
187: # Compile source name into ASCII module if needed.
188: # As side effect, append the module name to variable MODULES.
189: # Set LINK to "YES" if the module has been compiled.
190:
191: make_module()
192:
193: {
194: MODULES="${MODULES} ${1}"
195: MODIFSNAME="${LIBIFSNAME}/${1}.MODULE"
196: action_needed "${MODIFSNAME}" "${2}" || return 0;
197: SRCDIR=`dirname \`canonicalize_path "${2}"\``
198:
199: # #pragma convert has to be in the source file itself, i.e.
200: # putting it in an include file makes it only active
201: # for that include file.
202: # Thus we build a temporary file with the pragma prepended to
203: # the source file and we compile that themporary file.
204:
205: echo "#line 1 \"${2}\"" > __tmpsrcf.c
206: echo "#pragma convert(819)" >> __tmpsrcf.c
207: echo "#line 1" >> __tmpsrcf.c
208: cat "${2}" >> __tmpsrcf.c
209: CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('__tmpsrcf.c')"
210: # CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)"
211: CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST)"
212: CMD="${CMD} LOCALETYPE(*LOCALE) FLAG(10)"
213: CMD="${CMD} INCDIR('/qibm/proddata/qadrt/include'"
214: CMD="${CMD} '${TOPDIR}/include/curl' '${TOPDIR}/include' '${SRCDIR}'"
215: CMD="${CMD} '${TOPDIR}/packages/OS400'"
216:
217: if [ "${WITH_ZLIB}" != "0" ]
218: then CMD="${CMD} '${ZLIB_INCLUDE}'"
219: fi
220:
221: if [ "${WITH_LIBSSH2}" != "0" ]
222: then CMD="${CMD} '${LIBSSH2_INCLUDE}'"
223: fi
224:
225: CMD="${CMD} ${INCLUDES})"
226: CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
227: CMD="${CMD} OUTPUT(${OUTPUT})"
228: CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
229: CMD="${CMD} DBGVIEW(${DEBUG})"
230:
231: DEFINES="${3} BUILDING_LIBCURL"
232:
233: if [ "${WITH_ZLIB}" != "0" ]
234: then DEFINES="${DEFINES} HAVE_LIBZ HAVE_ZLIB_H"
235: fi
236:
237: if [ "${WITH_LIBSSH2}" != "0" ]
238: then DEFINES="${DEFINES} USE_LIBSSH2 HAVE_LIBSSH2_H"
239: fi
240:
241: if [ "${DEFINES}" ]
242: then CMD="${CMD} DEFINE(${DEFINES})"
243: fi
244:
245: system "${CMD}"
246: rm -f __tmpsrcf.c
247: LINK=YES
248: }
249:
250:
251: # Determine DB2 object name from IFS name.
252:
253: db2_name()
254:
255: {
256: if [ "${2}" = 'nomangle' ]
257: then basename "${1}" |
258: tr 'a-z-' 'A-Z_' |
259: sed -e 's/\..*//' \
260: -e 's/^\(.\).*\(.........\)$/\1\2/'
261: else basename "${1}" |
262: tr 'a-z-' 'A-Z_' |
263: sed -e 's/\..*//' \
264: -e 's/^CURL_*/C/' \
265: -e 's/^\(.\).*\(.........\)$/\1\2/'
266: fi
267: }
268:
269:
270: # Copy IFS file replacing version info.
271:
272: versioned_copy()
273:
274: {
275: sed -e "s/@LIBCURL_VERSION@/${LIBCURL_VERSION}/g" \
276: -e "s/@LIBCURL_VERSION_MAJOR@/${LIBCURL_VERSION_MAJOR}/g" \
277: -e "s/@LIBCURL_VERSION_MINOR@/${LIBCURL_VERSION_MINOR}/g" \
278: -e "s/@LIBCURL_VERSION_PATCH@/${LIBCURL_VERSION_PATCH}/g" \
279: -e "s/@LIBCURL_VERSION_NUM@/${LIBCURL_VERSION_NUM}/g" \
280: -e "s/@LIBCURL_TIMESTAMP@/${LIBCURL_TIMESTAMP}/g" \
281: < "${1}" > "${2}"
282: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>