Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Providing an m4 script to check for system-wide yajl library.

  • Loading branch information...
commit c829550708025b190131f1e1cc677323486725d2 1 parent 61f533b
@cristiangreco cristiangreco authored
Showing with 91 additions and 0 deletions.
  1. +2 −0  Makefile.am
  2. +8 −0 configure.ac
  3. +81 −0 m4/ac_check_yajl.m4
View
2  Makefile.am
@@ -1,3 +1,5 @@
+ACLOCAL_AMFLAGS = -I m4
+
AUTOMAKE_OPTIONS = gnu
dist_doc_DATA = README.markdown
View
8 configure.ac
@@ -2,6 +2,7 @@ AC_PREREQ([2.65])
AC_INIT([pincaster], [0.6], [bugs at pureftpd dot org])
AC_CONFIG_SRCDIR([src/app.c])
AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([1.9 dist-bzip2])
AM_MAINTAINER_MODE
@@ -30,6 +31,13 @@ LDFLAGS="$LDFLAGS -pthread"
AC_CHECK_LIB([m], [cosf],, AC_ERROR([libm not found]))
AC_CHECK_LIB([rt], [clock_gettime])
+AC_CHECK_YAJL([
+ LIBS="$YAJL_LIBS $LIBS"
+ CFLAGS="$YAJL_CFLAGS $CFLAGS"
+ ],[
+ AC_MSG_ERROR([YAJL library not found.])
+])
+
# Checks for header files.
AC_SYS_LARGEFILE
AC_HEADER_STDBOOL
View
81 m4/ac_check_yajl.m4
@@ -0,0 +1,81 @@
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_CHECK_YAJL([action-if-found], [action-if-not-found])
+#
+# DESCRIPTION
+#
+# Tests for the YAJL library.
+#
+# This macro calls:
+#
+# AC_SUBST(YAJL_CFLAGS) / AC_SUBST(YAJL_LIBS)
+#
+# LAST MODIFICATION
+#
+# 2010-06-29
+#
+# LICENSE
+#
+# Copyright (c) 2010 Cristian Greco <cristian@regolo.cc>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved.
+
+AC_DEFUN([AC_CHECK_YAJL], [
+ ac_yajl_found="no"
+
+ CPPFLAGS_SAVED="$CPPFLAGS"
+ LDFLAGS_SAVED="$LDFLAGS"
+ CFLAGS_SAVED="$CFLAGS"
+ LIBS_SAVED="$LIBS"
+
+ AC_CHECK_HEADER([yajl/yajl_parse.h], [
+ AC_CHECK_LIB([yajl], [yajl_parse], [
+ YAJL_CFLAGS=""
+ YAJL_LIBS="-lyajl"
+ ac_yajl_found="yes"
+ ], [
+ AC_MSG_WARN([yajl library not found])
+ ])
+ ], [
+ for ac_yajl_path in /usr /usr/local /opt /opt/local; do
+ AC_MSG_CHECKING([for yajl_parse.h in $ac_yajl_path])
+ if test -d "$ac_yajl_path/include/yajl/" -a -r "$ac_yajl_path/include/yajl/yajl_parse.h"; then
+ AC_MSG_RESULT([yes])
+ YAJL_CFLAGS="-I$ac_yajl_path/include"
+ YAJL_LIBS="-lyajl"
+ break;
+ else
+ AC_MSG_RESULT([no])
+ fi
+ done
+
+ CFLAGS="YAJL_CFLAGS $CFLAGS"
+ export CFLAGS
+ LIBS="$YAJL_LIBS $LIBS"
+ export LIBS
+
+ AC_MSG_CHECKING([for yajl_gen_alloc in -lyajl])
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([[ #include <yajl/yajl_gen.h> ]], [[ yajl_gen_config conf = { 1, " " }; yajl_gen g = yajl_gen_alloc(&conf, NULL); ]])
+ ], [
+ AC_MSG_RESULT([yes])
+ ac_yajl_found="yes"
+ ], [
+ AC_MSG_RESULT([no])
+ ])
+ ])
+
+ CPPFLAGS="$CPPFLAGS_SAVED"
+ LDFLAGS="$LDFLAGS_SAVED"
+ CFLAGS="$CFLAGS_SAVED"
+ LIBS="$LIBS_SAVED"
+
+ AS_IF([ test "x$ac_yajl_found" != xno ], [$1], [$2])
+
+AC_SUBST([YAJL_CFLAGS])
+AC_SUBST([YAJL_LIBS])
+])

0 comments on commit c829550

Please sign in to comment.
Something went wrong with that request. Please try again.