選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

69 行
2.4KB

  1. # Anticonf (tm) script inspired by Jeroen Ooms (2015)
  2. # This script will query 'pkg-config' for the required cflags and ldflags.
  3. # If pkg-config is unavailable or does not find the library, try setting
  4. # INCLUDE_DIR and LIB_DIR manually via e.g:
  5. # R CMD INSTALL --configure-vars='INCLUDE_DIR=/.../include LIB_DIR=/.../lib'
  6. # Library settings
  7. PKG_CONFIG_NAME="libpsl"
  8. PKG_DEB_NAME="libpsl-dev"
  9. PKG_RPM_NAME="libpsl-devel"
  10. PKG_CSW_NAME="libpsl_dev"
  11. PKG_TEST_HEADER="<libpsl.h>"
  12. PKG_LIBS="-lpsl"
  13. PKG_CFLAGS=""
  14. # Use pkg-config if available
  15. pkg-config --version >/dev/null 2>&1
  16. if [ $? -eq 0 ]; then
  17. PKGCONFIG_CFLAGS=`pkg-config --cflags ${PKG_CONFIG_NAME}`
  18. case "$PKGCONFIG_CFLAGS" in
  19. *PSL_STATICLIB*) PKGCONFIG_LIBS=`pkg-config --libs --static ${PKG_CONFIG_NAME}`;;
  20. *) PKGCONFIG_LIBS=`pkg-config --libs ${PKG_CONFIG_NAME}`;;
  21. esac
  22. fi
  23. # Note that cflags may be empty in case of success
  24. if [ "$INCLUDE_DIR" ] || [ "$LIB_DIR" ]; then
  25. echo "Found INCLUDE_DIR and/or LIB_DIR!"
  26. PKG_CFLAGS="-I$INCLUDE_DIR $PKG_CFLAGS"
  27. PKG_LIBS="-L$LIB_DIR $PKG_LIBS"
  28. elif [ "$PKGCONFIG_CFLAGS" ] || [ "$PKGCONFIG_LIBS" ]; then
  29. echo "Found pkg-config cflags and libs!"
  30. PKG_CFLAGS=${PKGCONFIG_CFLAGS}
  31. PKG_LIBS=${PKGCONFIG_LIBS}
  32. fi
  33. # Find compiler
  34. CC=`${R_HOME}/bin/R CMD config CC`
  35. CFLAGS=`${R_HOME}/bin/R CMD config CFLAGS`
  36. CPPFLAGS=`${R_HOME}/bin/R CMD config CPPFLAGS`
  37. # For debugging
  38. echo "Using PKG_CFLAGS=$PKG_CFLAGS"
  39. echo "Using PKG_LIBS=$PKG_LIBS"
  40. # Test configuration
  41. echo "#include $PKG_TEST_HEADER" | ${CC} ${CPPFLAGS} ${PKG_CFLAGS} ${CFLAGS} -E -xc - >/dev/null 2>&1 || R_CONFIG_ERROR=1;
  42. # Customize the error
  43. if [ $R_CONFIG_ERROR ]; then
  44. echo "------------------------- ANTICONF ERROR ---------------------------"
  45. echo "Configuration failed because $PKG_CONFIG_NAME was not found. Try installing:"
  46. echo " * deb: $PKG_DEB_NAME (Debian, Ubuntu, etc)"
  47. echo " * rpm: $PKG_RPM_NAME (Fedora, CentOS, RHEL)"
  48. echo " * csw: $PKG_CSW_NAME (Solaris)"
  49. echo "If $PKG_CONFIG_NAME is already installed, check that 'pkg-config' is in your"
  50. echo "PATH and PKG_CONFIG_PATH contains a $PKG_CONFIG_NAME.pc file. If pkg-config"
  51. echo "is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:"
  52. echo "R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'"
  53. echo "--------------------------------------------------------------------"
  54. exit 1;
  55. fi
  56. # Write to Makevars
  57. sed -e "s|@cflags@|$PKG_CFLAGS|" -e "s|@libs@|$PKG_LIBS|" src/Makevars.in > src/Makevars
  58. # Success
  59. exit 0