• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2#***************************************************************************
3#                                  _   _ ____  _
4#  Project                     ___| | | |  _ \| |
5#                             / __| | | | |_) | |
6#                            | (__| |_| |  _ <| |___
7#                             \___|\___/|_| \_\_____|
8#
9# Copyright (C) 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.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# SPDX-License-Identifier: curl
23#
24###########################################################################
25#
26#       tests compilation script for the OS/400.
27#
28
29
30SCRIPTDIR=`dirname "${0}"`
31. "${SCRIPTDIR}/initscript.sh"
32cd "${TOPDIR}/tests"
33
34
35#       Build programs in a directory.
36
37build_all_programs()
38
39{
40        #       Compile all programs.
41        #       The list is found in variable "noinst_PROGRAMS"
42
43        INCLUDES="'`pwd`' '${TOPDIR}/lib' '${TOPDIR}/src'"
44        MODS="${1}"
45        SRVPGMS="${2}"
46
47        for PGM in ${noinst_PROGRAMS}
48        do      DB2PGM=`db2_name "${PGM}"`
49                PGMIFSNAME="${LIBIFSNAME}/${DB2PGM}.PGM"
50
51                #       Extract preprocessor symbol definitions from
52                #               compilation options for the program.
53
54                PGMCFLAGS="`eval echo \"\\${${PGM}_CFLAGS}\"`"
55                PGMDFNS=
56
57                for FLAG in ${PGMCFLAGS}
58                do      case "${FLAG}" in
59                        -D?*)   DEFINE="`echo \"${FLAG}\" | sed 's/^..//'`"
60                                PGMDFNS="${PGMDFNS} '${DEFINE}'"
61                                ;;
62                        esac
63                done
64
65                #        Compile all C sources for the program into modules.
66
67                PGMSOURCES="`eval echo \"\\${${PGM}_SOURCES}\"`"
68                LINK=
69                MODULES=
70
71                for SOURCE in ${PGMSOURCES}
72                do      case "${SOURCE}" in
73                        *.c)    #       Special processing for libxxx.c files:
74                                #               their module name is determined
75                                #               by the target PROGRAM name.
76
77                                case "${SOURCE}" in
78                                lib*.c) MODULE="${DB2PGM}"
79                                        ;;
80                                *)      MODULE=`db2_name "${SOURCE}"`
81                                        ;;
82                                esac
83
84                                #       If source is in a sibling directory,
85                                #               prefix module name with 'X'.
86
87                                case "${SOURCE}" in
88                                ../*)   MODULE=`db2_name "X${MODULE}"`
89                                            ;;
90                                esac
91
92                                make_module "${MODULE}" "${SOURCE}" "${PGMDFNS}"
93                                if action_needed "${PGMIFSNAME}" "${MODIFSNAME}"
94                                then    LINK=yes
95                                fi
96                                ;;
97                        esac
98                done
99
100                #       Link program if needed.
101
102                if [ "${LINK}" ]
103                then    PGMLDADD="`eval echo \"\\${${PGM}_LDADD}\"`"
104                        for ARG in ${PGMLDADD}
105                        do      case "${ARG}" in
106                                -*)     ;;              # Ignore non-module.
107                                *)      MODULES="${MODULES} "`db2_name "${ARG}"`
108                                        ;;
109                                esac
110                        done
111                        MODULES="`echo \"${MODULES}\" |
112                            sed \"s/[^ ][^ ]*/${TARGETLIB}\/&/g\"`"
113                        CMD="CRTPGM PGM(${TARGETLIB}/${DB2PGM})"
114                        CMD="${CMD} ENTMOD(${TARGETLIB}/CURLMAIN)"
115                        CMD="${CMD} MODULE(${MODULES} ${MODS})"
116                        CMD="${CMD} BNDSRVPGM(${SRVPGMS} QADRTTS)"
117                        CMD="${CMD} TGTRLS(${TGTRLS})"
118                        CLcommand "${CMD}"
119                fi
120        done
121}
122
123
124#       Build programs in the server directory.
125
126(
127        cd server
128        get_make_vars Makefile.inc
129        build_all_programs "${TARGETLIB}/OS400SYS"
130)
131
132
133#       Build all programs in the libtest subdirectory.
134
135(
136        cd libtest
137        get_make_vars Makefile.inc
138
139        #       Special case: redefine chkhostname compilation parameters.
140
141        chkhostname_SOURCES=chkhostname.c
142        chkhostname_LDADD=curl_gethostname.o
143
144        build_all_programs "" "${TARGETLIB}/${SRVPGM}"
145)
146