aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
blob: 932b47cd25283e43a49e739b7adeb16e0f0137e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# file      : configure.ac
# author    : Boris Kolpackov <boris@codesynthesis.com>
# copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
# license   : GNU GPL v2; see accompanying LICENSE file

AC_PREREQ(2.60)
AC_INIT([libodb], [__value__(version)], [odb-users@codesynthesis.com])
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([odb/version.hxx])

AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects dist-bzip2 dist-zip tar-ustar])

LT_INIT([win32-dll])

AC_CANONICAL_HOST

# Check for C++ compiler and use it to compile the tests.
#
AC_PROG_CXX
AC_LANG(C++)

# Check for threads.
#
AC_ARG_ENABLE(
  [threads],
  AS_HELP_STRING([--disable-threads], [disable threads (enabled by default)]),
  [AS_IF([test x"$enableval" = xno], [threads=none], [threads=check])],
  [threads=check])

# If thread support is not disabled by the user, figure out what we
# can use.
#
AS_IF(
  [test x$threads = xcheck],
  [
   case $host_os in
     windows* | mingw*)
       AC_DEFINE([ODB_THREADS_WIN32], [1], [Have Win32 threads.])
       case $host_os in
         mingw*)
	   CXXFLAGS="$CXXFLAGS -mthreads"
	   ;;
       esac
       threads=win32
       ;;
     *)
       ACX_PTHREAD
       AS_IF(
         [test x$acx_pthread_ok = xyes],
         [
          threads=posix
          LIBS="$LIBS $PTHREAD_LIBS"
          CXXFLAGS="$CXXFLAGS $PTHREAD_CXXFLAGS"
          AC_DEFINE([ODB_THREADS_POSIX], [1], [Have POSIX threads.])
         ])
       ;;
   esac
  ],
  [AC_DEFINE([ODB_THREADS_NONE], [1], [Have no threads.])])

AM_CONDITIONAL([ODB_THREADS_NONE], [test x"$threads" = xnone])
AM_CONDITIONAL([ODB_THREADS_WIN32], [test x"$threads" = xwin32])
AM_CONDITIONAL([ODB_THREADS_POSIX], [test x"$threads" = xposix])

# Check if we should disable rpath.
#
AC_MSG_CHECKING([whether to use rpath])
AC_ARG_ENABLE(
  [rpath],
  [AC_HELP_STRING([--disable-rpath], [patch libtool to not use rpath])],
  [libtool_rpath="$enable_rpath"],
  [libtool_rpath="yes"])
AC_MSG_RESULT($libtool_rpath)

# Allow the user to specify the pkgconfig directory.
#
AC_ARG_WITH(
  [pkgconfigdir],
  [AC_HELP_STRING([--with-pkgconfigdir=DIR],[location of pkgconfig dir (default is libdir/pkgconfig)])],
  [pkgconfigdir=${withval}],
  [pkgconfigdir='${libdir}/pkgconfig'])
AC_SUBST([pkgconfigdir])

# Required by subdir-objects.
#
AM_PROG_CC_C_O

# Patch libtool to not use rpath if requested.
#
AC_CONFIG_COMMANDS(
  [libtool-rpath-patch],
  [if test "$libtool_use_rpath" = "no"; then
     sed < libtool > libtool-2 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_NO_RPATH__ "/'
     mv libtool-2 libtool
     chmod 755 libtool
  fi],
  [libtool_use_rpath=$libtool_rpath])

# Output.
#
AC_CONFIG_HEADERS([config.h odb/details/config.h])
AC_CONFIG_FILES([
  __path__(config_files)
])
AC_OUTPUT

AS_IF(
  [test x$threads = xcheck],
  [
    AC_MSG_NOTICE
    AC_MSG_NOTICE([warning: thread support not available, building single-threaded])
  ])