remove the CVSish $Id$ lines
[platform/upstream/curl.git] / packages / OS400 / make-tests.sh
1 #!/bin/sh
2 #
3 #       tests compilation script for the OS/400.
4 #
5
6
7 SCRIPTDIR=`dirname "${0}"`
8 . "${SCRIPTDIR}/initscript.sh"
9 cd "${TOPDIR}/tests"
10
11
12 #       tests directory not implemented yet.
13
14
15 #       Process the libtest subdirectory.
16
17 cd 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
25 eval "`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_]*[   ]*[=]/b keep'                   \
32         -e 'd'                                                          \
33         -e ': keep'                                                     \
34         -e 's/[         ]*=[    ]*/=/'                                  \
35         -e 's/=\\(.*[^  ]\\)[   ]*$/=\\"\\1\\"/'                        \
36         -e 's/\\$(\\([^)]*\\))/${\\1}/g'                                \
37         < Makefile.inc`"
38
39 #       Compile all programs.
40 #       The list is found in variable "noinst_PROGRAMS"
41
42 INCLUDES="'${TOPDIR}/tests/libtest' '${TOPDIR}/lib'"
43
44 for PGM in ${noinst_PROGRAMS}
45 do      DB2PGM=`db2_name "${PGM}"`
46         PGMIFSNAME="${LIBIFSNAME}/${DB2PGM}.PGM"
47
48         #       Extract preprocessor symbol definitions from compilation
49         #               options for the program.
50
51         PGMCFLAGS="`eval echo \"\\${${PGM}_CFLAGS}\"`"
52         PGMDEFINES=
53
54         for FLAG in ${PGMCFLAGS}
55         do      case "${FLAG}" in
56                 -D?*)   DEFINE="`echo \"${FLAG}\" | sed 's/^..//'`"
57                         PGMDEFINES="${PGMDEFINES} '${DEFINE}'"
58                         ;;
59                 esac
60         done
61
62         #        Compile all C sources for the program into modules.
63
64         PGMSOURCES="`eval echo \"\\${${PGM}_SOURCES}\"`"
65         LINK=
66         MODULES=
67
68         for SOURCE in ${PGMSOURCES}
69         do      case "${SOURCE}" in
70                 *.c)    #       Special processing for libxxx.c files: their
71                         #               module name is determined by the target
72                         #               PROGRAM name.
73
74                         case "${SOURCE}" in
75                         lib*.c) MODULE="${DB2PGM}"
76                                 ;;
77                         *)      MODULE=`db2_name "${SOURCE}"`
78                                 ;;
79                         esac
80
81                         make_module "${MODULE}" "${SOURCE}" "${PGMDEFINES}"
82                         if action_needed "${PGMIFSNAME}" "${MODIFSNAME}"
83                         then    LINK=yes
84                         fi
85                         ;;
86                 esac
87         done
88
89         #       Link program if needed.
90
91         if [ "${LINK}" ]
92         then    MODULES="`echo \"${MODULES}\" |
93                     sed \"s/[^ ][^ ]*/${TARGETLIB}\/&/g\"`"
94                 CMD="CRTPGM PGM(${TARGETLIB}/${DB2PGM})"
95                 CMD="${CMD} ENTMOD(QADRT/QADRTMAIN2)"
96                 CMD="${CMD} MODULE(${MODULES})"
97                 CMD="${CMD} BNDSRVPGM(${TARGETLIB}/${SRVPGM} QADRTTS)"
98                 CMD="${CMD} TGTRLS(${TGTRLS})"
99                 system "${CMD}"
100         fi
101 done