1# -*- Autoconf -*- 2# Copyright (C) 2007-2011 David Beckett http://www.dajobe.org/ 3 4AC_PREREQ([2.68]) 5AC_INIT([Flickcurl], [1.26], [http://bugs.librdf.org/], [flickcurl]) 6AC_CONFIG_SRCDIR([src/flickcurl.h]) 7AC_CONFIG_HEADERS([src/config.h]) 8AC_CONFIG_AUX_DIR(build) 9AC_CONFIG_MACRO_DIR(build) 10AM_INIT_AUTOMAKE([1.11 check-news std-options -Wobsolete -Wportability -Wsyntax -Wunsupported -Wextra-portability]) 11 12AM_MAINTAINER_MODE 13 14if test "$USE_MAINTAINER_MODE" = yes; then 15 CFLAGS=`echo $CFLAGS | sed -e "s/-O[A-Za-z0-9]*//"` 16 CXXFLAGS=`echo $CXXFLAGS | sed -e "s/-O[A-Za-z0-9]*//"` 17 CPPFLAGS=`echo $CPPFLAGS | sed -e "s/-O[A-Za-z0-9]*//"` 18fi 19 20dnl need to change quotes to allow square brackets 21changequote(<<, >>)dnl 22version="$PACKAGE_VERSION.0" 23version_major=`echo $version | sed -e 's/^\([^\.]*\)\.\([^\.]*\)\.\(.*\)$/\1/'` 24version_minor=`echo $version | sed -e 's/^\([^\.]*\)\.\([^\.]*\)\.\(.*\)$/\2/'` 25version_release=`echo $version | sed -e 's/^\([^\.]*\)\.\([^\.]*\)\.\(.*\)$/\3/'` 26changequote([, ])dnl 27 28version_decimal=`expr $version_major \* 10000 + $version_minor \* 100 + $version_release` 29AC_DEFINE_UNQUOTED(FLICKCURL_VERSION_DECIMAL, $version_decimal, [Release version as a decimal]) 30 31# for flickcurl-config.in 32FLICKCURL_VERSION_DECIMAL=$version_decimal 33AC_SUBST(FLICKCURL_VERSION_DECIMAL) 34 35 36# Libtool versioning 37# 38# CURRENT 39# The most recent interface number that this library implements. 40# 41# REVISION 42# The implementation number of the CURRENT interface. 43# 44# AGE 45# The difference between the newest and oldest interfaces that this 46# library implements. In other words, the library implements all the 47# interface numbers in the range from number `CURRENT - AGE' to 48# `CURRENT'. 49# 50# Rules: 51# 1. Start with version information of `0:0:0' for each libtool library. 52# 53# 2. Update the version information only immediately before a public 54# release of your software. More frequent updates are unnecessary, 55# and only guarantee that the current interface number gets larger 56# faster. 57# 58# 3. If the library source code has changed at all since the last 59# update, then increment REVISION (`C:R:A' becomes `C:r+1:A'). 60# 61# 4. If any interfaces have been added, removed, or changed since the 62# last update, increment CURRENT, and set REVISION to 0. 63# 64# 5. If any interfaces have been added since the last public release, 65# then increment AGE. 66# 67# 6. If any interfaces have been removed since the last public release, 68# then set AGE to 0. 69# 70# syntax: CURRENT[:REVISION[:AGE]] 71LIBFLICKCURL_LIBTOOL_VERSION=0:0:0 72AC_SUBST(LIBFLICKCURL_LIBTOOL_VERSION) 73 74 75AC_CANONICAL_HOST 76AM_SANITY_CHECK 77 78# Checks for programs. 79AM_PROG_AR 80AM_PROG_CC_C_O 81AC_MSG_CHECKING(whether $CC is clang) 82CC_IS_CLANG=no 83if $CC 2>&1 | grep clang >/dev/null 2>&1; then 84 CC_IS_CLANG=yes 85else 86 : 87fi 88AC_MSG_RESULT($CC_IS_CLANG) 89 90dnl Initialize libtool 91LT_INIT 92 93# Checks for libraries. 94 95libxml_min_version=2.6.8 96raptor_min_version=2.0.0 97libcurl_min_version=7.10.0 98 99# Checks for header files. 100AC_HEADER_STDC 101AC_CHECK_HEADERS([errno.h getopt.h stdlib.h stdint.h time.h string.h unistd.h]) 102AC_HEADER_TIME 103 104# Checks for typedefs, structures, and compiler characteristics. 105AC_C_CONST 106AC_TYPE_SIZE_T 107AC_STRUCT_TM 108AC_C_BIGENDIAN 109 110AC_CHECK_TYPE([u32]) 111AC_CHECK_SIZEOF(unsigned int, 4) 112AC_CHECK_SIZEOF(unsigned long, 4) 113 114# Checks for library functions. 115AC_FUNC_MALLOC 116AC_FUNC_REALLOC 117AC_FUNC_STRFTIME 118AC_FUNC_VPRINTF 119AC_CHECK_FUNCS([getopt getopt_long gettimeofday memset strdup usleep vsnprintf]) 120AC_SEARCH_LIBS(nanosleep, rt posix4, 121 AC_DEFINE(HAVE_NANOSLEEP, 1, [Define to 1 if you have the 'nanosleep' function.]), 122 AC_MSG_WARN(nanosleep was not found)) 123 124AM_CONDITIONAL(GETOPT, test $ac_cv_func_getopt = no -a $ac_cv_func_getopt_long = no) 125 126AC_MSG_CHECKING(whether need to declare optind) 127AC_LINK_IFELSE([AC_LANG_PROGRAM([[#ifdef HAVE_GETOPT_H 128#include <getopt.h> 129#endif]], [[int x=optind; 130]])],[AC_MSG_RESULT(no)],[AC_DEFINE(NEED_OPTIND_DECLARATION, 1, need 'extern int optind' declaration?) 131 AC_MSG_RESULT(yes)]) 132 133if test $ac_cv_func_vsnprintf = yes; then 134 AC_MSG_CHECKING(vsnprintf has C99 compatible return value) 135 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdarg.h> 136int is_c99(char *s, ...) { 137 char buffer[32]; 138 va_list args; 139 int r; 140 va_start(args, s); 141 r = vsnprintf(buffer, 5, s, args); 142 va_end(args); 143 144 return (r == 7); 145} 146 147int main(int argc, char* argv) { 148 return is_c99("1234567"); 149}]])],[AC_MSG_RESULT(no)],[AC_DEFINE(HAVE_C99_VSNPRINTF, 1, vsnprint has C99 compatible return value) 150 AC_MSG_RESULT(yes)], [ ], [ ]) 151fi 152 153 154AC_CHECK_PROGS(RECHO, echo) 155RECHO_C= 156RECHO_N= 157case `$RECHO -n x` in 158 -n*) 159 case `$RECHO 'xy\c'` in 160 *c*) 161 ;; 162 xy) 163 RECHO_C='\c' 164 ;; 165 esac;; 166 *) 167 RECHO_N='-n' 168 ;; 169esac 170 171AC_CHECK_PROGS(PKG_CONFIG, pkg-config) 172 173PKG_CONFIG_REQUIRES= 174 175 176dnl libxml - required 177LIBXML_MIN_VERSION=$libxml_min_version 178AC_SUBST(LIBXML_MIN_VERSION) 179 180AC_ARG_WITH(xml2-config, [ --with-xml2-config=PATH Location of libxml xml2-config []], xml2_config="$withval", xml2_config="") 181 182if test "X$xml2_config" != "Xno" ; then 183 if test "X$xml2_config" != "X" ; then 184 AC_MSG_CHECKING(for $xml2_config) 185 186 if test -f $xml2_config ; then 187 XML_CONFIG=$xml2_config 188 AC_MSG_RESULT(yes) 189 else 190 AC_MSG_RESULT(no - searching PATH) 191 fi 192 fi 193 194 if test "X$XML_CONFIG" = "X" ; then 195 AC_CHECK_PROGS(XML_CONFIG, xml2-config) 196 fi 197fi 198 199libxml_source=no 200if test "X$XML_CONFIG" != "X"; then 201 oCPPFLAGS="$CPPFLAGS" 202 oLIBS="$LIBS" 203 204 CPPFLAGS="`$XML_CONFIG --cflags` $CPPFLAGS" 205 LIBS="$LIBS `$XML_CONFIG --libs`" 206 AC_CHECK_FUNC(xmlCreatePushParserCtxt, have_xmlCreatePushParserCtxt=yes, have_xmlCreatePushParserCtxt=no) 207 208 AC_MSG_CHECKING(for libxml via xml2-config) 209 if test $have_xmlCreatePushParserCtxt = yes; then 210 libxml_source="xml2-config" 211 LIBXML_VERSION=`$XML_CONFIG --version` 212 fi 213 CPPFLAGS="$oCPPFLAGS" 214 LIBS="$oLIBS" 215else 216 AC_MSG_CHECKING(for libxml via pkg-config) 217 XML_CONFIG="$PKG_CONFIG libxml-2.0" 218 if $XML_CONFIG --exists; then 219 LIBXML_VERSION=`$XML_CONFIG --modversion 2>/dev/null` 220 libxml_source="pkg-config" 221 fi 222fi 223 224if test "$libxml_source" != "no"; then 225 AC_MSG_RESULT(yes - $LIBXML_VERSION via $libxml_source) 226else 227 AC_MSG_RESULT(no - not found) 228 AC_MSG_ERROR(Please install version $libxml_min_version or newer) 229fi 230 231libxml_min_version_dec=`echo $libxml_min_version | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'` 232libxml_version_dec=`echo $LIBXML_VERSION | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'` 233if test $libxml_version_dec -lt $libxml_min_version_dec; then 234 AC_MSG_ERROR(libxml $LIBXML_VERSION is too old - $libxml_min_version or newer required.) 235fi 236 237LIBS="$LIBS `$XML_CONFIG --libs`" 238CFLAGS="`$XML_CONFIG --cflags` $CFLAGS" 239 240if test $libxml_source = "pkg-config"; then 241 if test "X$PKG_CONFIG_REQUIRES" != X; then 242 PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES," 243 fi 244 PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES libxml-2.0 >= $LIBXML_MIN_VERSION" 245fi 246 247dnl curl - required 248LIBCURL_MIN_VERSION=$libcurl_min_version 249AC_SUBST(LIBCURL_MIN_VERSION) 250 251AC_ARG_WITH(curl-config, [ --with-curl-config=PATH Location of libcurl curl-config []], curl_config="$withval", curl_config="") 252 253if test "X$curl_config" != "Xno" ; then 254 if test "X$curl_config" != "X" ; then 255 AC_MSG_CHECKING(for $curl_config) 256 257 if test -f $curl_config ; then 258 CURL_CONFIG=$curl_config 259 AC_MSG_RESULT(yes) 260 else 261 AC_MSG_RESULT(no - searching PATH) 262 fi 263 fi 264 265 if test "X$CURL_CONFIG" = "X" ; then 266 AC_CHECK_PROGS(CURL_CONFIG, curl-config) 267 fi 268fi 269 270libcurl_source=no 271if test "X$CURL_CONFIG" != "X"; then 272 oCPPFLAGS="$CPPFLAGS" 273 oLIBS="$LIBS" 274 275 CPPFLAGS="`$CURL_CONFIG --cflags` $CPPFLAGS" 276 LIBS="$LIBS `$CURL_CONFIG --libs`" 277 AC_CHECK_HEADER(curl/curl.h) 278 AC_CHECK_FUNC(curl_easy_init, have_curl_easy_init=yes, have_curl_easy_init=no) 279 280 AC_MSG_CHECKING(for libcurl via curl-config) 281 if test $have_curl_easy_init = yes; then 282 libcurl_source="curl-config" 283 LIBCURL_VERSION=`$CURL_CONFIG --version | sed -e 's/^libcurl *//'` 284 fi 285 CPPFLAGS="$oCPPFLAGS" 286 LIBS="$oLIBS" 287else 288 AC_MSG_CHECKING(for libcurl via pkg-config) 289 CURL_CONFIG="$PKG_CONFIG libcurl" 290 if $CURL_CONFIG --exists; then 291 LIBCURL_VERSION=`$CURL_CONFIG --modversion 2>/dev/null` 292 libcurl_source="pkg-config" 293 fi 294fi 295 296if test "$libcurl_source" != "no"; then 297 AC_MSG_RESULT(yes - $LIBCURL_VERSION via $libcurl_source) 298else 299 AC_MSG_RESULT(no - not found) 300 AC_MSG_ERROR(Please install version $libcurl_min_version or newer) 301fi 302 303libcurl_min_version_dec=`echo $libcurl_min_version | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'` 304libcurl_version_dec=`echo $LIBCURL_VERSION | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'` 305if test $libcurl_version_dec -lt $libcurl_min_version_dec; then 306 AC_MSG_ERROR(libcurl $LIBCURL_VERSION is too old - $libcurl_min_version or newer required.) 307fi 308 309LIBS="$LIBS `$CURL_CONFIG --libs`" 310CFLAGS="`$CURL_CONFIG --cflags` $CFLAGS" 311 312if test $libcurl_source = "pkg-config"; then 313 if test "X$PKG_CONFIG_REQUIRES" != X; then 314 PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES," 315 fi 316 PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES libcurl >= $LIBCURL_MIN_VERSION" 317fi 318 319 320dnl raptor - optional 321AC_ARG_WITH(raptor, [ --with-raptor=yes|no|2 Use Raptor to serialize to triples (default=auto)], with_raptor="$withval", with_raptor="auto") 322 323# resolve autodetecting raptor 324if test "$with_raptor" = auto; then 325 if $PKG_CONFIG raptor2 --exists; then 326 with_raptor=yes 327 else 328 with_raptor=no 329 fi 330fi 331 332# Check raptor version and use it if new enough 333RAPTOR_VERSION= 334if test "$with_raptor" = yes -o "$with_raptor" = 2; then 335 RAPTOR_VERSION=`$PKG_CONFIG raptor2 --modversion 2>/dev/null` 336 337 if $PKG_CONFIG raptor2 --atleast-version=$raptor_min_version; then 338 with_raptor=yes 339 else 340 with_raptor=no 341 AC_MSG_WARN(Installed Raptor $RAPTOR_VERSION is too old - need $raptor_min_version) 342 fi 343else 344 with_raptor="no" 345fi 346RAPTOR_MIN_VERSION=$raptor_min_version 347AC_SUBST(RAPTOR_MIN_VERSION) 348 349 350AM_CONDITIONAL(RAPTOR, test $with_raptor != no) 351AC_MSG_CHECKING(whether to use Raptor) 352if test "$with_raptor" = yes; then 353 AC_MSG_RESULT(yes - $RAPTOR_VERSION) 354 RAPTOR_LIBS="`$PKG_CONFIG raptor2 --libs`" 355 RAPTOR_CFLAGS="`$PKG_CONFIG raptor2 --cflags`" 356 357 LIBS="$LIBS $RAPTOR_LIBS" 358 CPPFLAGS="$CPPFLAGS $RAPTOR_CFLAGS" 359 360 if test "X$PKG_CONFIG_REQUIRES" != X; then 361 PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES," 362 fi 363 PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES raptor2 >= $raptor_min_version" 364 AC_SUBST(RAPTOR_LIBS) 365 AC_SUBST(RAPTOR_CFLAGS) 366 AC_DEFINE(HAVE_RAPTOR, 1, [have Raptor RDF syntax library]) 367else 368 AC_MSG_RESULT(no) 369fi 370 371AC_ARG_ENABLE(offline, [ --enable-offline Turn on offline use of captured XML web service responses (default disabled). ], offline="yes", offline="no") 372AC_MSG_CHECKING(using offline mode) 373AC_MSG_RESULT($offline); 374if test $offline = yes; then 375 AC_DEFINE(OFFLINE, 1, [Offline mode]) 376fi 377AM_CONDITIONAL(OFFLINE, test $offline = yes) 378 379 380AC_ARG_ENABLE(capture, [ --enable-capture Turn on capturing web service responses (default disabled). ], capture="yes", capture="no") 381AC_MSG_CHECKING(capturing web service responses) 382AC_MSG_RESULT($capture); 383if test $capture = yes; then 384 AC_DEFINE(CAPTURE, 1, [Capture web service responses]) 385fi 386 387if test $offline = yes -a $capture = yes; then 388 AC_MSG_ERROR(Cannot use both offline mode and capturing web service responses) 389fi 390 391 392dnl compiler checks 393 394AC_DEFUN([FLICKCURL_CC_TRY_FLAG], [ 395 AC_MSG_CHECKING([whether $CC supports $1]) 396 flickcurl_save_CFLAGS="$CFLAGS" 397 if test $CC_IS_CLANG = yes; then 398 # Make unknown warnings into errors for clang so the test below works 399 CFLAGS="-Werror $CFLAGS" 400 fi 401 CFLAGS="$CFLAGS $1" 402 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ ])], [flickcurl_cc_flag=yes], [flickcurl_cc_flag=no]) 403 CFLAGS="$flickcurl_save_CFLAGS" 404 if test "X$flickcurl_cc_flag" = "Xyes"; then 405 ifelse([$2], , :, [$2]) 406 else 407 ifelse([$3], , :, [$3]) 408 fi 409 AC_MSG_RESULT($flickcurl_cc_flag) 410]) 411 412# Just too annoying: 413# -Wmissing-format-attribute 414possible_warnings="-Wall -Wextra \ 415-Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \ 416-Wmissing-declarations -Wnested-externs -Wredundant-decls -Wswitch-enum \ 417-Wsign-compare -Werror-implicit-function-declaration -Wwrite-strings 418-Wpacked -Wpointer-arith -Wcast-align -Winit-self \ 419-Wunsafe-loop-optimizations -Wdeclaration-after-statement \ 420-Wold-style-definition \ 421-Wno-missing-field-initializers -Wno-unused-parameter" 422 423warning_cflags= 424if test "$USE_MAINTAINER_MODE" = yes; then 425 AC_MSG_CHECKING(for supported $CC warning flags) 426 AC_MSG_RESULT($warning_cflags) 427 for warning in $possible_warnings; do 428 FLICKCURL_CC_TRY_FLAG([$warning], [warning_cflags="$warning_cflags $warning"]) 429 done 430 AC_MSG_CHECKING($CC supports warning flags) 431 AC_MSG_RESULT($warning_cflags) 432fi 433 434 435CPPFLAGS="-DFLICKCURL_INTERNAL=1 $CPPFLAGS" 436 437STANDARD_CFLAGS= 438MAINTAINER_CFLAGS="$warning_cflags" 439 440STANDARD_CFLAGS="$STANDARD_CFLAGS $CFLAGS" 441if test "$USE_MAINTAINER_MODE" = yes; then 442 CPPFLAGS="-g -DFLICKCURL_DEBUG=1 $CPPFLAGS" 443 CFLAGS="$MAINTAINER_CFLAGS $CFLAGS" 444fi 445 446AC_SUBST(STANDARD_CFLAGS) 447 448AC_SUBST(PKG_CONFIG_REQUIRES) 449 450AC_SUBST(ECHO) 451 452dnl automake 1.11 453AM_SILENT_RULES([no]) 454 455AC_CONFIG_FILES([Makefile 456libmtwist/Makefile 457getopt/Makefile 458src/Makefile 459utils/Makefile 460examples/Makefile 461docs/Makefile 462docs/version.xml 463flickcurl.spec 464flickcurl.rdf 465flickcurl.pc]) 466 467AC_CONFIG_FILES([flickcurl-config], [chmod +x flickcurl-config]) 468 469dnl Check for gtk-doc and docbook 470GTK_DOC_CHECK([1.3]) 471 472AC_OUTPUT 473 474AC_MSG_RESULT([ 475Flickcurl build summary: 476 libxml $LIBXML_VERSION via $libxml_source 477 curl $LIBCURL_VERSION via $libcurl_source 478 raptor $RAPTOR_VERSION 479]) 480