summaryrefslogtreecommitdiffstats
path: root/configure
blob: e67be05a2e04291a48111aabe5261aab6bc516ba (plain) (blame)
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
#!/bin/sh
# Configure script for util-linux - aeb, 990205
#
# We need to find out the following things:
#
# Version of gcc
#
# Existence of header files:
# H1. For fdisksunlabel.c: is there a <scsi/scsi.h>?
# H2. For fdisk.c: is there a <linux/blkpg.h>?
# H3. For kbd_rate.c: does <linux/kd.h> exist?
# H4. For nls.h: do we have <locale.h>?
# H5. For cal.c: do we have <langinfo.h>?
# H6. For mkswap.c: do we have <sys/user.h> or <asm/page.h>?
# H7. For nfsmount.c: do we have <rpcsvc/nfs_prot.h>?
# H8. For nfsmount.h (nfsmount_xdr.c: int32_t): do we have <asm/types.h>?
# H9. For raw.c: do we have <linux/raw.h>?
#
# Existence of functions:
# F1. For nfsmount.c: is inet_aton() available?
# F2. For mkswap.c: is fsync() available?
# F3. For agetty.c: is getdomainname() available?
# F4. For hwclock/kd.c: do we have nanosleep()?
# F5. For mkswap.c: do we have personality()?
# F6. For agetty.c: is updwtmp() available?
# F7. For pg.c: are fseeko() and ftello() available?
# F8. For fsck.cramfs.c: is lchown() available?
#
#  1. For sys-utils/cytune.c: do we need <linux/tqueue.h>?
#  2. For cfdisk, setterm, more, ul: do we have ncurses? How installed?
#  3. For more: do we have libtermcap?
#  4. For chfn, chsh, login, newgrp, passwd: do we need -lcrypt?
#  5. For sln: does static compilation work?
#  6. For lib/nls.h: do we have <libintl.h> and gettext()?
#  7. For xgettext: does it take the option --foreign-user?
#  8. For err.c: do we have __progname?
#  9. For script.c: do we have <pty.h> and openpty()?
# 10. For lib/widechar.h: do we have wide character support?
# 11. For pivot_root.c: does <linux/unistd.h> define __NR_pivot_root?
# 12. For hwclock.c: does struct tm have a field tm_gmtoff?
# 13. For nfsmount: does the output of rpcgen compile?
# 14. For fsck.cramfs, mkfs.cramfs: do we have libz?

rm -f make_include defines.h

VERSION=`cat VERSION`
echo
echo configuring util-linux-$VERSION
echo
echo "VERSION=$VERSION" > make_include
echo '#define UTIL_LINUX_VERSION "'$VERSION'"' > defines.h
echo '#define util_linux_version "util-linux-'$VERSION'"' >> defines.h
echo >> defines.h

CC=${CC-cc}
CFLAGS=${CFLAGS-"-O"}
LDFLAGS=${LDFLAGS-"-s"}
echo CC=$CC >> make_include
echo CFLAGS=$CFLAGS >> make_include
echo LDFLAGS=$LDFLAGS >> make_include

DEFS=
LIBS=
compile='$CC $CFLAGS $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1'
compile_with_warnings='$CC $CFLAGS $DEFS conftest.c -o conftest $LIBS 2>&1'
static_compile='$CC -static $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1'
eval COMPILE='"'$compile'"'
export COMPILE

rm -f conftest.c conftest

#
# Old gcc wants options like -m486, but gcc 3.0 says
# `-m486' is deprecated. Use `-march=i486' or `-mcpu=i486' instead.
#
echo "
int main(){ exit(0); }
" > conftest.c
gccout=`$CC $CFLAGS -m386 conftest.c -o conftest 2>&1 | grep "march="`
if test -z "$gccout"; then
    echo "HAVE_OLD_GCC=yes" >> make_include
fi
rm -f conftest conftest.c

#
# Find out about the existence of header files
#

