source: npl/mailserver/dspam/dspam-3.10.2/m4/pthread.m4 @ c5c522c

gcc484ntopperl-5.22
Last change on this file since c5c522c was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 2.3 KB
Line 
1# $Id: pthread.m4,v 1.3 2004/11/20 23:33:25 jonz Exp $
2# Autuconf macros for checking how to compile with pthreads
3# Jonathan Zdziarski <jonathan@nuclearelephant.com>
4#
5#   Public available macro:
6#       DS_PTHREADS([pthreads_cppflags_out],
7#                   [pthreads_ldflags_out],
8#                   [pthreads_libs_out],
9#                   [additional-action-if-found],
10#                   [additional-action-if-not-found])
11#
12AC_DEFUN([DS_PTHREADS],
13[
14ds_pthreads_save_CPPFLAGS="$CPPFLAGS"
15ds_pthreads_save_LDFLAGS="$LDFLAGS"
16ds_pthreads_save_LIBS="$LIBS"
17
18ds_pthreads_CPPFLAGS=""
19ds_pthreads_LDFLAGS=""
20ds_pthreads_LIBS=""
21
22AC_MSG_CHECKING([how you like your pthreads])
23pthreads_success="no"
24
25LIBS="$ds_pthreads_save_LIBS -pthread"
26
27AC_RUN_IFELSE([AC_LANG_SOURCE([[
28 #include <pthread.h>
29 #include <stdlib.h>
30
31 int main() {
32
33   pthread_mutex_t m;
34   pthread_mutex_init(&m, NULL);
35   pthread_exit(0);
36   exit(EXIT_FAILURE);
37 }
38
39]])],
40  [
41    pthreads_success="yes"
42    ds_pthreads_LIBS="-pthread"
43    AC_MSG_RESULT([-pthread])
44  ],
45  [ ])
46
47if test x"$pthreads_success" = xno
48then
49  LIBS="$ds_pthreads_save_LIBS -lpthread"
50
51AC_RUN_IFELSE([AC_LANG_SOURCE([[
52  #include <pthread.h>
53  #include <stdlib.h>
54
55  int main() {
56    pthread_mutex_t m;
57    pthread_mutex_init(&m, NULL);
58    pthread_exit(0);
59    exit(EXIT_FAILURE);
60  }
61
62]])],
63  [
64    pthreads_success="yes"
65    ds_pthreads_LIBS="-lpthread"
66    AC_MSG_RESULT([-lpthread])
67  ],
68  [ ])
69fi
70
71if test x"$pthreads_success" = xno
72then
73  LIBS="$ds_pthreads_save_LIBS -lpthread -mt"
74
75AC_RUN_IFELSE([AC_LANG_SOURCE([[
76  #include <pthread.h>
77  #include <stdlib.h>
78
79  int main() {
80    pthread_mutex_t m;
81    pthread_mutex_init(&m, NULL);
82    pthread_exit(0);
83    exit(EXIT_FAILURE);
84  }
85
86]])],
87  [
88    pthreads_success="yes"
89    ds_pthreads_LIBS="-lpthread -mt"
90    AC_MSG_RESULT([-lpthread -mt])
91  ],
92  [ ])
93fi
94
95if test x"$pthreads_success" = xno
96then
97  AC_MSG_RESULT([unknown])
98  AC_MSG_ERROR([Unable to determine how to compile with pthreads])
99fi
100
101CPPFLAGS="$ds_pthreads_save_CPPFLAGS"
102LDFLAGS="$ds_pthreads_save_LDFLAGS"
103LIBS="$ds_pthreads_save_LIBS"
104
105if test x"$pthreads_success" = xyes
106then
107    ifelse([$1], [], [:], [$1="$ds_pthreads_CPPFLAGS"])
108    ifelse([$2], [], [:], [$2="$ds_pthreads_LDFLAGS"])
109    ifelse([$3], [], [:], [$3="$ds_pthreads_LIBS"])
110    ifelse([$4], [], [:], [$4])
111    :
112else
113    ifelse([$5], [], [:], [$5])
114    :
115fi
116])
Note: See TracBrowser for help on using the repository browser.