Make curl an optional dependancy
authorJ. Ali Harlow <ali@juiblex.co.uk>
Tue Jan 06 16:00:32 2009 +0000 (2009-01-06)
changeset 3216f804141872c
parent 320 53e1185e2366
child 322 66c281524c98
Make curl an optional dependancy
configure.ac
src/main.c
     1.1 --- a/configure.ac	Tue Jan 06 14:06:00 2009 +0000
     1.2 +++ b/configure.ac	Tue Jan 06 16:00:32 2009 +0000
     1.3 @@ -122,7 +122,16 @@
     1.4  AC_MSG_RESULT($have_gcc4)
     1.5  
     1.6  
     1.7 -PKG_CHECK_MODULES(CURL, [libcurl])
     1.8 +AC_ARG_WITH([curl],
     1.9 +            [AS_HELP_STRING([--without-curl], [disable support for curl])],
    1.10 +            [],
    1.11 +            [with_curl=yes])
    1.12 +          
    1.13 +CURL_CFLAGS=
    1.14 +CURL_LIBS=
    1.15 +AS_IF([test "x$with_curl" != xno],
    1.16 +  [PKG_CHECK_MODULES(CURL, [libcurl])
    1.17 +   AC_DEFINE([HAVE_CURL], [1], [Define if you have curl])])
    1.18  AC_SUBST(CURL_CFLAGS)
    1.19  AC_SUBST(CURL_LIBS)
    1.20  
     2.1 --- a/src/main.c	Tue Jan 06 14:06:00 2009 +0000
     2.2 +++ b/src/main.c	Tue Jan 06 16:00:32 2009 +0000
     2.3 @@ -19,6 +19,8 @@
     2.4  
     2.5  #define _GNU_SOURCE
     2.6  
     2.7 +#include "config.h"
     2.8 +
     2.9  #include <stdlib.h>
    2.10  #include <stddef.h>
    2.11  #include <stdio.h>
    2.12 @@ -28,7 +30,9 @@
    2.13  #include <unistd.h>
    2.14  #include <fcntl.h>
    2.15  #include <dirent.h>
    2.16 +#ifdef HAVE_CURL
    2.17  #include <curl/curl.h>
    2.18 +#endif
    2.19  #include <fnmatch.h>
    2.20  #include <errno.h>
    2.21  #include "razor.h"
    2.22 @@ -348,6 +352,9 @@
    2.23  static int
    2.24  download_if_missing(const char *url, const char *file)
    2.25  {
    2.26 +#ifndef HAVE_CURL
    2.27 +	return 1;
    2.28 +#else
    2.29  	CURL *curl;
    2.30  	struct stat buf;
    2.31  	char error[256];
    2.32 @@ -398,6 +405,7 @@
    2.33  	curl_easy_cleanup(curl);
    2.34  
    2.35  	return 0;
    2.36 +#endif	/* HAVE_CURL */
    2.37  }
    2.38  
    2.39  #define YUM_URL "http://download.fedora.redhat.com" \