forked from MarcJHuber/event-driven-servers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·785 lines (636 loc) · 21.7 KB
/
configure
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
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
#!/usr/bin/env perl
#
# configure [args ...]
#
# A trivial configure script.
#
# (C) 2002-2022 by Marc Huber <[email protected]>
# All rights reserved.
#
# $Id$
#
use strict;
my $width = `stty size 2>/dev/null`;
if ($?) {
$width = 80;
} else {
$width =~ /\d+\s+(\d+)/;
$width = $1;
}
$width--;
sub wprint($) {
my $first = 1;
my @TXT = split(/\n/, $_[0], -1);
foreach my $txt (@TXT) {
print "\n" unless defined $first;
$first = undef;
my $len = 0;
my $t = $txt;
while (length $t > 0) {
$t =~ /^(\s*)(\S*)(.*)/;
my $l = length $1;
if ($len + $l < $width) {
print $1;
$len += $l;
} else {
print "\n";
$len = 0;
}
$l = length $2;
if ($len + $l < $width) {
print $2;
$len += $l;
} else {
print "\n", $2;
$len = $l;
}
$t = $3;
}
}
}
print "="x$width . "\n";
my ($sysname, $release, $machine, $cwd);
if (eval("require POSIX")) {
($sysname, undef, $release, undef, $machine) = POSIX::uname();
$cwd = POSIX::getcwd();
} else {
$sysname = `uname -s`;
$release = `uname -r`;
$machine = `uname -m`;
$cwd = `pwd`;
chomp ($sysname, $release, $machine, $cwd);
}
$sysname =~ tr/ \//--/;
$machine =~ tr/ \//--/;
$release =~ s/\([^)]+\)//; # cygwin ...
$release =~ tr/ \//--/;
$sysname = lc $sysname;
$machine = lc $machine;
$release = lc $release;
my $LIBARCH = undef;
$LIBARCH = "64" if $sysname =~ /linux/i && $machine =~ /64/ && -d "/usr/lib64";
my $aux = "";
my @DIRS_DEFAULT = qw(mavis spawnd mavisd ftpd tac_plus tac_plus-ng tcprelay);
my @ALLDIRS = qw(mavis spawnd mavisd ftpd tac_plus tac_plus-ng tcprelay );
my $DIRS_DEFAULT = join(" ", @DIRS_DEFAULT);
my $ALLDIRS = join(" ", @ALLDIRS);
my @options = qw(pcre2 ssl tls zlib freeradius pam execinfo sctp curl ipc ares crypto);
my %COMMENT;
my $sbin = "sbin";
my $lib = "lib";
my $libarch = "lib$LIBARCH";
my $doc = "share/mavis";
$COMMENT{"devpoll"} =
"The \"devpoll\" option enables /dev/poll support. You may use it on Linux with /dev/poll patch (untested, and unlikely), or on Sun Solaris (7.0 onwards).
";
$COMMENT{"epoll"} =
"Usually, Linux epoll support is autodetected. This option overrides autodetection, which may be useful if you're using a patched pre-sysepoll kernel (how much unlikely that is).
";
$COMMENT{"ares"} =
"c-ares is a library for asynchronous DNS requests. This option enables ftpd and tac_plus(-ng) to do DNS lookups.\n";
$COMMENT{"pcre2"} =
"ftpd can use the PCRE v2 (\"Perl Compatible Regular Expressions\" v2) library for path rewriting, and tac_plus may use it as an alternative to POSIX regular expression matching. Using it is highly recommended and virtually mandatory for tac_plus-ng.
";
$COMMENT{"freeradius"} =
"If you have the freeradius-client library installed, you may authenticate MAVIS requests by using the radmavis binary.
";
$COMMENT{"radcli"} =
"If you have the radcli library installed, you may authenticate MAVIS requests by using the radmavis binary.
";
$COMMENT{"pam"} =
"If you have the pam libraries installed, you may authenticate MAVIS requests by using the pammavis binary.
";
$COMMENT{"curl"} =
"If you have the curl libraries installed, you may use URLs to refer to configuration files.
";
$COMMENT{"ipc"} =
"If SYS-V IPC is available, configuration files may be cached in shared memory.
";
$COMMENT{"crypto"} =
"Use the \"crypto\" option for certain libcrypto support, e.g. DES or SHA1. The ssl option implies this one.
";
$COMMENT{"ssl"} =
"Use the \"ssl\" option if you have the OpenSSL libraries available. If enabled, TLS support is added to FTPd and TcpRelay, and TACACS+ will be able to utilize the crypto library.
";
$COMMENT{"tls"} =
"Use the \"tls\" option if you have the LibreTLS libraries available. If enabled, TLS support is added to tac_plus-ng and TcpRelay.
";
$COMMENT{"sctp"} =
"Use this option if your system supports SCTP.
";
$COMMENT{"zlib"} =
"The ftp daemon can support transparent gzip-style compression.
";
$COMMENT{"execinfo"} =
"In case of a program crash, execinfo may return a backtrace of the crashed process, which may be valuable for debugging.
";
if ($#ARGV > -1 && $ARGV[0] =~ /^--help$/)
{
wprint(
"Please note that this program is *not* a GNU configure program generated by autoconf, but a custom Perl script.
Usage: ./configure [args ...] [targets]
Recognized arguments: Defaults:
--prefix=DIR [/usr/local]
--bindir=DIR [/usr/local/bin]
--etcdir=DIR [/usr/local/etc]
--sbindir=DIR [/usr/local/$sbin]
--libdir=DIR [/usr/local/$lib]
--libarchdir=DIR [/usr/local/$lib$LIBARCH]
--libexecdir=DIR [/usr/local/libexec]
--docdir=DIR [/usr/local/$doc]
--installroot=DIR []
The C compiler used is usually clang. You may override that choice by specifiying a different one:
--with-cc=CC
For example, on MacOS X the following creates universal binaries with PPC and x86 code, both 32 and 64 bit:
./configure \"--with-cc=gcc -arch ppc64 -arch ppc -arch i386 -arch x86_64\"
$COMMENT{'devpoll'}
--without-devpoll
--with-devpoll
$COMMENT{'epoll'}
--without-epoll
--with-epoll
$COMMENT{'sctp'}
--without-sctp
--with-sctp
");
wprint("The options
--without-PACKAGE
--with-PACKAGE\[=DIR]
--with-PACKAGE-include=DIR
--with-PACKAGE-lib=DIR
are recognized for the following packages:
");
foreach my $o (sort @options)
{
wprint( "$o: $COMMENT{$o}
");
}
wprint (
"Supported targets:
$ALLDIRS
Default targets:
$DIRS_DEFAULT
This script should be smart enough to figure out availability of most configuration options by itself, so \"./configure\" without any arguments is sufficient in most cases.
You can easily skip features you don't need, e.g.:
./configure --without-curl --without-tls --without-ssl --without-crypto --without-ares --without-sctp --without-zlib [targets]
or, as a shortcut,
./configure --minimum [targets]
"
);
print "="x$width . "\n";
exit;
}
my %A;
foreach $a (@options) {
$A{"--with-$a"} = undef;
}
my $hint = "";
$hint = "(Called without arguments. \"--help\" will display the command line options.)\n" if $#ARGV < 0;
while ($#ARGV > -1) {
if ($ARGV[0] =~ /^(--[^=]+)=(.*)$/) {
$A{$1} = $2;
} elsif ($ARGV[0] =~ /^--([^-]+-[^-]+|debug)$/) {
$A{$ARGV[0]} = "1";
} elsif ($ARGV[0] =~ /^--[^-]+-[^-]+-[^-]+$/) {
$A{$ARGV[0]} = $ARGV[1];
shift @ARGV;
} else {
$A{$ARGV[0]} = undef;
}
shift @ARGV;
}
my $a;
my $DIRS = "";
foreach $a (keys %A) {
if ($a =~ /^--with-([^-]+)-include$/) {
$A{"--with-$1"} = "1" unless exists $A{"--with-$1"};
unless (exists $A{"--with-$1-lib"}) {
$A{"--with-$1-lib"} = $A{"--with-$1-include"};
$A{"--with-$1-lib"} =~ s/include$/lib/;
}
}
elsif ($a =~ /^--with-([^-]+)-lib$/) {
$A{"--with-$1"} = "1" unless exists $A{"--with-$1"};
unless (exists $A{"--with-$1-include"}) {
$A{"--with-$1-include"} = $A{"--with-$1-lib"};
$A{"--with-$1-include"} =~ s/lib$/include/;
}
} elsif ($a =~ /^--without-([^-]+)$/) {
$A{"--with-$1"} = "0";
delete $A{$a};
} elsif ($a =~ /^mavis$/) {
$DIRS = "$a$DIRS";
delete $A{$a};
} elsif (-d $a) {
$DIRS .= " $a";
delete $A{$a};
}
}
$DIRS = $DIRS_DEFAULT if $DIRS eq "";
if ($DIRS !~ /^mavis /){
$DIRS = "mavis$DIRS";
}
my %DEFS;
$DEFS{'DIRS'} = $DIRS unless $DIRS eq "";
$DEFS{"DEF"} = "";
$DEFS{"LD"} = "ld";
$DEFS{"BASE"} = $cwd;
$DEFS{"BASE"} = $cwd;
if (exists $A{"--with-devpoll"}) {
$DEFS{"WITH_DEVPOLL"} = $A{"--with-devpoll"};
delete $A{"--with-devpoll"};
}
if (exists $A{"--with-epoll"}) {
$DEFS{"WITH_EPOLL"} = $A{"--with-epoll"};
delete $A{"--with-epoll"};
}
if (exists $A{"--debug"}) {
$DEFS{"DEBUG"} = $A{"--debug"};
delete $A{"--debug"};
}
$A{"--prefix"} = "/usr/local" unless exists $A{"--prefix"};
$DEFS{"DEST"} = $A{"--prefix"};
foreach $a ("bin", "sbin", "etc", "libexec", "lib") {
$A{"--$a"."dir"} = $A{"--prefix"} . "/$a" unless exists $A{"--$a"."dir"};
$DEFS{uc($a)."DIR_DEST"} = $A{"--$a"."dir"};
delete $A{"--$a"."dir"};
}
my $LIBARCHDIR_DEST;
foreach $a ("libarch") {
$A{"--$a"."dir"} = $A{"--prefix"} . "/lib$LIBARCH" unless exists $A{"--$a"."dir"};
$LIBARCHDIR_DEST = $A{"--$a"."dir"};
$DEFS{uc($a)."DIR_DEST"} = $A{"--$a"."dir"};
delete $A{"--$a"."dir"};
}
foreach $a ("doc") {
$A{"--$a"."dir"} = $A{"--prefix"} . "/$doc" unless exists $A{"--$a"."dir"};
$DEFS{uc($a)."DIR_DEST"} = $A{"--$a"."dir"};
delete $A{"--$a"."dir"};
}
delete $A{"--prefix"};
if (exists $A{"--installroot"}) {
$DEFS{"INSTALLROOT"} = $A{"--installroot"};
delete $A{"--installroot"};
}
if (exists $A{"--minimum"}) {
$DEFS{"WITH_CURL"} = 0;
$DEFS{"WITH_TLS"} = 0;
$DEFS{"WITH_SSL"} = 0;
$DEFS{"WITH_CRYPTO"} = 0;
$DEFS{"WITH_ARES"} = 0;
$DEFS{"WITH_SCTP"} = 0;
$DEFS{"WITH_ZLIB"} = 0;
delete $A{"--minimum"};
}
foreach $a (@options) {
if (exists $A{"--with-$a"} && defined $A{"--with-$a"} && $A{"--with-$a"} =~ /^\//) {
$A{"--with-$a-lib"} = $A{"--with-$a"} . "/lib" unless exists $A{"--with-$a-lib"};
$A{"--with-$a-include"} = $A{"--with-$a"} . "/include" unless exists $A{"--with-$a-include"};
$A{"--with-$a"} = 1;
}
}
foreach $a (@options) {
if (exists $A{"--with-$a"} && defined $A{"--with-$a"} && $A{"--with-$a"} != 0) {
$A{"--with-$a-lib"} = "/usr/lib" unless exists $A{"--with-$a-lib"};
$A{"--with-$a-include"} = "/usr/include" unless exists $A{"--with-$a-include"};
}
}
foreach $a (@options) {
if (defined $A{"--with-$a"}) {
$DEFS{"WITH_" . uc ($a)} = $A{"--with-$a"};
if (exists $A{"--with-$a"} && defined $A{"--with-$a"} && $A{"--with-$a"} != 0) {
$DEFS{"LIBDIR_" . uc ($a)} = $A{"--with-$a-lib"};
delete $A{"--with-$a-lib"};
$DEFS{"INCDIR_" . uc ($a)} = $A{"--with-$a-include"};
delete $A{"--with-$a-include"};
}
}
delete $A{"--with-$a"};
}
$DEFS{"LIBARCH"} = $LIBARCH if defined $LIBARCH;
if (exists $A{"--with-cc"}) {
$DEFS{"CC"} = $A{"--with-cc"};
delete $A{"--with-cc"};
}
my $cctest;
$DEFS{"CC"} = $ENV{"CC"} if exists $ENV{"CC"} && !exists $DEFS{"CC"};
unless (exists $DEFS{"CC"}) {
$cctest = `clang -v 2>&1`;
$DEFS{"CC"} = "clang" unless $!;
}
unless (exists $DEFS{"CC"}) {
$cctest = `gcc -v 2>&1`;
$DEFS{"CC"} = "gcc" unless $!;
}
unless (exists $DEFS{"CC"}) {
$cctest = `cc -v 2>&1`;
$DEFS{"CC"} = "cc" unless $!;
}
die "Couldn't detect a C compiler on your system. Aborting right now.\n" unless exists $DEFS{"CC"};
$cctest = `$DEFS{"CC"} -v 2>&1` if $cctest eq "";
my $gcc_multiarch = `$DEFS{"CC"} -print-multiarch 2>/dev/null || echo`;
chomp $gcc_multiarch;
$LIBARCH = "/$gcc_multiarch" if $gcc_multiarch ne "" && -d "/usr/lib/$gcc_multiarch";
my (@rest) = sort keys %A;
if ($#rest > -1) {
wprint("The following options were not recognized:
\t" . join("\t\n", @rest) . "
Please correct the command line options, then call ./configure again. \"./configure --help\" will give you a list of all available options.
");
exit(-1);
}
my @OSLEVEL_ARR = split(/[^\d]+/, $release);
push(@OSLEVEL_ARR, 0, 0, 0);
$DEFS{"OSLEVEL"} = sprintf ("0x%.2x%.2x%.4x", @OSLEVEL_ARR);
$DEFS{"OSTYPE"} = $sysname;
$DEFS{"OS"} = "$sysname-$release-$machine";
$DEFS{'DEF'} .= " -DOSTYPE=$DEFS{'OSTYPE'} -DOSLEVEL=$DEFS{'OSLEVEL'} -DOS=" . '"\\"' . $DEFS{'OS'} . '\\""';
if ($cctest =~ /clang/) {
$DEFS{"CC"} = "clang";
$DEFS{"CC_GCC"} = 1;
$DEFS{"CC_CLANG"} = 1;
} elsif ($cctest =~ /gcc/) {
$DEFS{"CC"} = "gcc";
$DEFS{"CC_GCC"} = 1;
} elsif ($cctest =~ /Sunc C/) {
$DEFS{"CC_SUN"} = 1;
}
if (defined $DEFS{"CC_GCC"}) {
$DEFS{"CFLAGS"} = "-Wall -W -Wno-strict-prototypes -Wno-implicit-fallthrough";
$DEFS{"CFLAGS"} .= " -O2" if exists $DEFS{"CC_CLANG"} && !exists $DEFS{'DEBUG'};
$DEFS{"CFLAGS_PIC"} = "-fPIC";
$DEFS{"LDOPT_R"} = "-Wl,-rpath,";
$DEFS{"LD_SHARED"} = "$DEFS{'CC'} -shared";
$DEFS{"CFLAGS"} .= " -Werror -Wno-deprecated-declarations -Wno-unused-result" if exists $DEFS{'DEBUG'};
}
if (defined $DEFS{"CC_SUN"}) {
$DEFS{"CFLAGS"} = "-O";
$DEFS{"CFLAGS_PIC"} = "-G";
$DEFS{"LDOPT_R"} = "-Wl,-rpath,";
$DEFS{"LD_SHARED"} = "$DEFS{'CC'} $DEFS{'FLAGS_PIC'}";
}
$DEFS{"SHLIB_PRE"} = "lib";
$DEFS{"SHLIB_EXT"} = ".so";
if ($sysname eq "darwin") {
$DEFS{"LD_SHARED"} = "$DEFS{'CC'} -dynamiclib";
$DEFS{"SHLIB_EXT"} = ".dylib";
$DEFS{"LIB_MAVIS"} = "\"$DEFS{'LDOPT_R'}\@loader_path/../lib\"";
}
if ($sysname eq "cygwin_nt") {
$DEFS{"CFLAGS_PIC"} = "";
$DEFS{"SHLIB_PRE"} = "cyg";
$DEFS{"SHLIB_EXT"} = ".dll";
$DEFS{"EXEC_EXT"} = ".exe";
}
$DEFS{"INSTALL"} = "install -c";
if ($sysname eq "sunos") {
$DEFS{"LIB_NET"} = " -lnsl -lsocket";
if (`ld -v 2>&1` =~ /GNU/ != "") {
$DEFS{'LDOPT_R'} = "-R";
$DEFS{'LD_SHARED'} = "$DEFS{'LD'} -G -z textwarn";
}
unless (defined $DEFS{'CC_GCC'}) {
$DEFS{"CFLAGS"} = "-xO3 -xstrconst -xdepend -Xa -errwarn=%all";
$DEFS{"CFLAGS_PIC"} = "-KPIC";
}
$DEFS{"DEF"} .= " -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64";
$DEFS{"LIB_MAVIS"} = "$DEFS{'LDOPT_R'}\$\$ORIGIN/../lib";
foreach my $install ("/usr/bin/ginstall", "/usr/ucb/install", "/usr/bin/install") {
$DEFS{"INSTALL"} = $install if -x $install;
last;
}
}
if ($sysname eq "linux") {
$DEFS{"DEF"} .= " -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64";
$DEFS{"LIB_MAVIS"} = "$DEFS{'LDOPT_R'}\$\$ORIGIN/../lib$DEFS{'LIBARCH'}"
}
if (exists $DEFS{"DEBUG"}) {
$DEFS{"DEF"} .= " -DDEBUG";
$DEFS{"CFLAGS"} .= " -g -Og";
$DEFS{"CFLAGS"} .= " -ggdb" if exists $DEFS{"CC_GCC"};
}
$DEFS{"DIR_MAVIS"} = "$cwd/mavis";
$DEFS{"LIB_MAVIS"} .= " -L$cwd/build/$DEFS{'OS'}/mavis $DEFS{'LDOPT_R'}$DEFS{'LIBARCHDIR_DEST'} -lmavis";
$DEFS{"DIR_MISC"} = "$cwd/misc";
$DEFS{"INC"} .= " -I$cwd";
my (%FOUND, %NOT_FOUND);
my @LIB_SEARCH_DIRS;
my $search_dir = `$DEFS{'LD'} --verbose 2>/dev/null | grep SEARCH_DIR`;
if ($? == 0) {
@LIB_SEARCH_DIRS = split(/; ?/, $search_dir);
map {s/SEARCH_DIR\("=([^"]+)"\)*/$1/g; } @LIB_SEARCH_DIRS;
pop @LIB_SEARCH_DIRS;
$DEFS{'# LIB_SEARCH_DIRS'} = join(':', @LIB_SEARCH_DIRS);
}
my @INC_SEARCH_DIRS;
$search_dir = `$DEFS{'CC'} -E -Wp,-v - </dev/null 2>&1`;
if ($? == 0) {
foreach my $sd (split(/\n/m, $search_dir)) {
next unless $sd =~ /^ (\/.*)$/;
push @INC_SEARCH_DIRS, $1;
}
$DEFS{'# INC_SEARCH_DIRS'} = join(':', @INC_SEARCH_DIRS);
}
sub check_for($$$$$) {
my ($PKG, $pkg, $hdr, $lib, $defs) = @_;
return if exists $FOUND{"LIB-$PKG"};
unless (exists $DEFS{"WITH_$PKG"}) {
my $pc = `pkg-config --exists $pkg 2>/dev/null`;
if ($? == 0) {
my $L = `pkg-config --libs-only-L $pkg`;
my $I = `pkg-config --cflags-only-I $pkg`;
$DEFS{"LIBDIR_$PKG"} = $1 if (`pkg-config --libs-only-L $pkg` =~ /^-L(.*)$/);
$DEFS{"INCDIR_$PKG"} = $1 if (`pkg-config --cflags-only-I $pkg` =~ /^-I(.*)$/);
$DEFS{"WITH_$PKG"} = 1;
}
unless (exists $DEFS{"WITH_$PKG"}) {
my $inc;
for my $prefix ("/usr", "/usr/local", "/usr/sfw", "/usr/pkg", @INC_SEARCH_DIRS) {
if (-e "$prefix/include/$hdr") {
$inc = "$prefix/include";
} elsif (-e "$prefix/$hdr") {
$inc = "$prefix";
} else {
next;
}
my @g = glob("$prefix/$DEFS{'LIBARCH'}/lib$lib$DEFS{'SHLIB_EXT'}*");
if ($#g > -1) {
$DEFS{"WITH_$PKG"} = 1;
$DEFS{"INCDIR_$PKG"} = $inc;
$DEFS{"LIBDIR_$PKG"} = "$prefix/lib/$DEFS{'LIBARCH'}";
last;
}
@g = glob("$prefix/lib/lib$lib$DEFS{'SHLIB_EXT'}*");
if ($#g > -1) {
$DEFS{"WITH_$PKG"} = 1;
$DEFS{"INCDIR_$PKG"} = $inc;
$DEFS{"LIBDIR_$PKG"} = "$prefix/lib";
last;
}
@g = glob("$prefix/lib/$machine-linux-gnu/lib$lib$DEFS{'SHLIB_EXT'}*");
if ($#g > -1) {
$DEFS{"WITH_$PKG"} = 1;
$DEFS{"INCDIR_$PKG"} = $inc;
$DEFS{"LIBDIR_$PKG"} = "$prefix/$machine-linux-gnu/lib";
last;
}
}
if (defined $inc && !exists $DEFS{"WITH_$PKG"}) {
for my $prefix (@LIB_SEARCH_DIRS) {
my @g = glob("$prefix/lib$lib$DEFS{'SHLIB_EXT'}*");
if ($#g > -1) {
$DEFS{"WITH_$PKG"} = 1;
$DEFS{"INCDIR_$PKG"} = $inc;
$DEFS{"LIBDIR_$PKG"} = $prefix;
last;
}
}
}
}
}
if (exists $DEFS{"WITH_$PKG"} && $DEFS{"WITH_$PKG"} == 1) {
$DEFS{"INC_$PKG"} = "-I" . $DEFS{"INCDIR_$PKG"} if exists $DEFS{"INCDIR_$PKG"};
$DEFS{"LIB_$PKG"} = "";
$DEFS{"LIB_$PKG"} .= "-L" . $DEFS{"LIBDIR_$PKG"} . " " . $DEFS{'LDOPT_R'} . $DEFS{"LIBDIR_$PKG"} . " " if exists $DEFS{"LIBDIR_$PKG"};
$DEFS{"LIB_$PKG"} .= "-l$lib" if defined $lib;
$DEFS{'DEF'} .= " -DWITH_$PKG";
$DEFS{'DEF'} .= " $defs" if defined $defs;;
$FOUND{"LIB-$PKG"} = 1;
delete $NOT_FOUND{"LIB-$PKG"} if exists $NOT_FOUND{"LIB-$PKG"};
} else {
$NOT_FOUND{"LIB-$PKG"} = 1;
}
}
check_for("ARES", "libcares", "ares.h", "cares", "-DWITH_DNS");
$DEFS{"LIB_DNS"} = $DEFS{"LIB_ARES"} if exists $DEFS{"LIB_ARES"};
$DEFS{"WITH_DNS"} = 1 if exists $DEFS{"LIB_DNS"};
check_for("SSL", "openssl", "openssl/ssl.h", "ssl", undef) if !exists $DEFS{"WITH_TLS"} || $DEFS{"WITH_TLS"} == 0;
$DEFS{"LIB_SSL"} .= " -lcrypto" if exists $DEFS{"LIB_SSL"} && exists $DEFS{"WITH_CRYPTO"} && $DEFS{"WITH_CRYPTO"} == 0;
check_for("CRYPTO", "openssl", "openssl/ssl.h", "crypto", undef);
check_for("TLS", "libtls", "tls.h", "tls", undef) if !exists $DEFS{"WITH_SSL"} || $DEFS{"WITH_SSL"} == 0;
check_for("PCRE2", "libpcre2-8", "pcre2.h", "pcre2-8", "-DPCRE2_CODE_UNIT_WIDTH=8");
$DEFS{"INC_PCRE"} = $DEFS{"INC_PCRE2"} if exists $DEFS{"INC_PCRE2"};
$DEFS{"LIB_PCRE"} = $DEFS{"LIB_PCRE2"} if exists $DEFS{"LIB_PCRE2"};
check_for("FREERADIUS", "freeradius-client", "freeradius-client.h", "freeradius-client", undef);
#check_for("RADCLI", "radcli", "radcli/radcli.h", "radcli", undef) if !exists $DEFS{"WITH_FREERADIUS"} || $DEFS{"WITH_FREERADIUS"} == 0;
check_for("ZLIB", "zlib", "zlib.h", "z", undef);
check_for("EXECINFO", "execinfo", "execinfo.h", "execinfo", undef);
if ($sysname eq "linux" && -f "/usr/include/execinfo.h") {
$DEFS{"WITH_EXECINFO"} = 1;
delete $NOT_FOUND{"LIB-EXECINFO"};
}
check_for("CRYPT", "crypt", "crypt.h", "crypt", undef);
check_for("CRYPT", "crypt", "unistd.h", "crypt", undef);
check_for("CURL", "libcurl", "curl/curl.h", "curl", undef);
check_for("PAM", "libpam", "security/pam_appl.h", "pam", "-DHAVE_SECURITY_PAM_APPL_H");
check_for("PAM", "libpam", "pam/pam_appl.h", "pam", undef);
check_for("SCTP", "sctp", "netinet/sctp.h", "sctp", undef);
$DEFS{"LIB_DL"} = "-ldl" if $sysname eq "linux";
if ($sysname eq "sunos") {
$DEFS{"LIB_DL"} = "-ldl";
$DEFS{"WITH_PORT"} = 1 if !exists $DEFS{"WITH_PORT"} && -e "/usr/include/port.h";
$DEFS{"WITH_DEVPOLL"} = 1 if !exists $DEFS{"WITH_DEVPOLL"} && -e "/usr/include/sys/devpoll.h";
}
my $USRINCLUDESYS = "/usr/include/sys";
$USRINCLUDESYS = "/usr/include/$machine-linux-gnu/sys" if -d "/usr/include/$machine-linux-gnu/sys";
$DEFS{"WITH_IPC"} = 1 if -f "/usr/include/sys/ipc.h";
$DEFS{"WITH_IPC"} = 1 if -f "$USRINCLUDESYS/ipc.h";
my $mech_found;
if (!exists $DEFS{"WITH_POLL"} && -e "$USRINCLUDESYS/poll.h") {
$DEFS{"WITH_POLL"} = 1;
$mech_found = 1;
}
if (!exists $DEFS{"WITH_EPOLL"} && -e "$USRINCLUDESYS/epoll.h") {
$DEFS{"WITH_EPOLL"} = 1;
$mech_found = 1;
}
if (!exists $DEFS{"WITH_SELECT"} && -e "$USRINCLUDESYS/select.h") {
$DEFS{"WITH_SELECT"} = 1;
$mech_found = 1;
}
if (!exists $DEFS{"WITH_KQUEUE"} && -e "/usr/include/sys/event.h") {
$DEFS{"WITH_KQUEUE"} = 1;
$mech_found = 1;
}
unless ($mech_found) {
wprint "None of the supported event polling mechanisms seems to be available on your\nsystem. Check your installation, some include files may be missing.\n";
exit(-1);
}
foreach my $m ("PORT", "DEVPOLL", "EPOLL", "KQUEUE", "POLL", "SELECT", "IPC") {
$DEFS{"DEF"} .= " -DWITH_$m" if exists $DEFS{"WITH_$m"} && $DEFS{"WITH_$m"} == 1;
}
$DEFS{'# DEV FILES FOUND'} = join(" ", sort keys %FOUND ) if int keys %FOUND > 0;
$DEFS{'# DEV FILES NOT FOUND'} = join(" ", sort keys %NOT_FOUND ) if int keys %NOT_FOUND > 0;
my $content = "";
foreach my $k (sort keys %DEFS) {
$content .= "$k=$DEFS{$k}\n";
}
my $OUT;
my $what = "just created";
mkdir "build", 0755;
my $out = "build/Makefile.inc." . $DEFS{"OS"};
my $oldcontent = "";
if (-f $out) {
my $IN;
$/ = undef;
open IN, "<$out";
$oldcontent = <IN>;
close IN;
$oldcontent =~ s/^#[^\n]*\n//s;
}
if ($oldcontent eq $content) {
$what = "left unchanged";
} else {
rename $out, "$out.bak";
open OUT, ">$out" or die "open ($out): $!";
print OUT "# Generated by configure at " . localtime () . "\n";
print OUT $content;
close OUT;
system("make clean 2>/dev/null 1>&2") if $oldcontent ne "";
}
wprint $hint . "\n" if $hint ne "";;
wprint "Development files were not found for: " . join(", ", sort keys %NOT_FOUND) . "\n\n" if 0 < int keys %NOT_FOUND;
wprint "Development files were found for: " . join(", ", sort keys %FOUND) . "\n\n" if 0 < int keys %FOUND;
wprint "The file
$out
was $what. You may run \"make\" now. After that, you may wish to do a \"make install\". Alternatively, you'll find the compiled binaries (plus some ancillary scripts) in the
build/$DEFS{'OS'}/fakeroot/
directory structure. It's probably advisable to have a look there in any case, as you may or may not like the particular file system layout, and this will give you a chance to see it before installing.
Please direct support requests to the \"Event-Driven Servers\" Google Group at
event-driven-servers\@googlegroups.com
https://groups.google.com/group/event-driven-servers
or file an issue at
https://github.com/MarcJHuber/event-driven-servers
Support requests sent to the author's private email address may be silently ignored.
";
$out = "spawnd/perl/Makefile.PL";
open OUT, ">$out" or die "open ($out): $!";
print OUT <<EOT;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
NAME => 'Scm',
VERSION_FROM => 'Scm.pm',
INC => '-I../..',
LIBS => '-Wl,-rpath,$LIBARCHDIR_DEST -L$LIBARCHDIR_DEST -lmavis',
OBJECT => 'Scm.o',
);
EOT
close OUT;
unless (-d ".git/refs/heads") {
my $no_git = "GIT info is unavailable. This build might be outdated. Please make sure to update to the latest GIT version before issuing a support request.";
wprint ("
$no_git
"
);
mkdir(".git");
open OUT, ">>.git/index"; # GNUmakefile refers this. Just touch, dont overwrite.
close OUT;
$out = "misc/version.h";
open OUT, ">$out" or die "open ($out): $!";
print OUT "#define VERSION \"$no_git\"\n";
close OUT;
}
print "="x$width . "\n";
# vim: ts=4