-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·1039 lines (959 loc) · 21.6 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
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
#
# supervision configure script
#
#
# ZSH compatibility
#
if [ -n "${ZSH_VERSION}" ]; then
emulate sh
NULLCMD=:
setopt NO_GLOB_SUBST SH_WORD_SPLIT
disable -r end
fi
name="${0##*/}"
NULL=/dev/null
export LC_ALL=C LANG=C
shell_exec(){
echo "Trying to exec $1 shell"
command -v "$1" >$NULL 2>&1 && exec "$1"
}
unset FOO
(: ${FOO%%BAR}) 2>$NULL
E1="$?"
(: ${FOO?} ) 2>$NULL
E2="$?"
if test "$E1" != 0 || test "$E2" = 0; then
echo "Broken shell detected; trying bash..."
export CONFIGURE_EXEC=0
if test "$CONFIGURE_EXEC" -lt 1; then
CONFIGURE_EXEC=1
shell_exec bash "$0" "$@"
fi
if test "$CONFIGURE_EXEC" -lt 3; then
CONFIGURE_EXEC=3
shell_exec zsh "$0" "$@"
fi
if test "$CONFIGURE_EXEC" -lt 2; then
CONFIGURE_EXEC=2
shell_exec ksh "$0" "$@"
fi
echo "ERROR: No compatible shell interpreter found" >&2
echo "ERROR: Install a POSIX compatible shell like" >&2
echo "ERROR: bash, ksh, zsh, and try again" >&2
exit 1
fi
if ! . lib/sh/functions; then
echo "ERROR: Failed to source required file" >&2
exit 1
fi
unset CDPATH GREP_OPTIONS
export LOG_FD=3 CONFIG_LOG=config.log
export CONFIG_H=src/config.h CONFIG_MAK=config.mak
exec 3>$CONFIG_LOG
help_message(){
cat <<-EOH
Usage: configure [OPTIONS]
OPTIONS: [default options in square brackets]
Standard options:
--help print this help message
--exec-prefix=PREFIX install binary in EXEC_PREFIX [$exec_prefix]
--prefix=PREFIX install package in PREFIX [$prefix]
--datadir=DIR install data files in DIR [PREFIX/share/$package]
--docdir=DIR install documentation in DIR [PREFIX/share/doc/$package]
--libdir=DIR install libs in DIR [PREFIX/lib]
--shlibdir=DIR install shared libs in DIR [LIBDIR]
--incdir=DIR install includes in DIR [PREFIX/include]
--mandir=DIR install man page in DIR [PREFIX/share/man]
--sysconfdir=DIR install system wide data in DIR [$sysconfdir_default]
Component options:
--enable-debug build debugging code (can be disabled at runtime)
--enable-sysvinit build and install SysVinit compatibility service
--enable-runit install runit init-stage
--enable-s6 install s6 init-stage
Toolchain options:
--build=BUILD use build C compiler for CC
--host=HOST use host C compiler for CC
--ln_s=LN_S use symbolic link tool LN_S [$ln_s_default]
--cp_f=CP_F use copy tool CP_F [$cp_f_default]
--install=INSTALL use install tool INSTALL [$install_default]
--extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
--extra-cxxflags=ECFLAGS add ECFLAGS to CXXFLAGS [$CXXFLAGS]
--extra-cppflags=FLAGS add FLAGS to OBJCFLAGS [$CFLAGS]
--extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
EOH
exit ${1:-0}
}
log(){
echo "$@" >&$LOG_FD
}
LOG(){
echo "$@"
log "$@"
}
logfile(){
log BEGIN "$1"
pr -n -t "$1" >&$LOG_FD
log END "$1"
}
die_illegal(){
error "illegal option -- $@\nsee $0 --help for availlable options"
exit 1
}
INFO(){
log "$@"
info "@"
}
WARN(){
log "WARN: $@"
warn "$@"
}
ERROR(){
log "ERROR: $@"
error "$@"
}
DIE(){
local ret="$?"
ERROR "$@"
cat <<-EOH
Take a look at $CONFIG_LOG and include the file or part of it when reporting.
EOH
case "$ret" in
0) ret=1;;
esac
exit $ret
}
c_escape(){
printf "$*" | sed 's/["\\]/\\\0/g'
}
sh_quote(){
printf "$*" | sed "s/'/'\\\\''/g"
}
toupper(){
printf "$*" | tr '[a-z]' '[A-Z]'
}
tolower(){
printf "$*" | tr '[A-Z]' '[a-z]'
}
filter(){
local var pat="$1"
shift
for var; do
eval "case $var in $pat) echo $var;; esac;"
done
}
filter_out(){
local var pat="$1"
shift
for var; do
eval "case $var in $pat) ;; *) echo $var;; esac;"
done
}
unique(){
local i var="$1" unique
for i in $(echo \$$var); do
unique="$(filter_out "$i" $unique) $i"
done
eval "$var='$unique'"
}
map(){
local val map="$1"
shift
for val; do
eval $map
done
}
set_all(){
local var val="$1"
shift
for var; do
eval $var=$val
done
}
set_default(){
local var
for var; do
eval "$var=\"\$$var_default\""
done
}
set_weak(){
local var val="$1"
shift
for var; do
eval : \${$var:=$val}
done
}
sanitize_var_name(){
echo "$@" | sed 's/[^a-zA-Z0-9_]/_/g'
}
set_safe_var(){
local var="$1"
shift
eval $(sanitize_var_name "$var")='"$*"'
}
get_safe_var(){
shift
eval echo \$$(sanitize_var_name "$1")
}
enable(){
set_all yes $*
}
disable(){
set_all no "$@"
}
enable_weak(){
set_weak yes "$@"
}
disable_weak(){
set_weak no "$@"
}
enable_safe(){
enable $(sanitize_var_name "$@")
}
disable_safe(){
disable $(sanitize_var_name "$@")
}
enabled(){
eval yesno "\$$1"
}
disabled(){
enabled "$@" && return 1
}
set_default(){
local var
for var; do
eval : \${$var:=\$${var}_default}
done
}
print_enabled(){
local suffix="$1" val
shift
for val; do
enabled $val && printf "%s\n" ${val%%$suffix}
done
}
print_header(){
[ "${1%.h}" = "$1" ] &&
echo "#include $1" ||
echo "#include <$1>"
}
print_yesno(){
yesno "$1" && printf "yes" || printf "no"
}
if (eval "var=1; var+=2 2>$NULL; test x\$var = x12 2>$NULL"); then
append(){
local var="$1"
shift
eval "$var+=\" $*\""
}
else
append(){
local var="$1"
shift
eval "$var=\"\$$var $*\""
}
fi
prepend(){
local var="$1"
shift
eval "$var=\"$* \$$var\""
}
append_unique(){
local val var="$1"
shift
for val; do
eval isin "$val \$$var" || append "$var" "$val"
done
}
prepend_unique(){
local val var="$1"
shift
for val; do
eval isin "$val \$$var" || prepend "$var" "$val"
done
}
add_FLAGS(){
append_unique "$@"
}
add_CFLAGS(){
add_FLAGS CFLAGS "$@"
}
add_LDFLAGS(){
add_FLAGS LDFLAGS "$@"
}
add_CPPFLAGS(){
add_FLAGS CPPFLAGS "$@"
}
add_CXXFLAGS(){
add_FLAGS CXXFLAGS "$@"
}
check_cmd(){
log "$@"
"$@" >&$LOG_FD 2>&1
}
check_code(){
log check_code "$@"
local type="$1" header headers="$2" code="$3"
shift 3
{
for header in $headers; do
print_header "$header"
done
echo "int main(void) { $code; return 0; }"
} | check_$type "$@"
}
check_CC(){
log check_CC "$@"
cat >$TMP_C
logfile $TMP_C
check_cmd $CC $CPPFLAGS $CFLAGS "$@" $CC_C $CC_O $TMP_O $TMP_C
}
check_CP(){
log check_CP "$@"
cat >$TMP_C
logfile $TMP_C
check_cmd $CC $CPPFLAGS $CFLAGS "$@" $CC_O $TMP_E $TMP_C
}
check_CPP(){
log check_CPP "$@"
cat >$TMP_C
logfile $TMP_C
check_cmd $CC $CPPFLAGS $CFLAGS "$@" $CC_E $TMP_O $TMP_C
}
check_LD(){
log check_LD "$@"
local type="$1"
shift
local FLAGS="$(filter_out '-l*|*.so' "$@")"
local LIBS="$(filter '-l*|*.so' "$@")"
check_$type $flags || return
check_cmd $LD $LDFLAGS $FLAGS $LD_O $TMP_E $TMP_O $LIBS $EXTRALIBS
}
check_FLAGS(){
LOG check "$@"
local type=FLAGS
case "$1" in
LDFLAGS) type=LDFLAGS;;
STRIPLAGS) type=STRIPLAGS;;
esac
test_$type "$@" && add_FLAGS "$@"
}
check_CFLAGS(){
check_FLAGS CFLAGS "$@"
}
check_LDFLAGS(){
check_FLAGS LDFLAGS "$@"
}
check_CPPFLAGS(){
check_FLAGS CPPFLAGS "$@"
}
check_CXXFLAGS(){
check_FLAGS CXXFLAGS "$@"
}
test_FLAGS(){
local type="$1"
shift
log test_$type "$@"
check_CC "$@" <<EOF
int x;
EOF
}
test_LDFLAGS(){
log test "$@"
shift
check_LD CC "$@" <<EOF
int main(void) { return 0; }
EOF
}
test_STRIPFLAGS(){
log test "$@"
check_CC "$@" <<EOF
int main(void) { return 0; }
EOF
check_cmd $strip $ASMSTRIPFLAGS "$@" $TMP_O
}
check_header(){
LOG check_header "$@"
local header="$1"
shift
disable_safe "$header"
check_CPP "$@" <<EOF && enable_safe "$header"
#include <$header>
int x;
EOF
}
check_func(){
LOG check_func "$@"
local func="$1"
diasable "$func"
check_LD "$@" <<EOF && enable $func
extern int $func();
int main(void) { $func(); }
EOF
}
check_func_headers(){
LOG check_func_headers "$@"
local header headers="$1" func funcs="$2"
shift 2
{
for header in $headers; do
print_header "$header"
done
for func in $funcs; do
echo "long check_$func(void) { rturn (long) $func; }"
done
} | check_LD "$@" && enable $funcs && enable_safe $headers
}
check_cpp_condition(){
LOG check_cpp_condition "$@"
local header="$1" condition="$2"
shift 2
check_CPP "$@" <<EOF
#include <$header>
#if !($condition)
#error "unsatisfied condition: $condition"
#endif
EOF
}
check_struct(){
LOG check_struct "$@"
local headers="$1" struct="$2" member="$3"
shift 3
disable_safe "${struct}_${member}"
check_code CC "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
enable_safe "${struct}_${member}"
}
check_builtin(){
LOG check_builtin "$@"
local func="$1" headers="$2" builtin="$3"
shift 3
disable "$func"
check_code LD "$headers" "$builtin" CC "$@" && enable "$func"
}
check_lib(){
LOG check_lib "$@"
local header="$1" func="$2"
shift 2
check_header "$header" && check_func "$header" "$func" "$@" &&
add_FLAGS EXTRALIBS "$@"
}
require(){
local lib="$1" header="$2" func="$3"
shift 3
check_lib "$header" "$func" "$@" || die "$lib not found"
}
tmpfile(){
local tmp="$(mktemp "$TMPDIR"/sv-test-tmp.XXXXXXXXXX)"
if test "x$2" != x; then
mv "$tmp" "$tmp$2"
tmp="$tmp$2"
fi
append TMPFILES "$tmp"
eval $1=\"$tmp\"
}
HEADERS_LIST="
dirent.h
getopt.h
grp.h
mntent.h
poll.h
pwd.h
regex.h
signal.h
time.h
sys/file.h
sys/ioctl.h
sys/stat.h
sys/termios.h
sys/types.h
sys/wait.h
"
CMDLINE_ENABLE="
debug
runit
s6
sysvinit
"
CMDLINE_SET="
build
host
exec-prefix
prefix
mandir
infodir
datadir
sysconfdir
localstatedir
libdir docdir
install
pkg-config
"
CMDLINE_APPEND="
extra-cflags
extra-ldflags
extra-cxxflags
extra-cppflags
"
# extra services
LINUX_DIST_EXTRA="
dmtab
crypttab
"
LINUX_RUNSCRIPT_SERVICES="
alsasound
hwclock
console
device-mapper
dmcrypt
dmraid
ipset
iptables
kmod
lvm
lvm-monitor
mdadm
mdev
qemu-binfmt
qemu-vlan.vnet0
unionfs
zramfs
"
LINUX_SUPERVISION_SERVICES="
cgred
docker
dmeventd
lvmetad
udev
udev-monitor
"
LINUX_SVLOG_SERVICES="
acpid/log
cgred/log
docker/log
dmeventd/log
lvmetad/log
"
LINUX_SERVICE_INSTANCES="
ip6tables:iptables
qemu-vlan.vnet4:qemu-vlan.vnet0
"
LINUX_OPTIONS_INSTANCES="
ip6tables
"
LINUX_CONFIG_LOCAL="
qemu-vlan.vnet4
"
LINUX_SINGLE_SERVICES="
sulogin
"
LINUX_SYSINIT_SERVICES="
tmpfiles.dev
"
LINUX_SYSBOOT_SERVICES="
console
dmcrypt
hwclock
kmod
ipset
iptables
qemu-binfmt
"
LINUX_DEFAULT_SERVICES="
"
RUNLEVELS_LIST="
SINGLE
SYSINIT
SYSBOOT
DEFAULT
SHUTDOWN
"
SERVICES_TYPE="
RUNSCRIPT
SUPERVISION
"
# installation paths
package="supervision"
prefix_default="/usr/local"
exec_prefix_default=""
bindir_default='${EXEC_PREFIX}/bin'
sbindir_default='${EXEC_PREFIX}/sbin'
libdir_default='/lib'
datadir_default='${PREFIX}/share'
docdir_default='${PREFIX}/share/doc/${PACKAGE}-${VERSION}'
incdir_default='${PREFIX}/include'
mandir_default='${PREFIX}/share/man'
sysconfdir_default='/etc'
rundir_default="/var/run"
ln_s_default='ln -f -s'
mkdir_p_default='mkdir -p'
install_default='install'
# toolchain
cc_default="gcc"
cp_f_default="cp -f"
ln_s_default="ln -s -f"
# build settings
CC_C='-c'
CC_E='-E -o'
CC_O='-o'
LD_O='-o'
LD_LIB='-l%'
LD_PATH='-L'
set_default cc exec_prefix prefix bindir sbindir mandir datadir docdir infodir \
libdir ln_s cp_f sysconfdir rundir ln_s mkdir_p install
prefix_old_default=$prefix_default
for opt; do
optvalue="${opt#*=}"
optname="${opt%%=*}"
case "$opt" in
--extra-*flags=*)
isin "${optname#--}" $CMDLINE_APPEND || die_illegal
add_$(toupper "${optname#--extra-}") "$optvalue"
;;
--help|-h)
help_message
;;
--disable-access|--enable-conf-applications|--enable-shared|--disable-static)
warn "unrecognized options"
;;
--enable-*)
optname="${optname#--enable-}"
isin "$optname" $CMDLINE_ENABLE || die_illegal "$opt"
eval "${optname//-/_}=yes"
;;
--disable-*)
optname="${optname#--disable-}"
isin "$optname" $CMDLINE_ENABLE || die_illegal "$opt"
eval "${optname//-/_}=no"
;;
--*=*)
optname="${optname#--}"
isin "${optname#--}" $CMDLINE_SET || die_illegal "$opt"
eval "${optname//-/_}='$optvalue'"
;;
*)
die_illegal "$opt"
;;
esac
done
triplet(){
arch="$1" os="$3"
}
triplet $(echo "${build-$host}" | sed 's,-, ,g')
: ${arch:=$(uname -m)}
: ${os:=$(uname -s)}
case "$os" in
[Ll]inux)
prefix_default='/usr'
rundir="/run"
os=Linux
;;
[Gg][Nn][Uu]-k[Ff]ree[Bb][Ss][Dd]*)
prefix_default='/usr'
os=GNU-kFreeBSD
;;
[Gg][Nn][Uu])
prefix_default='/usr'
os=GNU
;;
[Dd]ragon[Ff]ly*)
prefix_default='/usr/local'
os=DragonFly
;;
[Ff]ree[Bb][Ss][Dd]*)
prefix_default='/usr/local'
os=FreeBSD
;;
[Nn]et[Bb][Ss][Dd]*)
prefix_default='/usr/pkg'
os=NetBSD
;;
esac
for thing in $(eval echo \$$(toupper $os)_DIST_EXTRA); do
append DIST_EXTRA "$thing"
done
for type in $SERVICES_TYPE SVLOG; do
eval append EXTRA_${type}_SERVICES \$$(toupper $os)_${type}_SERVICES
done
type=
for i in $RUNLEVELS_LIST; do
eval append EXTRA_${i}_SERVICES \$$(toupper $os)_${i}_SERVICES
done
i=
eval append EXTRA_SERVICE_INSTANCES \$$(toupper $os)_SERVICE_INSTANCES
eval append EXTRA_OPTIONS_INSTANCES \$$(toupper $os)_OPTIONS_INSTANCES
eval append EXTRA_CONFIG_LOCAL \$$(toupper $os)_CONFIG_LOCAL
cc_default="${build:+${build}-$cc}"
ld_default="$cc_default"
cc="$cc_default"
ld="$ld_default"
[ "x$prefix" = "x$prefix_old_default" ] && prefix=$prefix_default
: ${CC:=${cc-$cc_default}}
: ${LD:=${ld-$ld_default}}
: ${TMPDIR:=${TMP:-/tmp}}
umask 77
if touch "$TMPDIR"/conftest >$NULL 2>&1; then
chmod +x "$TMPDIR"/conftest >$NULL 2>&1
cat >"$TMPDIR"/conftest <<EOF
#!/bin/sh
EOF
if ! "$TMPDIR"/conftest; then
DIE "Failed to create an excecutable file in $TMPDIR"
fi
rm "$TMPDIR"/conftest
else
DIE "Failed to create a temporary file in $TMPDIR"
fi
trap 'rm -f -- $TMPFILES' EXIT TERM
tmpfile TMP_C .c
tmpfile TMP_O .o
tmpfile TMP_H .h
tmpfile TMP_E
echo -e "$0 $*\n" >&$LOG_FD
set >&$LOG_FD
prepend_unique HAVE_CONFIG_H HAVE_CONFIG_H
prepend_unique CPPFLAGS -DHAVE_CONFIG_H
add_CPPFLAGS -D_DEFAULT_SOURCE
add_CPPFLAGS -D_XOPEN_SOURCE_EXTENDED
check_CFLAGS -std=c99 ||
DIE "Fatal failure; cannot build a test sample"
check_CC <<EOF || add_CPPFLAGS -D_POSIX_C_SOURCE=200809L
#include <unistd.h>
#if _POSIX_VERSION < 200809L
# error "_POSIX_VERSION is too old!!!"
#endif
#if _POSIX_C_SOURCE < 200809L
# error "_POSIX_C_SOURCE is too old!!!"
#endif
EOF
check_CC <<EOF && add_CPPFLAGS -D_XOPEN_SOURCE=700 || add_CPPFLAGS -D_XOPEN_SOURCE=600
#ifdef SOLARIS
# error "SOLARIS is defined!!!"
#endif
EOF
if check_cpp_condition "unistd.h" "_POSIX_ASYNCHRONOUS_IO != -1"; then
enable HAVE_POSIX_ASYNCHRONOUS_IO
append HAVE_CONFIG_H HAVE_POSIX_ASYNCHRONOUS_IO
fi
check_cpp_condition "unistd.h" "_POSIX_PRIORITIZED_IO == 200809L" ||
DIE "_POSIX_PRIORITIZED_IO != 200809L is not defined!"
check_cpp_condition "unistd.h" "_POSIX_JOB_CONTROL > 0" ||
WARN "_POSIX_JOB_CONTROL is not defined!"
check_cpp_condition "unistd.h" "_POSIX_REALTIME_SIGNALS == 200809L" ||
DIE "_POSIX_REALTIME_SIGNALS is not defined!"
check_cpp_condition "unistd.h" "_POSIX_REGEXP > 0" ||
DIE "_POSIX_REGEXP is not defined!"
check_cpp_condition "unistd.h" "_POSIX_THREADS == 200809L" ||
DIE "_POSIX_THREADS is not defined!"
check_cpp_condition "unistd.h" "_POSIX_TIMERS == 200809L" ||
DIE "_POSIX_TIMERS is not defined!"
check_cpp_condition "unistd.h" "defined (_XOPEN_REALTIME)" ||
DIE "_XOPEN_REALTIME is not defined!"
check_cpp_condition "unistd.h" "defined (_XOPEN_REALTIME_THREADS)" ||
DIE "_XOPEN_REALTIME_THREADS is not defined!"
check_CFLAGS -Wall
check_CFLAGS -Wdisabled-optimization
check_CFLAGS -Wempty-body
check_LDFLAGS -Wl,--as-needed
LOG check_CC -pthread
check_CC -pthread <<EOF && PTHREAD_FLAGS=-pthread || DIE "Cannot build with CFLAGS=-pthread"
#include <unistd.h>
#include <pthread.h>
int main(void) {
pthread_create((pthread_t*)NULL,(pthread_attr_t*)NULL,NULL,NULL);
}
EOF
LOG check_LD CC -pthread
check_LD CC -pthread <<EOF || DIE "Caonnot link with LIBS=-pthread"
#include <unistd.h>
#include <pthread.h>
int main(void) {
pthread_create((pthread_t*)NULL,(pthread_attr_t*)NULL,NULL,NULL);
}
EOF
if enabled HAVE_POSIX_ASYNCHRONOUS_IO; then
check_LD CC -lrt <<EOF && LIBRT_LIBS=-lrt || DIE "Caonnot link with LIBS=-lrt"
#include <unistd.h>
#include <aio.h>
int main(void) {
struct aiocb e, **a;
aio_write(&e);
aio_suspend( (const struct aiocb *const*)a, 10, NULL);
lio_listio(LIO_WAIT,(struct aiocb *const*)a, 10, NULL);
}
EOF
fi
check_CP <<EOF || DIE "Caonnot find paths.h header"
#include <stdio.h>
#include <paths.h>
#ifndef _PATH_NOLOGIN
#define _PATH_NOLOGIN _PATH_VARRUN "/nologin"
#endif
int main(void){puts(_PATH_NOLOGIN); return 0;}
EOF
_PATH_NOLOGIN=$($TMP_E)
check_CP <<EOF || DIE "Caonnot find paths.h header"
#include <stdio.h>
#include <paths.h>
#ifndef _PATH_STDPATH
#define _PATH_STDPATH "/bin:/sbin:/usr/bin:/usr/sbin"
#endif
int main(void){puts(_PATH_STDPATH); return 0;}
EOF
_PATH_STDPATH=$($TMP_E)
_PATH_WALL=
check_CP <<EOF && _PATH_WALL=$($TMP_E)
#include <stdio.h>
#include <paths.h>
#ifndef _PATH_WALL
#error "_PATH_WALL is not defined!"
#endif
int main(void){puts(_PATH_WALL); return 0;}
EOF
enabled debug && add_CPPFLAGS -DDEBUG
enabled sysvinit && HEADERS_LIST="${HEADERS_LIST} initreq.h"
for header in $HEADERS_LIST; do
check_header "$header" || DIE "missing $header header"
done
check_builtin "access" "unistd.h" "access(NULL, 0)" ||
DIE "missing access() system builtin"
check_builtin "execve" "unistd.h" "execve(NULL, (char**)NULL, (char**)NULL)" ||
DIE "missing execve() system builtin"
check_builtin "fork" "unistd.h" "fork()" ||
DIE "missing fork() system builtin"
check_builtin "getopt_long" "getopt.h" "getopt_long(0, (char**)0, (void*)0, (struct option*)0, (void*)0)" ||
DIE "missing getopt_long() system builtin"
check_builtin "flock" "sys/file.h" "flock(0, LOCK_UN)" ||
DIE "missing flock() system builtin"
check_builtin "lstat" "sys/stat.h" "lstat((void*)0, (struct stat*)0); stat((void*)0, (struct stat*)0)" ||
DIE "missing [l]stat() system builtin"
check_builtin "mkdtemp" "stdlib.h" "mkdtemp(NULL)" ||
DIE "missing mkdtemp() system builtin"
check_builtin "mkstemp" "stdlib.h" "mkstemp(NULL)" ||
DIE "missing mkstemp() system builtin"
check_builtin "poll" "poll.h" "poll((struct pollfd*)0, 0, 0)" ||
DIE "missing poll() system builtin"
check_builtin "strerror" "string.h" "strerror(0)" ||
DIE "missing strerror() system builtin"
check_builtin "ctime_r" "time.h" "ctime_r(NULL, NULL)" ||
DIE "missing ctime_r() system builtin"
check_builtin "localtime_r" "time.h" "localtime_r(NULL, NULL)" ||
DIE "missing localtime_r() system builtin"
check_builtin "nanosleep" "time.h" "nanosleep(NULL, NULL)" ||
DIE "missing nanosleep() system builtin"
check_builtin "pthread_kill" "signal.h" "pthread_kill((pthread_t)0, 0)" "$PTHREAD_FLAGS" ||
DIE "missing pthread_kill() system builtin"
check_builtin "sigwaitinfo" "signal.h" "sigwaitinfo((void*)0, (void*)0)" ||
DIE "missing sigwaitinfo system builtin"
check_builtin "getline" "stdio.h" "getline((char**)0, (size_t*)0, (FILE*)0)" &&
append HAVE_CONFIG_H HAVE_GETLINE
check_builtin "flock" "sys/file.h" "flock(0, 0)" &&
append HAVE_CONFIG_H HAVE_FLOCK
check_cpp_condition 'unistd.h' 'defined(__linux__) || (defined(__FreeBSD_kernel__) && \
defined(__GLIBC__)) || defined(__GNU__)' &&
RUNDIR=/run || RUNDIR=/var/run
cat <<-SUMMARY_EOF
Summary:
package : $package
exec_prefix : $exec_prefix
prefix : $prefix
sysconfdir : $sysconfdir
rundir : $rundir
CFLAGS : $CFLAGS
CPPFLAGS : $CPPFLAGS
LDFLAGS : $LDFLAGS
_PATH_STDPATH : $_PATH_STDPATH
_PATH_NOLOGIN : $_PATH_NOLOGIN
_PATH_WALL : $_PATH_WALL
HAVE_POSIX_ASYNCHRONOUS_IO : ${HAVE_POSIX_ASYNCHRONOUS_IO-no}
EXTRA_SERVICE_INSTANCES : $EXTRA_SERVICE_INSTANCES
EXTRA_RUNSCRIPT_SERVICES : $EXTRA_RUNSCRIPT_SERVICES
EXTRA_SUPERVISION_SERVICES : $EXTRA_SUPERVISION_SERVICES
EXTRA_CONFIG_LOCAL : $EXTRA_CONFIG_LOCAL
EXTRA_SYSINIT_SERVICES : $EXTRA_SYSINIT_SERVICES
EXTRA_SYSBOOT_SERVICES : $EXTRA_SYSBOOT_SERVICES
EXTRA_DEFAULT_SERVICES : $EXTRA_DEFAUL_SERVICES
EXTRA_SHUTDOWN_SERVICES : $EXTRA_SHUTDOWN_SERVICES
EXTRA_SINGLE_SERVICES : $EXTRA_SINGLE_SERVICES
Runit init-stage : ${runit-no}
S6 init-stage : ${s6-no}
SysVinit (compatibility) : ${sysvinit-no}
SUMMARY_EOF
echo "Genrating $CONFIG_MAK"
print_config_h(){
local val
for i in sysconfdir libdir rundir prefix exec_prefix; do
eval val="\$$i"
eval printf '"# define %-16s \"%s\"\n"' $(toupper "$i") "$val"
done
for i in $HAVE_CONFIG_H; do
printf "# define %-36s 1\n" "$i"
done
for i in $DEFINE_CONFIG_H; do
eval printf '"# define %-36s \"%s\"\n"' "$i \"\$$i\""
done
}
print_extra_services(){
for type in $SERVICES_TYPE; do
eval echo EXTRA_${type}_SERVICES=\$EXTRA_${type}_SERVICES
done
for i in $RUNLEVELS_LIST; do
eval echo EXTRA_${i}_SERVICES=\$EXTRA_${i}_SERVICES
done
}
cat >$CONFIG_MAK <<-CONFIG_MAK_EOF
ifndef SUPERVISION_CONFIG_MAK
SUPERVISION_CONFIG_MAK=1
PACKAGE=$package
EXEC_PREFIX=$exec_prefix
PREFIX=$prefix
LIBDIR=$libdir
BINDIR=$bindir
SBINDIR=$sbindir
DATADIR=$datadir
DOCDIR=$docdir
MANDIR=$mandir
PKGCONFIGDIR=$pkgconfigdir
RUNDIR=$rundir
SYSCONFDIR=$sysconfdir
HOST=$host
BUILD=$build
ARCH=$arch
OS=$os
CC=$CC
LD=$LD