Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Utilities / cmcurl-7.19.0 / packages / OS400 / initscript.sh
blobdab36e83fa04d58ed5e9421a493ead6fae70d5be
1 #!/bin/sh
3 # $Id: initscript.sh,v 1.1.1.1 2008-09-23 16:32:05 hoffman Exp $
5 case "${SCRIPTDIR}" in
6 /*) ;;
7 *) SCRIPTDIR="`pwd`/${SCRIPTDIR}"
8 esac
10 while true
11 do case "${SCRIPTDIR}" in
12 */.) SCRIPTDIR="${SCRIPTDIR%/.}";;
13 *) break;;
14 esac
15 done
17 # The script directory is supposed to be in $TOPDIR/packages/os400.
19 TOPDIR=`dirname "${SCRIPTDIR}"`
20 TOPDIR=`dirname "${TOPDIR}"`
21 export SCRIPTDIR TOPDIR
23 # Extract the SONAME from the library makefile.
25 SONAME=`sed -e '/^VERSIONINFO=/!d' -e 's/^.* \([0-9]*\):.*$/\1/' -e 'q' \
26 < "${TOPDIR}/lib/Makefile.am"`
27 export SONAME
30 ################################################################################
32 # Tunable configuration parameters.
34 ################################################################################
36 TARGETLIB='CURL' # Target OS/400 program library
37 STATBNDDIR='CURL_A' # Static binding directory.
38 DYNBNDDIR='CURL' # Dynamic binding directory.
39 SRVPGM="CURL.${SONAME}" # Service program.
40 TGTCCSID='500' # Target CCSID of objects
41 DEBUG='*ALL' # Debug level
42 OPTIMIZE='10' # Optimisation level
43 OUTPUT='*NONE' # Compilation output option.
44 TGTRLS='V5R2M0' # Target OS release
46 export TARGETLIB STATBNDDIR DYNBNDDIR SRVPGM TGTCCSID DEBUG OPTIMIZE OUTPUT
47 export TGTRLS
50 ################################################################################
52 # Need to get the version definitions.
54 LIBCURL_VERSION=`grep '^#define *LIBCURL_VERSION ' \
55 "${TOPDIR}/include/curl/curlver.h" |
56 sed 's/.*"\(.*\)".*/\1/'`
57 LIBCURL_VERSION_MAJOR=`grep '^#define *LIBCURL_VERSION_MAJOR ' \
58 "${TOPDIR}/include/curl/curlver.h" |
59 sed 's/^#define *LIBCURL_VERSION_MAJOR *\([^ ]*\).*/\1/'`
60 LIBCURL_VERSION_MINOR=`grep '^#define *LIBCURL_VERSION_MINOR ' \
61 "${TOPDIR}/include/curl/curlver.h" |
62 sed 's/^#define *LIBCURL_VERSION_MINOR *\([^ ]*\).*/\1/'`
63 LIBCURL_VERSION_PATCH=`grep '^#define *LIBCURL_VERSION_PATCH ' \
64 "${TOPDIR}/include/curl/curlver.h" |
65 sed 's/^#define *LIBCURL_VERSION_PATCH *\([^ ]*\).*/\1/'`
66 LIBCURL_VERSION_NUM=`grep '^#define *LIBCURL_VERSION_NUM ' \
67 "${TOPDIR}/include/curl/curlver.h" |
68 sed 's/^#define *LIBCURL_VERSION_NUM *0x\([^ ]*\).*/\1/'`
69 LIBCURL_TIMESTAMP=`grep '^#define *LIBCURL_TIMESTAMP ' \
70 "${TOPDIR}/include/curl/curlver.h" |
71 sed 's/.*"\(.*\)".*/\1/'`
72 export LIBCURL_VERSION
73 export LIBCURL_VERSION_MAJOR LIBCURL_VERSION_MINOR LIBCURL_VERSION_PATCH
74 export LIBCURL_VERSION_NUM LIBCURL_TIMESTAMP
76 ################################################################################
78 # OS/400 specific definitions.
80 ################################################################################
82 LIBIFSNAME="/QSYS.LIB/${TARGETLIB}.LIB"
85 ################################################################################
87 # Procedures.
89 ################################################################################
91 # action_needed dest [src]
93 # dest is an object to build
94 # if specified, src is an object on which dest depends.
96 # exit 0 (succeeds) if some action has to be taken, else 1.
98 action_needed()
101 [ ! -e "${1}" ] && return 0
102 [ "${2}" ] || return 1
103 [ "${1}" -ot "${2}" ] && return 0
104 return 1
108 # make_module module_name source_name [additional_definitions]
110 # Compile source name into ASCII module if needed.
111 # As side effect, append the module name to variable MODULES.
112 # Set LINK to "YES" if the module has been compiled.
114 make_module()
117 MODULES="${MODULES} ${1}"
118 MODIFSNAME="${LIBIFSNAME}/${1}.MODULE"
119 action_needed "${MODIFSNAME}" "${2}" || return 0;
121 # #pragma convert has to be in the source file itself, i.e.
122 # putting it in an include file makes it only active
123 # for that include file.
124 # Thus we build a temporary file with the pragma prepended to
125 # the source file and we compile that themporary file.
127 echo "#line 1 \"${2}\"" > __tmpsrcf.c
128 echo "#pragma convert(819)" >> __tmpsrcf.c
129 echo "#line 1" >> __tmpsrcf.c
130 cat "${2}" >> __tmpsrcf.c
131 CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('__tmpsrcf.c')"
132 # CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)"
133 CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST)"
134 CMD="${CMD} LOCALETYPE(*LOCALE)"
135 CMD="${CMD} INCDIR('/qibm/proddata/qadrt/include'"
136 CMD="${CMD} '${TOPDIR}/include/curl' '${TOPDIR}/include'"
137 CMD="${CMD} '${TOPDIR}/packages/OS400' ${INCLUDES})"
138 CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
139 CMD="${CMD} OUTPUT(${OUTPUT})"
140 CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
141 CMD="${CMD} DBGVIEW(${DEBUG})"
143 if [ "${3}" ]
144 then CMD="${CMD} DEFINE(${3})"
147 system "${CMD}"
148 rm -f __tmpsrcf.c
149 LINK=YES
153 # Determine DB2 object name from IFS name.
155 db2_name()
158 basename "${1}" |
159 tr '[a-z-]' '[A-Z_]' |
160 sed -e 's/\..*//' \
161 -e 's/^\(..........\).*/\1/'
165 # Copy IFS file replacing version info.
167 versioned_copy()
170 sed -e "s/@LIBCURL_VERSION@/${LIBCURL_VERSION}/g" \
171 -e "s/@LIBCURL_VERSION_MAJOR@/${LIBCURL_VERSION_MAJOR}/g" \
172 -e "s/@LIBCURL_VERSION_MINOR@/${LIBCURL_VERSION_MINOR}/g" \
173 -e "s/@LIBCURL_VERSION_PATCH@/${LIBCURL_VERSION_PATCH}/g" \
174 -e "s/@LIBCURL_VERSION_NUM@/${LIBCURL_VERSION_NUM}/g" \
175 -e "s/@LIBCURL_TIMESTAMP@/${LIBCURL_TIMESTAMP}/g" \
176 < "${1}" > "${2}"