File: configure

package info (click to toggle)
r-cran-httpuv 1.6.15%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,292 kB
  • sloc: ansic: 6,499; cpp: 5,501; makefile: 103; sh: 56
file content (59 lines) | stat: -rwxr-xr-x 2,334 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env sh

PKG_CONFIG_NAME="libuv"
LIBUV_VERSION_REQUIRED="$PKG_CONFIG_NAME >= 1.43 $PKG_CONFIG_NAME < 2"

# If unset (default), will try to find libuv on system and fall back to bundled
# If true (case insensitive), will not look for system library
# If false, will not fall back to bundled if system library not found
USE_BUNDLED_LIBUV=`echo $USE_BUNDLED_LIBUV | tr '[:upper:]' '[:lower:]'`

bundle_libuv () {
  echo "** Using bundled copy of libuv"
  PKG_CFLAGS="-Ilibuv/include"
  PKG_LIBS="./libuv/.libs/libuv.a"
  # By setting DEPS, this triggers the libuv build in src/Makevars
  DEPS="libuv/.libs/libuv.a"
}

# First, look for suitable libuv installed on the system
if [ "${USE_BUNDLED_LIBUV}" != "true" ] && pkg-config --exists ''"${LIBUV_VERSION_REQUIRED}"'' 2>&1; then
  LIB_DIR="`pkg-config --variable=prefix --silence-errors ${PKG_CONFIG_NAME}`"
  PKG_CFLAGS=`pkg-config --cflags --silence-errors ${PKG_CONFIG_NAME}`
  PKG_LIBS=`pkg-config --libs ${PKG_CONFIG_NAME}`
  DEPS=""
  if [ `uname -s` = "Darwin" ]; then
    # We need to do static linking, but the macOS linker always prefers dynamic
    # so we'll look for libuv.a and move it somewhere else and pass that as -L
    NEW_LIB_DIR="src/libuv/.libs"
    mkdir -p ${NEW_LIB_DIR} && cp -f "${LIB_DIR}/lib/libuv.a" ${NEW_LIB_DIR}/libuv_static.a || true
    if [ -f "${NEW_LIB_DIR}/libuv_static.a" ]; then
      # Use it
      PKG_LIBS="-L`pwd`/${NEW_LIB_DIR} -luv_static"
      echo "** Using static libuv found by pkg-config in ${LIB_DIR}"
    else
      # libuv.a not there or otherwise that failed to copy, so fall back
      echo "** pkg-config did not find static libuv"
      bundle_libuv
    fi
  else
    echo "** Using libuv found by pkg-config in ${LIB_DIR}"
  fi
elif [ "${USE_BUNDLED_LIBUV}" != "false" ]; then
  # If not found, use the bundled copy (unless directed otherwise)
  bundle_libuv
else
  echo "** Did not find suitable libuv on your system,"
  echo "** and not building from source because USE_BUNDLED_LIBUV=false."
  echo "** Please install ${LIBUV_VERSION_REQUIRED} or unset USE_BUNDLED_LIBUV"
  exit 1
fi

# For debugging
echo "** PKG_CFLAGS=$PKG_CFLAGS"
echo "** PKG_LIBS=$PKG_LIBS"
# Write to Makevars
sed -e "s|@cflags@|$PKG_CFLAGS|" -e "s|@libs@|$PKG_LIBS|" -e "s|@deps@|$DEPS|" src/Makevars.in > src/Makevars

# Success
exit 0