forked from networkupstools/nut
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci_build.sh
executable file
·1886 lines (1704 loc) · 82.7 KB
/
ci_build.sh
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
#!/usr/bin/env bash
################################################################################
# This file is based on a template used by zproject, but isn't auto-generated. #
# Its primary use is to automate a number of BUILD_TYPE scenarios for the NUT #
# CI farm, but for the same reason it can also be useful to reduce typing for #
# reproducible build attempts with NUT development and refactoring workflows. #
# Note that it is driven by enviroment variables rather than CLI arguments -- #
# this approach better suits the practicalities of CI build farm technologies. #
################################################################################
set -e
SCRIPTDIR="`dirname "$0"`"
SCRIPTDIR="`cd "$SCRIPTDIR" && pwd`"
# Quick hijack for interactive development like this:
# BUILD_TYPE=fightwarn-clang ./ci_build.sh
# or to quickly hit the first-found errors in a larger matrix
# (and then easily `make` to iterate fixes), like this:
# CI_REQUIRE_GOOD_GITIGNORE="false" CI_FAILFAST=true DO_CLEAN_CHECK=no BUILD_TYPE=fightwarn ./ci_build.sh
#
# For out-of-tree builds you can specify a CI_BUILDDIR (absolute or relative
# to SCRIPTDIR - not current path), or just call .../ci_build.sh while being
# in a different directory and then it would be used with a warning. This may
# require that you `make distclean` the original source checkout first:
# CI_BUILDDIR=obj BUILD_TYPE=default-all-errors ./ci_build.sh
case "$BUILD_TYPE" in
fightwarn) ;; # for default compiler
fightwarn-all)
# This recipe allows to test with different (default-named)
# compiler suites if available. Primary goal is to see whether
# everything is building ok on a given platform, with one shot.
TRIED_BUILD=false
if (command -v gcc) >/dev/null ; then
TRIED_BUILD=true
BUILD_TYPE=fightwarn-gcc "$0" || exit
else
echo "SKIPPING BUILD_TYPE=fightwarn-gcc: compiler not found" >&2
fi
if (command -v clang) >/dev/null ; then
TRIED_BUILD=true
BUILD_TYPE=fightwarn-clang "$0" || exit
else
echo "SKIPPING BUILD_TYPE=fightwarn-clang: compiler not found" >&2
fi
if ! $TRIED_BUILD ; then
echo "FAILED to run: no default-named compilers were found" >&2
exit 1
fi
exit 0
;;
fightwarn-gcc)
CC="gcc"
CXX="g++"
CPP="cpp"
BUILD_TYPE=fightwarn
;;
fightwarn-clang)
CC="clang"
CXX="clang++"
if (command -v clang-cpp) >/dev/null 2>/dev/null ; then
CPP="clang-cpp"
else
CPP="clang -E"
fi
BUILD_TYPE=fightwarn
;;
esac
if [ "$BUILD_TYPE" = fightwarn ]; then
# For CFLAGS/CXXFLAGS keep caller or compiler defaults
# (including C/C++ revision)
BUILD_TYPE=default-all-errors
#BUILD_WARNFATAL=yes
# configure => "yes" except for antique compilers
BUILD_WARNFATAL=auto
# Current fightwarn goal is to have no warnings at preset level below,
# or at the level defaulted with configure.ac (perhaps considering the
# compiler version, etc.):
#[ -n "$BUILD_WARNOPT" ] || BUILD_WARNOPT=hard
#[ -n "$BUILD_WARNOPT" ] || BUILD_WARNOPT=medium
# configure => default to medium, detect by compiler type
[ -n "$BUILD_WARNOPT" ] || BUILD_WARNOPT=auto
# Eventually this constraint would be removed to check all present
# SSL implementations since their ifdef-driven codebases differ and
# emit varied warnings. But so far would be nice to get the majority
# of shared codebase clean first:
#[ -n "$NUT_SSL_VARIANTS" ] || NUT_SSL_VARIANTS=auto
# Similarly for libusb implementations with varying support
#[ -n "$NUT_USB_VARIANTS" ] || NUT_USB_VARIANTS=auto
fi
# Set this to enable verbose profiling
[ -n "${CI_TIME-}" ] || CI_TIME=""
case "$CI_TIME" in
[Yy][Ee][Ss]|[Oo][Nn]|[Tt][Rr][Uu][Ee])
CI_TIME="time -p " ;;
[Nn][Oo]|[Oo][Ff][Ff]|[Ff][Aa][Ll][Ss][Ee])
CI_TIME="" ;;
esac
# Set this to enable verbose tracing
[ -n "${CI_TRACE-}" ] || CI_TRACE="no"
case "$CI_TRACE" in
[Nn][Oo]|[Oo][Ff][Ff]|[Ff][Aa][Ll][Ss][Ee])
set +x ;;
[Yy][Ee][Ss]|[Oo][Nn]|[Tt][Rr][Uu][Ee])
set -x ;;
esac
[ -n "${CI_REQUIRE_GOOD_GITIGNORE-}" ] || CI_REQUIRE_GOOD_GITIGNORE="true"
case "$CI_REQUIRE_GOOD_GITIGNORE" in
[Nn][Oo]|[Oo][Ff][Ff]|[Ff][Aa][Ll][Ss][Ee])
CI_REQUIRE_GOOD_GITIGNORE="false" ;;
[Yy][Ee][Ss]|[Oo][Nn]|[Tt][Rr][Uu][Ee])
CI_REQUIRE_GOOD_GITIGNORE="true" ;;
esac
# Abort loops like BUILD_TYPE=default-all-errors as soon as we have a problem
# (allowing to rebuild interactively and investigate that set-up)?
[ -n "${CI_FAILFAST-}" ] || CI_FAILFAST=false
# We allow some CI setups to CI_SKIP_CHECK (avoiding it during single-process
# scripted build), so tests can be done as a visibly separate stage.
# This does not really apply to some build scenarios whose purpose is to
# loop and check many build scenarios (e.g. BUILD_TYPE="default-all-errors"
# and "fightwarn*" family), but it is up to caller when and why to set it.
# It is also a concern of the caller (for now) if actually passing the check
# relies on something this script does (set envvars, change paths...)
[ -n "${CI_SKIP_CHECK-}" ] || CI_SKIP_CHECK=false
# By default we configure and build in the same directory as source;
# and a `make distcheck` handles how we build from a tarball.
# However there are also cases where source is prepared (autogen) once,
# but is built in various directories with different configurations.
# This is something to test via CI, that recipes are not broken for
# such use-case. Note the path should be in .gitignore, e.g. equal to
# or under ./tmp/ or ./obj/ for the CI_REQUIRE_GOOD_GITIGNORE sanity
# checks to pass.
case "${CI_BUILDDIR-}" in
"") # Not set, likeliest case
CI_BUILDDIR="`pwd`"
if [ x"${SCRIPTDIR}" = x"${CI_BUILDDIR}" ] ; then
CI_BUILDDIR="."
else
echo "=== WARNING: This build will use '${CI_BUILDDIR}'"
echo "=== for an out-of-tree build of NUT with sources located"
echo "=== in '${SCRIPTDIR}'"
echo "=== PRESS CTRL+C NOW if you did not mean this! (Sleeping 5 sec)"
sleep 5
fi
;;
".") ;; # Is SCRIPTDIR, in-tree build
/*) ;; # Absolute path located somewhere else
*) # Non-trivial, relative to SCRIPTDIR, may not exist yet
CI_BUILDDIR="${SCRIPTDIR}/${CI_BUILDDIR}"
;;
esac
[ -n "$MAKE" ] || [ "$1" = spellcheck ] || MAKE=make
[ -n "$GGREP" ] || GGREP=grep
[ -n "$MAKE_FLAGS_QUIET" ] || MAKE_FLAGS_QUIET="VERBOSE=0 V=0 -s"
[ -n "$MAKE_FLAGS_VERBOSE" ] || MAKE_FLAGS_VERBOSE="VERBOSE=1 -s"
# This is where many symlinks like "gcc -> ../bin/ccache" reside
# (note: a "-" value requests to NOT use a CI_CCACHE_SYMLINKDIR;
# ccache may still be used via prefixing if the tool is found in
# the PATH, unless you export CI_CCACHE_USE=no also):
if [ -z "${CI_CCACHE_SYMLINKDIR-}" ] ; then
for D in \
"/usr/lib/ccache" \
"/mingw64/lib/ccache/bin" \
"/mingw32/lib/ccache/bin" \
"/usr/lib64/ccache" \
"/usr/libexec/ccache" \
"/usr/lib/ccache/bin" \
"/usr/local/lib/ccache" \
; do
if [ -d "$D" ] ; then
if ( ls -la "$D" | grep -e ' -> .*ccache' >/dev/null) \
|| ( test -n "`find "$D" -maxdepth 1 -type f -exec grep -li ccache '{}' \;`" ) \
; then
CI_CCACHE_SYMLINKDIR="$D" && break
else
echo "WARNING: Found potential CI_CCACHE_SYMLINKDIR='$D' but it did not host expected symlink patterns, skipped" >&2
fi
fi
done
if [ -n "${CI_CCACHE_SYMLINKDIR-}" ] ; then
echo "INFO: Detected CI_CCACHE_SYMLINKDIR='$CI_CCACHE_SYMLINKDIR'; specify another explicitly if desired" >&2
else
echo "WARNING: Did not find any CI_CCACHE_SYMLINKDIR; specify one explicitly if desired" >&2
fi
else
if [ x"${CI_CCACHE_SYMLINKDIR-}" = x- ] ; then
echo "INFO: Empty CI_CCACHE_SYMLINKDIR was explicitly requested" >&2
CI_CCACHE_SYMLINKDIR=""
fi
fi
# For two-phase builds (quick parallel make first, sequential retry if failed)
# how verbose should that first phase be? Nothing, automake list of ops, CLIs?
# See build_to_only_catch_errors_target() for a consumer of this setting.
case "${CI_PARMAKE_VERBOSITY-}" in
silent|quiet|verbose|default) ;;
*) CI_PARMAKE_VERBOSITY=silent ;;
esac
# Set up the parallel make with reasonable limits, using several ways to
# gather and calculate this information. Note that "psrinfo" count is not
# an honest approach (there may be limits of current CPU set etc.) but is
# a better upper bound than nothing...
[ -n "$NCPUS" ] || { \
NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`" || \
NCPUS="`/usr/bin/getconf NPROCESSORS_ONLN`" || \
NCPUS="`cat /proc/cpuinfo | grep -wc processor`" || \
{ [ -x /usr/sbin/psrinfo ] && NCPUS="`/usr/sbin/psrinfo | wc -l`"; } \
|| NCPUS=1; } 2>/dev/null
[ x"$NCPUS" != x -a "$NCPUS" -ge 1 ] || NCPUS=1
[ x"$NPARMAKES" = x ] && { NPARMAKES="`expr "$NCPUS" '*' 2`" || NPARMAKES=2; }
[ x"$NPARMAKES" != x -a "$NPARMAKES" -ge 1 ] || NPARMAKES=2
[ x"$MAXPARMAKES" != x ] && [ "$MAXPARMAKES" -ge 1 ] && \
[ "$NPARMAKES" -gt "$MAXPARMAKES" ] && \
echo "INFO: Detected or requested NPARMAKES=$NPARMAKES," \
"however a limit of MAXPARMAKES=$MAXPARMAKES was configured" && \
NPARMAKES="$MAXPARMAKES"
# GNU make allows to limit spawning of jobs by load average of the host,
# where LA is (roughly) the average amount over the last {timeframe} of
# queued processes that are ready to compute but must wait for CPU.
# The rough estimate for VM builders however seems that they always have
# some non-trivial LA, so we set the default limit per CPU relatively high.
[ x"$PARMAKE_LA_LIMIT" = x ] && PARMAKE_LA_LIMIT="`expr $NCPUS '*' 8`".0
# After all the tunable options above, this is the one which takes effect
# for actual builds with parallel phases. Specify a whitespace to neuter.
if [ -z "$PARMAKE_FLAGS" ]; then
PARMAKE_FLAGS="-j $NPARMAKES"
if LANG=C LC_ALL=C "$MAKE" --version 2>&1 | grep -E 'GNU Make|Free Software Foundation' > /dev/null ; then
PARMAKE_FLAGS="$PARMAKE_FLAGS -l $PARMAKE_LA_LIMIT"
echo "Parallel builds would spawn up to $NPARMAKES jobs (detected $NCPUS CPUs), or peak out at $PARMAKE_LA_LIMIT system load average" >&2
else
echo "Parallel builds would spawn up to $NPARMAKES jobs (detected $NCPUS CPUs)" >&2
fi
fi
# CI builds on Jenkins
[ -z "$NODE_LABELS" ] || \
for L in $NODE_LABELS ; do
case "$L" in
"NUT_BUILD_CAPS=cppunit=no")
[ -n "$CANBUILD_CPPUNIT_TESTS" ] || CANBUILD_CPPUNIT_TESTS=no ;;
"NUT_BUILD_CAPS=cppunit=no-gcc")
[ -n "$CANBUILD_CPPUNIT_TESTS" ] || CANBUILD_CPPUNIT_TESTS=no-gcc ;;
"NUT_BUILD_CAPS=cppunit=no-clang")
[ -n "$CANBUILD_CPPUNIT_TESTS" ] || CANBUILD_CPPUNIT_TESTS=no-clang ;;
"NUT_BUILD_CAPS=cppunit"|"NUT_BUILD_CAPS=cppunit=yes")
[ -n "$CANBUILD_CPPUNIT_TESTS" ] || CANBUILD_CPPUNIT_TESTS=yes ;;
# Some (QEMU) builders have issues running valgrind as a tool
"NUT_BUILD_CAPS=valgrind=no")
[ -n "$CANBUILD_VALGRIND_TESTS" ] || CANBUILD_VALGRIND_TESTS=no ;;
"NUT_BUILD_CAPS=valgrind"|"NUT_BUILD_CAPS=valgrind=yes")
[ -n "$CANBUILD_VALGRIND_TESTS" ] || CANBUILD_VALGRIND_TESTS=yes ;;
"NUT_BUILD_CAPS=cppcheck=no")
[ -n "$CANBUILD_CPPCHECK_TESTS" ] || CANBUILD_CPPCHECK_TESTS=no ;;
"NUT_BUILD_CAPS=cppcheck"|"NUT_BUILD_CAPS=cppcheck=yes")
[ -n "$CANBUILD_CPPCHECK_TESTS" ] || CANBUILD_CPPCHECK_TESTS=yes ;;
# Some workers (presumably where several executors or separate
# Jenkins agents) are enabled randomly fail NIT tests, once in
# a hundred runs or so. This option allows isolated workers to
# proclaim they are safe places to "make check-NIT" (and we can
# see if that is true, over time).
"NUT_BUILD_CAPS=NIT=no")
[ -n "$CANBUILD_NIT_TESTS" ] || CANBUILD_NIT_TESTS=no ;;
"NUT_BUILD_CAPS=NIT"|"NUT_BUILD_CAPS=NIT=yes")
[ -n "$CANBUILD_NIT_TESTS" ] || CANBUILD_NIT_TESTS=yes ;;
"NUT_BUILD_CAPS=docs:man=no")
[ -n "$CANBUILD_DOCS_MAN" ] || CANBUILD_DOCS_MAN=no ;;
"NUT_BUILD_CAPS=docs:man"|"NUT_BUILD_CAPS=docs:man=yes")
[ -n "$CANBUILD_DOCS_MAN" ] || CANBUILD_DOCS_MAN=yes ;;
"NUT_BUILD_CAPS=docs:all=no")
[ -n "$CANBUILD_DOCS_ALL" ] || CANBUILD_DOCS_ALL=no ;;
"NUT_BUILD_CAPS=docs:all"|"NUT_BUILD_CAPS=docs:all=yes")
[ -n "$CANBUILD_DOCS_ALL" ] || CANBUILD_DOCS_ALL=yes ;;
"NUT_BUILD_CAPS=drivers:all=no")
[ -n "$CANBUILD_DRIVERS_ALL" ] || CANBUILD_DRIVERS_ALL=no ;;
"NUT_BUILD_CAPS=drivers:all"|"NUT_BUILD_CAPS=drivers:all=yes")
[ -n "$CANBUILD_DRIVERS_ALL" ] || CANBUILD_DRIVERS_ALL=yes ;;
"NUT_BUILD_CAPS=cgi=no")
[ -n "$CANBUILD_LIBGD_CGI" ] || CANBUILD_LIBGD_CGI=no ;;
"NUT_BUILD_CAPS=cgi"|"NUT_BUILD_CAPS=cgi=yes")
[ -n "$CANBUILD_LIBGD_CGI" ] || CANBUILD_LIBGD_CGI=yes ;;
# Currently for nut-scanner, might be more later - hence agnostic naming:
"NUT_BUILD_CAPS=libltdl=no")
[ -n "$CANBUILD_WITH_LIBLTDL" ] || CANBUILD_WITH_LIBLTDL=no ;;
"NUT_BUILD_CAPS=libltdl"|"NUT_BUILD_CAPS=libltdl=yes")
[ -n "$CANBUILD_WITH_LIBLTDL" ] || CANBUILD_WITH_LIBLTDL=yes ;;
esac
done
if [ -z "$CI_OS_NAME" ]; then
# Check for dynaMatrix node labels support and map into a simple
# classification styled after (compatible with) that in Travis CI
for CI_OS_HINT in \
"$OS_FAMILY-$OS_DISTRO" \
"`grep = /etc/os-release 2>/dev/null`" \
"`cat /etc/release 2>/dev/null`" \
"`uname -o 2>/dev/null`" \
"`uname -s -r -v 2>/dev/null`" \
"`uname -a`" \
"`uname`" \
; do
[ -z "$CI_OS_HINT" -o "$CI_OS_HINT" = "-" ] || break
done
case "`echo "$CI_OS_HINT" | tr 'A-Z' 'a-z'`" in
*freebsd*)
CI_OS_NAME="freebsd" ;;
*openbsd*)
CI_OS_NAME="openbsd" ;;
*netbsd*)
CI_OS_NAME="netbsd" ;;
*debian*|*ubuntu*)
CI_OS_NAME="debian" ;;
*centos*|*fedora*|*redhat*|*rhel*)
CI_OS_NAME="centos" ;;
*linux*)
CI_OS_NAME="linux" ;;
*msys2*)
CI_OS_NAME="windows-msys2" ;;
*mingw*64*)
CI_OS_NAME="windows-mingw64" ;;
*mingw*32*)
CI_OS_NAME="windows-mingw32" ;;
*windows*)
CI_OS_NAME="windows" ;;
*[Mm]ac*|*arwin*|*[Oo][Ss][Xx]*)
CI_OS_NAME="osx" ;;
*openindiana*)
CI_OS_NAME="openindiana" ;;
*omnios*)
CI_OS_NAME="omnios" ;;
*bsd*)
CI_OS_NAME="bsd" ;;
*illumos*)
CI_OS_NAME="illumos" ;;
*solaris*)
CI_OS_NAME="solaris" ;;
*sunos*)
CI_OS_NAME="sunos" ;;
"-") ;;
*) echo "WARNING: Could not recognize CI_OS_NAME from CI_OS_HINT='$CI_OS_HINT', update './ci_build.sh' if needed" >&2
if [ "$OS_FAMILY-$OS_DISTRO" != "-" ]; then
echo "WARNING: I was told that OS_FAMILY='$OS_FAMILY' and OS_DISTRO='$OS_DISTRO'" >&2
fi
;;
esac
[ -z "$CI_OS_NAME" ] || echo "INFO: Detected CI_OS_NAME='$CI_OS_NAME'" >&2
fi
# CI builds on Travis
[ -n "$CI_OS_NAME" ] || CI_OS_NAME="$TRAVIS_OS_NAME"
case "${CI_OS_NAME}" in
windows*)
# At the moment WIN32 builds are quite particular in their
# desires, for headers to declare what is needed, and yet
# there is currently not much real variation in supportable
# build environment (mingw variants). Lest we hardcode
# stuff in configure script, define some here:
case "$CFLAGS" in
*-D_POSIX=*) ;;
*) CFLAGS="$CFLAGS -D_POSIX=1" ;;
esac
case "$CFLAGS" in
*-D_POSIX_C_SOURCE=*) ;;
*) CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112L" ;;
esac
case "$CFLAGS" in
*-D_WIN32_WINNT=*) ;;
*) CFLAGS="$CFLAGS -D_WIN32_WINNT=0xffff" ;;
esac
case "$CXXFLAGS" in
*-D_POSIX=*) ;;
*) CXXFLAGS="$CXXFLAGS -D_POSIX=1" ;;
esac
case "$CXXFLAGS" in
*-D_POSIX_C_SOURCE=*) ;;
*) CXXFLAGS="$CXXFLAGS -D_POSIX_C_SOURCE=200112L" ;;
esac
case "$CXXFLAGS" in
*-D_WIN32_WINNT=*) ;;
*) CXXFLAGS="$CXXFLAGS -D_WIN32_WINNT=0xffff" ;;
esac
;;
esac
# Analyze some environmental choices
if [ -z "${CANBUILD_LIBGD_CGI-}" ]; then
# No prereq dll and headers on win so far
[[ "$CI_OS_NAME" = "windows" ]] && CANBUILD_LIBGD_CGI=no
# NUT CI farm with Jenkins can build it; Travis could not
[[ "$CI_OS_NAME" = "freebsd" ]] && CANBUILD_LIBGD_CGI=yes \
|| [[ "$TRAVIS_OS_NAME" = "freebsd" ]] && CANBUILD_LIBGD_CGI=no
# See also below for some compiler-dependent decisions
fi
if [ -z "${PKG_CONFIG-}" ]; then
# Default to using one from PATH, if any - mostly for config tuning done
# below in this script
# DO NOT "export" it here so configure script can find one for the build
PKG_CONFIG="pkg-config"
fi
# Would hold full path to the CONFIGURE_SCRIPT="${SCRIPTDIR}/${CONFIGURE_SCRIPT_FILENAME}"
CONFIGURE_SCRIPT=""
autogen_get_CONFIGURE_SCRIPT() {
# Autogen once (delete the file if some scenario ever requires to re-autogen)
if [ -n "${CONFIGURE_SCRIPT}" -a -s "${CONFIGURE_SCRIPT}" ] ; then return 0 ; fi
pushd "${SCRIPTDIR}" || exit
if [[ "$CI_OS_NAME" == "windows" ]] ; then
# Debug once
[ -n "$CONFIGURE_SCRIPT" ] || find . -ls
CONFIGURE_SCRIPT="configure.bat"
else
CONFIGURE_SCRIPT="configure"
fi
if [ ! -s "./$CONFIGURE_SCRIPT" ]; then
# Note: modern auto(re)conf requires pkg-config to generate the configure
# script, so to stage the situation of building without one (as if on an
# older system) we have to remove it when we already have the script.
# This matches the use-case of distro-building from release tarballs that
# include all needed pre-generated files to rely less on OS facilities.
if [ "$CI_OS_NAME" = "windows" ] ; then
$CI_TIME ./autogen.sh || true
else
$CI_TIME ./autogen.sh ### 2>/dev/null
fi || exit
fi
# Retain the full path to configure script file
CONFIGURE_SCRIPT="${SCRIPTDIR}/${CONFIGURE_SCRIPT}"
popd || exit
}
configure_CI_BUILDDIR() {
autogen_get_CONFIGURE_SCRIPT
if [ "${CI_BUILDDIR}" != "." ]; then
# Per above, we always start this routine in absolute $SCRIPTDIR
echo "=== Running NUT build out-of-tree in ${CI_BUILDDIR}"
mkdir -p "${CI_BUILDDIR}" && cd "${CI_BUILDDIR}" || exit
fi
}
configure_nut() {
configure_CI_BUILDDIR
# Note: maintainer-clean checks remove this, and then some systems'
# build toolchains noisily complain about missing LD path candidate
if [ -n "$BUILD_PREFIX" ]; then
# tmp/lib/
mkdir -p "$BUILD_PREFIX"/lib
fi
if [ -n "$INST_PREFIX" ]; then
# .inst/
mkdir -p "$INST_PREFIX"
fi
# Help copy-pasting build setups from CI logs to terminal:
local CONFIG_OPTS_STR="`for F in "${CONFIG_OPTS[@]}" ; do echo "'$F' " ; done`" ### | tr '\n' ' '`"
while : ; do # Note the CI_SHELL_IS_FLAKY=true support below
echo "=== CONFIGURING NUT: $CONFIGURE_SCRIPT ${CONFIG_OPTS_STR}"
echo "=== CC='$CC' CXX='$CXX' CPP='$CPP'"
[ -z "${CI_SHELL_IS_FLAKY-}" ] || echo "=== CI_SHELL_IS_FLAKY='$CI_SHELL_IS_FLAKY'"
$CI_TIME $CONFIGURE_SCRIPT "${CONFIG_OPTS[@]}" \
&& return 0 \
|| { RES_CFG=$?
echo "FAILED ($RES_CFG) to configure nut, will dump config.log in a second to help troubleshoot CI" >&2
echo " (or press Ctrl+C to abort now if running interactively)" >&2
sleep 5
echo "=========== DUMPING config.log :"
$GGREP -B 100 -A 1 'Cache variables' config.log 2>/dev/null \
|| cat config.log || true
echo "=========== END OF config.log"
if [ "${CI_SHELL_IS_FLAKY-}" = true ]; then
# Real-life story from the trenches: there are weird systems
# which fail ./configure in random spots not due to script's
# quality. Then we'd just loop here.
echo "WOULD BE FATAL: FAILED ($RES_CFG) to $CONFIGURE_SCRIPT ${CONFIG_OPTS[*]} -- but asked to loop trying" >&2
else
echo "FATAL: FAILED ($RES_CFG) to $CONFIGURE_SCRIPT ${CONFIG_OPTS[*]}" >&2
echo "If you are sure this is not a fault of scripting or config option, try" >&2
echo " CI_SHELL_IS_FLAKY=true $0"
exit $RES_CFG
fi
}
done
}
build_to_only_catch_errors_target() {
if [ $# = 0 ]; then
build_to_only_catch_errors_target all ; return $?
fi
# Sub-shells to avoid crashing with "unhandled" faults in "set -e" mode:
( echo "`date`: Starting the parallel build attempt (quietly to build what we can) for '$@' ..."; \
( case "${CI_PARMAKE_VERBOSITY}" in
silent)
# Note: stderr would still expose errors and warnings (needed for
# e.g. CI analysis of coding issues, even if not treated as fatal)
$CI_TIME $MAKE $MAKE_FLAGS_QUIET -k $PARMAKE_FLAGS "$@" >/dev/null ;;
quiet)
$CI_TIME $MAKE $MAKE_FLAGS_QUIET -k $PARMAKE_FLAGS "$@" ;;
silent)
$CI_TIME $MAKE $MAKE_FLAGS_VERBOSE -k $PARMAKE_FLAGS "$@" ;;
default)
$CI_TIME $MAKE -k $PARMAKE_FLAGS "$@" ;;
esac ) && echo "`date`: SUCCESS" ; ) || \
( echo "`date`: Starting the sequential build attempt (to list remaining files with errors considered fatal for this build configuration) for '$@'..."; \
$CI_TIME $MAKE $MAKE_FLAGS_VERBOSE "$@" -k ) || return $?
return 0
}
build_to_only_catch_errors() {
build_to_only_catch_errors_target all || return $?
if [ "${CI_SKIP_CHECK}" = true ] ; then
echo "`date`: SKIP: not starting a '$MAKE check' for quick sanity test of the products built with the current compiler and standards, because caller requested CI_SKIP_CHECK=true; plain build has just succeeded however"
return 0
fi
echo "`date`: Starting a '$MAKE check' for quick sanity test of the products built with the current compiler and standards"
$CI_TIME $MAKE $MAKE_FLAGS_QUIET check \
&& echo "`date`: SUCCESS" \
|| return $?
return 0
}
ccache_stats() {
local WHEN="$1"
[ -n "$WHEN" ] || WHEN="some time around the"
if [ "$HAVE_CCACHE" = yes ]; then
if [ -d "$CCACHE_DIR" ]; then
echo "CCache stats $WHEN build:"
ccache -s || true
else
echo "WARNING: CCache stats $WHEN build: tool is enabled, but CCACHE_DIR='$CCACHE_DIR' was not found now" >&2
fi
fi
return 0
}
check_gitignore() {
# Optional envvars from caller: FILE_DESCR FILE_REGEX FILE_GLOB
# and GIT_ARGS GIT_DIFF_SHOW
local BUILT_TARGETS="$@"
[ -n "${FILE_DESCR-}" ] || FILE_DESCR="some"
# Note: regex actually used starts with catching Git markup, so
# FILE_REGEX should not include that nor "^" line-start marker.
# We also rule out files made by CI routines and this script.
# NOTEL: In particular, we need build results of `make cppcheck`
# later, so its recipe does not clean nor care for gitignore.
[ -n "${FILE_REGEX-}" ] || FILE_REGEX='.*'
# Shell-glob filename pattern for points of interest to git status
# and git diff; note that filenames starting with a dot should be
# reported by `git status -- '*'` and not hidden.
[ -n "${FILE_GLOB-}" ] || FILE_GLOB='*'
[ -n "${GIT_ARGS-}" ] || GIT_ARGS='' # e.g. GIT_ARGS="--ignored"
# Display contents of the diff?
# (Helps copy-paste from CI logs to source to amend quickly)
[ -n "${GIT_DIFF_SHOW-}" ] || GIT_DIFF_SHOW=true
[ -n "${BUILT_TARGETS-}" ] || BUILT_TARGETS="all? (usual default)"
echo "=== Are GitIgnores good after '$MAKE $BUILT_TARGETS'? (should have no output below)"
if [ ! -e .git ]; then
echo "WARNING: Skipping the GitIgnores check after '$BUILT_TARGETS' because there is no `pwd`/.git anymore" >&2
return 0
fi
# One invocation should report to log:
git status $GIT_ARGS -s -- "${FILE_GLOB}" \
| grep -E -v '^.. \.ci.*\.log.*' \
| grep -E "${FILE_REGEX}" \
|| echo "WARNING: Could not query git repo while in `pwd`" >&2
echo "==="
# Another invocation checks that there was nothing to complain about:
if [ -n "`git status $GIT_ARGS -s "${FILE_GLOB}" | grep -E -v '^.. \.ci.*\.log.*' | grep -E "^.. ${FILE_REGEX}"`" ] \
&& [ "$CI_REQUIRE_GOOD_GITIGNORE" != false ] \
; then
echo "FATAL: There are changes in $FILE_DESCR files listed above - tracked sources should be updated in the PR (even if generated - not all builders can do so), and build products should be added to a .gitignore file, everything made should be cleaned and no tracked files should be removed!" >&2
if [ "$GIT_DIFF_SHOW" = true ]; then
PAGER=cat git diff -- "${FILE_GLOB}" || true
fi
echo "==="
return 1
fi
return 0
}
can_clean_check() {
if [ "${DO_CLEAN_CHECK-}" = "no" ] ; then
# NOTE: Not handling here particular DO_MAINTAINER_CLEAN_CHECK or DO_DIST_CLEAN_CHECK
return 1
fi
if [ -s Makefile ] && [ -e .git ] ; then
return 0
fi
return 1
}
optional_maintainer_clean_check() {
if [ ! -e .git ]; then
echo "Skipping maintainer-clean check because there is no .git" >&2
return 0
fi
if [ ! -e Makefile ]; then
echo "WARNING: Skipping maintainer-clean check because there is no Makefile (did we clean in a loop earlier?)" >&2
return 0
fi
if [ "${DO_CLEAN_CHECK-}" = "no" ] || [ "${DO_MAINTAINER_CLEAN_CHECK-}" = "no" ] ; then
echo "Skipping maintainer-clean check because recipe/developer said so"
else
[ -z "$CI_TIME" ] || echo "`date`: Starting maintainer-clean check of currently tested project..."
# Note: currently Makefile.am has just a dummy "distcleancheck" rule
$CI_TIME $MAKE DISTCHECK_FLAGS="$DISTCHECK_FLAGS" $PARMAKE_FLAGS maintainer-clean || return
GIT_ARGS="--ignored" check_gitignore "maintainer-clean" || return
fi
return 0
}
optional_dist_clean_check() {
if [ ! -e .git ]; then
echo "Skipping distclean check because there is no .git" >&2
return 0
fi
if [ ! -e Makefile ]; then
echo "WARNING: Skipping distclean check because there is no Makefile (did we clean in a loop earlier?)" >&2
return 0
fi
if [ "${DO_CLEAN_CHECK-}" = "no" ] || [ "${DO_DIST_CLEAN_CHECK-}" = "no" ] ; then
echo "Skipping distclean check because recipe/developer said so"
else
[ -z "$CI_TIME" ] || echo "`date`: Starting dist-clean check of currently tested project..."
# Note: currently Makefile.am has just a dummy "distcleancheck" rule
$CI_TIME $MAKE DISTCHECK_FLAGS="$DISTCHECK_FLAGS" $PARMAKE_FLAGS distclean || return
check_gitignore "distclean" || return
fi
return 0
}
if [ "$1" = inplace ] && [ -z "$BUILD_TYPE" ] ; then
shift
BUILD_TYPE="inplace"
fi
if [ "$1" = spellcheck ] && [ -z "$BUILD_TYPE" ] ; then
# Note: this is a little hack to reduce typing
# and scrolling in (docs) developer iterations.
if [ -z "${MAKE-}" ] ; then
if (command -v gmake) >/dev/null 2>/dev/null ; then
# GNU make processes quiet mode better, which helps with this use-case
MAKE=gmake
else
# Use system default, there should be one
MAKE=make
fi
export MAKE
fi
case "$CI_OS_NAME" in
windows-msys2)
# https://github.com/msys2/MSYS2-packages/issues/2088
echo "=========================================================================="
echo "WARNING: some MSYS2 builds of aspell are broken with 'tex' support"
echo "Are you sure you run this in a functional build environment? Ctrl+C if not"
echo "=========================================================================="
sleep 5
;;
*) if ! (command -v aspell) 2>/dev/null >/dev/null ; then
echo "=========================================================================="
echo "WARNING: Seems you do not have 'aspell' in PATH (but maybe NUT configure"
echo "script would find the spellchecking toolkit elsewhere)"
echo "Are you sure you run this in a functional build environment? Ctrl+C if not"
echo "=========================================================================="
sleep 5
fi
;;
esac >&2
if [ -s Makefile ] && [ -s docs/Makefile ]; then
echo "Processing quick and quiet spellcheck with already existing recipe files, will only report errors if any ..."
build_to_only_catch_errors_target spellcheck ; exit
else
BUILD_TYPE="default-spellcheck"
shift
fi
fi
echo "Processing BUILD_TYPE='${BUILD_TYPE}' ..."
echo "Build host settings:"
set | grep -E '^(CI_.*|OS_*|CANBUILD_.*|NODE_LABELS|MAKE|C.*FLAGS|LDFLAGS|ARCH.*|BITS.*|CC|CXX|CPP|DO_.*|BUILD_.*)=' || true
uname -a
echo "LONG_BIT:`getconf LONG_BIT` WORD_BIT:`getconf WORD_BIT`" || true
if command -v xxd >/dev/null ; then xxd -c 1 -l 6 | tail -1; else if command -v od >/dev/null; then od -N 1 -j 5 -b | head -1 ; else hexdump -s 5 -n 1 -C | head -1; fi; fi < /bin/ls 2>/dev/null | awk '($2 == 1){print "Endianness: LE"}; ($2 == 2){print "Endianness: BE"}' || true
case "$BUILD_TYPE" in
default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-spellcheck|default-shellcheck|default-nodoc|default-withdoc|default-withdoc:man|"default-tgt:"*)
LANG=C
LC_ALL=C
export LANG LC_ALL
if [ -d "./tmp/" ]; then
rm -rf ./tmp/
fi
if [ -d "./.inst/" ]; then
rm -rf ./.inst/
fi
# Pre-create locations; tmp/lib in particular to avoid (on MacOS xcode):
# ld: warning: directory not found for option '-L/Users/distiller/project/tmp/lib'
# Note that maintainer-clean checks can remove these directory trees,
# so we re-create them just in case in the configure_nut() method too.
mkdir -p tmp/lib .inst/
BUILD_PREFIX="$PWD/tmp"
INST_PREFIX="$PWD/.inst"
echo "PATH='$PATH' before possibly applying CCACHE into the mix"
( echo "$PATH" | grep ccache ) >/dev/null && echo "WARNING: ccache is already in PATH"
if [ -n "$CC" ]; then
echo "CC='$CC' before possibly applying CCACHE into the mix"
$CC --version $CFLAGS || \
$CC --version || true
fi
if [ -n "$CXX" ]; then
echo "CXX='$CXX' before possibly applying CCACHE into the mix"
$CXX --version $CXXFLAGS || \
$CXX --version || true
fi
if [ x"${CI_CCACHE_USE-}" = xno ]; then
HAVE_CCACHE=no
CI_CCACHE_SYMLINKDIR=""
echo "WARNING: Caller required to not use ccache even if available" >&2
else
if [ -n "${CI_CCACHE_SYMLINKDIR}" ]; then
# Tell ccache the PATH without itself in it, to avoid loops processing
PATH="`echo "$PATH" | sed -e 's,^'"${CI_CCACHE_SYMLINKDIR}"'/?:,,' -e 's,:'"${CI_CCACHE_SYMLINKDIR}"'/?:,,' -e 's,:'"${CI_CCACHE_SYMLINKDIR}"'/?$,,' -e 's,^'"${CI_CCACHE_SYMLINKDIR}"'/?$,,'`"
fi
CCACHE_PATH="$PATH"
CCACHE_DIR="${HOME}/.ccache"
export CCACHE_PATH CCACHE_DIR PATH
HAVE_CCACHE=no
if (command -v ccache || which ccache) \
&& ( [ -z "${CI_CCACHE_SYMLINKDIR}" ] || ls -la "${CI_CCACHE_SYMLINKDIR}" ) \
; then
HAVE_CCACHE=yes
fi
mkdir -p "${CCACHE_DIR}"/ || HAVE_CCACHE=no
fi
ccache_stats "before"
CONFIG_OPTS=()
COMMON_CFLAGS=""
EXTRA_CFLAGS=""
EXTRA_CPPFLAGS=""
EXTRA_CXXFLAGS=""
is_gnucc() {
if [ -n "$1" ] && LANG=C "$1" --version 2>&1 | grep 'Free Software Foundation' > /dev/null ; then true ; else false ; fi
}
is_clang() {
if [ -n "$1" ] && LANG=C "$1" --version 2>&1 | grep 'clang version' > /dev/null ; then true ; else false ; fi
}
filter_version() {
# Starting with number like "6.0.0" or "7.5.0-il-0" is fair game,
# but a "gcc-4.4.4-il-4" (starting with "gcc") is not
sed -e 's,^.* \([0-9][0-9]*\.[0-9][^ ),]*\).*$,\1,' -e 's, .*$,,' | grep -E '^[0-9]' | head -1
}
ver_gnucc() {
[ -n "$1" ] && LANG=C "$1" --version 2>&1 | grep -i gcc | filter_version
}
ver_clang() {
[ -n "$1" ] && LANG=C "$1" --version 2>&1 | grep -i 'clang' | filter_version
}
COMPILER_FAMILY=""
if [ -n "$CC" -a -n "$CXX" ]; then
if is_gnucc "$CC" && is_gnucc "$CXX" ; then
COMPILER_FAMILY="GCC"
export CC CXX
elif is_clang "$CC" && is_clang "$CXX" ; then
COMPILER_FAMILY="CLANG"
export CC CXX
fi
else
# Generally we prefer GCC unless it is very old so we can't impact
# its warnings and complaints.
if is_gnucc "gcc" && is_gnucc "g++" ; then
# Autoconf would pick this by default
COMPILER_FAMILY="GCC"
[ -n "$CC" ] || CC=gcc
[ -n "$CXX" ] || CXX=g++
export CC CXX
elif is_gnucc "cc" && is_gnucc "c++" ; then
COMPILER_FAMILY="GCC"
[ -n "$CC" ] || CC=cc
[ -n "$CXX" ] || CXX=c++
export CC CXX
fi
if ( [ "$COMPILER_FAMILY" = "GCC" ] && \
case "`ver_gnucc "$CC"`" in
[123].*) true ;;
4.[0123][.,-]*) true ;;
4.[0123]) true ;;
*) false ;;
esac && \
case "`ver_gnucc "$CXX"`" in
[123].*) true ;;
4.[0123][.,-]*) true ;;
4.[0123]) true ;;
*) false ;;
esac
) ; then
echo "NOTE: default GCC here is very old, do we have a CLANG instead?.." >&2
COMPILER_FAMILY="GCC_OLD"
fi
if [ -z "$COMPILER_FAMILY" ] || [ "$COMPILER_FAMILY" = "GCC_OLD" ]; then
if is_clang "clang" && is_clang "clang++" ; then
# Autoconf would pick this by default
[ "$COMPILER_FAMILY" = "GCC_OLD" ] && CC="" && CXX=""
COMPILER_FAMILY="CLANG"
[ -n "$CC" ] || CC=clang
[ -n "$CXX" ] || CXX=clang++
export CC CXX
elif is_clang "cc" && is_clang "c++" ; then
[ "$COMPILER_FAMILY" = "GCC_OLD" ] && CC="" && CXX=""
COMPILER_FAMILY="CLANG"
[ -n "$CC" ] || CC=cc
[ -n "$CXX" ] || CXX=c++
export CC CXX
fi
fi
if [ "$COMPILER_FAMILY" = "GCC_OLD" ]; then
COMPILER_FAMILY="GCC"
fi
fi
if [ -n "$CPP" ] ; then
# Note: can be a multi-token name like "clang -E" or just not a full pathname
( [ -x "$CPP" ] || $CPP --help >/dev/null 2>/dev/null ) && export CPP
else
if is_gnucc "cpp" ; then
CPP=cpp && export CPP
else
case "$COMPILER_FAMILY" in
CLANG*|GCC*) CPP="$CC -E" && export CPP ;;
esac
fi
fi
if [ -z "${CANBUILD_LIBGD_CGI-}" ]; then
if [[ "$CI_OS_NAME" = "openindiana" ]] ; then
# For some reason, here gcc-4.x (4.4.4, 4.9) have a problem with
# configure-time checks of libgd; newer compilers fare okay.
# Feel free to revise this if the distro packages are fixed
# (or the way configure script and further build uses them).
# UPDATE: Per https://github.com/networkupstools/nut/pull/1089
# This is a systems issue (in current OpenIndiana 2021.04 built
# with a newer GCC version, the older GCC is not ABI compatible
# with the libgd shared object file). Maybe this warrants later
# caring about not just the CI_OS_NAME but also CI_OS_RELEASE...
if [[ "$COMPILER_FAMILY" = "GCC" ]]; then
case "`LANG=C $CC --version | head -1`" in
*[\ -][01234].*)
echo "WARNING: Seems we are running with gcc-4.x or older on $CI_OS_NAME, which last had known issues with libgd; disabling CGI for this build"
CANBUILD_LIBGD_CGI=no
;;
esac
fi
fi
fi
# Note: Potentially there can be spaces in entries for multiple
# *FLAGS here; this should be okay as long as entry expands to
# one token when calling shell (may not be the case for distcheck)
CONFIG_OPTS+=("CFLAGS=-I${BUILD_PREFIX}/include ${CFLAGS}")
CONFIG_OPTS+=("CPPFLAGS=-I${BUILD_PREFIX}/include ${CPPFLAGS}")
CONFIG_OPTS+=("CXXFLAGS=-I${BUILD_PREFIX}/include ${CXXFLAGS}")
CONFIG_OPTS+=("LDFLAGS=-L${BUILD_PREFIX}/lib ${LDFLAGS}")
DEFAULT_PKG_CONFIG_PATH="${BUILD_PREFIX}/lib/pkgconfig"
SYSPKG_CONFIG_PATH="" # Let the OS guess... usually
case "`echo "$CI_OS_NAME" | tr 'A-Z' 'a-z'`" in
*openindiana*|*omnios*|*solaris*|*illumos*|*sunos*)
case "$CC$CXX$CFLAGS$CXXFLAGS$LDFLAGS" in
*-m64*)
SYS_PKG_CONFIG_PATH="/usr/lib/64/pkgconfig:/usr/lib/amd64/pkgconfig:/usr/lib/sparcv9/pkgconfig:/usr/lib/pkgconfig"
;;
*-m32*)
SYS_PKG_CONFIG_PATH="/usr/lib/32/pkgconfig:/usr/lib/pkgconfig:/usr/lib/i86pc/pkgconfig:/usr/lib/i386/pkgconfig:/usr/lib/sparcv7/pkgconfig"
;;
*)
case "$ARCH$BITS" in
*64*)
SYS_PKG_CONFIG_PATH="/usr/lib/64/pkgconfig:/usr/lib/amd64/pkgconfig:/usr/lib/sparcv9/pkgconfig:/usr/lib/pkgconfig"
;;
*32*)
SYS_PKG_CONFIG_PATH="/usr/lib/32/pkgconfig:/usr/lib/pkgconfig:/usr/lib/i86pc/pkgconfig:/usr/lib/i386/pkgconfig:/usr/lib/sparcv7/pkgconfig"
;;
esac
;;
esac
;;
esac
if [ -n "$SYS_PKG_CONFIG_PATH" ] ; then
if [ -n "$PKG_CONFIG_PATH" ] ; then
PKG_CONFIG_PATH="$SYS_PKG_CONFIG_PATH:$PKG_CONFIG_PATH"
else
PKG_CONFIG_PATH="$SYS_PKG_CONFIG_PATH"
fi
fi
if [ -n "$PKG_CONFIG_PATH" ] ; then
CONFIG_OPTS+=("PKG_CONFIG_PATH=${DEFAULT_PKG_CONFIG_PATH}:${PKG_CONFIG_PATH}")
else
CONFIG_OPTS+=("PKG_CONFIG_PATH=${DEFAULT_PKG_CONFIG_PATH}")
fi
CONFIG_OPTS+=("--enable-keep_nut_report_feature")
CONFIG_OPTS+=("--prefix=${BUILD_PREFIX}")
CONFIG_OPTS+=("--sysconfdir=${BUILD_PREFIX}/etc/nut")
CONFIG_OPTS+=("--with-udev-dir=${BUILD_PREFIX}/etc/udev")
CONFIG_OPTS+=("--with-devd-dir=${BUILD_PREFIX}/etc/devd")
CONFIG_OPTS+=("--with-hotplug-dir=${BUILD_PREFIX}/etc/hotplug")
if [ x"${INPLACE_RUNTIME-}" = xtrue ]; then
CONFIG_OPTS+=("--enable-inplace-runtime")
fi
# TODO: Consider `--enable-maintainer-mode` to add recipes that
# would quickly regenerate Makefile(.in) if you edit Makefile.am
# TODO: Resolve port-collision reliably (for multi-executor agents)
# and enable the test for CI runs. Bonus for making it quieter.
if [ "${CANBUILD_NIT_TESTS-}" != yes ] ; then
CONFIG_OPTS+=("--enable-check-NIT")
else
echo "WARNING: Build agent does not say it can reliably 'make check-NIT'" >&2
CONFIG_OPTS+=("--disable-check-NIT")
fi
if [ -n "${PYTHON-}" ]; then
# WARNING: Watch out for whitespaces, not handled here!
CONFIG_OPTS+=("--with-python=${PYTHON}")
fi
# Even in scenarios that request --with-all, we do not want
# to choke on absence of desktop-related modules in Python.
# Just make sure relevant install recipes are tested:
CONFIG_OPTS+=("--with-nut_monitor=force")