#
# H1. For fdisk/fdisksunlabel.c: is <scsi/scsi.h> available?
#     Some kernels have <scsi/scsi.h> that uses u_char
#     But maybe there is already a typedef. Let us use a #define
#
echo "
#define u_char	unsigned char
#include <scsi/scsi.h>
#undef u_char
int main(){ exit(0); }
" > conftest.c
eval $compile
if test -s conftest; then
        echo "#define HAVE_scsi_h" >> defines.h
        echo "You have <scsi/scsi.h>"
else
        echo "You don't have <scsi/scsi.h>"
fi
rm -f conftest conftest.c

#
# H2. For fdisk/fdisk.c: is <linux/blkpg.h> available?
#
if ./testincl "linux/blkpg.h"; then
        echo "#define HAVE_blkpg_h" >> defines.h
fi

#
# H3. Does <linux/kd.h> exist?
#
if ./testincl "linux/kd.h"; then
	echo "#define HAVE_kd_h" >> defines.h
fi

#
# H4. For lib/nls.h: do we have <locale.h>?
#
if ./testincl "locale.h"; then
        echo "#define HAVE_locale_h" >> defines.h
fi

#
# H5. For cal.c: do we have <langinfo.h>?
#
if ./testincl "langinfo.h"; then
        echo "#define HAVE_langinfo_h" >> defines.h
fi

#
# H6. For mkswap.c: do we have <sys/user.h> or <asm/page.h>?
#
if ./testincl "sys/user.h"; then
        echo "#define HAVE_sys_user_h" >> defines.h
else if ./testincl "asm/page.h"; then
        echo "#define HAVE_asm_page_h" >> defines.h
fi fi

#
# H7. For nfsmount.c: do we have <rpcsvc/nfs_prot.h>?
#
if ./testincl "rpcsvc/nfs_prot.h"; then
	echo "#define HAVE_rpcsvc_nfs_prot_h" >> defines.h
fi

#
# H8. For nfsmount.h: do we have <asm/types.h>?
#
if ./testincl "asm/types.h"; then
        echo "#define HAVE_asm_types_h" >> defines.h
fi

#
# H9. For raw.c: do we have <linux/raw.h>?
#
if ./testincl "linux/raw.h"; then
        echo "HAVE_RAW_H=yes" >> make_include
fi


#
# Find out about the existence of functions
#

#
# F1. For mount/nfsmount.c: is inet_aton() available?
#
echo "
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int main(int a, char **v){
  if (a == -1)	/* false */
	inet_aton((const char *) 0, (struct in_addr *) 0);
  exit(0);
}
" > conftest.c
eval $compile
if test -s conftest; then
	echo "#define HAVE_inet_aton" >> defines.h
	echo "You have inet_aton()"
else
	echo "You don't have inet_aton()"
fi
rm -f conftest conftest.c

#
# F2. For mkswap.c: is fsync() available?
#
echo "
#include <unistd.h>
int main(int a, char **v){
  if (a == -1)  /* false */
    fsync(0);
  exit(0);
}
" > conftest.c
eval $compile
if test -s conftest; then
	echo "#define HAVE_fsync" >> defines.h
	echo "You have fsync()"
else
	echo "You don't have fsync()"
fi
rm -f conftest conftest.c

#
# F3. For agetty.c: is getdomainname() available?
#
echo "
#include <unistd.h>
int main(int a, char **v){
  char buf[1];
  if (a == -1)  /* false */
    getdomainname(buf, sizeof buf);
  exit(0);
}
" > conftest.c
eval $compile
if test -s conftest; then
        echo "#define HAVE_getdomainname" >> defines.h
        echo "You have getdomainname()"
else
        echo "You don't have getdomainname()"
fi
rm -f conftest conftest.c

#
# F4. For hwclock/kd.c: do we have nanosleep?
#
echo "
#include <time.h>
int main () {
  struct timespec sleep = { 0, 1 };
  nanosleep( &sleep, NULL );
  exit(0);
}
" > conftest.c
eval $compile
if test -s conftest; then
	echo "#define HAVE_nanosleep" >> defines.h
	echo "You have nanosleep()"
else
	echo "You don't have nanosleep()"
fi
rm -f conftest conftest.c

#
# F5. For mkswap.c: do we have personality()?
#
echo "
int main () {
  extern int personality(unsigned long);
  personality(0);
  exit(0);
}
" > conftest.c
eval $compile
if test -s conftest; then
	echo "#define HAVE_personality" >> defines.h
	echo "You have personality()"
