summaryrefslogtreecommitdiff
path: root/configure.ac
blob: c08f62d36ffca7aacc2c5747a6622f113a80fdfa (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
AC_INIT([libpthread-stubs],
        0.1,
        [xcb@lists.freedesktop.org])
AC_CONFIG_SRCDIR([pthread-stubs.pc.in])
AM_INIT_AUTOMAKE([foreign dist-bzip2])

AC_CONFIG_HEADERS([config.h])

AC_PROG_LIBTOOL
AC_PROG_CC


dnl Detection code for compilers supporting the __attribute__((weak, alias))
dnl feature. Original code present in unieject's repository
dnl Diego Pettenò <flameeyes@gentoo.org>
ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
AC_CACHE_CHECK([if compiler supports __attribute__((weak, alias))],
	[cc_cv_attribute_alias],
	[AC_COMPILE_IFELSE([
		void other_function(void *foo) { }
		void some_function(void *foo) __attribute__((weak, alias("other_function")));
		],
		[cc_cv_attribute_alias=yes],
		[cc_cv_attribute_alias=no])
	])
CFLAGS="$ac_save_CFLAGS"
if test "x$cc_cv_attribute_alias" = "xyes"; then
	AC_DEFINE([SUPPORT_ATTRIBUTE_ALIAS], 1, [Define this if the compiler supports the alias attribute])
fi


PKG_CONFIG_LIBS=
AC_CHECK_FUNCS([pthread_self pthread_mutex_init pthread_mutex_destroy pthread_mutex_lock pthread_mutex_unlock pthread_cond_init pthread_cond_destroy pthread_cond_wait pthread_cond_signal pthread_cond_broadcast pthread_equal],
	       [], [PKG_CONFIG_LIBS='-L${libdir} -lpthread-stubs'])
AC_SUBST([PKG_CONFIG_LIBS])
AM_CONDITIONAL(BUILD_LIB, test x$PKG_CONFIG_LIBS != x)

AC_CONFIG_FILES([Makefile pthread-stubs.pc])
AC_OUTPUT