configure 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/bin/sh
  2. #
  3. # Copyright 2016 Garrett D'Amore <garrett@damore.org>
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"),
  7. # to deal in the Software without restriction, including without limitation
  8. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. # and/or sell copies of the Software, and to permit persons to whom
  10. # the Software is furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included
  13. # in all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. # IN THE SOFTWARE.
  22. #
  23. #
  24. # This configure script provides the usual autoconf style interface for
  25. # installation, but simply uses cmake.
  26. #
  27. SRCDIR=`dirname $0`
  28. CURDIR=`pwd`
  29. strip_arg()
  30. {
  31. x=`echo "$1" | sed "s/[^=]*=//"`
  32. eval $2=\"$x\"
  33. }
  34. warn() {
  35. echo "$*" 1>&2
  36. }
  37. find_prog() {
  38. SIFS="${IFS= }"
  39. IFS=:
  40. for p in $PATH; do
  41. if [ -x ${p}/$1 ]
  42. then
  43. IFS="${SIFS}"
  44. echo "${p}/${1}"
  45. return 0
  46. fi
  47. done
  48. IFS="${SIFS}"
  49. return 1
  50. }
  51. need_cmake() {
  52. warn "This program requires CMake 2.6 or newer to build."
  53. warn "Obtain CMake from www.cmake.org"
  54. exit 1
  55. }
  56. help() {
  57. echo "This configure script is a convenience wrapper around"
  58. echo "CMake. Only a limited subset of configuration options"
  59. echo "are supported. For a fully featured build, use CMake".
  60. echo
  61. echo "Execute as $0 [options]"
  62. echo
  63. echo "Options supported are:"
  64. echo
  65. echo " --prefix={path} Set installation directory prefix."
  66. echo " --with-cmake={path} Location of CMake executable."
  67. echo
  68. exit 1
  69. }
  70. # Argument parsing
  71. PREFIX=/usr/local
  72. while [ -n "$1" ]; do
  73. case "$1" in
  74. --with-cmake)
  75. CMAKE="$2"
  76. shift 2
  77. ;;
  78. --with-cmake=*)
  79. strip_arg "$1" CMAKE
  80. shift
  81. ;;
  82. --prefix)
  83. if [ -z "$2" ]; then
  84. help
  85. fi
  86. PREFIX="$2"
  87. shift 2
  88. ;;
  89. --prefix=*)
  90. strip_arg "$1" PREFIX
  91. shift
  92. ;;
  93. *)
  94. help
  95. ;;
  96. esac
  97. done
  98. if [ -z "${CMAKE}" ]; then
  99. CMAKE=`find_prog cmake` || need_cmake
  100. fi
  101. if [ -f src/nn.h ]
  102. then
  103. warn "NOTE: Building in the source directory is not recommended."
  104. fi
  105. GENERATOR="Unix Makefiles"
  106. "$CMAKE" -G "$GENERATOR" "-DCMAKE_INSTALL_PREFIX=$PREFIX" $SRCDIR