File: configure.ac

package info (click to toggle)
skstream 0.3.9-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,896 kB
  • ctags: 535
  • sloc: sh: 10,997; cpp: 2,605; makefile: 64
file content (375 lines) | stat: -rw-r--r-- 8,061 bytes parent folder | download | duplicates (3)
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
dnl Initialise autoconf

AC_INIT([skstream], [0.3.9], [alriddoch@googlemail.com])
AC_CONFIG_SRCDIR([skstream/skstream.cpp])
AC_CONFIG_HEADERS([config.h])

dnl Detect the canonical host environment

AC_CANONICAL_HOST

dnl Initialise automake

AM_INIT_AUTOMAKE([nostdinc dist-bzip2 check-news color-tests])

SKSTREAM_CURRENT=7
SKSTREAM_REVISION=0
SKSTREAM_AGE=0
SKSTREAM_VERSION_INFO=$SKSTREAM_CURRENT:$SKSTREAM_REVISION:$SKSTREAM_AGE
SKSTREAM_VERSION_NO=$SKSTREAM_CURRENT.$SKSTREAM_AGE.$SKSTREAM_REVISION

SKSTREAM_UNIX_PC=
SKSTREAM_UNIX_PC_IN=
SKSTREAM_LIB_SUFFIX="-0.3"
SKSTREAM_LIBS="-lskstream$SKSTREAM_LIB_SUFFIX"
SKSTREAM_EXTRA_LIBS=

AC_SUBST(SKSTREAM_CURRENT)
AC_SUBST(SKSTREAM_VERSION_INFO)
AC_SUBST(SKSTREAM_VERSION_NO)

dnl Test for GNU libtool

LT_INIT([disable-static])

dnl Test for C++ compiler

AC_PROG_CXX

AC_ARG_ENABLE(debug,
    [  --enable-debug          enable debug information [default=no]],
    [
        if test "$enableval" = "yes"; then
            CXXFLAGS="$CXXFLAGS -Wall -DDEBUG"
        else
            CXXFLAGS="$CXXFLAGS -Wall -DNDEBUG"
        fi
    ],[
        CXXFLAGS="$CXXFLAGS -Wall -DNDEBUG"
    ]
)

dnl Test for ANSI standard language features

dnl Test for C++ bool keyword

AC_LANG(C++)

dnl Test for C++ Standard Library

AC_CHECK_HEADERS(cstdio iostream string)

dnl Test for mingw32

# There might be a better way to do this.
AC_MSG_CHECKING(for mingw32)
AC_TRY_COMPILE(,[
#ifdef __MINGW32__
#error MingW32 detected, adding -lws2_32 and -lwsock32 to LIBS
#endif
],
AC_MSG_RESULT(no),[
AC_MSG_RESULT(yes)
LIBS="$LIBS -lws2_32 -lwsock32"
SKSTREAM_EXTRA_LIBS="$SKSTREAM_EXTRA_LIBS -lws2_32 -lwsock32"
])

dnl Test for types

