check: Use mkstemp instead of tempnam if possible
[platform/upstream/gstreamer.git] / m4 / check-checks.m4
1 dnl Check for things that check needs/wants and that we don't check for already
2 dnl AM_GST_CHECK_CHECKS()
3
4 AC_DEFUN([AG_GST_CHECK_CHECKS],
5 [
6 AC_MSG_NOTICE([Running check unit test framework checks now...])
7
8 CHECK_MAJOR_VERSION=0
9 CHECK_MINOR_VERSION=9
10 CHECK_MICRO_VERSION=14
11 CHECK_VERSION=$CHECK_MAJOR_VERSION.$CHECK_MINOR_VERSION.$CHECK_MICRO_VERSION
12
13 AC_SUBST(CHECK_MAJOR_VERSION)
14 AC_SUBST(CHECK_MINOR_VERSION)
15 AC_SUBST(CHECK_MICRO_VERSION)
16 AC_SUBST(CHECK_VERSION)
17
18 dnl Checks for header files and declarations
19 AC_CHECK_HEADERS([unistd.h sys/wait.h sys/time.h], [], [], [AC_INCLUDES_DEFAULT])
20
21 AC_CHECK_FUNCS([localtime_r])
22
23 dnl Check for getpid() and _getpid()
24 AC_CHECK_FUNCS([getpid _getpid])
25
26 dnl Check for strdup() and _strdup()
27 AC_CHECK_DECLS([strdup])
28 AC_CHECK_FUNCS([_strdup])
29
30 dnl Check for mkstemp
31 AC_CHECK_FUNCS([mkstemp])
32
33 dnl Check for fork
34 AC_CHECK_FUNCS([fork], HAVE_FORK=1, HAVE_FORK=0)
35 AC_SUBST(HAVE_FORK)
36
37 dnl Check for alarm, localtime_r and strsignal
38 dnl First check for time.h as it might be used by localtime_r
39 AC_CHECK_HEADERS([time.h])
40 AC_CHECK_DECLS([alarm, localtime_r, strsignal], [], [], [
41     AC_INCLUDES_DEFAULT
42 #if HAVE_TIME_H
43 #include <time.h>
44 #endif /* HAVE_TIME_H */
45 ])
46 AC_CHECK_FUNCS([alarm setitimer strsignal])
47 AM_CONDITIONAL(HAVE_ALARM, test "x$ac_cv_func_alarm" = "xyes")
48 AM_CONDITIONAL(HAVE_LOCALTIME_R, test "x$ac_cv_func_localtime_r" = "xyes")
49 AM_CONDITIONAL(HAVE_STRSIGNAL, test "x$ac_cv_func_strsignal" = "xyes")
50
51 dnl Check if struct timespec/itimerspec are defined in time.h. If not, we need
52 dnl to define it in libs/gst/check/libcheck/libcompat.h. Note the optional
53 dnl inclusion of pthread.h. On MinGW(-w64), the pthread.h file contains the
54 dnl timespec/itimerspec definitions.
55 AC_CHECK_MEMBERS([struct timespec.tv_sec, struct timespec.tv_nsec], [],
56   [AC_DEFINE_UNQUOTED(STRUCT_TIMESPEC_DEFINITION_MISSING, 1,
57     [Need to define the timespec structure])], [
58 #include <time.h>
59 #if HAVE_PTHREAD
60 #include <pthread.h>
61 #endif /* HAVE_PTHREAD */
62 ])
63 AC_CHECK_MEMBERS([struct itimerspec.it_interval, struct itimerspec.it_value],
64   [], [AC_DEFINE_UNQUOTED(STRUCT_ITIMERSPEC_DEFINITION_MISSING, 1,
65     [Need to define the itimerspec structure])], [
66 #include <time.h>
67 #if HAVE_PTHREAD
68 #include <pthread.h>
69 #endif /* HAVE_PTHREAD */
70 ])
71
72 dnl Check if types timer_t/clockid_t are defined. If not, we need to define
73 dnl it in libs/gst/check/libcheck/ibcompat.h. Note the optional inclusion of
74 dnl pthread.h. On MinGW(-w64), the pthread.h file contains the
75 dnl timer_t/clockid_t definitions.
76 AC_CHECK_TYPE(timer_t, [], [
77     AC_DEFINE([timer_t], [int], [timer_t])
78   ], [
79     AC_INCLUDES_DEFAULT
80 #if HAVE_PTHREAD
81 #include <pthread.h>
82 #endif /* HAVE_PTHREAD */
83 ])
84 AC_CHECK_TYPE(clockid_t, [], [
85     AC_DEFINE([clockid_t], [int], [clockid_t])
86   ], [
87     AC_INCLUDES_DEFAULT
88 #if HAVE_PTHREAD
89 #include <pthread.h>
90 #endif /* HAVE_PTHREAD */
91 ])
92
93 dnl Check for POSIX timer functions in librt
94 AC_CHECK_LIB([rt], [timer_create, timer_settime, timer_delete])
95 AM_CONDITIONAL(HAVE_TIMER_CREATE_SETTIME_DELETE, test "x$ac_cv_lib_rt_timer_create__timer_settime__timer_delete" = "xyes")
96
97 dnl Allow for checking HAVE_CLOCK_GETTIME in automake files
98 AM_CONDITIONAL(HAVE_CLOCK_GETTIME, test "x$ac_cv_func_clock_gettime" = "xyes")
99
100 dnl Create _stdint.h in the top-level directory
101 AX_CREATE_STDINT_H
102
103 dnl Disable subunit support for the time being
104 enable_subunit=false
105
106 if test xfalse = x"$enable_subunit"; then
107 ENABLE_SUBUNIT="0"
108 else
109 ENABLE_SUBUNIT="1"
110 fi
111 AC_SUBST(ENABLE_SUBUNIT)
112 AC_DEFINE_UNQUOTED(ENABLE_SUBUNIT, $ENABLE_SUBUNIT, [Subunit protocol result output])
113
114 AM_CONDITIONAL(SUBUNIT, test x"$enable_subunit" != "xfalse")
115
116 ])