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