else
	echo "You don't have personality()"
fi
rm -f conftest conftest.c

#
# F6. For agetty.c: is updwtmp() available?
#
echo '
#include <string.h>
#include <utmp.h>
int main(int a, char **v){
  struct  utmp ut;
  memset (&ut, 0, sizeof(ut));
  if (a == -1)  /* false */
    updwtmp("/nowhere/wtmp", &ut);
  exit(0);
}
' > conftest.c
eval $compile
if test -s conftest; then
        echo "#define HAVE_updwtmp" >> defines.h
        echo "You have updwtmp()"
else
        echo "You don't have updwtmp()"
fi
rm -f conftest conftest.c

#
# F7. For pg.c: are fseeko() and ftello() available?
#
echo '
#include <stdio.h>
int main(int a, char **v){
  fseeko(stdout, 0, 0);
  ftello(stdout);
  exit(0);
}
' > conftest.c
eval $compile
if test -s conftest; then
        echo "#define HAVE_fseeko" >> defines.h
        echo "You have fseeko()"
else
        echo "You don't have fseeko()"
fi
rm -f conftest conftest.c

#
# F8. For fsck.cramfs.c: is lchown() available?
#
echo '
#include <sys/types.h>
#include <unistd.h>
int main(int a, char **v){
  lchown("nowhere",0,0);
  exit(0);
}
' > conftest.c
gccout=`eval $compile_with_warnings | grep "lchown is not implemented"`
if test -s conftest -a -z "$gccout"; then
        echo "#define HAVE_lchown" >> defines.h
        echo "You have lchown()"
else
        echo "You don't have lchown()"
fi
rm -f conftest conftest.c

#
# 1. cytune.c may need struct tq_struct
#
echo "
#include <sys/types.h>
#include <linux/cyclades.h>
int main(){ exit(0); }
" > conftest.c
eval $compile
if test -s conftest; then
	echo "You don't need <linux/tqueue.h>"
else
	echo "#define NEED_tqueue_h" >> defines.h
	echo "You need <linux/tqueue.h>"
fi
rm -f conftest conftest.c

#
# 2. How is [n]curses installed?
#
test_curses_h=0
have_ncurses=1
if ! ./testincl "term.h"; then
	have_ncurses=0
elif ./testincl -q "ncurses/curses.h"; then
	echo "HAVE_NCURSES=yes" >> make_include
	echo "CURSESFLAGS=-I/usr/include/ncurses -DNCH=0" >> make_include
	echo "You have ncurses. Using <ncurses/curses.h>."
elif ./testincl -q "ncurses.h"; then
	echo "HAVE_NCURSES=yes" >> make_include
	echo "CURSESFLAGS=-DNCH=1" >> make_include
	echo "You have ncurses. Using <ncurses.h>."
elif [ -f /usr/local/include/ncurses.h ]; then
	echo "HAVE_NCURSES=yes" >> make_include
	echo "CURSESFLAGS=-I/usr/local/include -DNCH=1" >> make_include
	echo "You have ncurses. Using /usr/local/include/ncurses.h."
elif ./testincl -q "curses.h"; then
	test_curses_h=1
else
	have_ncurses=0
fi
#
# If we found a curses.h, test whether it is ncurses
# (It should define __NCURSES_H and NCURSES_VERSION and NCURSES_CONST ...)
#
if [ $test_curses_h = 1 ]; then
  echo "
  #include <curses.h>
  int main(){ char *c = NCURSES_VERSION; exit(0); }
  " > conftest.c
  eval $compile
  if test -s conftest; then
	echo "HAVE_NCURSES=yes" >> make_include
	echo "CURSESFLAGS=-DNCH=0" >> make_include
	echo "You have ncurses. Using <curses.h>."
  else
	have_ncurses=0
  fi
  rm -f conftest conftest.c
fi

if [ $have_ncurses = 0 ]; then
	echo "HAVE_NCURSES=no" >> make_include
	echo "You don't have ncurses - I will not make ul and setterm."
