cxxall 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #! /bin/sh
  2. # Attempt to compile all *.cpp files in the current directory, that are
  3. # not already compiled. Uses zc++ wrapper around C++ compiler, to add
  4. # additional compile arguments.
  5. #
  6. # Written by Ewen McNeill <ewen@imatix.com>, 2014-07-19
  7. # Updated by Ewen McNeill <ewen@imatix.com>, 2014-07-24
  8. #---------------------------------------------------------------------------
  9. VERBOSE="${VERBOSE:-}" # Set to non-empty for already done status
  10. export VERBOSE
  11. # Locate compiler wrapper
  12. BIN_DIR=$(dirname $0)
  13. if [ -z "${BIN_DIR}" ]; then BIN_DIR="."; fi
  14. case "${BIN_DIR}" in
  15. .) BIN_DIR="$(pwd)"; ;;
  16. /*) ;;
  17. *) BIN_DIR="$(pwd)/${BIN_DIR}"; ;;
  18. esac
  19. ZCXX="${BIN_DIR}/zc++"
  20. # Determine compile flags
  21. CPPFLAGS="-D_XOPEN_SOURCE_EXTENDED=1 -D_OPEN_THREADS=3 -D_OPEN_SYS_SOCK_IPV6"
  22. CXXFLAGS="-DZMQ_HAVE_ZOS -DHAVE_CONFIG_H -D_REENTRANT -D_THREAD_SAFE -DZMQ_USE_POLL"
  23. case $(pwd) in
  24. *src) CXXFLAGS="${CXXFLAGS} -I."
  25. ;;
  26. *tests) CXXFLAGS="${CXXFLAGS} -I. -I../src -I../include"
  27. ;;
  28. *) echo "Currently only builds in src/ and tests/" >&2
  29. exit 1
  30. ;;
  31. esac
  32. skip() {
  33. SRC="$1"
  34. OBJ="$2"
  35. if [ -n "${VERBOSE}" ]; then
  36. echo " ${SRC} compiled already"
  37. fi
  38. }
  39. compile() {
  40. SRC="$1"
  41. OBJ="$2"
  42. echo "CXX ${SRC}"
  43. "${ZCXX}" ${CXXFLAGS} ${CPPFLAGS} -+ -c -o "${OBJ}" "${SRC}"
  44. }
  45. for SRC in *.cpp; do
  46. OBJ=$(echo $SRC | sed 's/\.cpp/.o/;')
  47. if [ -f "${OBJ}" ]; then
  48. if [ "${OBJ}" -nt "${SRC}" ]; then
  49. skip "${SRC}" "${OBJ}"
  50. else
  51. compile "${SRC}" "${OBJ}"
  52. fi
  53. else
  54. compile "${SRC}" "${OBJ}"
  55. fi
  56. done