Imported Upstream version 7.21.3
[platform/upstream/curl.git] / packages / OS400 / make-lib.sh
1 #!/bin/sh
2 #
3 #       libcurl compilation script for the OS/400.
4 #
5
6 SCRIPTDIR=`dirname "${0}"`
7 . "${SCRIPTDIR}/initscript.sh"
8 cd "${TOPDIR}/lib"
9
10
11 #      Create and compile the identification source file.
12
13 echo '#pragma comment(user, "libcurl version '"${LIBCURL_VERSION}"'")' > os400.c
14 echo '#pragma comment(date)' >> os400.c
15 echo '#pragma comment(copyright, "Copyright (C) 1998-2010 Daniel Stenberg et al. OS/400 version by P. Monnerat")' >> os400.c
16 make_module     OS400           os400.c
17 LINK=                           # No need to rebuild service program yet.
18 MODULES=
19
20
21 #       Get source list.
22
23 CSOURCES()
24
25 {
26         shift                   # Drop the equal sign.
27         CSOURCES="$*"           # Get the file names.
28 }
29
30 HHEADERS()
31
32 {
33         shift                   # Drop the equal sign.
34         HHEADERS="$*"           # Get the file names.
35 }
36
37 . Makefile.inc
38
39
40 #       Compile the sources into modules.
41
42 INCLUDES="'`pwd`'"
43
44 make_module     OS400SYS        "${SCRIPTDIR}/os400sys.c"
45 make_module     CCSIDCURL       "${SCRIPTDIR}/ccsidcurl.c"
46
47 for SRC in ${CSOURCES}
48 do      MODULE=`basename "${SRC}" .c |
49                 tr '[a-z]' '[A-Z]'   |
50                 sed -e 's/^\(..........\).*/\1/'`
51         make_module "${MODULE}" "${SRC}"
52 done
53
54
55 #       If needed, (re)create the static binding directory.
56
57 if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
58 then    LINK=YES
59 fi
60
61 if [ "${LINK}" ]
62 then    rm -rf "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
63         CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${STATBNDDIR})"
64         CMD="${CMD} TEXT('LibCurl API static binding directory')"
65         system "${CMD}"
66
67         for MODULE in ${MODULES}
68         do      CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})"
69                 CMD="${CMD} OBJ((${TARGETLIB}/${MODULE} *MODULE))"
70                 system "${CMD}"
71         done
72 fi
73
74
75 #       The exportation file for service program creation must be in a DB2
76 #               source file, so make sure it exists.
77
78 if action_needed "${LIBIFSNAME}/TOOLS.FILE"
79 then    CMD="CRTSRCPF FILE(${TARGETLIB}/TOOLS) RCDLEN(112)"
80         CMD="${CMD} TEXT('curl: build tools')"
81         system "${CMD}"
82 fi
83
84
85 #       Gather the list of symbols to export.
86
87 EXPORTS=`grep '^CURL_EXTERN[    ]'                                      \
88               "${TOPDIR}"/include/curl/*.h                              \
89               "${SCRIPTDIR}/ccsidcurl.h"                                |
90          sed -e 's/^.*CURL_EXTERN[      ]\(.*\)(.*$/\1/'                \
91              -e 's/[    ]*$//'                                          \
92              -e 's/^.*[         ][      ]*//'                           \
93              -e 's/^\*//'                                               \
94              -e 's/(\(.*\))/\1/'`
95
96 #       Create the service program exportation file in DB2 member if needed.
97
98 BSF="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR"
99
100 if action_needed "${BSF}" Makefile.am
101 then    LINK=YES
102 fi
103
104 if [ "${LINK}" ]
105 then    echo " STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('LIBCURL_${SONAME}')" \
106             > "${BSF}"
107         for EXPORT in ${EXPORTS}
108         do      echo ' EXPORT    SYMBOL("'"${EXPORT}"'")' >> "${BSF}"
109         done
110
111         echo ' ENDPGMEXP' >> "${BSF}"
112 fi
113
114
115 #       Build the service program if needed.
116
117 if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM"
118 then    LINK=YES
119 fi
120
121 if [ "${LINK}" ]
122 then    CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})"
123         CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(BNDSRC)"
124         CMD="${CMD} MODULE(${TARGETLIB}/OS400)"
125         CMD="${CMD} BNDDIR(${TARGETLIB}/${STATBNDDIR})"
126         CMD="${CMD} BNDSRVPGM(QADRTTS QGLDCLNT QGLDBRDR)"
127         CMD="${CMD} TEXT('curl API library')"
128         CMD="${CMD} TGTRLS(${TGTRLS})"
129         system "${CMD}"
130         LINK=YES
131 fi
132
133
134 #       If needed, (re)create the dynamic binding directory.
135
136 if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
137 then    LINK=YES
138 fi
139
140 if [ "${LINK}" ]
141 then    rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
142         CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
143         CMD="${CMD} TEXT('LibCurl API dynamic binding directory')"
144         system "${CMD}"
145         CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
146         CMD="${CMD} OBJ((*LIBL/${SRVPGM} *SRVPGM))"
147         system "${CMD}"
148 fi
149
150
151 #       Rebuild the formdata test if needed.
152
153 if [ "${TEST_FORMDATA}" ]
154 then    MODULES=
155         make_module TFORMDATA   formdata.c      "'_FORM_DEBUG' 'CURLDEBUG'"
156         make_module TSTREQUAL   strequal.c      "'_FORM_DEBUG' 'CURLDEBUG'"
157         make_module TMEMDEBUG   memdebug.c      "'_FORM_DEBUG' 'CURLDEBUG'"
158         make_module TMPRINTF    mprintf.c       "'_FORM_DEBUG' 'CURLDEBUG'"
159         make_module TSTRERROR   strerror.c      "'_FORM_DEBUG' 'CURLDEBUG'"
160         #       The following modules should not be needed (see comment in
161         #               formdata.c. However, there are some unsatisfied
162         #               external references leading in the following
163         #               modules to be (recursively) needed.
164         MODULES="${MODULES} EASY STRDUP SSLGEN QSSL HOSTIP HOSTIP4 HOSTIP6"
165         MODULES="${MODULES} URL HASH TRANSFER GETINFO COOKIE SENDF SELECT"
166         MODULES="${MODULES} INET_NTOP SHARE HOSTTHRE MULTI LLIST FTP HTTP"
167         MODULES="${MODULES} HTTP_DIGES HTTP_CHUNK HTTP_NEGOT TIMEVAL HOSTSYN"
168         MODULES="${MODULES} CONNECT SOCKS PROGRESS ESCAPE INET_PTON GETENV"
169         MODULES="${MODULES} DICT LDAP TELNET FILE TFTP NETRC PARSEDATE"
170         MODULES="${MODULES} SPEEDCHECK SPLAY BASE64 SECURITY IF2IP MD5"
171         MODULES="${MODULES} KRB5 OS400SYS"
172
173         PGMIFSNAME="${LIBIFSNAME}/TFORMDATA.PGM"
174
175         if action_needed "${PGMIFSNAME}"
176         then    LINK=YES
177         fi
178
179         if [ "${LINK}" ]
180         then    CMD="CRTPGM PGM(${TARGETLIB}/TFORMDATA)"
181                 CMD="${CMD} ENTMOD(QADRT/QADRTMAIN2)"
182                 CMD="${CMD} MODULE("
183
184                 for MODULE in ${MODULES}
185                 do      CMD="${CMD} ${TARGETLIB}/${MODULE}"
186                 done
187
188                 CMD="${CMD} ) BNDSRVPGM(QADRTTS)"
189                 CMD="${CMD} TGTRLS(${TGTRLS})"
190                 system "${CMD}"
191         fi
192 fi