else
	echo "LIBCURSES=-lncurses" >> make_include
fi

#
# 3. Some systems have /usr/lib/termcap.so -> /usr/lib/termcap.so.2
# where however the latter file does not exist. When termcap does
# not exist, we can try to compile more with curses instead.
#
echo '
#include <termcap.h>
int main(){ exit(0); tgetnum("li"); }
' > conftest.c
LIBS=-ltermcap
eval $compile
LIBS=
if test -s conftest; then
	echo "#define HAVE_termcap" >> defines.h
	echo "HAVE_TERMCAP=yes" >> make_include
	echo "LIBTERMCAP=-ltermcap" >> make_include
	echo "You have termcap"
else
	echo "HAVE_TERMCAP=no" >> make_include
	if [ $have_ncurses = 0 ]; then
		echo "You don't have termcap - I will not make more."
	else
		echo "You don't have termcap"
	fi
fi
rm -f conftest conftest.c

#
# 4. Do we need -lcrypt?
#
echo '
#define _XOPEN_SOURCE
#include <unistd.h>
int main(){ char *c = crypt("abc","pw"); exit(0); }
' > conftest.c
eval $compile
if test -s conftest; then
	echo "NEED_LIBCRYPT=no" >> make_include
	echo "You don't need -lcrypt"
else
	echo "NEED_LIBCRYPT=yes" >> make_include
	echo "You need -lcrypt"
fi
rm -f conftest conftest.c

#
# 5. Does static compilation work?
#
echo "
int main(){ return 0; }
" > conftest.c
eval $static_compile
if test -s conftest; then
	: OK, nothing special
else
	echo "CAN_DO_STATIC=no" >> make_include
	echo "Strange... Static compilation fails here."
fi
rm -f conftest.c conftest

#
# 6. For lib/nls.h: do we have <libintl.h> and gettext() ?
#
echo '
#include <libintl.h>
int main(int a, char **v){
  if (a == -1)  /* false */
        gettext("There is no gettext man page\n");
  exit(0);
}
' > conftest.c
eval $compile
if test -s conftest; then
        echo '#define HAVE_libintl_h' >> defines.h
        echo "You have <libintl.h> and gettext()"
        echo '#define MAY_ENABLE_NLS' >> defines.h
        MAY_ENABLE_NLS=yes
else
        echo "You don't have native language support"
        MAY_ENABLE_NLS=no
fi
rm -f conftest conftest.c


#
# 7. Does xgettext exist and take the option --foreign-user?
#
# We use the bash builtin "type" here.
# I don't see an easy way to avoid it.
# Many Linux systems do not have "which". Maybe "env" can be used.
# Writing /usr/bin/xgettext is no good: one may have xgettext elsewhere.
#
if (test $MAY_ENABLE_NLS = yes && type xgettext > /dev/null 2>&1); then
	msg=`xgettext --foreign-user 2>&1 | grep unrecognized`
	if test -n "$msg"; then
		echo "FOREIGN = " >> make_include
	else
		echo "FOREIGN = --foreign-user" >> make_include
	fi
	echo "HAVE_XGETTEXT=yes" >> make_include
else
	echo "HAVE_XGETTEXT=no" >> make_include
fi


#
# 8. For err.c: do we have __progname?
# [make sure gcc -O does not optimize the access away]
#
echo "
#include <stdio.h>
extern char *__progname;
int main(){ printf(__progname); exit(0); }
" > conftest.c
eval $compile
if test -s conftest; then
        echo "#define HAVE_progname" >> defines.h
        echo "You have __progname"
else
        echo "You don't have __progname"
fi
rm -f conftest conftest.c

#
# 9. For script.c: do we have <pty.h> and openpty()?
#
echo "
#include <pty.h>
int main(){ exit(0); openpty(0, 0, 0, 0, 0); }
" > conftest.c
LIBS=-lutil
eval $compile
LIBS=
if test -s conftest; then
	echo "HAVE_OPENPTY=yes" >> make_include
	echo "#define HAVE_openpty" >> defines.h
	echo "You have <pty.h> and openpty()"
else
	echo "You don't have <pty.h> and openpty()"
fi
rm -f conftest conftest.c

