Debian Codegraph @

configure

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 # Anticonf (tm) script by Jeroen Ooms (2025)
3 # This script will query 'pkg-config' for the required cflags and ldflags.
4 # If pkg-config is unavailable or does not find the library, try setting
5 # INCLUDE_DIR and LIB_DIR manually via e.g:
6 # R CMD INSTALL --configure-vars='INCLUDE_DIR=/.../include LIB_DIR=/.../lib'
7
8 # Library settings
9 PKG_CONFIG_NAME="libcurl"
10 PKG_DEB_NAME="libcurl4-openssl-dev"
11 PKG_RPM_NAME="libcurl-devel"
12 PKG_APK_NAME="curl-dev"
13 PKG_TEST_HEADER="<curl/curl.h>"
14 PKG_LIBS="-lcurl"
15 PKG_CFLAGS=""
16
17 #export PKG_CONFIG_PATH="/opt/homebrew/opt/curl/lib/pkgconfig"
18
19 # (Jan 2025) MacOS ships a very buggy libcurl 8.7.1 so we avoid this until apple updates it
20 # See: https://github.com/jeroen/curl/issues/376
21 if [scip-shell system . . `[`. `unamescip-shell system . . uname.` = "Darwin" ]; then
22 MINVERSION="--atleast-version=8.8.0"
23 fi
24
25 # Use pkg-config if available
26 pkg-config ${PKG_CONFIG_NAME} ${MINVERSION} 2>/dev/nullscip-shell filesystem . . `/dev/null`.
27 if [scip-shell system . . `[`. $? -eq 0 ]; then
28 PKGCONFIG_CFLAGS=`pkg-config --cflags ${PKG_CONFIG_NAME}`
29 case "$PKGCONFIG_CFLAGS" in
30 *CURL_STATICLIB*) PKGCONFIG_LIBS=`pkg-config --libs --static ${PKG_CONFIG_NAME}`;;
31 *) PKGCONFIG_LIBS=`pkg-config --libs ${PKG_CONFIG_NAME}`;;
32 esac
33 fi
34
35 # Note that cflags may be empty in case of success
36 if [scip-shell system . . `[`. "$CURL_CFLAGS" ] || [scip-shell system . . `[`. "$CURL_LIBS" ]; then
37 echoscip-shell system . . echo. "Found CURL_CFLAGS and/or CURL_LIBS!"
38 PKG_CFLAGS="$CURL_CFLAGS"
39 PKG_LIBS="$CURL_LIBS"
40 elif [scip-shell system . . `[`. "$INCLUDE_DIR" ] || [scip-shell system . . `[`. "$LIB_DIR" ]; then
41 echoscip-shell system . . echo. "Found INCLUDE_DIR and/or LIB_DIR!"
42 PKG_CFLAGS="-I$INCLUDE_DIR $PKG_CFLAGS"
43 PKG_LIBS="-L$LIB_DIR $PKG_LIBS"
44 elif [scip-shell system . . `[`. "$PKGCONFIG_CFLAGS" ] || [scip-shell system . . `[`. "$PKGCONFIG_LIBS" ]; then
45 echoscip-shell system . . echo. "Found pkg-config cflags and libs!"
46 PKG_CFLAGS=${PKGCONFIG_CFLAGS}
47 PKG_LIBS=${PKGCONFIG_LIBS}
48 elif [scip-shell system . . `[`. `unamescip-shell system . . uname.` = "Darwin" ]; then
49 # Temporary fix for: https://github.com/jeroen/curl/issues/376
50 curlscip-shell system . . curl. -sfL "https://autobrew.github.io/scripts/libcurl-macos" > autobrew
51 . ./autobrewscip-shell source . . `./autobrew`.
52 fi
53
54 # Find compiler
55 CC=`${R_HOME}/bin/R CMD config CC`
56 CFLAGS=`${R_HOME}/bin/R CMD config CFLAGS`
57 CPPFLAGS=`${R_HOME}/bin/R CMD config CPPFLAGS`
58
59 # For debugging
60 echoscip-shell system . . echo. "Using PKG_CFLAGS=$PKG_CFLAGS"
61 echoscip-shell system . . echo. "Using PKG_LIBS=$PKG_LIBS"
62
63 # Test configuration
64 echoscip-shell system . . echo. "#include $PKG_TEST_HEADER" | ${CC} ${CPPFLAGS} ${PKG_CFLAGS} ${CFLAGS} -E -xc - >/dev/nullscip-shell filesystem . . `/dev/null`. 2>configure.log
65
66 # Customize the error
67 if [scip-shell system . . `[`. $? -ne 0 ]; then
68 echoscip-shell system . . echo. "--------------------------- [ANTICONF] --------------------------------"
69 echoscip-shell system . . echo. "Configuration failed because $PKG_CONFIG_NAME was not found. Try installing:"
70 echoscip-shell system . . echo. " * deb: $PKG_DEB_NAME (Debian, Ubuntu, etc)"
71 echoscip-shell system . . echo. " * rpm: $PKG_RPM_NAME (Fedora, CentOS, RHEL)"
72 echoscip-shell system . . echo. " * apk: $PKG_APK_NAME (Alpine)"
73 echoscip-shell system . . echo. "If $PKG_CONFIG_NAME is already installed, check that 'pkg-config' is in your"
74 echoscip-shell system . . echo. "PATH and PKG_CONFIG_PATH contains a $PKG_CONFIG_NAME.pc file. If pkg-config"
75 echoscip-shell system . . echo. "is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:"
76 echoscip-shell system . . echo. "R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'"
77 echoscip-shell system . . echo. "-------------------------- [ERROR MESSAGE] ---------------------------"
78 catscip-shell system . . cat. configure.log
79 echoscip-shell system . . echo. "--------------------------------------------------------------------"
80 exit 1
81 fi
82
83 # Test minimum version
84 ${CC} -E ${CPPFLAGS} ${PKG_CFLAGS} ${CFLAGS} tools/version.c >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
85 if [scip-shell system . . `[`. $? -ne 0 ]; then
86
87 # On curl < 7.73 (RHEL-8 / Ubuntu 20.04) enable the static library
88 if [scip-shell system . . `[`. `unamescip-shell system . . uname.` = "Linux" ]; then
89 echoscip-shell system . . echo. "Local libcurl is too old. Downloading a static libcurl for legacy Linux..."
90 echoscip-shell system . . echo. "For alternative solutions see: https://github.com/jeroen/curl/issues/416"
91 curlscip-shell system . . curl. -sOL "https://github.com/jeroen/curl/releases/download/libcurl-8.14.1/get-curl-linux.sh" && . ./get-curl-linux.shscip-shell source . . `./get-curl-linux.sh`.
92 fi
93
94 # MacOS 13 CRAN builder has MacOS 11.3 SDK
95 # Also for people compiling from source on MacOS 11
96 if [scip-shell system . . `[`. `unamescip-shell system . . uname.` = "Darwin" ] && [scip-shell system . . `[`. -z "$BREWDIR" ] && ${R_HOME}/bin/Rscript --vanilla tools/testversion.R "7.80"; then
97 PKG_CFLAGS="$PKG_CFLAGS -DENABLE_MACOS_POLYFILL"
98 fi
99 fi
100
101 # Write to Makevars
102 sedscip-shell system . . sed. -e "s|@cflags@|$PKG_CFLAGS|" -e "s|@libs@|$PKG_LIBS|" src/Makevars.in > src/Makevars
103
104 # Success
105 exit 0