Make curl an optional dependancy
authorJ. Ali Harlow <ali@juiblex.co.uk>
Tue, 6 Jan 2009 16:00:32 +0000 (16:00 +0000)
committerJ. Ali Harlow <ali@juiblex.co.uk>
Tue, 6 Jan 2009 16:00:32 +0000 (16:00 +0000)
configure.ac
src/main.c

index dd40a0b..56f2ea0 100644 (file)
@@ -122,7 +122,16 @@ fi
 AC_MSG_RESULT($have_gcc4)
 
 
-PKG_CHECK_MODULES(CURL, [libcurl])
+AC_ARG_WITH([curl],
+            [AS_HELP_STRING([--without-curl], [disable support for curl])],
+            [],
+            [with_curl=yes])
+          
+CURL_CFLAGS=
+CURL_LIBS=
+AS_IF([test "x$with_curl" != xno],
+  [PKG_CHECK_MODULES(CURL, [libcurl])
+   AC_DEFINE([HAVE_CURL], [1], [Define if you have curl])])
 AC_SUBST(CURL_CFLAGS)
 AC_SUBST(CURL_LIBS)
 
index 9ee2023..09bf2e3 100644 (file)
@@ -19,6 +19,8 @@
 
 #define _GNU_SOURCE
 
+#include "config.h"
+
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -28,7 +30,9 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <dirent.h>
+#ifdef HAVE_CURL
 #include <curl/curl.h>
+#endif
 #include <fnmatch.h>
 #include <errno.h>
 #include "razor.h"
@@ -348,6 +352,9 @@ show_progress(void *clientp,
 static int
 download_if_missing(const char *url, const char *file)
 {
+#ifndef HAVE_CURL
+       return 1;
+#else
        CURL *curl;
        struct stat buf;
        char error[256];
@@ -398,6 +405,7 @@ download_if_missing(const char *url, const char *file)
        curl_easy_cleanup(curl);
 
        return 0;
+#endif /* HAVE_CURL */
 }
 
 #define YUM_URL "http://download.fedora.redhat.com" \