-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconfigure
executable file
·581 lines (501 loc) · 16.1 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
#!/bin/sh
# WendzelNNTPd configure script by Steffen 'cdp_xe' Wendzel.
# Based on the Xyria:DNSd/cdpNNTPd configure script I wrote in 2004 or 2005.
# This script is basically unchanged since 2015 as I only added detail
# improvements.
# e-mail: <steffen (at) wendzel (dot) de>
# web: https://www.wendzel.de
#
# WendzelNNTPd is distributed under the following license:
#
# Copyright (c) 2004-2023 Steffen Wendzel <steffen (at) wendzel (dot) de>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
VERSION="2.6.1 - Oct-16-2023"
MAKEFILE_INC="Makefile.inc"
USE_SOLARIS_NETLIBS="NO"
USE_GCCLOCAL_PTHREAD="NO"
NEED_GCCLOCAL_PTHREAD="NO"
USE_LIBPTHREAD="YES"
ORDER=""
COMPILER=cc
OS=`uname -s`
RELEASE=`uname -r`
TABCPATH='src/'
# Default for usage of TLS is YES
USE_TLS="YES"
###################################################
out()
{
if [ "$OS" = "SunOS" ]; then
echo $1 '\c'
else
echo -n $1
fi
}
check()
{
RET_VAL=$?
if [ "$4" != "" ]; then
CHK_VAL=$4
else
CHK_VAL="0"
fi
if [ "$RET_VAL" = "$CHK_VAL" ]; then
echo $1
else
echo "$2 (returned $RET_VAL, what is not eq to $CHK_VAL)"
echo $3
exit
fi
}
############# WELCOME #########################
echo "This is the WendzelNNTPd configuration script v.${VERSION}"
echo
echo "Written by Steffen Wendzel"
echo " https://www.wendzel.de"
echo
###### check some env #########
ADD_CFLAGS=$CFLAGS
ADD_LNKFLAGS=$LDFLAGS
# make /usr/local the default DESTDIR
if [ "$DESTDIR" = "" ]; then
DESTDIR=/usr/local
fi
# make /usr/local/etc the default CONFDIR
if [ "$CONFDIR" = "" ]; then
CONFDIR=/usr/local/etc
fi
# make wendzelnntpd.conf the default CONFFILE
if [ "$CONFFILE" = "" ]; then
CONFFILE="wendzelnntpd.conf"
fi
if [ "$FAKECDIR" = "" ]; then
FAKECDIR=$CONFDIR
fi
# if TLS is explicit disable, then compile without
# Default for SSL/TLS is YES
if [ "$TLS" = "" ]; then
USE_TLS="YES"
# Compile without SSL/TLS
elif [ "$TLS" = "NO" ]; then
USE_TLS="NO"
# Compile with SSL/TLS
else
USE_TLS="YES"
fi
if [ "$1" != "" ]; then
echo "This configure script takes some environment variables:"
echo
echo "1) Directory setup (can be used e.g. if you build a package/port):"
echo
echo "DESTDIR - The installation destination base dir (would be /usr"
echo " or /usr/local in 99% of all cases) and there is"
echo " usually little reason to change this variable."
echo " The default value is: /usr/local"
echo "CONFFILE - The config file name of the source config file"
echo " The default value is: wendzelnntpd.conf"
echo "CONFDIR - The installation destination of the config file"
echo " (would be /etc or /usr/local/etc in 99% of all cases)."
echo " The default value is: /usr/local/etc"
echo "FAKECDIR - This is a fake directory to place the config file into"
echo " (for example copy to ./fakeroot-xyz/etc/ but the code"
echo " will use CONFDIR nevertheless). This is useful for"
echo " building ports and packages in Linux and *BSD. However,"
echo " use-cases will be pretty rare."
echo " The default value: same as CONFDIR"
echo
echo "2) Databases (options to disable support at compile-time):"
echo
echo "MYSQL=NO - Disables support for MySQL if you do not wish to"
echo " install mysqlclient and mysql development libraries."
echo " or if you do not wish to have WendzelNNTPd contain"
echo " any support for MySQL (use: 'MYSQL=NO ./configure')."
echo "SQLITE=NO - Disables support for SQLITE if you do not wish to"
echo " install sqlite development libraries or if you do"
echo " not wish to have WendzelNNTPd contain any support"
echo " for SQLite (use: 'SQLITE=NO ./configure')."
echo "POSTGRES=NO - Disables support for PostgreSQL if you do not wish"
echo " to install the related library. [DEFAULT]"
echo "POSTGRES=YES- Enables PostgreSQL support."
echo
echo "Note: You can only deactivate *either* MYSQL *or* SQLITE *or*"
echo "PostgreSQL but not all of them, i.e., at least one database is"
echo "required to operate WendzelNNTPd."
echo
echo "3) Encryption (options to disable support at compile-time):"
echo
echo "TLS=NO - Disables support for TLS encryption"
echo "If encryption is not enabled, openssl is needed to be installed."
exit 1
fi
############# OS DEPENDENT PART ###############
echo "operating system is...$OS"
echo "operating system release is...$RELEASE"
out 'checking for Solaris...'
if [ "$OS" = "SunOS" ]; then
echo "yes"
USE_SOLARIS_NETLIBS="YES"
TABCPATH=""
out "byte_order..."
if [ "`uname -m`" = "i86pc" ]; then
ORDER=1
echo "little endian"
else
ORDER=0
echo "big endian"
echo
echo "NOTE: WendzelNNTPd was never tested on big endian platforms."
echo
fi
else
echo "no"
fi
out "config for gcc-local -pthread..."
if [ "$OS" = "OpenBSD" ]; then
USE_GCCLOCAL_PTHREAD="YES"
NEED_GCCLOCAL_PTHREAD="YES"
USE_LIBPTHREAD="NO"
fi
echo "done"
if [ "$OS" = "FreeBSD" -o "$OS" = "OpenBSD" -o "$OS" = "NetBSD" ]; then
out "*BSD detected, setting compiler to 'cc'.\n"
COMPILER=cc
fi
out "checking for linux sort parameters (-bg)..."
if [ "$OS" = "Linux" ]; then
ADDSORT="-bg"
echo "yes"
else
echo "no"
fi
out "checking for 'install' command..."
if [ "$OS" = "FreeBSD" ]; then
install >/dev/null 2>&1; check "yes" "no" "you need the 'install' tool." 64
else
install >/dev/null 2>&1; check "yes" "no" "you need the 'install' tool." 1
fi
# == error because no useful parameter provided, but that is what we need, because if not present, return value would be 127==not found
#if [ "$?" = "127" ]; then
# echo "no"
#else
# echo "yes"
#fi
out "configuring for 'install' command parameters..."
if [ "$OS" = "SunOS" ]; then
# OpenSolaris
CMD_INSTALL_USEROPT="-u"
else
# OpenBSD, FreeBSD, Linux
CMD_INSTALL_USEROPT="-o"
fi
echo "done, using '$CMD_INSTALL_USEROPT root' for installation."
############# OS INDEPENDENT PART #############
out "checking for (g)cc..."; $COMPILER -v >/dev/null 2>&1; check "yes" "no" "You need (g)cc (or set PATH)."
###############
out "checking for libc..."
cat << EOF >temp.c
#include <stdio.h>
int main() {
printf("WendzelNNTPd\n");
return 0;
}
EOF
$COMPILER $ADD_LNKFLAGS -o temp temp.c>/dev/null 2>&1; check "yes" "no" "You need libc."
rm -f temp temp.c
###############
out "checking for -fstack-protector..."
cat << EOF >temp.c
#include <stdio.h>
int main() {
printf("WendzelNNTPd\n");
return 0;
}
EOF
$COMPILER $ADD_LNKFLAGS -o temp -fstack-protector temp.c>/dev/null 2>&1
if [ "$?" = "1" ]; then
echo "no (compiling without stack protection)"
STACK_PROT=""
else
echo "yes"
STACK_PROT="-fstack-protector"
fi
rm -f temp temp.c
###############
out "checking for strftime()/ltime()..."
cat << EOF >temp.c
#include <time.h>
int main() {
char unused[0xff] = {'\0'};
time_t ltime;
ltime = time(NULL);
if (ltime == (time_t) - 1) {
return 0;
}
strftime(unused, 0xff-1, "%a, %d %b %y %H:%M:%S", localtime(<ime));
return 0;
}
EOF
$COMPILER $ADD_LNKFLAGS -o temp temp.c >/dev/null 2>&1; check "yes" "no" "You need strftime() and ltime()."
rm -f temp temp.c
###############
out "checking for %z support in strftime()..."
cat << EOF >temp.c
#include <time.h>
int main() {
char unused[0xff] = {'\0'};
time_t ltime;
ltime = time(NULL);
if (ltime == (time_t) - 1) {
return;
}
strftime(unused, 0xff-1, "%z", localtime(<ime));
return 0;
}
EOF
$COMPILER $ADD_LNKFLAGS -o temp temp.c >/dev/null 2>&1
if [ "$?" = "0" ]; then
echo "yes"
else
ADD_CFLAGS=`echo $ADD_CFLAGS " -DNOSUPPORT_STRFTIME_z_FLAG "`
echo "no"
fi
rm -f temp temp.c
###############
#out "checking for g++..."; g++ -v >/dev/null 2>&1; check "yes" "no" "You need g++ (or set PATH)."
out "checking for flex..."; flex -V >/dev/null 2>&1; check "yes" "no" "You need flex."
out "checking for bison..."; bison -V >/dev/null 2>&1; check "yes" "no" "You need Bison."
################
# Database stuff
################
# The default setting is that POSTGRES must be activated excplicitly.
# Thus, if not explicitly set to YES, use the value "NO".
if [ "$POSTGRES" = "" ]; then
POSTGRES="NO"
fi
if [ "$SQLITE" = "NO" -a "$MYSQL" = "NO" -a "$POSTGRES" = "NO" ]; then
echo "error: you cannot deactivate support for MySQL, Postgres *and* SQlite as"
echo "you need to integrate support for at least one database!";
exit 1
fi
if [ "$SQLITE" = "NO" ]; then
out "configuring without SQlite3 support ..."; echo
else
out "checking for sqlite3..."; sqlite3 -version 2>/dev/null
if [ "$?" = "127" ]; then
echo "no (You need SQLite3 or newer (or disable SQLite3 support, cf. ./configure --help).)"
exit 1
fi
out "checking for libsqlite3..."
cat << EOF > temp.c
#include <sqlite3.h>
int main() {
sqlite3 *db;
int rc;
rc = sqlite3_open("nothing", &db);
sqlite3_close(db);
return 0;
}
EOF
$COMPILER $ADD_LNKFLAGS -o temp temp.c -lsqlite3 -I/usr/local/include -L/usr/local/lib >/dev/null 2>&1; check "yes" "no" "You need libSQLite3 development files and library (or disable SQLite3 support, cf. ./configure --help)."
rm -f temp temp.c
fi
# libMySQL check
if [ "$MYSQL" = "NO" ]; then
out "configuring without MySQL support ..."; echo
else
out "checking for MySQL client library..."
cat << EOF > temp.c
#include <mysql/mysql.h>
#include <stdio.h>
MYSQL *myhndl = NULL;
int main() {
if ((myhndl = mysql_init(NULL)) == NULL) {
fprintf(stderr, "mysql_init() error\n");
return 1;
}
return 0;
}
EOF
$COMPILER $ADD_LNKFLAGS -o temp temp.c -lmysqlclient -I/usr/local/include -L/usr/local/lib >/dev/null 2>&1; check "yes" "no" "You need the MySQL client library and their development files (or disable MySQL support, cf. ./configure --help)."
rm -f temp temp.c
fi
# PostgreSQL check
if [ "$POSTGRES" = "NO" ]; then
out "configuring without PostgreSQL library support (libpq) ..."; echo
else
out "checking for PostgreSQL library..."
cat << EOF > temp.c
#include <libpq-fe.h>
#include <stdio.h>
int main() {
PGconn *unused; /* check whether the datatype is present. */
return 0;
}
EOF
$COMPILER $ADD_LNKFLAGS -o temp temp.c -lpq -I/usr/local/include -L/usr/local/lib -I/usr/include/postgresql >/dev/null 2>&1; check "yes" "no" "You need the PostgreSQL library and their development files (or disable PostgreSQL support, cf. ./configure --help)."
rm -f temp temp.c
fi
###############
out "checking for libpthread..."
cat << EOF >temp.c
#include <pthread.h>
int main(){pthread_self();return 0;}
EOF
$COMPILER $ADD_LNKFLAGS -o temp temp.c -lpthread >/dev/null 2>&1; check "yes" "no" "You need libpthread."
rm -f temp temp.c
###############
out "checking for libmhash..."
cat << EOF >temp.c
#include <mhash.h>
int main(){MHASH td = mhash_init(MHASH_MD5);return 0;}
EOF
$COMPILER $ADD_LNKFLAGS -I/usr/local/include/ -L/usr/local/lib/ -o temp temp.c -lmhash >/dev/null 2>&1; check "yes" "no" "You need libmhash."
rm -f temp temp.c
###############
out "checking for SHA-256..."
cat << EOF >temp.c
#include <mhash.h>
int main(){MHASH td = mhash_init(MHASH_SHA256);return 0;}
EOF
$COMPILER $ADD_LNKFLAGS -I/usr/local/include/ -L/usr/local/lib/ -o temp temp.c -lmhash >/dev/null 2>&1; check "yes" "no" "You need a version of libmhash that supports SHA-256."
rm -f temp temp.c
###############
out "checking for strndup()..."
cat << EOF >temp.c
#include <stdio.h>
#include <string.h>
#ifdef __svr4__
#include <strings.h>
#endif
int main(){char *q = "test"; strndup(q, 1);return 0;}
EOF
$COMPILER $ADD_LNKFLAGS -o temp temp.c >/dev/null 2>&1
if [ "$?" = "0" ]; then
echo "yes"
else
echo "no [adding to ADD_CFLAGS]"
ADD_CFLAGS=`echo $ADD_CFLAGS " -DNOSUPPORT_STRNDUP "`
fi
rm -f temp temp.c
###############
if [ "$USE_TLS" = "NO" ]; then
out "configuring without TLS support ..."; echo
else
out "checking for openssl..."
openssl version >/dev/null 2>&1; check "yes" "no" "You need openssl (or set PATH)."
out "checking for libssl..."
cat << EOF >temp.c
#include <openssl/ssl.h>
int main(){SSL_library_init();return 0;}
EOF
$COMPILER $ADD_LNKFLAGS -o temp temp.c -lssl 2>&1; check "yes" "no" "You need libssl."
rm -f temp temp.c
fi
############# rc.d script ADJUSTMENT ##########
echo -n "patching scripts/startup/init.d_script_raw to scripts/startup/init.d_script..."
echo -n $DESTDIR | sed 's/\//\\\//g' >ignore
PATCH_DESTDIR=`cat ignore`
rm ignore
cat scripts/startup/init.d_script_raw | sed 's/REPLACETHIS\_WITH\_DAEMONPATH/'$PATCH_DESTDIR'\/sbin\/wendzelnntpd/' > scripts/startup/init.d_script
echo "done."
############# MAKEFILE.INC CREATE #############
out "creating Makefile.inc..."
cat /dev/null > $MAKEFILE_INC
echo "SORT=sort $ADDSORT" >> $MAKEFILE_INC
echo "CMD_INSTALL_USEROPT=$CMD_INSTALL_USEROPT" >> $MAKEFILE_INC
if [ "$USE_SOLARIS_NETLIBS" = "YES" ]; then
echo 'SOLNETLIBS=-lnsl -lsocket'>> $MAKEFILE_INC
else
echo 'SOLNETLIBS='>> $MAKEFILE_INC
fi
if [ "$NEED_GCCLOCAL_PTHREAD" = "YES" ]; then
echo 'GCCLOCALPTHREAD=-pthread'>> $MAKEFILE_INC
else
echo 'GCCLOCALPTHREAD='>> $MAKEFILE_INC
fi
if [ "$USE_LIBPTHREAD" = "YES" ]; then
echo 'LIBPTHREAD=-lpthread'>> $MAKEFILE_INC
else
echo 'LIBPTHREAD='>> $MAKEFILE_INC
fi
if [ "$MYSQL" = "NO" ]; then
echo 'MYSQLLIB='>> $MAKEFILE_INC
echo 'MYSQLOBJ='>> $MAKEFILE_INC
ADD_CFLAGS=`echo $ADD_CFLAGS " -DNOMYSQL "`
else
echo 'MYSQLLIB=-lmysqlclient'>> $MAKEFILE_INC
echo 'MYSQLOBJ=db_mysql.o'>> $MAKEFILE_INC
fi
if [ "$POSTGRES" = "NO" ]; then
echo 'POSTGRESLIB='>> $MAKEFILE_INC
echo 'POSTGRESOBJ='>> $MAKEFILE_INC
ADD_CFLAGS=`echo $ADD_CFLAGS " -DNOPOSTGRES "`
else
echo 'POSTGRESLIB=-lpq'>> $MAKEFILE_INC
echo 'POSTGRESOBJ=db_postgres.o'>> $MAKEFILE_INC
fi
if [ "$USE_TLS" = "YES" ]; then
echo 'OPENSSLOBJ=libssl.o' >> $MAKEFILE_INC
echo 'OPENSSLLIB=-lssl -lcrypto' >> $MAKEFILE_INC
ADD_CFLAGS=`echo $ADD_CFLAGS " -DUSE_TLS "`
else
echo 'OPENSSLOBJ=' >> $MAKEFILE_INC
echo 'OPENSSLLIB=' >> $MAKEFILE_INC
fi
if [ "$SQLITE" = "NO" ]; then
echo 'SQLITELIB='>> $MAKEFILE_INC
echo 'SQLITEOBJ='>> $MAKEFILE_INC
ADD_CFLAGS=`echo $ADD_CFLAGS " -DNOSQLITE "`
# mysql does not run a command for setup but sqlite
# requires it in 'make install'. Thus, let make know
# when no sqlite is there ...
echo 'SQLITEINST=NO'>> $MAKEFILE_INC
else
echo 'SQLITELIB=-lsqlite3'>> $MAKEFILE_INC
echo 'SQLITEOBJ=db_sqlite3.o'>> $MAKEFILE_INC
fi
echo "LIBMHASH=-lmhash">> $MAKEFILE_INC
echo "TABCPATH=$TABCPATH">> $MAKEFILE_INC
echo "ORDER=-DORDER=$ORDER">> $MAKEFILE_INC
echo >> $MAKEFILE_INC
echo "STACK_PROT=$STACK_PROT">> $MAKEFILE_INC
echo "ADD_CFLAGS=$ADD_CFLAGS">> $MAKEFILE_INC
echo "ADD_LNKFLAGS=$ADD_LNKFLAGS">> $MAKEFILE_INC
echo >> $MAKEFILE_INC
echo "DESTDIR=$DESTDIR">> $MAKEFILE_INC
echo "CONFDIR=$CONFDIR">> $MAKEFILE_INC
echo "CONFFILE=$CONFFILE">> $MAKEFILE_INC
echo "FAKECDIR=$FAKECDIR">> $MAKEFILE_INC
echo "
SRC=src
LIBDIRS=-L/usr/local/lib
INCDIRS=-I. -I./src -I./src/include -I/usr/local/include -I/usr/include/postgresql
CPP=g++
CC=$COMPILER
LEX=flex
YACC=bison
" >> $MAKEFILE_INC
echo "done."
echo "(you can now run make (or gmake on OpenSolaris) ...)"