Skip to content
Permalink
Browse files

Rework autotools chain.

  • Loading branch information...
vstakhov committed Mar 18, 2014
1 parent e108cc4 commit d90931a1576560373573a83bb2d1a8e85a3db56a
Showing with 120 additions and 64 deletions.
  1. +2 −20 Makefile.am
  2. +57 −39 configure.ac
  3. +19 −0 src/Makefile.am
  4. +8 −0 src/ucl_emitter.c
  5. +26 −2 src/ucl_internal.h
  6. +4 −0 src/ucl_schema.c
  7. +2 −0 src/ucl_util.c
  8. +1 −0 stamp-h.in
  9. +1 −3 tests/test_basic.c
@@ -1,21 +1,3 @@
libucl_common_cflags= -I$(top_srcdir)/src \
-I$(top_srcdir)/include \
-I$(top_srcdir)/uthash \
-I$(top_srcdir)/src \
-DPREFIX=\"$(prefix)\" \
-Wall -W -Wno-unused-parameter -Wno-pointer-sign
lib_LTLIBRARIES= libucl.la
libucl_la_SOURCES= src/ucl_emitter.c \
src/ucl_hash.c \
src/ucl_parser.c \
src/ucl_schema.c \
src/ucl_util.c \
src/xxhash.c
libucl_la_CFLAGS= $(libucl_common_cflags) \
@CURL_CFLAGS@
libucl_la_LIBADD= @LIBFETCH_LIBS@ \
@CURL_LIBS@
ACLOCAL_AMFLAGS = -I m4

include_HEADERS= include/ucl.h

ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src
@@ -1,13 +1,19 @@
m4_define([maj_ver], [0])
m4_define([med_ver], [3])
m4_define([min_ver], [0])
m4_define([UCL_VERSION], [maj_ver.med_ver.min_ver])
m4_define([so_version], [maj_ver:med_ver])
m4_define([ucl_version], [maj_ver.med_ver.min_ver])

