summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 237821b17676885bbcaccdf7d354dd67418b2b3d (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
AC_INIT([timer], [0.1], [the_jk@yahoo.com])
AC_CONFIG_MACRO_DIR([m4])

AC_ISC_POSIX
AC_HEADER_STDC
AC_C_CONST
AC_C_INLINE
#AC_C_BIGENDIAN
AC_C___ATTRIBUTE__
#AC_PROG_RANLIB

AM_INIT_AUTOMAKE([dist-bzip2 foreign color-tests parallel-tests])
AM_SILENT_RULES([yes])
AC_PROG_CC
AM_PROG_CC_C_O

DEFINES="-D_GNU_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE"
AX_CFLAGS_WARN_ALL([DEFINES])
AC_ARG_ENABLE([debug], AC_HELP_STRING([compile with debug options]),
              if test "x$enableval" = "xyes"; then
                DEFINES="$DEFINES -g -DDEBUG"
              fi)
AC_SUBST([DEFINES])

# Common

AC_HEADER_STDBOOL

AC_SEARCH_LIBS([round], [m],, AC_MSG_ERROR([need round]))

# Threads

AC_CHECK_HEADER([pthread.h],have_pthread=1,have_pthread=0)
if test "x$have_pthread" = "x1"; then
  OLDCFLAGS="$CFLAGS"
  OLDLDFLAGS="$LDFLAGS"
  CFLAGS="$OLDCFLAGS -pthread"
  LDFLAGS="$OLDLDFLAGS -pthread"
  AC_SEARCH_LIBS([pthread_create], [pthread],, have_pthread=0)
  LDFLAGS="$OLDLDFLAGS"
  CFLAGS="$OLDCFLAGS"
  if test "x$have_pthread" = "x1"; then
    DEFINES="$DEFINES -pthread"
    LIBS="$LIBS -pthread"
  fi

  OLDCFLAGS="$CFLAGS"
  CFLAGS="$OLDCFLAGS $DEFINES"

  AC_CHECK_FUNC([pthread_yield],[have_pthread_yield=1],[have_pthread_yield=0])
  AC_DEFINE_UNQUOTED([HAVE_PTHREAD_YIELD],[$have_pthread_yield],[define to 1 if pthread_yield is available])

  if test "x$have_pthread_yield" = "x1"; then
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <pthread.h>
]],[[
return pthread_yield();
]])],pthread_yield_void=0,
     pthread_yield_void=1)
    AC_DEFINE_UNQUOTED([PTHREAD_YIELD_VOID],[$pthread_yield_void],[define to 1 if pthread_yield returns void])
  fi
  CFLAGS="$OLDCFLAGS"
fi
AM_CONDITIONAL([HAVE_PTHREAD], [test "x$have_pthread" = "x1"])
AC_DEFINE_UNQUOTED([HAVE_PTHREAD],[$have_pthread],[define to 1 if pthread is available])

if test "x$have_pthread" = "x0"; then
  AC_MSG_ERROR([no thread implementation found])
fi

# timeval
AC_CHECK_TYPES([struct timespec],,,[[#include <time.h>]])

# clock

AC_SEARCH_LIBS([clock_gettime], [rt], [have_clock_gettime=1], [have_clock_gettime=0])
AC_DEFINE_UNQUOTED([HAVE_CLOCK_GETTIME], [$have_clock_gettime], [Define to 1 if clock_gettime is available])

# XCB

PKG_PROG_PKG_CONFIG()

xcb_modules="xcb xcb-event xcb-keysyms"
PKG_CHECK_EXISTS([xcb-icccm >= 0.3.8],
                 [have_xcb_icccm=1
                  xcb_modules="$xcb_modules xcb-icccm"],[have_xcb_icccm=0])

PKG_CHECK_MODULES([XCB], [$xcb_modules])

AC_DEFINE_UNQUOTED([HAVE_XCB_ICCCM],[$have_xcb_icccm],[define to 1 if xcb-icccm is available])

# Finish up

AC_CONFIG_HEADERS([config.h])
AC_OUTPUT([Makefile src/Makefile])