-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·636 lines (570 loc) · 16.9 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
#!/bin/sh
# Configure script for varlpenis
# Seth Price - updated 31 Oct 2022
###########################################################
# VARIABLE INITIALISATION
# Package information
pkg_name="varlpenis"
pkg_version="3.0.3-dev"
# Error-reporting shenanigans
log_w="warning"
log_e="ERROR"
# Default compile/build paths
default_srcdir="./src"
default_docdir="./doc"
# Default installation paths
# (`${PREFIX}' expands within the Makefile)
default_prefix="/usr/local"
default_bindir="\${PREFIX}/bin"
default_datadir="\${PREFIX}/share"
default_localedir="\${DATADIR}/locale"
default_mandir="\${DATADIR}/man"
# Default programs
default_cc="cc"
default_ld="ld"
default_rm="rm -r"
# Default program arguments
default_CFLAGS="-DVP_PROGRAM_NAME=\${PACKAGE_NAME} -DVP_VERSION_STR=\${PACKAGE_VERSION}"
default_LDFLAGS=""
# Script variables
helpme="no"
is_verbose="no"
is_quiet="no"
is_permissive="no"
ifndef_guards="yes"
use_lintl="yes"
# Default feature values
use_color="unset" #deprecated
use_color_ansi="no"
use_color_conio="no"
use_color_woe32="no"
use_fullwidth="no"
use_gettext="no"
use_sysexits="no"
use_posixtime="no"
# Check whether shell/system `echo' supports flags
if test "`echo -n`" = "-n"; then
n=""
else
# $n expands to this in `echo $n`, removing the newline
n="-n"
fi
###########################################################
# PARSE OPTIONS
# Check for this first so that it can apply to arguments
# which came before it on the command line
for arg in "$@"; do
case $arg in
--ignore-invalid-arguments)
is_permissive="yes"
;;
esac
done
# The `us_' variables are left undefined unless specified as options
for arg in "$@"; do
case $arg in
--bindir=*)
us_bindir=`echo "$arg" | sed 's/--bindir=//'`
;;
--datadir=*)
us_datadir=`echo "$arg" | sed 's/--datadir=//'`
;;
--help | -help | -h | --h)
helpme="yes"
;;
--localedir=*)
us_localedir=`echo "$arg" | sed 's/--localedir=//'`
;;
--mandir=*)
us_mandir=`echo "$arg" | sed 's/--mandir=//'`
;;
--no-ifndef-guards)
ifndef_guards="no"
;;
--prefix=*)
us_prefix=`echo "$arg" | sed 's/--prefix=//'`
;;
--quiet | -q)
is_quiet="yes"
;;
--srcdir=*)
us_srcdir=`echo "$arg" | sed 's/--srcdir=//'`
;;
--use-*)
feature=`echo "$arg" | sed 's/--use-//; s/[-.]/_/'`
# If the feature variable isn't already initialised to
# a default value up above, it (probably) doesn't exist
if eval test -n \"\$use_$feature\"; then
eval use_$feature="yes"
else
echo "$log_e: Unrecognised feature \`$feature'. Type \`$0 --help' for help." >&2
exit 1
fi
;;
--verbose | -v)
is_verbose="yes"
;;
-*)
if test "$is_permissive" = "no"; then
echo "$log_e: Unrecognised option \`$arg'. Type \`$0 --help' for help." >&2
exit 1
fi
;;
*)
if test "$is_permissive" = "no"; then
echo "$log_e: Stray argument \`$arg'. Type \`$0 --help' for help." >&2
exit 1
fi
;;
esac
done
if test "$helpme" = "yes"; then
cat <<EOF
Configure script for varlpenis, copyright 2019, 2022 Seth Price
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g. CC, CFLAGS), specify them with
\`VAR=VALUE'. See below for descriptions of some useful variables.
Script configuration:
-h, --help Display this message and exit
-q, --quiet Do not print \'Checking...' messages
-v, --verbose Be verbose in saying what's going on
--srcdir=DIR Find the source files in directory DIR
Installation directories:
--prefix=DIR Normal prefix [$default_prefix]
--bindir=DIR User executables [$default_bindir]
--datadir=DIR Read-only program data [$default_datadir]
--localedir=DIR Message translations (if using) [$default_localedir]
--mandir=DIR UNIX manpage documentation [$default_mandir]
--no-ifndef-guards Ignore environment variables for installation dirs
Optional features (using --use-FEATURE [all are off by default]):
color-ansi Enable colour support using ANSI escape codes
color-conio " " " " DOS \`textcolor()'
color-woe32 " " " " the Windows Console API
fullwidth Enable fullwidth (CJK) character output using UTF-8
gettext Enable message translations using gettext
posixtime Use higher-resolution time for better random numbers
sysexits Exit with values from system's \`sysexits.h'
Environment variables:
CC C compiler command [ auto-detected ]
CFLAGS C compiler flags [$default_CFLAGS]
LDFLAGS Linker flags, e.g. -L<lib dir> if you have libraries
in a non-standard directory <lib dir>
[$default_LDFLAGS]
LIBS Libraries to pass to the linker, e.g. -l<library>
These variables may already be set by your shell. If you don't want
\`configure' to decide for you, append \`VARIABLE=' to the command line.
EOF
exit 0
fi
# Check for conflicting flags
if test "$is_verbose" = "yes" && test "$is_quiet" = "yes"; then
echo "Flags \`-q' and \`-v' cannot be used together." >&2
exit 1
fi
test "$is_verbose" = "yes" && echo "Entering verbose mode."
# Make sure only one `--use-color-TYPE' flag is set
# TODO: clean this up somehow
if (test "$use_color_ansi" = "yes" && test "$use_color_woe32" = "yes") || \
(test "$use_color_ansi" = "yes" && test "$use_color_conio" = "yes") || \
(test "$use_color_woe32" = "yes" && test "$use_color_conio" = "yes"); then
echo "$log_e: Cannot use more than one \`--use-color-TYPE'"\
"flag at once." >&2
exit 1
fi
# Check for deprecated `--use-color' flag
if test "$use_color" != "unset"; then
echo "$log_w: The \`--use-color' flag is deprecated. " \
"Assuming you meant \`--use-color-ansi'." >&2
use_color_ansi="yes"
fi
# Check whether PWD is usable
test "$is_verbose" = "yes" &&
echo $n "Checking whether PWD is read-/write-able... "
cs_pwd=`pwd` && test -n "$cs_pwd" &&
ls_di=`ls -di .` &&
pwd_ls_di=`cd "$cd_pwd" && ls -di .` ||
{
echo "$log_e: Working directory cannot be determined." >&2
exit 1
}
test -w "$cs_pwd" ||
{
echo "$log_e: Working directory is not writeable." >&2
exit 1
}
test "$is_verbose" = "yes" && echo "yes."
# Set installation directories
for var in srcdir docdir prefix bindir datadir localedir mandir; do
eval usval="\$us_$var"
eval defval="\$default_$var"
if test -n "$usval" && test ! "$usval" = "$defval"; then
test "$is_verbose" = "yes" &&
echo "Using user-specified directory for \`$var': $usval"
eval $var="\$us_$var"
else
test "$is_verbose" = "yes" &&
echo "Using default directory for \`$var': $defval"
eval $var="\$default_$var"
fi
done
# Check for compiler toolkits
if test -n "$CC" && command -v "$CC" >/dev/null 2>&1; then
# XXX dangerous assumption
test "$is_verbose" = "yes" &&
echo "Using user-specified compiler toolkit: \`$CC'."
else
# In verbose mode, "Checking for..." displays each iteration;
# otherwise, just show this catch-all message
test "$is_quiet" = "no" && test "$is_verbose" = "no" &&
echo $n "Checking for a valid compiler... "
# XXX There has to be a more elegant way to do this
while true; do
test "$is_verbose" = "yes" &&
echo $n "Checking for Clang toolkit... "
if command -v clang >/dev/null 2>&1; then
test "$is_quiet" = "no" && echo "found."
CC="clang"
break
else
test "$is_verbose" = "yes" && echo "not found."
fi
test "$is_verbose" = "yes" &&
echo $n "Checking for GNU toolkit... "
if command -v gcc >/dev/null 2>&1; then
test "$is_quiet" = "no" && echo "found."
CC="gcc"
break
else
test "$is_verbose" = "yes" && echo "not found."
fi
# XXX probably dangerous
test "$is_verbose" = "yes" &&
echo $n "Checking for something named \`cc'... "
if command -v cc >/dev/null 2>&1; then
test "$is_quiet" = "no" && echo "found."
CC="cc"
break
else
test "$is_verbose" = "yes" && echo "not found."
fi
# TODO: more valid toolkits
echo "$log_e: No acceptable compiler found in \$PATH." >&2
echo "$log_e: Specify a compiler using \`CC=/path/to' when "\
"running this script." >&2
exit 1
done
test "$is_verbose" = "yes" && echo "CC: $CC"
fi
# Check for C standard library (at least those used in the program)
test "$is_quiet" = "no" &&
echo $n "Checking for C89 standard library headers... "
cat >conftest.c <<_EOF
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int main() { return 0; }
_EOF
(eval $CC $CFLAGS conftest.c -o conftest) 2>conftest.err
rm -f conftest.o conftest.c conftest
if test ! -s conftest.err; then
test "$is_quiet" = "no" && echo "found."
rm -f conftest.err
else
test "$is_quiet" = "no" && echo "not found."
echo "$log_e: C standard library is not properly implemented." >&2
echo "$log_e: Specify a valid include dir in your CFLAGS with "\
"\`CFLAGS=-I/path/to/dir' when running this script." >&2
exit 1
fi
# Check for POSIX standard library
test "$is_quiet" = "no" &&
echo $n "Checking for POSIX standard library headers... "
cat >conftest.c <<_EOF
#include <unistd.h>
int main() { return 0; }
_EOF
(eval $CC $CFLAGS conftest.c -o conftest) 2>conftest.err
rm -f conftest.o conftest.c conftest
if test ! -s conftest.err; then
test "$is_quiet" = "no" && echo "found."
rm -f conftest.err
else
test "$is_quiet" = "no" && echo "not found."
echo "$log_e: POSIX standard library is not properly implemented." >&2
echo "$log_e: Specify a valid include dir in your CFLAGS with "\
"\`CFLAGS=-I/path/to/dir' when running this script." >&2
exit 1
fi
# Check for DOS `conio.h'
if test "$use_color_conio" = "yes"; then
test "$is_quiet" = "no" &&
echo $n "Checking for conio \`conio.h'... "
cat >conftest.c <<_EOF
#include <conio.h>
int main() { return 0; }
_EOF
(eval $CC $CFLAGS conftest.c -o conftest) 2>conftest.err
rm -f conftest.o conftest.c conftest
if test ! -s conftest.err; then
test "$is_quiet" = "no" && echo "found."
rm -f conftest.err
else
test "$is_quiet" = "no" && echo "not found."
echo "$log_e: Cannot find \`conio.h'." >&2
echo "$log_e: Specify a valid include dir in your CFLAGS with"\
"\`CFLAGS=-I/path/to/dir' when running this script." >&2
exit 1
fi
fi
# Check for Windows API
if test "$use_color_woe32" = "yes"; then
test "$is_quiet" = "no" &&
echo $n "Checking for Windows header files... "
cat >conftest.c <<_EOF
#include <windows.h>
int main() { return 0; }
_EOF
(eval $CC $CFLAGS conftest.c -o conftest) 2>conftest.err
rm -f conftest.o conftest.c conftest
if test ! -s conftest.err; then
test "$is_quiet" = "no" && echo "found."
rm -f conftest.err
else
test "$is_quiet" = "no" && echo "not found."
echo "$log_e: Cannot find \`windows.h'." >&2
echo "$log_e: Specify a valid include dir in your CFLAGS with"\
"\`CFLAGS=-I/path/to/dir' when running this script." >&2
exit 1
fi
fi
# Check for libintl (gettext)
if test "$use_gettext" = "yes"; then
test "$is_quiet" = "no" &&
echo $n "Checking for libintl (gettext)... "
cat >conftest.c <<_EOF
#include <libintl.h>
#include <locale.h>
int main() { return 0; }
_EOF
(eval $CC $CFLAGS conftest.c -o conftest) 2>conftest.err
rm -f conftest.o conftest
if test ! -s conftest.err; then
test "$is_quiet" = "no" && echo "found."
rm -f conftest.err
else
test "$is_quiet" = "no" && echo "not found."
echo "$log_e: libintl is not properly implemented." >&2
echo "$log_e: Specify a valid include dir in your CFLAGS with "\
"\`CFLAGS=-I/path/to/dir' when running this script." >&2
exit 1
fi
test "$is_quiet" = "no" &&
echo $n "Checking whether libintl must be explicitly linked... "
(eval $CC $CFLAGS conftest.c -o conftest) 2>conftest.err
rm -f conftest.o conftest.c conftest
if test ! -s conftest.err; then
use_lintl="no"
test "$is_quiet" = "no" && echo "no."
else
use_lintl="yes"
test "$is_quiet" = "no" && echo "yes."
fi
rm -f conftest.err
fi
# Check for `sysexits.h'
if test "$use_sysexits" = "yes"; then
test "$is_quiet" = "no" &&
echo $n "Checking for \`sysexits.h'... "
cat >conftest.c <<_EOF
#include <sysexits.h>
int main() { return EX_OK; }
_EOF
(eval $CC $CFLAGS conftest.c -o conftest) 2>conftest.err
rm -f conftest.o conftest.c conftest
if test ! -s conftest.err; then
test "$is_quiet" = "no" && echo "found."
rm -f conftest.err
else
test "$is_quiet" = "no" && echo "not found."
echo "$log_e: \`sysexits.h' does not work as expected." >&2
echo "$log_e: Specify a valid include dir in your CFLAGS with "\
"\`CFLAGS=-I/path/to/dir' when running this script." >&2
exit 1
fi
fi
# Check for POSIX `sys/time.h'
if test "$use_posixtime" = "yes"; then
test "$is_quiet" = "no" &&
echo $n "Checking for POSIX \`sys/time.h'... "
cat >conftest.c <<_EOF
#include <sys/time.h>
int main() { return 0; }
_EOF
(eval $CC $CFLAGS conftest.c -o conftest) 2>conftest.err
rm -f conftest.o conftest.c conftest
if test ! -s conftest.err; then
test "$is_quiet" = "no" && echo "found."
rm -f conftest.err
else
test "$is_quiet" = "no" && echo "not found."
echo "$log_e: POSIX library is not properly implemented." >&2
echo "$log_e: Specify a valid include dir in your CFLAGS with "\
"\`CFLAGS=-I/path/to/dir' when running this script." >&2
exit 1
fi
fi
# Generate `$CFLAGS' based on what the user specified
test "$is_verbose" = "yes" &&
echo $n "Computing CFLAGS... "
test -z "$CFLAGS" && CFLAGS=""
CFLAGS="$CFLAGS $default_CFLAGS"
test "$is_verbose" = "yes" && echo "done."
test "$is_verbose" = "yes" && test -n "$CFLAGS" &&
echo "CFLAGS: $CFLAGS"
# Generate `$feature_flags` based on `--use-FEATURE` variables
test "$is_verbose" = "yes" &&
echo $n "Computing feature CFLAGS... "
feature_CFLAGS=""
test "$use_color_ansi" = "yes" &&
feature_CFLAGS="$feature_CFLAGS -DVP_USE_COLOR_ANSI"
test "$use_color_woe32" = "yes" &&
feature_CFLAGS="$feature_CFLAGS -DVP_USE_COLOR_WOE32"
test "$use_fullwidth" = "yes" &&
feature_CFLAGS="$feature_CFLAGS -DVP_USE_FULLWIDTH"
test "$use_gettext" = "yes" &&
feature_CFLAGS="$feature_CFLAGS -DVP_USE_GETTEXT"
test "$use_gettext" = yes && "$use_lintl" = "yes" &&
feature_CFLAGS="$feature_CFLAGS -lintl"
test "$use_gettext" = "yes" && test -n "$localedir" &&
feature_CFLAGS="$feature_CFLAGS -DVP_LOCALE_DIR=\\\"\${LOCALEDIR}\\\""
test "$use_sysexits" = "yes" &&
feature_CFLAGS="$feature_CFLAGS -DVP_USE_SYSEXITS"
test "$use_posixtime" = "yes" &&
feature_CFLAGS="$feature_CFLAGS -DVP_USE_POSIXTIME"
test "$is_verbose" = "yes" && echo "done."
test "$is_verbose" = "yes" && test -n "$feature_CFLAGS" &&
echo "FEATURE_CFLAGS: $feature_CFLAGS"
# =============
test "$is_quiet" = "no" &&
echo $n "Generating Makefile... "
cat >Makefile <<_EOF
## Makefile for varlpenis
## Generated by \`configure'
# Package info
# XXX needs backslashes before \`"'
PACKAGE_NAME=\\"$pkg_name\\"
PACKAGE_VERSION=\\"$pkg_version\\"
# Programs
CC=$CC
CTAGS=ctags
SHELL=/bin/sh
RM=rm -rf
_EOF
if test "$use_gettext" = "yes"; then
cat >>Makefile <<_EOF
XGETTEXT=xgettext
MSGINIT=msginit
MSGMERGE=msgmerge
MSGFMT=msgfmt
_EOF
fi
cat >>Makefile <<_EOF
# Compiler flags
CFLAGS=$CFLAGS
LDFLAGS=$LDFLAGS
FEATURE_CFLAGS=$feature_CFLAGS
# Install commands
INSTALL=install -C
INSTALL_DIR=\${INSTALL} -d -m 755
INSTALL_PROGRAM=\${INSTALL} -m 755
INSTALL_PROGRAM_STRIP=\${INSTALL_PROGRAM} -s
INSTALL_DATA=\${INSTALL} -m 644
_EOF
if test "$use_gettext" = "yes"; then
cat >>Makefile <<_EOF
INSTALL_LOCALE=\${INSTALL} -m 644
_EOF
fi
cat >>Makefile <<_EOF
INSTALL_MAN=\${INSTALL} -m 644
# Installation directories
SRCDIR=$srcdir
DOCDIR=$docdir
_EOF
if test "$ifndef_guards" = "no"; then
cat >>Makefile <<_EOF
PREFIX=$prefix
BINDIR=$bindir
DATADIR=$datadir
_EOF
if test "$use_gettext" = "yes"; then
cat >>Makefile <<_EOF
LOCALEDIR=$localedir
_EOF
fi
cat >>Makefile <<_EOF
MANDIR=$mandir
_EOF
else
cat >>Makefile <<_EOF
.ifndef PREFIX
PREFIX=$prefix
.endif
.ifndef BINDIR
BINDIR=$bindir
.endif
.ifndef DATADIR
DATADIR=$datadir
.endif
_EOF
if test "$use_gettext" = "yes"; then
cat >>Makefile <<_EOF
.ifndef LOCALEDIR
LOCALEDIR=$localedir
.endif
_EOF
fi
cat >>Makefile <<_EOF
.ifndef MANDIR
MANDIR=$mandir
.endif
_EOF
fi
if test "$use_gettext" = "yes"; then
cat >>Makefile <<_EOF
# If these are set, clean/install/etc targets will
# also trigger clean-mo/install-mo/etc
BUILD_MO=build-mo-files
INSTALL_MO=install-mo-files
UNINSTALL_MO=uninstall-mo-files
CLEAN_MO=clean-mo-files
# gettext tools options
XGETTEXT_OPTIONS = --add-comments --sort-output
MSGID_BUGS_ADDRESS = sprice623@aol.com
COPYRIGHT_HOLDER = Seth Price
_EOF
fi
cat Makefile.in >> Makefile
if test "$use_gettext" = "yes"; then
cat >>Makefile <<_EOF
_EOF
cat $srcdir/po/Makefile.in >> Makefile
fi
test "$is_quiet" = "no" && echo "done."
test "$is_quiet" = "no" &&
echo $n "Generating \`check.sh'... "
cat >check.sh <<_EOF
#!/bin/sh
test -f ./varlpenis || { echo "not found"; exit 1; }
tmp=\`./varlpenis -l 7 -e 3\`
test "\$tmp" = "8=======D~~~" && { echo "works"; exit 0; }
echo "failed"; exit 1
_EOF
test "$is_quiet" = "no" && echo "done."
test "$is_quiet" = "no" &&
echo "Configuration complete; type \`make' to build."
exit 0