#! /bin/sh # Build tests/* executables; assumes that libzmq.a is already built # # Written by Ewen McNeill , 2014-07-21 # Updated by Ewen McNeill , 2014-07-22 #--------------------------------------------------------------------------- set -e # Stop on errors VERBOSE="${VERBOSE:-}" # Set to non-empty for already done status export VERBOSE # Figure out where we are BIN_DIR=$(dirname $0) if [ -z "${BIN_DIR}" ]; then BIN_DIR="."; fi case "${BIN_DIR}" in .) BIN_DIR="$(pwd)"; ;; /*) ;; *) BIN_DIR="$(pwd)/${BIN_DIR}"; ;; esac # Locate compiler wrapper ZCXX="${BIN_DIR}/zc++" # Locate top of source tree, assuming we're in builds/zos TOP="${BIN_DIR}/../.." SRC="${TOP}/src" TESTS="${TOP}/tests" if [ -f "${SRC}/platform.hpp" -a -f "${SRC}/libzmq.a" ]; then : else echo "Error: run makezmqlib to build libzmq.a first" >&2 exit 1 fi # Copy in replacement test with timeout, if main version is not already # up to date # if [ -f "${TESTS}/test_fork.cpp" ] && grep "TIMEOUT" "${TESTS}/test_fork.cpp" >/dev/null 2>&1; then : # Already copied in else echo "Updating test_fork.cpp to version with master timeout" cp -p "${BIN_DIR}/test_fork.cpp" "${TESTS}/test_fork.cpp" fi # Compile all the source cd "${TESTS}" "${BIN_DIR}/cxxall" # Link all the executables that are not already linked skip() { OBJ="$1" EXE="$2" if [ -n "${VERBOSE}" ]; then echo "${OBJ} linked to ${EXE}" fi } compile() { OBJ="$1" EXE="$2" echo " LD ${EXE}" "${ZCXX}" -L ../src -o "${EXE}" "${OBJ}" -lzmq } for OBJ in *.o; do EXE=$(echo "${OBJ}" | sed 's/\.o//;') if [ -f "${EXE}" ]; then if [ "${EXE}" -nt "${OBJ}" ]; then skip "${OBJ}" "${EXE}" else compile "${OBJ}" "${EXE}" fi else compile "${OBJ}" "${EXE}" fi done