AC_MSG_CHECKING([for socket type])
SKSTREAM_SOCKET_TYPE=int;
SKSTREAM_SOCKET_HEADER="#include <unistd.h>"
AC_TRY_COMPILE([#include <ws2tcpip.h>],
[
    SOCKET foo;
    return foo; /* Avoids warning */
],
[
    SKSTREAM_SOCKET_TYPE=SOCKET
    SKSTREAM_SOCKET_HEADER="#include <ws2tcpip.h>"
],
[
    SKSTREAM_SOCKET_TYPE=int
    SKSTREAM_SOCKET_HEADER="#include <unistd.h>"
])
AC_MSG_RESULT($SKSTREAM_SOCKET_TYPE)
AC_SUBST(SKSTREAM_SOCKET_TYPE)
AC_SUBST(SKSTREAM_SOCKET_HEADER)

AC_MSG_CHECKING([for socket address length type])
SKSTREAM_SOCKLEN_TYPE=int;
AC_TRY_COMPILE([#include <unistd.h>
                #include <sys/socket.h>],
[
    socklen_t foo = 0;
    return foo != 0; /* Avoids warning */
],
[
    SKSTREAM_SOCKLEN_TYPE=socklen_t
],
[
    SKSTREAM_SOCKLEN_TYPE=int
])
AC_MSG_RESULT($SKSTREAM_SOCKLEN_TYPE)
AC_SUBST(SKSTREAM_SOCKLEN_TYPE)

AC_MSG_CHECKING([for unix domain sockets])
AC_TRY_COMPILE([#include <sys/types.h>
                #include <sys/socket.h>
                #include <sys/un.h>],
[
    sockaddr_un sa;
    sa.sun_family = AF_UNIX;
],
[
    AC_MSG_RESULT(yes)
    AC_DEFINE(SKSTREAM_UNIX_SOCKETS, 1,
              [Define if unix domain sockets are supported])
    SKSTREAM_UNIX_PC=skstream-unix-0.3.pc
    SKSTREAM_UNIX_PC_IN=skstream-unix-0.3.pc.in
],
[
    AC_MSG_RESULT(no)
])

AC_SUBST(SKSTREAM_UNIX_PC)
AC_SUBST(SKSTREAM_UNIX_PC_IN)

AC_MSG_CHECKING([for timeval header])
SKSTREAM_TIMEVAL_HEADER="#include <sys/time.h>"
SKSTREAM_UNIX_HEADER_FLAG=0
SKSTREAM_BEOS_HEADER_FLAG=0
SKSTREAM_WINDOWS_HEADER_FLAG=0

AC_TRY_COMPILE([#include <winsock2.h>],
[
    timeval foo;
    return &foo == 0; /* Avoids warning */
],
[
    SKSTREAM_TIMEVAL_HEADER="#include <winsock2.h>"
    SKSTREAM_WINDOWS_HEADER_FLAG=1
],
[
    AC_TRY_COMPILE([#include <sys/time.h>],
    [
        timeval foo;
        return &foo == 0; /* Avoids warning */
    ],
    [
        SKSTREAM_TIMEVAL_HEADER="#include <sys/time.h>"
        SKSTREAM_UNIX_HEADER_FLAG=1
    ],
    [
        AC_TRY_COMPILE([#include <net/socket.h>],
        [
            timeval foo;
            return &foo == 0; /* Avoids warning */
        ],
        [
            SKSTREAM_TIMEVAL_HEADER="#include <net/socket.h>"
            SKSTREAM_BEOS_HEADER_FLAG=1
        ],
        [
            AC_MSG_ERROR(Unable to find header for timeval type)
        ])

    ])
])

AC_MSG_RESULT($SKSTREAM_TIMEVAL_HEADER)
AC_SUBST(SKSTREAM_TIMEVAL_HEADER)
AC_SUBST(SKSTREAM_UNIX_HEADER_FLAG)
AC_SUBST(SKSTREAM_BEOS_HEADER_FLAG)
AC_SUBST(SKSTREAM_WINDOWS_HEADER_FLAG)

dnl Test for socket block error value

AC_MSG_CHECKING([for socket block error value])
AC_TRY_COMPILE([#include <errno.h>],
[
    int i = EINPROGRESS;
    return i == 0; /* Avoids warning */
],
[
    SKSTREAM_BLOCK_ERROR_VAL=EINPROGRESS
],
[
    AC_TRY_COMPILE([#include <windows.h>],
    [
        int i = WSAEWOULDBLOCK;
        return i == 0; /* Avoids warning */
    ],
    [
        SKSTREAM_BLOCK_ERROR_VAL=WSAEWOULDBLOCK
    ],
    [
        AC_MSG_RESULT(failed)
        AC_MSG_ERROR(Unable to determine error message for socket blocking)
    ])
])
AC_MSG_RESULT($SKSTREAM_BLOCK_ERROR_VAL)
AC_SUBST(SKSTREAM_BLOCK_ERROR_VAL)

dnl Test for IPv6 socket addresses

dnl Test for nsl library

AC_CHECK_FUNC(gethostbyname,,
[
    AC_MSG_CHECKING([for gethostbyname in ws2tcpip.h])
    AC_TRY_COMPILE(
    [
        #include <ws2tcpip.h>
    ],
    [
        ::gethostbyname("foo");
    ],
    [
        AC_MSG_RESULT(yes)
    ],
    [
        AC_MSG_RESULT(no)
        AC_CHECK_LIB(nsl, gethostbyname,
        [
            LIBS="$LIBS -lnsl"
            SKSTREAM_EXTRA_LIBS="$SKSTREAM_EXTRA_LIBS -lnsl"
        ],
        [
            AC_MSG_ERROR(Unable to find gethostbyname() socket call.)
        ])
    ])
])

dnl Test for socket library

AC_CHECK_FUNC(connect,,
[
    AC_MSG_CHECKING([for connect in ws2tcpip.h])
    AC_TRY_COMPILE(
    [
        #include <ws2tcpip.h>
    ],
    [
        ::connect(0, 0, 0);
    ],
    [
        AC_MSG_RESULT(yes)
    ],
    [
        AC_MSG_RESULT(no)
        AC_CHECK_LIB(socket, connect,
        [
            LIBS="$LIBS -lsocket"
            SKSTREAM_EXTRA_LIBS="$SKSTREAM_EXTRA_LIBS -lsocket"
        ],
        [
            AC_MSG_ERROR(Unable to find connect() socket call.)
        ])
    ])
])

dnl Test for closesocket

AC_MSG_CHECKING([for closesocket])
AC_TRY_COMPILE([#include <ws2tcpip.h>],
[
    closesocket(0);
],
[
    AC_DEFINE(HAVE_CLOSESOCKET, 1, "Define to 1 if you have the `closesocket' function.")
    AC_MSG_RESULT(yes)
],
[
    AC_MSG_RESULT(no)
])

dnl Test for getaddrinfo

AC_CHECK_FUNC(getaddrinfo,
[
    AC_DEFINE(HAVE_GETADDRINFO, 1, "Define to 1 if you have the `getaddrinfo' function.")
],
[
    CXXFLAGS="$CXXFLAGS -DWINVER=0x501"
    AC_MSG_CHECKING([for getaddrinfo in ws2tcpip.h])
    AC_TRY_COMPILE(
    [
        #include <ws2tcpip.h>
    ],
    [
        getaddrinfo(0, 0, 0, 0);
    ],
    [
        AC_MSG_RESULT(yes)
        AC_DEFINE(HAVE_GETADDRINFO, 1, "Define to 1 if you have the `getaddrinfo' function.")
    ],
    [
        AC_MSG_RESULT(no)
    ])
])

AC_CHECK_FUNC(gai_strerror,
[
    AC_DEFINE(HAVE_GAI_STRERROR, 1, "Define to 1 if you have the `gai_strerror' function.")
],
[
    CXXFLAGS="$CXXFLAGS -DWINVER=0x501"
    AC_MSG_CHECKING([for gai_strerror in ws2tcpip.h])
    AC_TRY_COMPILE(
    [
        #include <ws2tcpip.h>
    ],
    [
        gai_strerror(0);
    ],
    [
        AC_MSG_RESULT(yes)
        AC_DEFINE(HAVE_GAI_STRERROR, 1, "Define to 1 if you have the `gai_strerror' function.")
    ],
    [
        AC_MSG_RESULT(no)
    ])
])

dnl Test for Libraries

PKG_PROG_PKG_CONFIG

PKG_CHECK_MODULES(CPPUNIT, cppunit >= 1.0,
    [
        found_cppunit=yes
    ],
    [
        AC_MSG_WARN([Could not Find CppUnit - Tests will not work])
        found_cppunit=no
    ])

AM_CONDITIONAL(USE_CPPUNIT, test "$found_cppunit" = "yes")

dnl test for support programs

AC_CHECK_PROG(SK_ZIP, zip, zip, no)
AM_CONDITIONAL(HAVE_PROG_ZIP, test x$ac_cv_prog_SK_ZIP = xzip)

AC_SUBST(SKSTREAM_LIB_SUFFIX)
AC_SUBST(SKSTREAM_LIBS)
AC_SUBST(SKSTREAM_EXTRA_LIBS)

AC_DEFINE(CONFIG_H_INCLUDED, 1, true if config.h was included)

dnl Generate files

AC_CONFIG_FILES([
	Makefile
	skstream/Makefile
	ping/Makefile
	tools/Makefile
	test/Makefile
	skstream.spec
	mingw32-skstream.spec
	skstream-0.3.pc
	skstream-unix-0.3.pc
	skstream/skstreamconfig.h
])
AC_OUTPUT