aboutsummaryrefslogtreecommitdiff
path: root/m4/odp_pthread.m4
blob: ad1ecdff4f955bc5edf741d938ba5d4d5f850ff5 (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
# Copyright (c) 2018, Linaro Limited
# All rights reserved.
#
# SPDX-License-Identifier:     BSD-3-Clause
#
# ODP_PTHREAD
# -----------
# Check for pthreads availability
AC_DEFUN([ODP_PTHREAD], [
	AC_MSG_CHECKING([for pthread support in -pthread])
	AC_LANG_PUSH([C])
	saved_cflags="$CFLAGS"
	saved_ldflags="$LDFLAGS"
	PTHREAD_CFLAGS="-pthread"
	CFLAGS="$AM_CFLAGS $CFLAGS $PTHREAD_CFLAGS"
	PTHREAD_LIBS="-pthread"
	LDFLAGS="$AM_LDFLAGS $LDFLAGS $PTHREAD_LIBS"
	AC_TRY_LINK_FUNC([pthread_create], [pthread=yes])
	CFLAGS="$saved_cflags"
	LDFLAGS="$saved_ldflags"
	if test x"$pthread" != "xyes"; then
		AC_MSG_FAILURE([pthread is not supported])
	fi
	AC_MSG_RESULT([yes])
	AC_LANG_POP([C])
	AC_SUBST([PTHREAD_LIBS])
	AC_SUBST([PTHREAD_CFLAGS])
])