AC_SUBST([UCL_VERSION])
AC_INIT([libucl],[UCL_VERSION],[https://github.com/vstakhov/libucl],[libucl])
AC_INIT([libucl],[ucl_version],[https://github.com/vstakhov/libucl],[libucl])
AC_CONFIG_SRCDIR([configure.ac])
AM_INIT_AUTOMAKE([1.11 foreign -Wno-portability no-dist-gzip dist-xz])

UCL_VERSION=ucl_version
SO_VERSION=so_version

AC_SUBST(UCL_VERSION)
AC_SUBST(SO_VERSION)

AC_PROG_CC_C99
LT_INIT
AC_CONFIG_MACRO_DIR([m4])
@@ -19,58 +25,70 @@ AC_TYPE_SIZE_T
AC_CHECK_HEADERS_ONCE([fcntl.h unistd.h])
AC_TYPE_OFF_T
AC_FUNC_MMAP

if test "$ac_cv_func_mmap_fixed_mapped" = "yes"; then
FILEMAP=unixfilemap
else
FILEMAP=readfilemap
fi
AC_SUBST(FILEMAP)
AC_CHECK_HEADERS_ONCE([fcntl.h])
AC_CHECK_HEADERS_ONCE([sys/types.h])
AC_CHECK_HEADERS_ONCE([sys/stat.h])
AC_CHECK_HEADERS_ONCE([sys/param.h])
AC_CHECK_HEADERS_ONCE([sys/mman.h])
AC_CHECK_HEADERS_ONCE([stdlib.h])
AC_CHECK_HEADERS_ONCE([stddef.h])
AC_CHECK_HEADERS_ONCE([stdarg.h])
AC_CHECK_HEADERS_ONCE([stdbool.h])
AC_CHECK_HEADERS_ONCE([stdint.h])
AC_CHECK_HEADERS_ONCE([string.h])
AC_CHECK_HEADERS_ONCE([unistd.h])
AC_CHECK_HEADERS_ONCE([stdbool.h])
AC_CHECK_HEADERS_ONCE([ctype.h])
AC_CHECK_HEADERS_ONCE([errno.h])
AC_CHECK_HEADERS_ONCE([limits.h])
AC_CHECK_HEADERS_ONCE([libgen.h])
AC_CHECK_HEADERS_ONCE([stdio.h])
AC_CHECK_HEADERS_ONCE([float.h])
AC_CHECK_HEADERS_ONCE([math.h])

AC_SEARCH_LIBS([SSL_library_init], [ssl], [
AC_DEFINE(HAVE_OPENSSL, 1, [Define to 1 if you have the 'ssl' library (-lssl).])
LIBSSL_LIB="-lssl"
LIBS_EXTRA="${LIBS_EXTRA} -lssl"
], [-lcrypto])
dnl Example of default-disabled feature
AC_ARG_ENABLE([urls], AS_HELP_STRING([--enable-urls], [Enable URLs fetch (requires libfetch or libcurl)]))
AC_ARG_ENABLE([signatures], AS_HELP_STRING([--enable-signatures],
[Enable signatures check (requires openssl)]))

AS_IF([test "x$enable_signatures" = "xyes"], [
AC_SEARCH_LIBS([EVP_MD_CTX_create], [crypto], [
AC_DEFINE(HAVE_OPENSSL, 1, [Define to 1 if you have the 'crypto' library (-lcrypto).])
LIBSSL_LIB="-lcrypto"
LIBS_EXTRA="${LIBS_EXTRA} -lcrypto"
], [AC_MSG_ERROR([unable to find the EVP_MD_CTX_create() function])])
])

AC_CHECK_HEADER([fetch.h], [
AC_DEFINE(HAVE_FETCH_H, 1, [Define to 1 if you have the <fetch.h> header file.])
AC_CHECK_LIB(fetch, fetchXGet, [
AC_DEFINE(HAVE_LIBFETCH, 1, [Define to 1 if you have the 'fetch' library (-fetch).])
LIBFETCH_LIBS="-lfetch"
have_libfetch="yes"
LIBS_EXTRA="${LIBS_EXTRA} -lfetch"
AS_IF([test "x$enable_urls" = "xyes"], [
AC_CHECK_HEADER([fetch.h], [
AC_DEFINE(HAVE_FETCH_H, 1, [Define to 1 if you have the <fetch.h> header file.])
AC_CHECK_LIB(fetch, fetchXGet, [
AC_DEFINE(HAVE_LIBFETCH, 1, [Define to 1 if you have the 'fetch' library (-fetch).])
LIBFETCH_LIBS="-lfetch"
have_libfetch="yes"
LIBS_EXTRA="${LIBS_EXTRA} -lfetch"
])
], [],[
#include <stdio.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
])
], [],[
#include <stdio.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
AC_SUBST(LIBFETCH_LIBS)

AS_IF([ test "x$have_libfetch" != "xyes"], [
dnl Fallback to libcurl
PKG_CHECK_MODULES([CURL], [libcurl], [
AC_DEFINE(CURL_FOUND, 1, [Use libcurl])
LIBS_EXTRA="${LIBS_EXTRA} -lcurl"],
[AC_MSG_ERROR([unable to find neither libfetch nor libcurl])])
])
AC_SUBST(CURL_FOUND)
AC_SUBST(CURL_LIBS)
AC_SUBST(CURL_CFLAGS)
])
AC_SUBST([LIBFETCH_LIBS])

AS_IF([ test "x$have_libfetch" != "xyes"], [
dnl Fallback to libcurl
PKG_CHECK_MODULES([CURL], [libcurl], [
AC_DEFINE(CURL_FOUND, 1, [Use libcurl])
LIBS_EXTRA="${LIBS_EXTRA} -lcurl"],
[])], [])
AC_SUBST([CURL_FOUND])
AC_SUBST([CURL_LIBS])
AC_SUBST([CURL_CFLAGS])

AC_CONFIG_FILES(Makefile \
src/Makefile \
libucl.pc)
AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
AC_OUTPUT
@@ -0,0 +1,19 @@
libucl_common_cflags= -I$(top_srcdir)/src \
-I$(top_srcdir)/include \
-I$(top_srcdir)/uthash \
-Wall -W -Wno-unused-parameter -Wno-pointer-sign
lib_LTLIBRARIES= libucl.la
libucl_la_SOURCES= ucl_emitter.c \
ucl_hash.c \
ucl_parser.c \
ucl_schema.c \
ucl_util.c \
xxhash.c
libucl_la_CFLAGS= $(libucl_common_cflags) \
@CURL_CFLAGS@
libucl_la_LDFLAGS = -version-info @SO_VERSION@
libucl_la_LIBADD= @LIBFETCH_LIBS@ \
@CURL_LIBS@

include_HEADERS= $(top_srcdir)/include/ucl.h

@@ -21,8 +21,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifdef HAVE_FLOAT_H
#include <float.h>
#endif
#ifdef HAVE_MATH_H
#include <math.h>
#endif
#include "ucl.h"
#include "ucl_internal.h"
#include "ucl_chartable.h"
@@ -28,19 +28,43 @@
#include "config.h"
#endif

#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#ifndef _WIN32
#include <sys/mman.h>
#endif

#ifdef HAVE_SYS_MMAN_H
# ifndef _WIN32
# include <sys/mman.h>
# endif
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif

#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif

#include "utlist.h"
#include "utstring.h"
@@ -27,8 +27,12 @@
#include "ucl_internal.h"
#include "tree.h"
#include "utlist.h"
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif

static bool
ucl_string_to_type (const char *input, ucl_type_t *res)
@@ -25,7 +25,9 @@
#include "ucl_internal.h"
#include "ucl_chartable.h"

#ifdef HAVE_LIBGEN_H
#include <libgen.h> /* For dirname */
#endif

#ifdef HAVE_OPENSSL
#include <openssl/err.h>
@@ -0,0 +1 @@
timestamp
@@ -21,10 +21,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include "ucl.h"
#include "ucl_internal.h"

int
main (int argc, char **argv)

0 comments on commit d90931a

Please sign in to comment.
You can’t perform that action at this time.