This repository has been archived by the owner on Nov 14, 2022. It is now read-only.
forked from tmate-io/tmate-ssh-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
604 lines (549 loc) · 13.6 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
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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
# configure.ac
AC_INIT(tmux, 2.2)
AC_CONFIG_AUX_DIR(etc)
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_CANONICAL_HOST
# When CFLAGS isn't set at this stage and gcc is detected by the macro below,
# autoconf will automatically use CFLAGS="-O2 -g". Prevent that by using an
# empty default.
: ${CFLAGS=""}
# Set up the compiler in two different ways and say yes we may want to install.
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_EGREP
AC_PROG_INSTALL
PKG_PROG_PKG_CONFIG
# Default tmux.conf goes in /etc not ${prefix}/etc.
test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc
AC_ARG_ENABLE(
latency,
AC_HELP_STRING(--enable-latency, "enable latency (requires libssh head)"),
found_latency=$enable_latency
)
AM_CONDITIONAL(IS_LATENCY, test "x$found_latency" = xyes)
AC_ARG_ENABLE(
devenv,
AC_HELP_STRING(--enable-devenv, "dev env (port 2200, no random tokens)"),
found_devenv=$enable_devenv
)
AM_CONDITIONAL(IS_DEVENV, test "x$found_devenv" = xyes)
# Is this --enable-debug?
found_debug=yes
AC_ARG_ENABLE(
debug,
AC_HELP_STRING(--enable-debug, enable debug build flags),
found_debug=$enable_debug
)
AM_CONDITIONAL(IS_DEBUG, test "x$found_debug" = xyes)
# Is this --enable-coverage?
AC_ARG_ENABLE(
coverage,
AC_HELP_STRING(--enable-coverage, enable coverage build flags),
found_coverage=$enable_coverage
)
AM_CONDITIONAL(IS_COVERAGE, test "x$found_coverage" = xyes)
# Is this a static build?
AC_ARG_ENABLE(
static,
AC_HELP_STRING(--enable-static, create a static build),
found_static=$enable_static
)
if test "x$found_static" = xyes; then
LDFLAGS="$LDFLAGS -static"
PKG_CONFIG="pkg-config --static"
fi
# Is this gcc?
AM_CONDITIONAL(IS_GCC, test "x$GCC" = xyes)
# Is this Sun CC?
AC_EGREP_CPP(
yes,
[
#ifdef __SUNPRO_C
yes
#endif
],
found_suncc=yes,
found_suncc=no
)
AM_CONDITIONAL(IS_SUNCC, test "x$found_suncc" = xyes)
# Is this glibc?
AC_MSG_CHECKING(for glibc)
AC_EGREP_CPP(
yes,
[
#include <features.h>
#ifdef __GLIBC__
yes
#endif
],
found_glibc=yes,
found_glibc=no
)
AM_CONDITIONAL(IS_GLIBC, test "x$found_glibc" = xyes)
AC_MSG_RESULT($found_glibc)
# Check for various headers. Alternatives included from compat.h.
AC_CHECK_HEADERS(
[ \
bitstring.h \
curses.h \
dirent.h \
fcntl.h \
inttypes.h \
libutil.h \
ncurses.h \
ndir.h \
paths.h \
pty.h \
stdint.h \
sys/dir.h \
sys/ndir.h \
sys/tree.h \
term.h \
util.h \
]
)
# Look for library needed for flock.
AC_SEARCH_LIBS(flock, bsd)
# Check for some functions that are replaced or omitted.
AC_CHECK_FUNCS(
[ \
dirfd \
flock \
setproctitle \
sysconf \
cfmakeraw \
]
)
# Look for clock_gettime. Must come before event_init.
AC_SEARCH_LIBS(clock_gettime, rt)
# Look for libevent.
PKG_CHECK_MODULES(
LIBEVENT,
libevent,
[
CPPFLAGS="$LIBEVENT_CFLAGS $CPPFLAGS"
LIBS="$LIBEVENT_LIBS $LIBS"
found_libevent=yes
],
[
AC_SEARCH_LIBS(
event_init,
[event event-1.4 event2],
found_libevent=yes,
found_libevent=no
)
]
)
if test "x$found_libevent" = xno; then
AC_MSG_ERROR("libevent not found")
fi
# Look for ncurses
PKG_CHECK_MODULES(
LIBNCURSES,
ncurses,
[
CPPFLAGS="$LIBNCURSES_CFLAGS $CPPFLAGS"
LIBS="$LIBNCURSES_LIBS $LIBS"
found_curses=yes
],
[
AC_SEARCH_LIBS(
setupterm,
[ncurses curses terminfo],
found_curses=yes,
found_curses=no
)
]
)
if test "x$found_curses" = xno; then
AC_MSG_ERROR("curses not found")
fi
# Look for utempter.
AC_CHECK_HEADER(utempter.h, found_utempter=yes, found_utempter=no)
if test "x$found_utempter" = xyes; then
AC_SEARCH_LIBS(
utempter_add_record,
utempter,
found_utempter=yes,
found_utempter=no
)
if test "x$found_utempter" = xyes; then
AC_DEFINE(HAVE_UTEMPTER)
fi
fi
PKG_CHECK_MODULES(
MSGPACK,
msgpack >= 1.2.0,
[
CPPFLAGS="$MSGPACK_CFLAGS $CPPFLAGS"
LIBS="$MSGPACK_LIBS $LIBS"
found_msgpack=yes
],
found_msgpack=no
)
if test "x$found_msgpack" = xno; then
AC_MSG_ERROR("msgpack >= 1.2.0 not found")
fi
PKG_CHECK_MODULES(
LIBSSH,
libssh >= 0.7.0,
[
CPPFLAGS="$LIBSSH_CFLAGS $CPPFLAGS"
LIBS="$LIBSSH_LIBS $LIBS"
found_libssh=yes
],
found_libssh=no
)
if test "x$found_libssh" = xno; then
AC_MSG_ERROR("libssh >= 0.7.0 not found")
fi
AC_CHECK_FUNCS([setresuid setresgid setreuid setregid])
# Check for b64_ntop.
AC_MSG_CHECKING(for b64_ntop)
AC_TRY_LINK(
[
#include <sys/types.h>
#include <netinet/in.h>
#include <resolv.h>
],
[b64_ntop(NULL, 0, NULL, 0);],
found_b64_ntop=yes,
found_b64_ntop=no
)
if test "x$found_b64_ntop" = xno; then
AC_MSG_RESULT(no)
AC_MSG_CHECKING(for b64_ntop with -lresolv)
LIBS="$LIBS -lresolv"
AC_TRY_LINK(
[
#include <sys/types.h>
#include <netinet/in.h>
#include <resolv.h>
],
[b64_ntop(NULL, 0, NULL, 0);],
found_b64_ntop=yes,
found_b64_ntop=no
)
if test "x$found_b64_ntop" = xno; then
AC_MSG_RESULT(no)
fi
fi
if test "x$found_b64_ntop" = xyes; then
AC_DEFINE(HAVE_B64_NTOP)
AC_MSG_RESULT(yes)
fi
AM_CONDITIONAL(NO_B64_NTOP, [test "x$found_b64_ntop" = xno])
# Look for networking libraries.
AC_SEARCH_LIBS(inet_ntoa, nsl)
AC_SEARCH_LIBS(socket, socket)
AC_CHECK_LIB(xnet, socket)
# Check for CMSG_DATA. Some platforms require _XOPEN_SOURCE_EXTENDED (for
# example see xopen_networking(7) on HP-UX).
XOPEN_DEFINES=
AC_MSG_CHECKING(for CMSG_DATA)
AC_EGREP_CPP(
yes,
[
#include <sys/socket.h>
#ifdef CMSG_DATA
yes
#endif
],
found_cmsg_data=yes,
found_cmsg_data=no
)
AC_MSG_RESULT($found_cmsg_data)
if test "x$found_cmsg_data" = xno; then
AC_MSG_CHECKING(if CMSG_DATA needs _XOPEN_SOURCE_EXTENDED)
AC_EGREP_CPP(
yes,
[
#define _XOPEN_SOURCE 1
#define _XOPEN_SOURCE_EXTENDED 1
#include <sys/socket.h>
#ifdef CMSG_DATA
yes
#endif
],
found_cmsg_data=yes,
found_cmsg_data=no
)
AC_MSG_RESULT($found_cmsg_data)
if test "x$found_cmsg_data" = xyes; then
XOPEN_DEFINES="-D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED"
else
AC_MSG_ERROR("CMSG_DATA not found")
fi
fi
AC_SUBST(XOPEN_DEFINES)
# Look for imsg in libutil. compat/imsg.c is linked by Makefile.am if missing.
AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
if test "x$found_imsg_init" = xyes; then
AC_DEFINE(HAVE_IMSG)
fi
AM_CONDITIONAL(NO_IMSG, [test "x$found_imsg_init" = xno])
# Look for forkpty in libutil. compat/forkpty-*.c is linked if not found.
AC_SEARCH_LIBS(forkpty, util, found_forkpty=yes, found_forkpty=no)
if test "x$found_forkpty" = xyes; then
AC_DEFINE(HAVE_FORKPTY)
fi
AM_CONDITIONAL(NO_FORKPTY, [test "x$found_forkpty" = xno])
# Look for closefrom, compat/closefrom.c used if missing.
AC_CHECK_FUNC(closefrom, found_closefrom=yes, found_closefrom=no)
if test "x$found_closefrom" = xyes; then
AC_DEFINE(HAVE_CLOSEFROM)
fi
AM_CONDITIONAL(NO_CLOSEFROM, [test "x$found_closefrom" = xno])
# Look for daemon, compat/daemon.c used if missing.
AC_CHECK_FUNC(daemon, found_daemon=yes, found_daemon=no)
if test "x$found_daemon" = xyes; then
AC_DEFINE(HAVE_DAEMON)
fi
AM_CONDITIONAL(NO_DAEMON, [test "x$found_daemon" = xno])
# Look for setenv, compat/setenv.c used if missing.
AC_CHECK_FUNC(setenv, found_setenv=yes, found_setenv=no)
if test "x$found_setenv" = xyes; then
AC_DEFINE(HAVE_SETENV)
fi
AM_CONDITIONAL(NO_SETENV, [test "x$found_setenv" = xno])
# Look for strlcpy, compat/strlcpy.c used if missing.
AC_CHECK_FUNC(strlcpy, found_strlcpy=yes, found_strlcpy=no)
if test "x$found_strlcpy" = xyes; then
AC_DEFINE(HAVE_STRLCPY)
fi
AM_CONDITIONAL(NO_STRLCPY, [test "x$found_strlcpy" = xno])
# Look for strlcat, compat/strlcat.c used if missing.
AC_CHECK_FUNC(strlcat, found_strlcat=yes, found_strlcat=no)
if test "x$found_strlcat" = xyes; then
AC_DEFINE(HAVE_STRLCAT)
fi
AM_CONDITIONAL(NO_STRLCAT, [test "x$found_strlcat" = xno])
# Look for asprintf, compat/asprintf.c used if missing.
AC_CHECK_FUNC(asprintf, found_asprintf=yes, found_asprintf=no)
if test "x$found_asprintf" = xyes; then
AC_DEFINE(HAVE_ASPRINTF)
fi
AM_CONDITIONAL(NO_ASPRINTF, [test "x$found_asprintf" = xno])
# Look for fgetln, compat/fgetln.c used if missing.
AC_CHECK_FUNC(fgetln, found_fgetln=yes, found_fgetln=no)
if test "x$found_fgetln" = xyes; then
AC_DEFINE(HAVE_FGETLN)
fi
AM_CONDITIONAL(NO_FGETLN, [test "x$found_fgetln" = xno])
# Look for fparseln, compat/fparseln.c used if missing.
AC_CHECK_FUNC(fparseln, found_fparseln=yes, found_fparseln=no)
if test "x$found_fparseln" = xyes; then
AC_DEFINE(HAVE_FPARSELN)
fi
AM_CONDITIONAL(NO_FPARSELN, [test "x$found_fparseln" = xno])
# Look for strcasestr, compat/strcasestr.c used if missing.
AC_CHECK_FUNC(strcasestr, found_strcasestr=yes, found_strcasestr=no)
if test "x$found_strcasestr" = xyes; then
AC_DEFINE(HAVE_STRCASESTR)
fi
AM_CONDITIONAL(NO_STRCASESTR, [test "x$found_strcasestr" = xno])
# Look for strsep, compat/strsep.c used if missing.
AC_CHECK_FUNC(strsep, found_strsep=yes, found_strsep=no)
if test "x$found_strsep" = xyes; then
AC_DEFINE(HAVE_STRSEP)
fi
AM_CONDITIONAL(NO_STRSEP, [test "x$found_strsep" = xno])
# Look for strtonum, compat/strtonum.c used if missing.
AC_CHECK_FUNC(strtonum, found_strtonum=yes, found_strtonum=no)
if test "x$found_strtonum" = xyes; then
AC_DEFINE(HAVE_STRTONUM)
fi
AM_CONDITIONAL(NO_STRTONUM, [test "x$found_strtonum" = xno])
# Look for stravis, compat/{vis,unvis}.c used if missing.
AC_CHECK_FUNC(stravis, found_stravis=yes, found_stravis=no)
if test "x$found_stravis" = xyes; then
AC_MSG_CHECKING(if strnvis is broken)
AC_EGREP_HEADER([strnvis\(char \*, const char \*, size_t, int\)],
vis.h,
AC_MSG_RESULT(no),
[found_stravis=no])
if test "x$found_stravis" = xno; then
AC_MSG_RESULT(yes)
fi
fi
if test "x$found_stravis" = xyes; then
AC_DEFINE(HAVE_VIS)
fi
AM_CONDITIONAL(NO_VIS, [test "x$found_stravis" = xno])
# Look for cfmakeraw, compat/cfmakeraw.c used if missing.
AC_CHECK_FUNC(cfmakeraw, found_cfmakeraw=yes, found_cfmakeraw=no)
if test "x$found_cfmakeraw" = xyes; then
AC_DEFINE(HAVE_CFMAKERAW)
fi
AM_CONDITIONAL(NO_CFMAKERAW, [test "x$found_cfmakeraw" = xno])
# Look for openat, compat/openat.c used if missing.
AC_CHECK_FUNC(openat, found_openat=yes, found_openat=no)
if test "x$found_openat" = xyes; then
AC_DEFINE(HAVE_OPENAT)
fi
AM_CONDITIONAL(NO_OPENAT, [test "x$found_openat" = xno])
# Look for reallocarray, compat/reallocarray.c used if missing.
AC_CHECK_FUNC(reallocarray, found_reallocarray=yes, found_reallocarray=no)
if test "x$found_reallocarray" = xyes; then
AC_DEFINE(HAVE_REALLOCARRAY)
fi
AM_CONDITIONAL(NO_REALLOCARRAY, [test "x$found_reallocarray" = xno])
# Look for getopt. glibc's getopt does not enforce argument order and the ways
# of making it do so are stupid, so just use our own instead.
AC_CHECK_FUNC(getopt, found_getopt=yes, found_getopt=no)
if test "x$found_getopt" != xno; then
AC_CHECK_DECLS(
[optarg, optind, optreset],
,
found_getopt=no,
[
#include <unistd.h>
]
)
if test "x$found_getopt" != xno; then
AC_MSG_CHECKING(if system getopt should be avoided)
if test "x$found_glibc" = xyes; then
found_getopt=no
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
AC_DEFINE(HAVE_GETOPT)
fi
fi
fi
AM_CONDITIONAL(NO_GETOPT, [test "x$found_getopt" = xno])
# Check for BSD-style integer types.
AC_MSG_CHECKING(for BSD-style unsigned types)
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[
#include <sys/types.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#else
#include <inttypes.h>
#endif
int main(void)
{ u_int8_t u8; u_int16_t u16; u_int32_t u32; u_int64_t u64; }
])],
[AC_DEFINE(HAVE_BSD_TYPES) AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no)
)
# Look for a suitable queue.h.
AC_CHECK_DECL(
TAILQ_PREV,
found_queue_h=yes,
found_queue_h=no,
[#include <sys/queue.h>]
)
AC_CHECK_DECL(
TAILQ_REPLACE,
,
found_queue_h=no,
[#include <sys/queue.h>]
)
if test "x$found_queue_h" = xyes; then
AC_DEFINE(HAVE_QUEUE_H)
fi
# Look for __progname.
AC_MSG_CHECKING(for __progname)
AC_LINK_IFELSE([AC_LANG_SOURCE(
[
#include <stdio.h>
#include <stdlib.h>
extern char *__progname;
int main(void) {
const char *cp = __progname;
printf("%s\n", cp);
exit(0);
}
])],
[AC_DEFINE(HAVE___PROGNAME) AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no)
)
# Look for fcntl(F_CLOSEM).
AC_CHECK_DECL(
F_CLOSEM,
AC_DEFINE(HAVE_FCNTL_CLOSEM),
,
[#include <fcntl.h>]
)
# Look for /proc/$$.
AC_MSG_CHECKING(for /proc/\$\$)
if test -d /proc/$$; then
AC_DEFINE(HAVE_PROC_PID)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
# Man page defaults to mdoc.
MANFORMAT=mdoc
AC_SUBST(MANFORMAT)
# Figure out the platform for osdep-*.c and forkpty-*.c.
AC_MSG_CHECKING(platform)
case "$host_os" in
*aix*)
AC_MSG_RESULT(aix)
PLATFORM=aix
;;
*darwin*)
AC_MSG_RESULT(darwin)
AC_DEFINE(BROKEN_CMSG_FIRSTHDR)
PLATFORM=darwin
;;
*dragonfly*)
AC_MSG_RESULT(dragonfly)
PLATFORM=dragonfly
;;
*linux*)
AC_MSG_RESULT(linux)
PLATFORM=linux
AC_DEFINE(IS_LINUX)
;;
*freebsd*)
AC_MSG_RESULT(freebsd)
PLATFORM=freebsd
;;
*netbsd*)
AC_MSG_RESULT(netbsd)
PLATFORM=netbsd
;;
*openbsd*)
AC_MSG_RESULT(openbsd)
PLATFORM=openbsd
;;
*sunos*)
AC_MSG_RESULT(sunos)
PLATFORM=sunos
;;
*solaris*)
AC_MSG_RESULT(sunos)
PLATFORM=sunos
MANFORMAT=man
;;
*hpux*)
AC_MSG_RESULT(hpux)
PLATFORM=hpux
;;
*cygwin*)
AC_MSG_RESULT(cygwin)
PLATFORM=cygwin
;;
*)
AC_MSG_RESULT(unknown)
PLATFORM=unknown
;;
esac
AC_SUBST(PLATFORM)
AM_CONDITIONAL(IS_AIX, test "x$PLATFORM" = xaix)
AM_CONDITIONAL(IS_DARWIN, test "x$PLATFORM" = xdarwin)
AM_CONDITIONAL(IS_DRAGONFLY, test "x$PLATFORM" = xdragonfly)
AM_CONDITIONAL(IS_LINUX, test "x$PLATFORM" = xlinux)
AM_CONDITIONAL(IS_FREEBSD, test "x$PLATFORM" = xfreebsd)
AM_CONDITIONAL(IS_NETBSD, test "x$PLATFORM" = xnetbsd)
AM_CONDITIONAL(IS_OPENBSD, test "x$PLATFORM" = xopenbsd)
AM_CONDITIONAL(IS_SUNOS, test "x$PLATFORM" = xsunos)
AM_CONDITIONAL(IS_HPUX, test "x$PLATFORM" = xhpux)
AM_CONDITIONAL(IS_UNKNOWN, test "x$PLATFORM" = xunknown)
# autoconf should create a Makefile.
AC_OUTPUT(Makefile)