-
Notifications
You must be signed in to change notification settings - Fork 124
/
configure
executable file
·794 lines (731 loc) · 18.5 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
#!/bin/sh
# Try and be like autotools configure, but without autotools
VERSION=0.60
# Ensure that we do not inherit these from env
OS=
BUILD=
HOST=
TARGET=
BUILD_TESTS=
BUILD_API_DOCS=
BUILD_STATIC=
SILENT=yes
HAVE_VISIBILITY=no
SET_RPATH=
DEBUG=
FULL_DEBUG=
BUILD_LTO=
usage()
{
cat <<_EOF
\`configure' configures XBPS to adapt to many kinds of systems.
By default, \`make install' will install all the files in
\`/usr/local/sbin', \`/usr/local/lib' etc. You can specify
an installation prefix other than \`/usr/local' using \`--prefix',
for instance \`--prefix=\$HOME'.
--prefix=DIR Install architecture-independent files in PREFIX
--exec-prefix=DIR Install architecture-dependent files in EPREFIX
--bindir=DIR Executables [PREFIX/bin]
--libdir=DIR Object code libraries [PREFIX/lib]
--includedir=DIR C header files [EPREFIX/include]
--mandir=DIR Man documentation [EPREFIX/share/man]
--datadir=DIR Read-only architecture-independent data [EPREFIX/share]
--sysconfdir=DIR Configuration files directory [PREFIX/etc]
--pkgconfigdir=DIR pkg-config directory [EPREFIX/lib/pkgconfig]
--testsdir=DIR Test suite directory [EPREFIX/tests]
--localstatedir=DIR Local state directory to store XBPS db files [/var]
--dbdir=DIR Path to the pkgdb directory [LOCALSTATEDIR/db/xbps]
--verbose Disable silent build to see compilation details
--enable-rpath Link binaries with rpath '\$ORIGIN/../lib'
--enable-api-docs Install XBPS API Library documentation (default disabled)
--enable-debug Enables debugging (assertions and -g, default enabled)
--enable-fulldebug Enables extra debugging code (default disabled)
--enable-static Build XBPS static utils (default disabled)
--enable-lto Build with Link Time Optimization (default disabled)
--enable-tests Build and install Kyua tests (default disabled)
Needs atf >= 0.15 (https://github.com/jmmv/atf)
Needs kyua to run the test suite (https://github.com/jmmv/kyua)
_EOF
exit 1
}
for x; do
opt=${x%%=*}
var=${x#*=}
case "$opt" in
--enable-debug) DEBUG=yes;;
--enable-fulldebug) FULL_DEBUG=yes;;
--enable-rpath) SET_RPATH=yes;;
--prefix) PREFIX=$var;;
--exec-prefix) EPREFIX=$var;;
--bindir) BINDIR=$var;;
--mandir) MANDIR=$var;;
--datadir) SHAREDIR=$var;;
--build) BUILD=$var;;
--host) HOST=$var;;
--target) TARGET=$var;;
--includedir) INCLUDEDIR=$var;;
--sysconfdir) SYSCONFDIR=$var;;
--localstatedir) LOCALSTATEDIR=$var;;
--libdir) LIBDIR=$var;;
--datadir|--infodir) ;; # ignore autotools
--dbdir) DBDIR=$var;;
--enable-api-docs) BUILD_API_DOCS=$var;;
--verbose) unset SILENT;;
--pkgconfigdir) PKGCONFIGDIR=$var;;
--enable-tests) BUILD_TESTS=yes;;
--enable-static) BUILD_STATIC=yes;;
--enable-lto) BUILD_LTO=yes;;
--testsdir) TESTSDIR=$var;;
--help) usage;;
*) echo "$0: WARNING: unknown option $opt" >&2;;
esac
done
: ${SED:=sed}
: ${PREFIX:=/usr/local}
: ${EPREFIX:=${PREFIX}}
: ${SYSCONFDIR:=${PREFIX}/etc}
: ${BINDIR:=${PREFIX}/bin}
: ${LIBDIR:=${EPREFIX}/lib}
: ${SHAREDIR:=${EPREFIX}/share}
: ${MANDIR:=${EPREFIX}/share/man}
: ${INCLUDEDIR:=${EPREFIX}/include}
: ${PKGCONFIGDIR:=${LIBDIR}/pkgconfig}
: ${TESTSDIR:=${EPREFIX}/tests}
: ${LOCALSTATEDIR:=/var}
: ${DBDIR:=${LOCALSTATEDIR}/db/xbps}
: ${TOPDIR:=..}
_which()
{
x="$(command -v "$1" 2>/dev/null)"
if [ -n "$x" ]; then
echo "$x"
return 0
fi
for x in /sbin/"$1" /usr/sbin/"$1" \
/usr/pkg/sbin/"$1" /usr/local/sbin/"$1"
do
if [ -e "$x" ]; then
echo "$x"
return 0
fi
done
return 1
}
CONFIG_MK=config.mk
if [ -z "$BUILD" ]; then
BUILD=`uname -m`-unknown-`uname -s | tr '[:upper:]' '[:lower:]'`
fi
if [ -z "$HOST" ]; then
[ -z "$TARGET" ] && TARGET=$BUILD
HOST=$TARGET
fi
if [ -z "$TARGET" ]; then
[ -z "$HOST" ] && HOST=$BUILD
TARGET=$HOST
fi
if [ -z "$OS" ]; then
# Derive OS from cpu-manufacturer-os-kernel
CPU=${TARGET%%-*}
REST=${TARGET#*-}
MANU=${REST%%-*}
REST=${REST#*-}
OS=${REST%%-*}
REST=${REST#*-}
KERNEL=${REST%%-*}
fi
echo "Configuring xbps for ... $OS"
rm -f $CONFIG_MK
echo "# Common vars used by XBPS on $OS." >$CONFIG_MK
echo "XBPS_OS = $OS" >>$CONFIG_MK
echo "VERSION = $VERSION" >>$CONFIG_MK
echo "TOPDIR ?= $TOPDIR" >>$CONFIG_MK
echo "PREFIX ?= $PREFIX" >>$CONFIG_MK
echo "EPREFIX ?= $EPREFIX" >>$CONFIG_MK
echo "SBINDIR ?= $BINDIR" >>$CONFIG_MK
echo "INCLUDEDIR ?= $INCLUDEDIR" >>$CONFIG_MK
echo "LIBDIR ?= $LIBDIR" >>$CONFIG_MK
echo "MANDIR ?= $MANDIR" >>$CONFIG_MK
echo "SHAREDIR ?= $SHAREDIR" >>$CONFIG_MK
echo "PKGCONFIGDIR ?= $PKGCONFIGDIR" >>$CONFIG_MK
echo "TESTSDIR ?= $TESTSDIR" >>$CONFIG_MK
echo "DBDIR ?= $DBDIR" >>$CONFIG_MK
ETCDIR="${SYSCONFDIR}/xbps.d"
echo "ETCDIR ?= $ETCDIR" >>$CONFIG_MK
if [ -z "$CC" ]; then
printf "Looking for compiler ... "
for b in $TARGET- ""; do
for cc in gcc icc clang tcc pcc cc; do
if type $b$cc >/dev/null 2>&1; then
CC=$b$cc
echo "$CC"
break
fi
done
[ -n "$CC" ] && break
done
if [ -z "$CC" ]; then
echo
echo "no suitable compiler found - aborting" >&2
exit 1
fi
else
echo "Using compiler $CC"
fi
[ -z "$DEBUG" ] && DEBUG=yes
echo "CC = $CC" >>$CONFIG_MK
echo "CFLAGS = -O2" >>$CONFIG_MK
echo "LDFLAGS = -L\$(TOPDIR)/lib" >>$CONFIG_MK
echo "CPPFLAGS = -D_DEFAULT_SOURCE -D_GNU_SOURCE -I. -I\$(TOPDIR) -I\$(TOPDIR)/include" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_SYSCONF_PATH=\\\"${ETCDIR}\\\"" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_SYSDEFCONF_PATH=\\\"${SHAREDIR}/xbps.d\\\"" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_VERSION=\\\"${VERSION}\\\"" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_META_PATH=\\\"${DBDIR}\\\"" >>$CONFIG_MK
echo "CPPFLAGS += -DUNUSED=\"__attribute__((__unused__))\"" >>$CONFIG_MK
if [ -d .git ] && command -v git >/dev/null; then
_gitrev=$(git rev-parse --short HEAD)
echo "CPPFLAGS += -DXBPS_GIT=\\\"${_gitrev}\\\"" >>$CONFIG_MK
fi
if [ -n "$DEBUG" -a "$DEBUG" != no -a "$DEBUG" != false ]; then
echo "Building with debugging symbols."
echo "CPPFLAGS += -DDEBUG" >>$CONFIG_MK
echo "CFLAGS += -g" >>$CONFIG_MK
echo "LIBXBPS_LDFLAGS += -g" >>$CONFIG_MK
else
echo "CPPFLAGS+= -DNDEBUG" >>$CONFIG_MK
fi
if [ -n "$FULL_DEBUG" ]; then
echo "Enabling extra debugging code."
echo "CPPFLAGS+= -DFULL_DEBUG" >>$CONFIG_MK
fi
case "$OS" in
linux)
echo "CPPFLAGS += -D_XOPEN_SOURCE=700" >>$CONFIG_MK
echo "CPPFLAGS += -D_FILE_OFFSET_BITS=64" >> $CONFIG_MK
;;
*)
;;
esac
# Add CPPFLAGS/CFLAGS/LDFLAGS to CC for testing features
XCC="$CC $CFLAGS $CPPFLAGS $LDFLAGS"
check_compiler_flag()
{
local flag="$1"
local mode="$2"
local var="$3"
local rv=0
[ -z "$var" ] && var="CFLAGS"
printf "Checking if $CC supports -${mode}${flag} ... "
cat <<EOF >_ccflag.c
#include <stdio.h>
int main(void) { return 0; }
EOF
if $XCC -${mode}${flag} _ccflag.c -o _ccflag 2>_ccflag.err; then
if ! test -s _ccflag.err; then
if [ "$mode" = "W" -a -z "$var" ]; then
echo "CPPFLAGS += -${mode}${flag}" >>$CONFIG_MK
else
echo "$var += -${mode}${flag}" >>$CONFIG_MK
fi
echo "yes."
else
rv=1
echo "no."
fi
else
rv=1
echo "no."
fi
[ -z "$SILENT" ] && cat _ccflag.err
rm -f _ccflag.c _ccflag _ccflag.err
return $rv
}
# If supported, make sure to disable --as-needed for CC tests.
check_compiler_flag "l,--no-as-needed" W LDFLAGS
if [ $? -eq 0 ]; then
XCC="$XCC -Wl,--no-as-needed"
fi
#
# Check for some compiler warning flags.
#
for f in all extra error shadow "format=2" missing-prototypes \
missing-declarations nested-externs vla overlength-strings \
unsafe-loop-optimizations undef sign-compare \
missing-include-dirs old-style-definition \
init-self redundant-decls float-equal missing-noreturn \
cast-align cast-qual pointer-arith comment \
declaration-after-statement write-strings stack-protector; do
check_compiler_flag ${f} W
done
#
# Check for some compiler flags.
#
check_compiler_flag PIC f CFLAGS
check_compiler_flag "inline-functions" f CFLAGS
check_compiler_flag stack-protector-strong f CFLAGS
if [ $? -ne 0 ]; then
check_compiler_flag stack-protector f CFLAGS
if [ $? -eq 0 ]; then
if [ "$CC" = "gcc" ]; then
check_compiler_flag "param ssp-buffer-size=1" - CFLAGS
fi
fi
fi
check_compiler_flag "visibility=default" f SHAREDLIB_CFLAGS
if [ $? -eq 0 ]; then
HAVE_VISIBILITY=yes
echo "CPPFLAGS += -DHAVE_VISIBILITY=1" >>$CONFIG_MK
echo "HAVE_VISIBILITY = 1" >>$CONFIG_MK
fi
#
# Check for -Wl,--export-dynamic and if it fails, try -rdynamic.
#
check_compiler_flag "l,--export-dynamic" W LIBXBPS_LDFLAGS
if [ $? -ne 0 ]; then
check_compiler_flag dynamic r LIBXBPS_LDFLAGS
fi
#
# Check for -Wl,-z,relro,-z,now
check_compiler_flag "l,-z,relro,-z,now" W LDFLAGS
#
# Check if PIE is supported.
#
check_compiler_flag PIE f PROG_CFLAGS
if [ $? -eq 0 ]; then
check_compiler_flag pie "" PROG_LDFLAGS
fi
if [ $? -eq 0 ]; then
BUILD_PIE_VALUE=yes
else
BUILD_PIE_VALUE=no
fi
#
# A C99 compiler is required to build xbps.
#
check_compiler_flag "std=c99" "" CFLAGS
if [ $? -ne 0 ]; then
echo "ERRROR: A compatible C99 compiler is required, exiting..."
exit 1
fi
#
# Enable LTO if supported (clang and gcc)
#
if [ "$BUILD_LTO" = "yes" ]; then
check_compiler_flag lto f CFLAGS
if [ $? -eq 0 ]; then
echo "LDFLAGS += -flto" >> $CONFIG_MK
if [ "$CC" = "gcc" ]; then
echo "AR = gcc-ar" >> $CONFIG_MK
echo "RANLIB = gcc-ranlib" >>$CONFIG_MK
fi
fi
fi
if [ -n "$CFLAGS" ]; then
echo "CFLAGS += $CFLAGS" >>$CONFIG_MK
fi
if [ -n "$LDFLAGS" ]; then
echo "LDFLAGS += $LDFLAGS" >>$CONFIG_MK
fi
if [ -n "$CPPFLAGS" ]; then
echo "CPPFLAGS += $CPPFLAGS" >>$CONFIG_MK
fi
if [ "$CC" = "tcc" ]; then
echo "CFLAGS += -Wno-error" >>$CONFIG_MK
fi
# openssl 3 compatibility
echo "CFLAGS += -Wno-error=deprecated-declarations">>$CONFIG_MK
# libfetch
echo "CPPFLAGS += -I\$(TOPDIR)/lib/fetch" >>$CONFIG_MK
echo "LDFLAGS += -lssl" >>$CONFIG_MK
echo "STATIC_LIBS = \$(TOPDIR)/lib/libxbps.a" >>$CONFIG_MK
# proplib
echo "CPPFLAGS += -I\$(TOPDIR)/lib/portableproplib" >>$CONFIG_MK
echo "CPPFLAGS += -I\$(TOPDIR)/lib/portableproplib/prop" >>$CONFIG_MK
echo "CFLAGS += -pthread" >>$CONFIG_MK
#
# Check for GCC atomic builtins.
#
func=atomic
printf "Checking for GCC atomic builtins ... "
cat <<EOF >_$func.c
int main() {
volatile unsigned long val = 1;
__sync_fetch_and_add(&val, 1);
__sync_fetch_and_sub(&val, 1);
__sync_add_and_fetch(&val, 1);
__sync_sub_and_fetch(&val, 1);
return 0;
}
EOF
if $XCC _$func.c -o _$func 2>/dev/null; then
echo yes.
HAVE_ATOMICS=1
else
echo no.
fi
rm -f _$func.c _$func
if test -n "$HAVE_ATOMICS"; then
echo "CPPFLAGS += -DHAVE_ATOMICS" >> $CONFIG_MK
fi
#
# Check for vasprintf().
#
func=vasprintf
printf "Checking for $func() ... "
if test -n "$HAVE_VASPRINTF"; then
echo "yes (cached)."
else
cat <<EOF >_$func.c
#define _GNU_SOURCE
#include <stdio.h>
#include <stdarg.h>
int main(void) {
va_list ap;
vasprintf(NULL, NULL, ap);
return 0;
}
EOF
if $XCC _$func.c -o _$func 2>/dev/null; then
echo yes.
HAVE_VASPRINTF=1
else
echo no.
fi
rm -f _$func.c _$func
fi
if test -n "$HAVE_VASPRINTF"; then
echo "CPPFLAGS += -DHAVE_VASPRINTF" >> $CONFIG_MK
else
echo "COMPAT_OBJS+= compat/vasprintf.o" >>$CONFIG_MK
fi
#
# Check for strcasestr().
#
func=strcasestr
printf "Checking for $func() ... "
cat <<EOF >_$func.c
#define _GNU_SOURCE
#include <string.h>
int main(void) {
const char *h = "NEEDCOFEE";
const char *n = "IneedCoffee";
strcasestr(n, h);
return 0;
}
EOF
if $XCC _$func.c -o _$func 2>/dev/null; then
echo yes.
echo "CPPFLAGS += -DHAVE_STRCASESTR" >>$CONFIG_MK
else
echo no.
echo "COMPAT_OBJS += compat/strcasestr.o" >>$CONFIG_MK
fi
rm -f _$func _$func.c
#
# Check for strlcpy().
#
func=strlcpy
printf "Checking for $func() ... "
cat <<EOF >_$func.c
#include <string.h>
int main(void) {
const char s1[] = "foo";
char s2[10];
strlcpy(s2, s1, sizeof(s2));
return 0;
}
EOF
if $XCC _$func.c -o _$func 2>/dev/null; then
echo yes.
echo "CPPFLAGS += -DHAVE_STRLCPY" >> $CONFIG_MK
else
echo no.
echo "COMPAT_OBJS += compat/strlcpy.o" >>$CONFIG_MK
fi
rm -f _$func.c _$func
#
# Check for strlcat().
func=strlcat
printf "Checking for $func() ... "
cat <<EOF > _$func.c
#include <string.h>
int main(void) {
const char src[] = "foo";
char dst[10];
strlcat(dst, src, sizeof(dst));
return 0;
}
EOF
if $XCC _$func.c -o _$func 2>/dev/null; then
echo yes.
echo "CPPFLAGS += -DHAVE_STRLCAT" >>$CONFIG_MK
else
echo no.
echo "COMPAT_OBJS += compat/strlcat.o" >>$CONFIG_MK
fi
rm -f _$func.c _$func
#
# Check for strnstr().
func=strnstr
printf "Checking for $func() ... "
cat <<EOF > _$func.c
#include <string.h>
int main(void) {
const char big[] = "foo";
const char little[] = "f";
strnstr(big, little, 3);
return 0;
}
EOF
if $XCC _$func.c -o _$func 2>/dev/null; then
echo yes.
echo "CPPFLAGS += -DHAVE_STRNSTR" >>$CONFIG_MK
else
echo no.
fi
rm -f _$func.c _$func
#
# Check for humanize_number().
func=humanize_number
printf "Checking for $func() ... "
cat <<EOF > _$func.c
#include <stdio.h>
#include <util.h>
int main(void) {
humanize_number(NULL, 0, 0, NULL, 0, 0);
return 0;
}
EOF
if $XCC _$func.c -lutil -o _$func 2>/dev/null; then
echo yes.
echo "CPPFLAGS+= -DHAVE_HUMANIZE_NUMBER" >>$CONFIG_MK
else
echo no.
echo "COMPAT_OBJS+= compat/humanize_number.o" >>$CONFIG_MK
fi
rm -f _$func.c _$func
#
# Check for rbtree_ininit().
#
func=rb_tree_init
printf "Checking for $func() ... "
cat <<EOF > _$func.c
#include <sys/rbtree.h>
int main(void) {
rb_tree_init(NULL, NULL);
return 0;
}
EOF
if $XCC _$func.c -o _$func 2>/dev/null; then
echo yes.
echo "CPPFLAGS += -DHAVE_RBTREE" >>$CONFIG_MK
else
echo no.
echo "LIBPROP_OBJS += portableproplib/rb.o" >>$CONFIG_MK
fi
rm -f _$func.c _$func
#
# Check for fdatasync().
#
func=fdatasync
printf "Checking for $func() ... "
cat <<EOF > _$func.c
#include <unistd.h>
int main(void) {
fdatasync(0);
return 0;
}
EOF
if $XCC _$func.c -o _$func 2>/dev/null; then
echo yes.
echo "CPPFLAGS += -DHAVE_FDATASYNC" >>$CONFIG_MK
else
echo no.
fi
rm -f _$func.c _$func
#
# Check for clock_gettime(3).
#
func=clock_gettime
printf "Checking for $func() ... "
cat <<EOF > _$func.c
#include <time.h>
int main(void) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return 0;
}
EOF
if $XCC _$func.c -lrt -o _$func 2>/dev/null; then
echo yes.
echo "CPPFLAGS += -DHAVE_CLOCK_GETTIME" >>$CONFIG_MK
echo "LDFLAGS += -lrt" >>$CONFIG_MK
echo "STATIC_LIBS += -lrt" >>$CONFIG_MK
else
echo no.
fi
rm -f _$func.c _$func
#
# zlib is required.
#
func=InflateInit2
printf "Checking for $func() ... "
cat <<EOF > _$func.c
#include <zlib.h>
int main(void) {
z_stream strm;
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
inflateInit2(&strm, 15+16);
return 0;
}
EOF
if $XCC _$func.c -lz -o _$func 2>/dev/null; then
echo yes.
echo "LDFLAGS += -lz" >>$CONFIG_MK
echo "STATIC_LIBS += -lz" >>$CONFIG_MK
else
ZLIB=no
fi
rm -f _$func.c _$func
if [ "$ZLIB" = "no" ]; then
echo "Failed to link with your system's zlib, can't continue..."
exit 1
fi
#
# If building API library documentation, doxygen and graphviz are required.
#
if [ -n "$BUILD_API_DOCS" ]; then
echo "Building API documentation via doxygen and graphviz."
printf "Checking for doxygen ..."
DOXYGEN_BIN=$(_which doxygen)
if [ -z "$DOXYGEN_BIN" ]; then
echo "not found, exiting."
exit 1
else
echo yes
fi
printf "Checking for graphviz ... "
DOT_BIN=$(_which dot)
if [ -z "$DOT_BIN" ]; then
echo "dot(1) command not found, exiting."
exit 1
else
echo yes
fi
echo "BUILD_API_DOCS= yes" >> $CONFIG_MK
BUILD_API_DOCS_VALUE=yes
else
BUILD_API_DOCS_VALUE=no
fi
#
# pkg-config is required to know dependencies for static linking.
#
printf "Checking for pkg-config ... "
PKGCONFIG_BIN=$(_which pkg-config)
if [ -z "$PKGCONFIG_BIN" ]; then
echo "not found, exiting."
exit 1
else
echo yes
fi
#
# libarchive with pkg-config support is required.
#
LIBARCHIVE_REQVER=3.3.3
printf "Checking for libarchive >= ${LIBARCHIVE_REQVER} via pkg-config ... "
if ! pkg-config --atleast-version=${LIBARCHIVE_REQVER} libarchive; then
echo "libarchive.pc file not found, exiting."
exit 1
else
echo "found version $(pkg-config --modversion libarchive)."
echo "CFLAGS += $(pkg-config --cflags libarchive)" >>$CONFIG_MK
echo "LDFLAGS += $(pkg-config --libs libarchive)" >>$CONFIG_MK
echo "STATIC_LIBS += $(pkg-config --libs --static libarchive)" \
>>$CONFIG_MK
fi
#
# libssl with pkg-config support is required.
#
printf "Checking for libssl via pkg-config ... "
if pkg-config --exists 'libssl' && ! pkg-config --exists libtls ; then
echo "found OpenSSL version $(pkg-config --modversion libssl)."
elif pkg-config --exists libssl libtls; then
echo "found LibreSSL version $(pkg-config --modversion libssl)."
else
echo "libssl.pc file not found or incompatible version detected, exiting."
exit 1
fi
echo "CFLAGS += $(pkg-config --cflags libssl)" >>$CONFIG_MK
echo "LDFLAGS += $(pkg-config --libs libssl)" >>$CONFIG_MK
echo "STATIC_LIBS += $(pkg-config --libs --static libssl)" \
>>$CONFIG_MK
#
# If --enable-static enabled, build static binaries.
#
if [ "$BUILD_STATIC" = "yes" ]; then
echo "BUILD_STATIC = yes" >>$CONFIG_MK
BUILD_STATIC_VALUE=yes
else
BUILD_STATIC_VALUE=no
fi
#
# If --enable-tests enabled, check for ATF >= 0.15 via pkg-config.
#
if [ "$BUILD_TESTS" = "yes" ]; then
printf "Checking for ATF via pkg-config ... "
if ! pkg-config --atleast-version=0.15 atf-c; then
echo "ATF >= 0.15 not found in PKG_CONFIG_LIBDIR, exiting."
exit 1
fi
echo "found version $(pkg-config --modversion atf-c)."
echo "TEST_CFLAGS += $(pkg-config --cflags atf-c)" >>$CONFIG_MK
echo "TEST_LDFLAGS += $(pkg-config --libs atf-c)" >>$CONFIG_MK
echo "BUILD_TESTS = yes" >>$CONFIG_MK
BUILD_TESTS_VALUE=yes
else
BUILD_TESTS_VALUE=no
fi
if [ -n "$SILENT" ]; then
echo "SILENT = @" >>$CONFIG_MK
else
echo "SILENT =" >>$CONFIG_MK
fi
if [ "$SET_RPATH" ]; then
echo "PROG_LDFLAGS = -Wl,-rpath='XORIGIN/../lib'" >>$CONFIG_MK
sed -i 's,XORIGIN,$$ORIGIN,' $CONFIG_MK
fi
echo
echo " XBPS has been configured with the following options:"
echo
echo " PREFIX = $PREFIX"
echo " EPREFIX = $EPREFIX"
echo " BINDIR = $BINDIR"
echo " LIBDIR = $LIBDIR"
echo " INCLUDEDIR = $INCLUDEDIR"
echo " SHAREDIR = $SHAREDIR"
echo " MANDIR = $MANDIR"
echo " ETCDIR = $ETCDIR"
echo " DBDIR = $DBDIR"
echo " CFLAGS = $CFLAGS"
echo " LDFLAGS = $LDFLAGS"
echo
echo " Build API documentation = $BUILD_API_DOCS_VALUE"
echo " Build Kyua test suite = $BUILD_TESTS_VALUE"
echo " Build programs as PIE = $BUILD_PIE_VALUE"
echo " Build static programs = $BUILD_STATIC_VALUE"
echo " Build with LTO = $BUILD_LTO"
echo " Build with debugging = $DEBUG"
echo " Build with full debug = $FULL_DEBUG"
if [ -n "$HAVE_VISIBILITY" ]; then
echo " Symbol visibility = $HAVE_VISIBILITY"
fi
if [ -n "$SET_RPATH" ]; then
echo " Build with rpath = $SET_RPATH"
fi
echo
echo " You can now run make && make install clean."
echo
exit 0