forked from arminbiere/kissat
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure
executable file
·696 lines (595 loc) · 18.8 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
#!/bin/sh
asan=no
check=unknown
check_all=no
check_heap=no
check_kitten=no
check_queue=no
check_vectors=no
check_walk=no
compact=no
coverage=no
debug=no
default=no
extreme=no
embedded=unknown
kitten=unknown
logging=unknown
metrics=unknown
m32=no
options=yes
optimize=unknown
pedantic=unknown
pic=no
profile=no
proofs=yes
quiet=no
sat=no
shared=no
static=no
statistics=unknown
symbols=unknown
testdefault=unknown
ultimate=no
unsat=no
passtocompiler=""
passtolinker=""
goals="libkissat.a kissat"
usage () {
cat <<EOF
usage: configure [ <option> ... ]
where <option> is one of the following
EOF
if [ "$1" = complete ]
then
cat <<EOF
-h print only a list of common command line options
--help print this complete list of all command line options
EOF
else
cat <<EOF
-h print this list of common command line options
--help print a complete list of all command line options
EOF
fi
cat <<EOF
-c include assertion checking code (default for '-g')
-g compile for testing and debugging (implies '-c', '-s', '-l')
-l include logging code (default for '-g', needs run-time enabling too)
-p pedantic compilation ('-Werror -std=c99 --pedantic')
-s add symbols (default for '-g')
EOF
if [ ! "$1" = complete ]
then
cat << EOF
For a complete list of command line options try '--help'.
EOF
exit 0
fi
cat << EOF
Options used to instrument the code for coverage and performance profiling.
--coverage include line coverage code (to be used with 'gcov')
--profile include profiling code (to be used with 'gprof')
For coverage testing it might be useful to enforce different compiler
optimization levels, i.e., lower than the default '-O3' (without '-g').
-O[0|1|2|3] set the optimization level of the compiler explicitly
We have compile time options which save memory and speed up the solver by
limiting the size of formulas that can be handled, fix the default
configuration, disable messages, profiling and certain statistics.
--compact limit watcher stacks and clause arena size
--no-options fix all solver options to their default value
--quiet disable messages, built-in profiling and metrics
--competition same as '--no-options --quiet' (competition configuration)
--extreme same as '--compact --no-options --quiet'
--no-proofs do not include code for proof generation
--ultimate all configurations above ('--extreme --no-proofs')
For '--no-options' (and '--extreme', '--ultimate', and '--competition' too)
we allow the following options which enforce a different option at compile
time (corresponding to the same run-time settings without '--no-options'):
--default do not enforce specialized option configurations
--sat force options to focus on satisfiable instance
--unsat force options to focus on unsatisfiable instance
Redundant metrics and statistics gathering code can be enabled and disabled
separately. Only essential counters are updated and printed without these.
Metrics are considered to be statistics, thus '--metrics' also implies
'--statistics' and vice versa '--no-statistics' implies '--no-metrics.
--metrics include metrics code (default with '-g', '-l')
--no-metrics no metrics code (default with '--quiet' etc.)
--statistics include statistics code (default without '--extreme')
--no-statistics no statistics code (default with '--extreme')
For (delta) debugging and testing the parser can read options embedded
in DIMACS files. This feature is enabled for '-c', '-g', and '-l' but
disabled for optimized compilation (without '-c', '-g', nor '-l'),
except that '--embedded' is also assumed with '--coverage' unless options
are disabled (with '--no-options', '--extreme' or '--no-options').
--embedded | -e allow parsing option value pairs in DIMACS file
--no-embedded disable parsing option value pairs in DIMACS file
The default goal of the generated 'makefile' only builds the library
'libkissat.a' and the stand alone SAT solver 'kissat'. The test program
'tissat' is only compiled on demand (with 'make test'), unless '-g',
'--coverage' or '--embedded' is specified. To force compilation of
'tissat' by default use the following:
--test compile test program by default (default with '-g')
--no-test do not compile test program (default without '-g')
The sub-solver 'kitten' used for extracting definitions has a stand-alone
mode and for testing purposes can be compiled into a 'kitten' binary.
--kitten generate 'kitten' binary too (default with '-g')
--no-kitten do not generate 'kitten' binary (default without '-g')
Enable (very) expensive low-level checkers for data structures:
--check-all check consistency of all data structures
--check-heap check consistency of binary heaps
--check-kitten check consistencies in 'Kitten' sub-solver
--check-queue check consistency of the variable-move-to-front queue
--check-vectors check consistency of watch vectors
--check-walk check consistency of local search
Enabling any of these enforces assertion and online proof checking ('-c').
We also allow an explicit choice of the C compiler.
CC=<compiler> default is 'gcc' (and we regularly test with 'CC=clang')
The following options are for convenience and in essence just passed through
to the makefile and thus the compiler to avoid editing the makefile. However,
for '-m32' the configure script checks that it can actually really do 32-bit
builds. Furthermore, in case of '-fsanitize=address' the macro '-DASAN' is
defined, such that some tests incompatible with ASAN can be omitted.
-m32 add '-m32' option to compile for 32-bit
-f... add '-f...' options,('-fsanitize=address', '-fpic' ...)
-static add '-static' linking flag
-shared add '-fpic' compilation flag and produce shared library
The default configuration builds optimized code with 'gcc' without symbols,
an no checking, metrics, embedded options parsing nor logging code included.
EOF
exit 0
}
msg () {
echo "configure: $*"
}
if [ -t 1 ]
then
BOLD="\033[1m"
NORMAL="\033[0m"
RED="\033[1;31m"
else
BOLD=""
NORMAL=""
RED=""
fi
die () {
echo "${BOLD}configure: ${RED}error:${NORMAL} $*" 1>&2
exit 1
}
[ $# = 0 ] && \
msg "default configuration (see '-h')"
while [ $# -gt 0 ]
do
case "$1" in
-h) usage;;
--help) usage complete;;
-p) pedantic=yes;;
-c) check=yes;;
-g) debug=yes;;
-l) logging=yes;;
-s) symbols=yes;;
--coverage) coverage=yes;;
--profile) profile=yes;;
-O0) optimize=0;;
-O1) optimize=1;;
-O2) optimize=2;;
-O3) optimize=3;;
--compact) compact=yes;;
--no-options) options=no;;
--quiet) quiet=yes;;
--extreme) extreme=yes;;
--competition) options=no; quiet=yes;;
--default) default=yes;;
--sat) sat=yes;;
--unsat) unsat=yes;;
--no-proofs) proofs=no;;
--ultimate) ultimate=yes;;
--metrics)
[ $metrics = no ] && \
die "can not combine '--metrics' and '--no-metrics'"
metrics=yes
;;
--no-metrics)
[ $metrics = yes ] && \
die "can not combine '--metrics' and '--no-metrics'"
metrics=no
;;
--stats | --statistics)
[ $statistics = no ] && \
die "can not combine '--statistics' and '--no-statistics'"
statistics=yes
;;
--no-stats | --no-statistics)
[ $statistics = yes ] && \
die "can not combine '--statistics' and '--no-statistics'"
statistics=no
;;
-e|--embedded) embedded=yes;;
--no-embedded) embedded=no;;
-m32) m32=yes;;
-static|--static) static=yes;;
-shared|--shared) shared=yes;;
-fpic|-fPIC) passtocompiler="$passtocompiler $1"; pic=yes;;
-f*)
[ x"`echo $1|grep fsanitize=.*address`" = x ] || asan=yes
passtolinker="$passtolinker $1"
passtocompiler="$passtocompiler $1"
;;
--test|-tests|--tests) testdefault=yes;;
--no-test|--no-tests) testdefault=no;;
--kitten) kitten=yes;;
--no-kitten) kitten=no;;
--check-all) check_all=yes;;
--check-heap) check_heap=yes;;
--check-kitten) check_kitten=yes;;
--check-queue) check_queue=yes;;
--check-vectors) check_vectors=yes;;
--check-walk) check_walk=yes;;
CC=*) CC="`echo \"$1\"|sed -e s,^CC=,,`";;
*) die "invalid option '$1' (try '-h')";;
esac
shift
done
dir="`pwd|sed -e 's,.*/,,'`"
if [ -d src -a -f VERSION ]
then
BUILD=build
elif [ -f kissat.h -o x"$dir" = xtest -o x"$dir" = xscripts ]
then
BUILD=../build/
elif [ -d ../src -a -f ../VERSION ]
then
BUILD=../"`pwd|sed -e 's,.*/,,'`"
else
die "could not find 'src' nor 'VERSION' in current nor parent directory"
fi
if [ -d "$BUILD" ]
then
msg "reusing existing build directory '$BUILD'"
else
mkdir "$BUILD" || exit 1
msg "new build directory '$BUILD'"
fi
cd "$BUILD" || exit 1
BUILD="`pwd`"
ROOT="`pwd|sed -e 's,/[^/]*$,,'`"
cat <<EOF >../makefile
all:
\$(MAKE) -C "$BUILD"
kissat:
\$(MAKE) -C "$BUILD" kissat
tissat:
\$(MAKE) -C "$BUILD" tissat
clean:
rm -f "$ROOT"/makefile
-\$(MAKE) -C "$BUILD" clean
rm -rf "$BUILD"
coverage:
\$(MAKE) -C "$BUILD" coverage
indent:
\$(MAKE) -C "$BUILD" indent
test:
\$(MAKE) -C "$BUILD" test
.PHONY: all clean coverage indent kissat test tissat
EOF
[ $statistics = no -a $metrics = yes ] && \
die "can not combine '--no-statistics' and '--metrics'"
[ $statistics = yes -a $metrics = yes ] && \
die "redundant combination '--statistics' and '--metrics'"
[ $statistics = no -a $metrics = no ] && \
die "redundant combination '--no-statistics' and '--no-metrics'"
[ $statistics = yes -a $metrics = yes ] && \
die "redundant combination '--statistics' and '--metrics'"
[ $shared = yes -a $static = yes ] && \
die "can not combine '--static' and '--shared'"
if [ $debug = yes ]
then
[ $check = yes ] && die "can not combine '-g' and '-c'"
[ $logging = yes ] && die "can not combine '-g' and '-l'"
[ $symbols = yes ] && die "can not combine '-g' and '-s'"
[ $metrics = yes ] && "can not combine '-g' and '--metrics'"
[ $statistics = yes ] && "can not combine '-g' and '--statistics'"
fi
if [ $quiet = yes ]
then
[ $logging = yes ] && die "can not combine '--quiet' and '-l'"
[ $metrics = no ] && "can not combine '--quiet' and '--no-metrics'"
[ $statistics = no ] && "can not combine '--quiet' and '--no-statistics'"
fi
if [ $extreme = yes ]
then
[ $compact = yes ] && die "can not combine '--extreme' and '--compact'"
[ $embedded = yes ] && die "can not combine '--extreme' and '--embedded'"
[ $logging = yes ] && die "can not combine '--extreme' and '-l'"
[ $options = no ] && die "can not combine '--extreme' and '--no-options'"
[ $quiet = yes ] && die "can not combine '--extreme' and '--quiet'"
[ $ultimate = yes ] && die "can not combine '--extreme' and '--ultimate'"
[ $metrics = no ] && "can not combine '--extreme' and '--no-metrics'"
[ $statistics = no ] && "can not combine '--extreme' and '--no-statistics'"
compact=yes
options=no
quiet=yes
fi
if [ $ultimate = yes ]
then
[ $compact = yes ] && die "can not combine '--ultimate' and '--compact'"
[ $embedded = yes ] && die "can not combine '--ultimate' and '--embedded'"
[ $logging = yes ] && die "can not combine '--ultimate' and '-l'"
[ $options = no ] && die "can not combine '--ultimate' and '--no-options'"
[ $proofs = no ] && die "can not combine '--ultimate' and '--no-proofs'"
[ $quiet = yes ] && die "can not combine '--ultimate' and '--quiet'"
[ $metrics = no ] && "can not combine '--ultimate' and '--no-metrics'"
[ $statistics = no ] && "can not combine '--ultimate' and '--no-statistics'"
compact=yes
options=no
proofs=no
quiet=yes
fi
[ $default = yes -a $sat = yes ] && \
die "can not combine '--default' and '--sat'"
[ $default = yes -a $unsat = yes ] && \
die "can not combine '--default' and '--unsat'"
[ $sat = yes -a $unsat = yes ] && die "can not combine '--sat' and '--unsat'"
[ $default = yes -a $options = yes ] && \
die "can not use '--default' without '--no-options'"
[ $sat = yes -a $options = yes ] && \
die "can not use '--sat' without '--no-options'"
[ $unsat = yes -a $options = yes ] && \
die "can not use '--unsat' without '--no-options'"
if [ $options = no ]
then
[ $embedded = yes ] && die "can not combine '--no-options' and '--embedded'"
fi
if [ $metrics = unknown ]
then
if [ $statistics = no ]
then
metrics=no
elif [ $debug = yes -o $logging = yes ]
then
metrics=yes
else
metrics=no
fi
elif [ $metrics = yes ]
then
[ $logging = yes ] && die "can not combine '--metrics' and '-l'"
else
[ $debug = no -a $logging = no ] && \
die "can not use '--no-metrics' without '-g' nor '-l'"
fi
if [ $statistics = unknown ]
then
if [ $metrics = yes -o $debug = yes -o $logging = yes ]
then
statistics=yes
else
statistics=no
fi
elif [ $statistics = yes -a $logging = yes ]
then
die "can not combine '--metrics' and '-l'"
fi
if [ $check_all = yes ]
then
check_heap=yes
check_kitten=yes
check_queue=yes
check_vectors=yes
check_walk=yes
fi
[ $check_heap = yes ] && check=yes
[ $check_kitten = yes ] && check=yes
[ $check_queue = yes ] && check=yes
[ $check_vectors = yes ] && check=yes
[ $check_walk = yes ] && check=yes
if [ $embedded = unknown ]
then
if [ $options = no ]
then
embedded=no
elif [ $check = yes -o $debug = yes -o $logging = yes -o $coverage = yes ]
then
embedded=yes
else
embedded=no
fi
elif [ $embedded = yes ]
then
[ $check = yes ] && die "can not combine '--embedded' and '-c'"
[ $debug = yes ] && die "can not combine '--embedded' and '-g'"
[ $logging = yes ] && die "can not combine '--embedded' and '-l'"
elif [ $check = no -a $debug = no -a $logging = no ]
then
die "can not use '--no-embedded' without '-c', '-g', nor '-l'"
fi
[ $quiet = yes ] && logging=no
[ $symbols = unknown ] && symbols=$debug
[ $logging = unknown ] && logging=$debug
[ $check = unknown ] && check=$debug
[ "$CC" = "" ] && CC=gcc
if [ $m32 = yes ]
then
passtolinker="$passtolinker -m32"
passtocompiler="$passtocompiler -m32"
cat <<EOF > m32.c
#include <stdio.h>
int main (void) {
printf ("%zu\n", sizeof (void*));
return 0;
}
EOF
if $CC -m32 -o m32 m32.c 1>/dev/null 2>/dev/null
then
res="`./m32 2>/dev/null`"
if [ "$res" = 4 ]
then
msg "compilation with '-m32' leads to pointer size of '$res' bytes"
else
die "'$BUILD/m32' determines pointer size of '$res' bytes"
fi
else
die "32-bit compilation '$CC -m32 $BUILD/m32.c' failed (install 'g++-multilib' before using '-m32' option)"
fi
fi
CFLAGS=""
case "$CC" in
gcc*|*-gcc|clang*)
CFLAGS="$CFLAGS -W -Wall"
[ $pedantic = yes ] && \
CFLAGS="$CFLAGS -Werror -std=c99 --pedantic"
if [ $optimize = unknown ]
then
[ $debug = no ] && CFLAGS="$CFLAGS -O3"
else
CFLAGS="$CFLAGS -O$optimize"
fi
[ $symbols = yes ] && CFLAGS="$CFLAGS -ggdb3"
if [ $profile = yes ]
then
CFLAGS="$CFLAGS -pg"
passtolinker="$passtolinker -pg"
fi
if [ $coverage = yes ]
then
passtocompiler="$passtocompiler -ftest-coverage -fprofile-arcs"
passtolinker="$passtolinker -ftest-coverage -fprofile-arcs"
fi
;;
*)
CFLAGS="$CFLAGS -W"
if [ $optimize = unknown ]
then
[ $debug = no ] && CFLAGS="$CFLAGS -O"
else
CFLAGS="$CFLAGS -O$optimize"
fi
[ $symbols = yes ] && CFLAGS="$CFLAGS -g"
if [ $profile = yes ]
then
CFLAGS="$CFLAGS -p"
passtolinker="$passtolinker -p"
fi
;;
esac
case x"$CC" in
x*gcc*)
gccversion="`$CC --version|head -1|awk '{print \$NF}'`"
case x"$gccversion" in
x4*)
msg "GCC version $gccversion requires '-std=c99'"
CFLAGS="$CFLAGS -std=c99"
;;
*)
msg "assuming GCC version $gccversion uses C99 by default"
;;
esac
;;
esac
[ $shared = yes -a $pic = no ] && passtocompiler="$passtocompiler -fpic"
[ $asan = yes ] && CFLAGS="$CFLAGS -DASAN"
[ $check_heap = yes ] && CFLAGS="$CFLAGS -DCHECK_HEAP"
[ $check_kitten = yes ] && CFLAGS="$CFLAGS -DCHECK_KITTEN"
[ $check_queue = yes ] && CFLAGS="$CFLAGS -DCHECK_QUEUE"
[ $check_vectors = yes ] && CFLAGS="$CFLAGS -DCHECK_VECTORS"
[ $check_walk = yes ] && CFLAGS="$CFLAGS -DCHECK_WALK"
[ $compact = yes ] && CFLAGS="$CFLAGS -DCOMPACT"
if [ $coverage = yes ]
then
case "$CC" in
gcc*) CFLAGS="$CFLAGS -DCOVERAGE"
esac
fi
[ $embedded = yes ] && CFLAGS="$CFLAGS -DEMBEDDED"
[ $quiet = no -a $logging = yes ] && CFLAGS="$CFLAGS -DLOGGING"
[ $check = no ] && CFLAGS="$CFLAGS -DNDEBUG"
[ $metrics = yes ] && CFLAGS="$CFLAGS -DMETRICS"
[ $options = no ] && CFLAGS="$CFLAGS -DNOPTIONS"
[ $proofs = no ] && CFLAGS="$CFLAGS -DNPROOFS"
[ $quiet = yes ] && CFLAGS="$CFLAGS -DQUIET"
[ $sat = yes ] && CFLAGS="$CFLAGS -DSAT"
[ $statistics = yes -a $metrics = no ] && CFLAGS="$CFLAGS -DSTATISTICS"
[ $unsat = yes ] && CFLAGS="$CFLAGS -DUNSAT"
CFLAGS="${CFLAGS}$passtocompiler"
msg "compiler '$CC $CFLAGS'"
[ $static = yes ] && passtolinker="$passtolinker -static"
if [ "$passtolinker" = "" ]
then
LD="${CC}"
msg "linker '$LD' (no additional options)"
else
LD="${CC}$passtolinker"
msg "linker '$LD' (additional options)"
fi
case "$CC" in
*-linux-gnu-gcc)
architecture="`echo $CC|sed -e 's,\(.*\)-linux-gnu-gcc,\1,'`"
AR="${architecture}-linux-gnu-ar"
msg "cross compilation for '$architecture' (using '$AR')"
;;
*)
AR="ar"
msg "using default 'ar' (no cross compilation)"
;;
esac
if [ $testdefault = unknown ]
then
if [ $coverage = yes -o $embedded = yes ]
then
testdefault=yes
else
testdefault=$debug
fi
fi
testgoal="tissat"
if [ $testdefault = yes ]
then
msg "adding '$testgoal' goal to default makefile goal too"
goals="$goals $testgoal"
else
msg "no '$testgoal' binary generated (without '--test')"
fi
sharedlibrary="libkissat.so"
if [ $shared = yes ]
then
msg "adding '$sharedlibrary' shared library to default makefile goal too"
goals="$goals $sharedlibrary"
else
if [ -f $sharedlibrary ]
then
msg "removing stale dynamic library '$sharedlibrary' (without '-shared')"
rm -f $sharedlibrary || exit 1
fi
msg "no '$sharedlibrary' shared library generated (without '-shared')"
fi
[ $kitten = unknown ] && kitten=$debug
kittengoal="kitten"
if [ $kitten = yes ]
then
msg "adding '$kittengoal' binary to default makefile goal too"
goals="$goals $kittengoal"
KITTEN=" -DKITTEN"
else
if [ -f $kittengoal ]
then
msg "removing stale '$kittengoal' binary (without '--kitten')"
rm -f $kittengoal || exit 1
fi
msg "no '$kittengoal' binary generated (without '--kitten')"
KITTEN=""
fi
rm -f makefile
sed \
-e "s#@CC@#$CC$CFLAGS#" \
-e "s#@KITTEN@#$KITTEN#" \
-e "s#@LD@#$LD#" \
-e "s#@AR@#$AR#" \
-e "s#@GOALS@#$goals#" \
../makefile.in > makefile
if [ -f ../src/makefile ]
then
msg "removing src/makefile"
rm -f ../src/makefile
fi
msg "linking src/makefile"
ln -s $ROOT/makefile ../src