#
# 10. For lib/widechar.h: do we have wide character support?
# [Do we have the headers <wchar.h>, <wctype.h>, the types wchar_t, wint_t
# and the fgetwc, fputwc, WEOF functions/macros?]
#
echo "
#include <wchar.h>
#include <wctype.h>
#include <stdio.h>
int main () {
  wchar_t wc;
  wint_t w;
  w = fgetwc(stdin);
  if (w == WEOF) exit(1);
  wc = w;
  fputwc(wc,stdout);
  exit(0);
}
" > conftest.c
eval $compile
if test -s conftest && ./conftest < conftest.c > /dev/null 2>/dev/null; then
        echo "#define ENABLE_WIDECHAR" >> defines.h
        echo "You have wide character support"
else
        echo "You don't have wide character support"
fi
rm -f conftest conftest.c

#
# 11. For pivot_root.c: does <linux/unistd.h> define __NR_pivot_root?
#
echo "
#include <linux/unistd.h>
int main(void)
{
    return __NR_pivot_root;
}
" >conftest.c
eval $compile
if test -s conftest; then
	echo "HAVE_PIVOT_ROOT=yes" >> make_include
	echo "You have __NR_pivot_root"
else
	echo "You don't have __NR_pivot_root"
fi
rm -f conftest conftest.c

#
# 12. For hwclock.c: does struct tm have a field tm_gmtoff?
#
echo "
#include <time.h>
#include <unistd.h>
int main(int a, char **v)
{
    struct tm *tm = localtime(0);
    if (a == -1)  /* false */
        sleep(tm->tm_gmtoff);
    exit(0);
}
" >conftest.c
eval $compile
if test -s conftest; then
        echo "#define HAVE_tm_gmtoff" >> defines.h
        echo "You have a tm_gmtoff field in struct tm"
else
        echo "You don't have a tm_gmtoff field in struct tm"
fi
rm -f conftest conftest.c

#
# 13. For nfsmount: does the output of rpcgen compile?
#
# On some systems the output of rpcgen compiles with warnings
# Here we conclude "Your rpcgen output does not compile"
# and use pregenerated files. If one wishes to use rpcgen anyway,
# just add the line "HAVE_GOOD_RPC=yes" to make_include.
#
rm -f conftest conftestx.c conftestl.c conftest.h conftest.x
rm -f conftestx.o conftestl.o
echo "
#ifdef RPC_CLNT
%#include <string.h>            /* for memset() */
#endif
%#include <asm/types.h>
typedef opaque fhandle[1];
union fhstatus switch (unsigned fhs_status) {
case 0:
        fhandle fhs_fhandle;
default:
        void;
};
typedef string dirpath<1024>;
struct ppathcnf {
    short   pc_mask[2];
};

program MOUNTPROG {
    version MOUNTVERS {
	fhstatus
	MOUNTPROC_MNT(dirpath) = 1;
    } = 2;
} = 100005;
" > conftest.x
if rpcgen -h -o conftest.h conftest.x 2> conferrs && \
   rpcgen -c -o conftestx.c conftest.x 2>> conferrs && \
   rpcgen -l -o conftestl.c conftest.x 2>> conferrs && \
   cc -c conftestx.c 2>> conferrs && cc -c conftestl.c 2>> conferrs && \
   test ! -s conferrs
then
        echo "HAVE_GOOD_RPC=yes" >> make_include
        echo "Your rpcgen seems to work"
else
        echo "Your rpcgen output does not compile - using pregenerated code"
fi
rm -f conftest conftestx.c conftestl.c conftest.h conftest.x conferrs
rm -f conftestx.o conftestl.o

#
# 14. For fsck.cramfs, mkfs.cramfs: do we have libz?
#
echo '
#include <zlib.h>
int main(){ exit(0); crc32(0, 0, 0); }
' > conftest.c
LIBS=-lz
eval $compile
LIBS=
if test -s conftest; then
        echo "HAVE_ZLIB=yes" >> make_include
        echo "You have zlib"
else
        echo "HAVE_ZLIB=no" >> make_include
        echo "You don't have zlib"
fi
rm -f conftest conftest.c