Diff of /configure [000000] .. [413088]

Switch to unified view

a b/configure
1
#!/bin/sh
2
# Anticonf (tm) script by Jeroen Ooms (2020)
3
PKG_CONFIG_NAME="opencv4"
4
PKG_CONFIG_NAME_ALT="opencv"
5
PKG_DEB_NAME="libopencv-dev"
6
PKG_RPM_NAME="opencv-devel"
7
PKG_TEST_HEADER="<opencv2/opencv.hpp>"
8
PKG_TEST_HEADER_XFEATURES2D="<opencv2/xfeatures2d.hpp>"
9
PKG_LIBS="-lopencv_{stitching,superres,videostab,aruco,bgsegm,bioinspired,ccalib,dnn_objdetect,\
10
dpm,face,photo,fuzzy,hfs,img_hash,line_descriptor,optflow,reg,rgbd,saliency,stereo,structured_light,\
11
phase_unwrapping,surface_matching,tracking,datasets,dnn,plot,xfeatures2d,shape,video,ml,ximgproc,\
12
calib3d,features2d,highgui,videoio,flann,xobjdetect,imgcodecs,objdetect,xphoto,imgproc,core}"
13
14
# Use pkg-config if available
15
PCVERSION=`pkg-config --version 2>/dev/null`
16
if [ $? -eq 0 ]; then
17
  echo "This is pkg-config $PCVERSION"
18
  if pkg-config --exists ${PKG_CONFIG_NAME} ; then
19
    PKGCONFIG_CFLAGS=`pkg-config --cflags ${PKG_CONFIG_NAME}`
20
    PKGCONFIG_LIBS=`pkg-config --libs ${PKG_CONFIG_NAME}`
21
    PKGCONFIG_PREFIX=`pkg-config --variable=prefix ${PKG_CONFIG_NAME}`
22
  elif pkg-config --exists ${PKG_CONFIG_NAME_ALT}; then
23
    PKGCONFIG_CFLAGS=`pkg-config --cflags ${PKG_CONFIG_NAME_ALT}`
24
    PKGCONFIG_LIBS=`pkg-config --libs ${PKG_CONFIG_NAME_ALT}`
25
    PKGCONFIG_PREFIX=`pkg-config --variable=prefix ${PKG_CONFIG_NAME_ALT}`
26
  fi
27
fi
28
29
# Note that cflags may be empty in case of success
30
if [ "$PKGCONFIG_CFLAGS" ] || [ "$PKGCONFIG_LIBS" ]; then
31
  echo "Found pkg-config cflags and libs!"
32
  PKG_CFLAGS=${PKGCONFIG_CFLAGS}
33
  PKG_LIBS=${PKGCONFIG_LIBS}
34
  if [ "$PKGCONFIG_PREFIX" ]; then
35
    PKG_CFLAGS="$PKG_CFLAGS -D_DATA_PREFIX=${PKGCONFIG_PREFIX}"
36
  fi
37
elif [ `uname` = "Darwin" ]; then
38
  curl -sfL "https://autobrew.github.io/scripts/opencv" > autobrew
39
    . ./autobrew
40
  uniq cleanup > cleanup_tmp && mv cleanup_tmp cleanup
41
fi
42
43
## adding additional features for Morpho derived C++ functions ### DELETE THIS LATER, Morpho no longer required!
44
# PKG_LIBS=$(echo $PKG_LIBS $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS))
45
# PKG_LIBS="$LAPACK_LIBS $BLAS_LIBS $FLIBS $PKG_LIBS"
46
47
# For debugging
48
echo "Using PKG_CFLAGS=$PKG_CFLAGS"
49
echo "Using PKG_LIBS=$PKG_LIBS"
50
51
# Use CXX17 if available (preferred for recent opencv)
52
CXX17=`${R_HOME}/bin/R CMD config CXX17` || unset CXX17
53
54
if [ "$CXX17" ]; then
55
echo "Found C++17 compiler: $CXX17"
56
CXXVER=CXX17
57
else
58
echo "Using C++11 compiler"
59
CXXVER=CXX11
60
fi
61
62
CXX=$($R_HOME/bin/R CMD config ${CXXVER})
63
CXXSTD=$($R_HOME/bin/R CMD config ${CXXVER}STD)
64
CXXFLAGS="$($R_HOME/bin/R CMD config ${CXXVER}FLAGS)"
65
CPPFLAGS="$($R_HOME/bin/R CMD config CPPFLAGS)"
66
CXXCPP="$CXX $CXXSTD -E"
67
68
# Test configuration
69
echo "#include $PKG_TEST_HEADER" | ${CXXCPP} ${CPPFLAGS} ${PKG_CFLAGS} ${CXXFLAGS} -xc++ - >/dev/null 2>configure.log
70
71
if [ $? -ne 0 ]; then
72
  echo "-----------------------------[ ANTICONF ]-------------------------------"
73
  echo "Configuration failed to find $PKG_CONFIG_NAME library. Try installing:"
74
  echo " * deb: $PKG_DEB_NAME (Debian, Ubuntu, etc)"
75
  echo " * rpm: $PKG_RPM_NAME (Fedora, CentOS, RHEL)"
76
  echo "If $PKG_CONFIG_NAME is already installed, check that 'pkg-config' is in your"
77
  echo "PATH and PKG_CONFIG_PATH contains a $PKG_CONFIG_NAME.pc file."
78
  echo "---------------------------[ ERROR MESSAGE ]----------------------------"
79
  cat configure.log
80
  echo "------------------------------------------------------------------------"
81
  exit 1
82
fi
83
84
echo "#include $PKG_TEST_HEADER_XFEATURES2D" | ${CXXCPP} ${CPPFLAGS} ${PKG_CFLAGS}  ${CXXFLAGS} -xc++ - >/dev/null 2>>configure.log
85
if [ $? -ne 0 ]; then
86
  echo "Module $PKG_TEST_HEADER_XFEATURES2D has not been found on your system"
87
  echo "Make sure to have an $PKG_CONFIG_NAME library installed with the module available"
88
  exit 1
89
else
90
  PKG_CFLAGS="$PKG_CFLAGS -DHAVE_XFEATURES2D"
91
fi
92
93
# Write to Makevars
94
sed -e "s|@cflags@|$PKG_CFLAGS|" -e "s|@libs@|$PKG_LIBS|" -e "s|CXX11|${CXXVER}|" src/Makevars.in > src/Makevars
95
96
# Success
97
exit 0
98
99
# Basilisk configuration
100
${R_HOME}/bin/Rscript -e "basilisk::configureBasiliskEnv()"