summaryrefslogtreecommitdiff
path: root/configure.ac
blob: e6e71ec55e0af51219fab6b2bef6fd5b483048c8 (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
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
fi
AM_CONDITIONAL([HAVE_PTHREAD], [test "x$have_pthread" = "x1"])

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

# timeval

# clock

have_clock_gettime=0
have_clock_nanosleep=0
CLOCK_LIBS=

AC_MSG_CHECKING([for clock_gettime])
AC_LINK_IFELSE([AC_LANG_CALL([], [clock_gettime])],
               AC_MSG_RESULT([yes])
               have_clock_gettime=1,
               AC_MSG_RESULT([no])
               OLDLIBS="$LIBS"
               LIBS="$LIBS -lrt"
               AC_MSG_CHECKING([for clock_gettime in -lrt])
               AC_LINK_IFELSE([AC_LANG_CALL([], [clock_gettime])],
                              AC_MSG_RESULT([yes])
                              have_clock_gettime=1
                              CLOCK_LIBS="$CLOCK_LIBS -lrt",
                              AC_MSG_RESULT([no]))
               LIBS="$OLDLIBS")
AC_DEFINE_UNQUOTED([HAVE_CLOCK_GETTIME], [$have_clock_gettime], [define to 1 if clock_gettime is available])
AC_MSG_CHECKING([for clock_nanosleep])
AC_LINK_IFELSE([AC_LANG_CALL([], [clock_nanosleep])],
               AC_MSG_RESULT([yes])
               have_clock_nanosleep=1,
               AC_MSG_RESULT([no])
               OLDLIBS="$LIBS"
               LIBS="$LIBS -lrt"
               AC_MSG_CHECKING([for clock_nanosleep in -lrt])
               AC_LINK_IFELSE([AC_LANG_CALL([], [clock_nanosleep])],
                              AC_MSG_RESULT([yes])
                              have_clock_nanosleep=1
                              CLOCK_LIBS="$CLOCK_LIBS -lrt",
                              AC_MSG_RESULT([no]))
               LIBS="$OLDLIBS")
AC_DEFINE_UNQUOTED([HAVE_CLOCK_NANOSLEEP], [$have_clock_nanosleep], [define to 1 if clock_nanosleep is available])
AC_SUBST([CLOCK_LIBS])

# 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])