-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure.ac
245 lines (199 loc) · 6.16 KB
/
configure.ac
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
dnl Copyright (c) 2005, Eric Crahen
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a copy
dnl of this software and associated documentation files (the "Software"), to deal
dnl in the Software without restriction, including without limitation the rights
dnl to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
dnl copies of the Software, and to permit persons to whom the Software is furnished
dnl to do so, subject to the following conditions:
dnl
dnl The above copyright notice and this permission notice shall be included in all
dnl copies or substantial portions of the Software.
dnl
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
dnl AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
dnl WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
dnl CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AC_REVISION($Revision$ZT_VERSION $)
AC_INIT
AC_CONFIG_SRCDIR([README])
AC_COPYRIGHT([Eric Crahen, 2000-2002])
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
ZT_MAJOR_VERSION=2
ZT_MINOR_VERSION=3
ZT_MICRO_VERSION=3
ZT_INTERFACE_AGE=0
ZT_BINARY_AGE=0
ZT_VERSION=$ZT_MAJOR_VERSION.$ZT_MINOR_VERSION.${ZT_MICRO_VERSION}
AC_SUBST(ZT_MAJOR_VERSION)
AC_SUBST(ZT_MINOR_VERSION)
AC_SUBST(ZT_MICRO_VERSION)
AC_SUBST(ZT_INTERFACE_AGE)
AC_SUBST(ZT_BINARY_AGE)
AC_SUBST(ZT_VERSION)
dnl prepare version info
LT_RELEASE=$ZT_MAJOR_VERSION.$ZT_MINOR_VERSION
LT_CURRENT=`expr $ZT_MICRO_VERSION - $ZT_INTERFACE_AGE`
LT_REVISION=$ZT_INTERFACE_AGE
LT_AGE=`expr $ZT_BINARY_AGE - $ZT_INTERFACE_AGE`
AC_SUBST(LT_RELEASE)
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)
AM_INIT_AUTOMAKE(ZThread, $ZT_VERSION)
AM_CONFIG_HEADER(src/config.h)
AM_ACLOCAL_INCLUDE(share)
dnl Check for support
AC_PROG_CXX
COMPILER_OPTIONS=""
LINKER_OPTIONS=""
dnl Check for pthreads support
AM_DETECT_PTHREAD
AM_WITH_DOXYGEN
AM_ENABLE_ATOMIC_LINUX
AM_ENABLE_ATOMIC_GCC
AM_DETECT_FTIME
dnl Setup compiler/linker options based on the target type
case "$target" in
*-*-mingw32*)
dnl MingW32 should use native win32 threads
;;
*-apple-darwin*)
dnl Use the Mac multiprocessing library
LINKER_OPTIONS="-framework CoreServices"
;;
*)
dnl Assume pthreads
if test x"$PTHREAD_CFLAGS" != x; then
COMPILER_OPTIONS="$PTHREAD_CFLAGS"
fi
if test x"$PTHREAD_LIBS" != x; then
LINKER_OPTIONS="$PTHREAD_LIBS"
fi
;;
esac
dnl Switch to C++ mode and check for needed C++ headers
AC_LANG_PUSH([C++])
dnl Configure the compiling options
case "$CXX" in
*cl.exe) # Microsoft Visual Studio
CXXFLAGS="/nologo /MT /W3 /GX /O2 /YX /FD /c"
CXXFLAGS="$CXXFLAGS /D \"_MBCS\" /D \"_LIB" /D \"WIN32\"
;;
*) # GNU
CXXFLAGS="$CXXFLAGS -Wall"
;;
esac
dnl Header checks
AC_HEADER_STDC
AC_CHECK_HEADERS(errno.h)
dnl Check for debug-mode
AC_ARG_ENABLE(debug,
[ --enable-debug Enable debug symbols [default=no]],
[
dnl Enable debug info
case "$CXX" in
*cl.exe)
;;
*)
CXXFLAGS="$CXXFLAGS -g"
esac
],[
dnl Disable debug info
case "$CXX" in
*cl.exe)
CXXFLAGS="$CXXFLAGS /D NDEBUG"
;;
*)
CXXFLAGS="$CXXFLAGS -DNDEBUG"
esac
])
dnl Select implementation
AC_MSG_CHECKING(for target implementation)
ZT_TYPE="auto"
AC_ARG_ENABLE(win9x,
[ --enable-win9x Select WIN9X implementation [default=no]],
[
if test $ZT_TYPE != auto; then
AC_MSG_ERROR(Select one implementation)
fi
ZT_TYPE="win9x"
COMPILER_OPTIONS="$COMPILER_OPTIONS -DZT_WIN9X"
])
AC_ARG_ENABLE(win32,
[ --enable-win32 Select WIN32 implementation [default=autodetect]],
[
if test $ZT_TYPE != auto; then
AC_MSG_ERROR(Select one implementation)
fi
ZT_TYPE="win32"
COMPILER_OPTIONS="$COMPILER_OPTIONS -DZT_WIN32"
])
AC_ARG_ENABLE(posix,
[ --enable-posix Select POSIX implementation [default=autodetect]],
[
if test $ZT_TYPE != auto; then
AC_MSG_ERROR(Select one implementation)
fi
ZT_TYPE="posix"
COMPILER_OPTIONS="$COMPILER_OPTIONS -DZT_POSIX"
])
AC_ARG_ENABLE(macos,
[ --enable-macos Select MacOS implementation [default=autodetect]],
[
if test $ZT_TYPE != auto; then
AC_MSG_ERROR(Select one implementation)
fi
ZT_TYPE="macos"
COMPILER_OPTIONS="$COMPILER_OPTIONS -DZT_MACOS"
])
AC_ARG_ENABLE(vanilla,
[ --enable-vanilla Select vanilla implementation [default=autodetect]],
[
COMPILER_OPTIONS="$COMPILER_OPTIONS -DZT_VANILLA"
])
if test $ZT_TYPE = auto; then
ZT_TYPE="compile-time guess"
fi
AC_MSG_RESULT($ZT_TYPE)
dnl Configure targets
SUBDIRS="src"
dnl AC_ARG_ENABLE(examples,
dnl [ --enable-examples Include examples in the project build. [default=yes]],,
dnl [
dnl SUBDIRS="$SUBDIRS examples"
dnl ])
dnl Enable priorities
AC_ARG_ENABLE(priorities, [ --enable-priorities Enable pthreads priorities [default=yes]], AC_DEFINE(ZTHREAD_DISABLE_PRIORITY,,[No OS priority support]))
dnl Disable IO interrupt w/ signal mechanism
AC_ARG_ENABLE(io-interrupts, [ --enable-interrupts Enable interrupt hooks [default=yes]], AC_DEFINE(ZTHREAD_DISABLE_INTERRUPT,,[No interrupt() hooks]))
dnl Check for setsigjmp
AC_MSG_CHECKING(for sigsetjmp())
AC_TRY_LINK( [#include <setjmp.h>], [sigjmp_buf t; sigsetjmp(t, 0);],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
AC_DEFINE(ZTHREAD_DISABLE_INTERRUPT,,[No interrupt() hooks])
])
dnl Check for beginthreadex
AC_MSG_CHECKING(for _beginthreadex())
AC_TRY_LINK( [#include <windows.h>], [_beginthreadex((void*)0, 0, 0, (void*)0, 0, (void*)0);],
[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BEGINTHREADEX,,[_beginthreadex()])
], [AC_MSG_RESULT(no)])
dnl Configure the final compiler & linker options
COMPILER_OPTIONS="$COMPILER_OPTIONS $CXXFLAGS"
LINKER_OPTIONS="$LINKER_OPTIONS $LDFLAGS"
dnl Configured flags for compiling ZThreads
AC_SUBST(LINKER_OPTIONS)
AC_SUBST(COMPILER_OPTIONS)
dnl Extra variables users can customize
AC_SUBST(EXTRA_LINKER_OPTIONS)
AC_SUBST(EXTRA_COMPILER_OPTIONS)
AM_PROG_LIBTOOL
AC_SUBST(SUBDIRS)
AC_CONFIG_FILES([Makefile src/Makefile share/zthread-config share/zthread.spec])
AC_OUTPUT