Debian Codegraph @

builds/zos/maketests

raw symbols SCIP
1 #! /bin/sh
2 # Build tests/* executables; assumes that libzmq.a or libzmq.so/libzmq.x
3 # is already built
4 #
5 # If libzmq.so and libzmq.x exist, then dynamic linking is used, otherwise
6 # static linking is used.
7 #
8 # Written by Ewen McNeill <[email protected]>, 2014-07-21
9 # Updated by Ewen McNeill <[email protected]>, 2014-07-22
10 #---------------------------------------------------------------------------
11
12 set -e # Stop on errors
13
14 VERBOSE="${VERBOSE:-}" # Set to non-empty for already done status
15 export VERBOSE
16
17 # Figure out where we are
18 BIN_DIR=$(dirname $0)
19 if [ -z "${BIN_DIR}" ]; then BIN_DIR="."; fi
20 case "${BIN_DIR}" in
21 .) BIN_DIR="$(pwd)"; ;;
22 /*) ;;
23 *) BIN_DIR="$(pwd)/${BIN_DIR}"; ;;
24 esac
25
26 # Locate compiler wrapper
27 ZCXX="${BIN_DIR}/zc++"
28
29 # Locate top of source tree, assuming we're in builds/zos
30 TOP="${BIN_DIR}/../.."
31 SRC="${TOP}/src"
32 TESTS="${TOP}/tests"
33
34 # Figure out how we are going to link to ZMQ
35 LINK_TYPE=unknown
36
37 if [ -f "${SRC}/platform.hpp" -a -f "${SRC}/libzmq.so" -a -f "${SRC}/libzmq.x" ]; then
38 LINK_TYPE=dynamic
39 elif [ -f "${SRC}/platform.hpp" -a -f "${SRC}/libzmq.a" ]; then
40 LINK_TYPE=static
41 else
42 echo "Error: run makezmqlib to build libzmq.a and/or libzmq.so/libzmq.x first" >&2
43 exit 1
44 fi
45
46 # Copy in replacement test with timeout, if main version is not already
47 # up to date
48 #
49 if [ -f "${TESTS}/test_fork.cpp" ] &&
50 grep "TIMEOUT" "${TESTS}/test_fork.cpp" >/dev/null 2>&1; then
51 : # Already copied in
52 else
53 echo "Updating test_fork.cpp to version with master timeout"
54 cp -p "${BIN_DIR}/test_fork.cpp" "${TESTS}/test_fork.cpp"
55 fi
56
57 # Compile all the source
58 if [ "${LINK_TYPE}" = "dynamic" ]; then
59 ZCXXFLAGS="${ZCXXFLAGS} -Wc,DLL"
60 export ZXCCFLAGS
61 echo "Building tests to use DLL: ${ZCXXFLAGS}"
62 fi
63
64 cd "${TESTS}"
65 "${BIN_DIR}/cxxall"
66
67 # Link all the executables that are not already linked
68 skip() {
69 OBJ="$1"
70 EXE="$2"
71 if [ -n "${VERBOSE}" ]; then
72 echo "${OBJ} linked to ${EXE}"
73 fi
74 }
75
76 link() {
77 OBJ="$1"
78 EXE="$2"
79 echo " LD ${EXE}"
80 case "${LINK_TYPE}" in
81 static) "${ZCXX}" -L ../src -o "${EXE}" "${OBJ}" -lzmq
82 ;;
83 dynamic) "${ZCXX}" -o "${EXE}" "${OBJ}" ../src/libzmq.x
84 ;;
85 *) echo "Do not know how to do ${LINK_TYPE} linking!" 2>&1
86 exit 1
87 ;;
88 esac
89 }
90
91 for OBJ in *.o; do
92 EXE=$(echo "${OBJ}" | sed 's/\.o//;')
93 if [ -f "${EXE}" ]; then
94 if [ "${EXE}" -nt "${OBJ}" ]; then
95 skip "${OBJ}" "${EXE}"
96 else
97 link "${OBJ}" "${EXE}"
98 fi
99 else
100 link "${OBJ}" "${EXE}"
101 fi
102 done