makelibzmq 1.51 KB
Newer Older
1
#! /bin/sh
2 3 4 5 6 7 8 9 10
# Build libzmq.a static library and libzmq.so dynamic library
#
# Usage: makelibzmq
#        BUILD_DLL=false makelibzmq     # Skip building DLL
#
# NOTE: We do a single compile run for both static and dynamic libraries
# which results in the static library having -Wc,exportall compiled objects;
# in practice this doesn't seem to cause a problem beyond using some extra
# space (around 10%).
11 12
#
# Written by Ewen McNeill <ewen@imatix.com>, 2014-07-21
13
# Updated by Ewen McNeill <ewen@imatix.com>, 2014-07-22
14 15 16 17
#---------------------------------------------------------------------------

set -e    # Stop on errors

18 19
BUILD_DLL="${BUILD_DLL:-true}"     # Build DLL by default

20 21 22 23 24 25 26 27
# 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
28
ZCXX="${BIN_DIR}/zc++"
29 30 31 32 33 34 35 36

# Locate top of source tree, assuming we're in builds/zos
TOP="${BIN_DIR}/../.."
SRC="${TOP}/src"

# Install pre-generated platform.hpp
cp -p "${BIN_DIR}/platform.hpp" "${SRC}/platform.hpp"

37 38 39 40 41 42 43
# Compile all the source (optionally ready for a DLL)
if [ "${BUILD_DLL}" = "true" ]; then
  ZCXXFLAGS="${ZCXXFLAGS} -Wc,exportall"
  export ZCXXFLAGS
  #echo "Building DLL with ${ZCXXFLAGS}"
fi

44 45 46 47 48
cd "${SRC}"
"${BIN_DIR}/cxxall"

# Make static library
ar r libzmq.a *.o
49 50 51 52 53 54

# Optionally Make dynamic library
if [ "${BUILD_DLL}" = "true" ]; then
  #echo "Building libzmq.so DLL"
  "${ZCXX}" -Wl,DLL -o libzmq.so *.o
fi