Linux build : fix undefined pragma
[scilab.git] / scilab / m4 / curl.m4
1 dnl
2 dnl Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 dnl Copyright (C) S/E - 2012 - Sylvestre Ledru
4 dnl 
5 dnl Copyright (C) 2012 - 2016 - Scilab Enterprises
6 dnl
7 dnl This file is hereby licensed under the terms of the GNU GPL v2.0,
8 dnl pursuant to article 5.3.4 of the CeCILL v.2.1.
9 dnl This file was originally licensed under the terms of the CeCILL v2.1,
10 dnl and continues to be available under such terms.
11 dnl For more information, see the COPYING file which you should have received
12 dnl along with this program.
13 dnl
14 dnl CURL detection
15 dnl
16
17 dnl CURL is mandatory in Scilab 
18 dnl When we check :
19 dnl * if the path is provided or that we have to find it ourself
20 dnl * if it is available
21 dnl * what are the compilation flags 
22 dnl * what are linking flags
23 AC_DEFUN([AC_CURL], [
24
25
26 AC_ARG_WITH(curl,
27     AC_HELP_STRING([--with-curl=DIR],[Set the path to your CURL installation]),
28     [with_curl=$withval],
29     [with_curl='yes']
30     )
31
32 if test "$with_curl" != 'yes' -a "$with_curl" != 'no'; then
33     # Look if curl-config (which provides cflags and ldflags) is available
34     AC_MSG_CHECKING([curl, for curl-config])
35     CURL_FOUND=0
36     CURL_CONFIG="$with_curl/bin/curl-config"
37     if test -x "$CURL_CONFIG"; then
38         AC_MSG_RESULT([$CURL_CONFIG])
39         CURL_FOUND=1
40     fi
41     if test $CURL_FOUND -eq 0; then
42         CURL_CONFIG="$with_curl/curl-config"
43         if test -x "$CURL_CONFIG"; then
44             CURL_FOUND=1
45             AC_MSG_RESULT([$CURL_CONFIG])
46         fi
47     fi
48     if test $CURL_FOUND -eq 0; then
49         AC_MSG_ERROR([Unable to find $CURL_CONFIG. Please check the path you provided])
50     else
51        unset CURL_FOUND
52     fi
53 else
54     if $WITH_DEVTOOLS; then # Scilab thirdparties
55         CURL_CONFIG="$DEVTOOLS_BINDIR/curl-config"
56     else
57         AC_CHECK_PROGS(CURL_CONFIG,curl-config,no)
58         if test "x$CURL_CONFIG" = "xno"; then
59             AC_MSG_ERROR([Unable to find curl-config in the path. Please check your installation of curl (example : libcurl3 & libcurl3-dev with Debian)])
60         fi
61     fi
62 fi
63 saved_cflags="$CFLAGS"
64 saved_LIBS="$LIBS"
65
66 CURL_CFLAGS=`$CURL_CONFIG --cflags`
67 CURL_LIBS=`$CURL_CONFIG --libs`
68 CURL_VERSION=`$CURL_CONFIG --version`
69
70 CURL_REQUIRED_VERSION=7.6
71     PKG_CHECK_MODULES(CURL,
72                       libcurl >= $CURL_REQUIRED_VERSION)
73
74 LIBS="$CURL_LIBS $LIBS"
75 CFLAGS="$CURL_CFLAGS $CFLAGS"
76
77 AC_CHECK_LIB([curl], [curl_easy_setopt],
78                [],
79                [AC_MSG_ERROR([curl : library missing. (Cannot find symbol curl_easy_setopt). Check if curl is installed and if the version is correct])]
80                )
81
82 AC_CHECK_HEADERS([curl.h])
83
84 LIBS="$saved_LIBS"
85 CFLAGS="$saved_cflags"
86
87 AC_SUBST(CURL_CFLAGS)
88 AC_SUBST(CURL_LIBS)
89 AC_SUBST(CURL_VERSION)
90
91 AC_DEFINE_UNQUOTED([CURL_CFLAGS],["$CURL_CFLAGS"],[CURL flags])
92 AC_DEFINE_UNQUOTED([CURL_LIBS],["$CURL_LIBS"],[CURL library])
93 AC_DEFINE_UNQUOTED([CURL_VERSION],["$CURL_VERSION"],[CURL version])
94
95 # Gets compilation and library flags
96 ])