• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.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#       tests compilation script for the OS/400.
25#
26
27
28SCRIPTDIR=`dirname "${0}"`
29. "${SCRIPTDIR}/initscript.sh"
30cd "${TOPDIR}/tests"
31
32
33#       tests directory not implemented yet.
34
35
36#       Process the libtest subdirectory.
37
38cd libtest
39
40#       Get definitions from the Makefile.inc file.
41#       The `sed' statement works as follows:
42#       _ Join \nl-separated lines.
43#       _ Retain only lines that begins with "identifier =".
44#       _ Turn these lines into shell variable assignments.
45
46eval "`sed -e ': begin'                                                 \
47        -e '/\\\\$/{'                                                   \
48        -e 'N'                                                          \
49        -e 's/\\\\\\n/ /'                                               \
50        -e 'b begin'                                                    \
51        -e '}'                                                          \
52        -e '/^[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[=]/b keep'             \
53        -e 'd'                                                          \
54        -e ': keep'                                                     \
55        -e 's/[[:space:]]*=[[:space:]]*/=/'                             \
56        -e 's/=\\(.*[^[:space:]]\\)[[:space:]]*$/=\\"\\1\\"/'           \
57        -e 's/\\$(\\([^)]*\\))/${\\1}/g'                                \
58        < Makefile.inc`"
59
60#       Special case: redefine chkhostname compilation parameters.
61
62chkhostname_SOURCES=chkhostname.c
63chkhostname_LDADD=curl_gethostname.o
64
65#       Compile all programs.
66#       The list is found in variable "noinst_PROGRAMS"
67
68INCLUDES="'${TOPDIR}/tests/libtest' '${TOPDIR}/lib'"
69
70for PGM in ${noinst_PROGRAMS}
71do      DB2PGM=`db2_name "${PGM}"`
72        PGMIFSNAME="${LIBIFSNAME}/${DB2PGM}.PGM"
73
74        #       Extract preprocessor symbol definitions from compilation
75        #               options for the program.
76
77        PGMCFLAGS="`eval echo \"\\${${PGM}_CFLAGS}\"`"
78        PGMDEFINES=
79
80        for FLAG in ${PGMCFLAGS}
81        do      case "${FLAG}" in
82                -D?*)   DEFINE="`echo \"${FLAG}\" | sed 's/^..//'`"
83                        PGMDEFINES="${PGMDEFINES} '${DEFINE}'"
84                        ;;
85                esac
86        done
87
88        #        Compile all C sources for the program into modules.
89
90        PGMSOURCES="`eval echo \"\\${${PGM}_SOURCES}\"`"
91        LINK=
92        MODULES=
93
94        for SOURCE in ${PGMSOURCES}
95        do      case "${SOURCE}" in
96                *.c)    #       Special processing for libxxx.c files: their
97                        #               module name is determined by the target
98                        #               PROGRAM name.
99
100                        case "${SOURCE}" in
101                        lib*.c) MODULE="${DB2PGM}"
102                                ;;
103                        *)      MODULE=`db2_name "${SOURCE}"`
104                                ;;
105                        esac
106
107                        make_module "${MODULE}" "${SOURCE}" "${PGMDEFINES}"
108                        if action_needed "${PGMIFSNAME}" "${MODIFSNAME}"
109                        then    LINK=yes
110                        fi
111                        ;;
112                esac
113        done
114
115        #       Link program if needed.
116
117        if [ "${LINK}" ]
118        then    PGMLDADD="`eval echo \"\\${${PGM}_LDADD}\"`"
119                for LDARG in ${PGMLDADD}
120                do      case "${LDARG}" in
121                        -*)     ;;              # Ignore non-module.
122                        *)      MODULES="${MODULES} "`db2_name "${LDARG}"`
123                                ;;
124                        esac
125                done
126                MODULES="`echo \"${MODULES}\" |
127                    sed \"s/[^ ][^ ]*/${TARGETLIB}\/&/g\"`"
128                CMD="CRTPGM PGM(${TARGETLIB}/${DB2PGM})"
129                CMD="${CMD} ENTMOD(QADRT/QADRTMAIN2)"
130                CMD="${CMD} MODULE(${MODULES})"
131                CMD="${CMD} BNDSRVPGM(${TARGETLIB}/${SRVPGM} QADRTTS)"
132                CMD="${CMD} TGTRLS(${TGTRLS})"
133                system "${CMD}"
134        fi
135done
136