2 # Configure script for util-linux - aeb, 990205
4 # We need to find out the following things:
8 # Existence of header files:
9 # H1. For fdisksunlabel.c: is there a <scsi/scsi.h>?
10 # H2. For fdisk.c: is there a <linux/blkpg.h>?
11 # H3. For kbd_rate.c: does <linux/kd.h> exist?
12 # H4. For nls.h: do we have <locale.h>?
13 # H5. For cal.c: do we have <langinfo.h>?
14 # H6. For mkswap.c: do we have <sys/user.h> or <asm/page.h>?
15 # H7. For nfsmount.c: do we have <rpcsvc/nfs_prot.h>?
16 # H8. For nfsmount.h (nfsmount_xdr.c: int32_t): do we have <asm/types.h>?
17 # H9. For raw.c: do we have <linux/raw.h>?
19 # Existence of functions:
20 # F1. For nfsmount.c: is inet_aton() available?
21 # F2. For mkswap.c: is fsync() available?
22 # F3. For agetty.c: is getdomainname() available?
23 # F4. For hwclock/kd.c: do we have nanosleep()?
24 # F5. For mkswap.c: do we have personality()?
25 # F6. For agetty.c: is updwtmp() available?
26 # F7. For pg.c: are fseeko() and ftello() available?
27 # F8. For fsck.cramfs.c: is lchown() available?
29 # 1. For sys-utils/cytune.c: do we need <linux/tqueue.h>?
30 # 2. For cfdisk, setterm, more, ul: do we have ncurses? How installed?
31 # 3. For more: do we have libtermcap?
32 # 4. For chfn, chsh, login, newgrp, passwd: do we need -lcrypt?
33 # 5. For sln: does static compilation work?
34 # 6. For lib/nls.h: do we have <libintl.h> and gettext()?
35 # 7. For xgettext: does it take the option --foreign-user?
36 # 8. For err.c: do we have __progname?
37 # 9. For script.c: do we have <pty.h> and openpty()?
38 # 10. For lib/widechar.h: do we have wide character support?
39 # 11. For pivot_root.c: does <linux/unistd.h> define __NR_pivot_root?
40 # 12. For hwclock.c: does struct tm have a field tm_gmtoff?
41 # 13. For nfsmount: does the output of rpcgen compile?
42 # 14. For fsck.cramfs, mkfs.cramfs: do we have libz?
44 rm -f make_include defines.h
48 echo configuring util-linux-
$VERSION
50 echo "VERSION=$VERSION" > make_include
51 echo '#define UTIL_LINUX_VERSION "'$VERSION'"' > defines.h
52 echo '#define util_linux_version "util-linux-'$VERSION'"' >> defines.h
57 LDFLAGS
=${LDFLAGS-"-s"}
58 echo CC
=$CC >> make_include
59 echo CFLAGS
=$CFLAGS >> make_include
60 echo LDFLAGS
=$LDFLAGS >> make_include
64 compile
='$CC $CFLAGS $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1'
65 compile_with_warnings
='$CC $CFLAGS $DEFS conftest.c -o conftest $LIBS 2>&1'
66 static_compile
='$CC -static $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1'
67 eval COMPILE
='"'$compile'"'
70 rm -f conftest.c conftest
73 # Old gcc wants options like -m486, but gcc 3.0 says
74 # `-m486' is deprecated. Use `-march=i486' or `-mcpu=i486' instead.
77 int main(){ exit(0); }
79 gccout
=`$CC $CFLAGS -m386 conftest.c -o conftest 2>&1 | grep "march="`
80 if test -z "$gccout"; then
81 echo "HAVE_OLD_GCC=yes" >> make_include
83 rm -f conftest conftest.c
86 # Find out about the existence of header files
90 # H1. For fdisk/fdisksunlabel.c: is <scsi/scsi.h> available?
91 # Some kernels have <scsi/scsi.h> that uses u_char
92 # But maybe there is already a typedef. Let us use a #define
95 #define u_char unsigned char
96 #include <scsi/scsi.h>
98 int main(){ exit(0); }
101 if test -s conftest
; then
102 echo "#define HAVE_scsi_h" >> defines.h
103 echo "You have <scsi/scsi.h>"
105 echo "You don't have <scsi/scsi.h>"
107 rm -f conftest conftest.c
110 # H2. For fdisk/fdisk.c: is <linux/blkpg.h> available?
112 if .
/testincl
"linux/blkpg.h"; then
113 echo "#define HAVE_blkpg_h" >> defines.h
117 # H3. Does <linux/kd.h> exist?
119 if .
/testincl
"linux/kd.h"; then
120 echo "#define HAVE_kd_h" >> defines.h
124 # H4. For lib/nls.h: do we have <locale.h>?
126 if .
/testincl
"locale.h"; then
127 echo "#define HAVE_locale_h" >> defines.h
131 # H5. For cal.c: do we have <langinfo.h>?
133 if .
/testincl
"langinfo.h"; then
134 echo "#define HAVE_langinfo_h" >> defines.h
138 # H6. For mkswap.c: do we have <sys/user.h> or <asm/page.h>?
140 if .
/testincl
"sys/user.h"; then
141 echo "#define HAVE_sys_user_h" >> defines.h
142 else if .
/testincl
"asm/page.h"; then
143 echo "#define HAVE_asm_page_h" >> defines.h
147 # H7. For nfsmount.c: do we have <rpcsvc/nfs_prot.h>?
149 if .
/testincl
"rpcsvc/nfs_prot.h"; then
150 echo "#define HAVE_rpcsvc_nfs_prot_h" >> defines.h
154 # H8. For nfsmount.h: do we have <asm/types.h>?
156 if .
/testincl
"asm/types.h"; then
157 echo "#define HAVE_asm_types_h" >> defines.h
161 # H9. For raw.c: do we have <linux/raw.h>?
163 if .
/testincl
"linux/raw.h"; then
164 echo "HAVE_RAW_H=yes" >> make_include
169 # Find out about the existence of functions
173 # F1. For mount/nfsmount.c: is inet_aton() available?
176 #include <sys/socket.h>
177 #include <netinet/in.h>
178 #include <arpa/inet.h>
179 int main(int a, char **v){
180 if (a == -1) /* false */
181 inet_aton((const char *) 0, (struct in_addr *) 0);
186 if test -s conftest
; then
187 echo "#define HAVE_inet_aton" >> defines.h
188 echo "You have inet_aton()"
190 echo "You don't have inet_aton()"
192 rm -f conftest conftest.c
195 # F2. For mkswap.c: is fsync() available?
199 int main(int a, char **v){
200 if (a == -1) /* false */
206 if test -s conftest
; then
207 echo "#define HAVE_fsync" >> defines.h
208 echo "You have fsync()"
210 echo "You don't have fsync()"
212 rm -f conftest conftest.c
215 # F3. For agetty.c: is getdomainname() available?
219 int main(int a, char **v){
221 if (a == -1) /* false */
222 getdomainname(buf, sizeof buf);
227 if test -s conftest
; then
228 echo "#define HAVE_getdomainname" >> defines.h
229 echo "You have getdomainname()"
231 echo "You don't have getdomainname()"
233 rm -f conftest conftest.c
236 # F4. For hwclock/kd.c: do we have nanosleep?
241 struct timespec sleep = { 0, 1 };
242 nanosleep( &sleep, NULL );
247 if test -s conftest
; then
248 echo "#define HAVE_nanosleep" >> defines.h
249 echo "You have nanosleep()"
251 echo "You don't have nanosleep()"
253 rm -f conftest conftest.c
256 # F5. For mkswap.c: do we have personality()?
260 extern int personality(unsigned long);
266 if test -s conftest
; then
267 echo "#define HAVE_personality" >> defines.h
268 echo "You have personality()"
270 echo "You don't have personality()"
272 rm -f conftest conftest.c
275 # F6. For agetty.c: is updwtmp() available?
280 int main(int a, char **v){
282 memset (&ut, 0, sizeof(ut));
283 if (a == -1) /* false */
284 updwtmp("/nowhere/wtmp", &ut);
289 if test -s conftest
; then
290 echo "#define HAVE_updwtmp" >> defines.h
291 echo "You have updwtmp()"
293 echo "You don't have updwtmp()"
295 rm -f conftest conftest.c
298 # F7. For pg.c: are fseeko() and ftello() available?
302 int main(int a, char **v){
303 fseeko(stdout, 0, 0);
309 if test -s conftest
; then
310 echo "#define HAVE_fseeko" >> defines.h
311 echo "You have fseeko()"
313 echo "You don't have fseeko()"
315 rm -f conftest conftest.c
318 # F8. For fsck.cramfs.c: is lchown() available?
321 #include <sys/types.h>
323 int main(int a, char **v){
324 lchown("nowhere",0,0);
328 gccout
=`eval $compile_with_warnings | grep "lchown is not implemented"`
329 if test -s conftest
-a -z "$gccout"; then
330 echo "#define HAVE_lchown" >> defines.h
331 echo "You have lchown()"
333 echo "You don't have lchown()"
335 rm -f conftest conftest.c
338 # 1. cytune.c may need struct tq_struct
341 #include <sys/types.h>
342 #include <linux/cyclades.h>
343 int main(){ exit(0); }
346 if test -s conftest
; then
347 echo "You don't need <linux/tqueue.h>"
349 echo "#define NEED_tqueue_h" >> defines.h
350 echo "You need <linux/tqueue.h>"
352 rm -f conftest conftest.c
355 # 2. How is [n]curses installed?
359 if ! .
/testincl
"term.h"; then
361 elif .
/testincl
-q "ncurses/curses.h"; then
362 echo "HAVE_NCURSES=yes" >> make_include
363 echo "CURSESFLAGS=-I/usr/include/ncurses -DNCH=0" >> make_include
364 echo "You have ncurses. Using <ncurses/curses.h>."
365 elif .
/testincl
-q "ncurses.h"; then
366 echo "HAVE_NCURSES=yes" >> make_include
367 echo "CURSESFLAGS=-DNCH=1" >> make_include
368 echo "You have ncurses. Using <ncurses.h>."
369 elif [ -f /usr
/local
/include
/ncurses.h
]; then
370 echo "HAVE_NCURSES=yes" >> make_include
371 echo "CURSESFLAGS=-I/usr/local/include -DNCH=1" >> make_include
372 echo "You have ncurses. Using /usr/local/include/ncurses.h."
373 elif .
/testincl
-q "curses.h"; then
379 # If we found a curses.h, test whether it is ncurses
380 # (It should define __NCURSES_H and NCURSES_VERSION and NCURSES_CONST ...)
382 if [ $test_curses_h = 1 ]; then
385 int main(){ char *c = NCURSES_VERSION; exit(0); }
388 if test -s conftest
; then
389 echo "HAVE_NCURSES=yes" >> make_include
390 echo "CURSESFLAGS=-DNCH=0" >> make_include
391 echo "You have ncurses. Using <curses.h>."
395 rm -f conftest conftest.c
398 if [ $have_ncurses = 0 ]; then
399 echo "HAVE_NCURSES=no" >> make_include
400 echo "You don't have ncurses - I will not make ul and setterm."
402 echo "LIBCURSES=-lncurses" >> make_include
406 # 3. Some systems have /usr/lib/termcap.so -> /usr/lib/termcap.so.2
407 # where however the latter file does not exist. When termcap does
408 # not exist, we can try to compile more with curses instead.
412 int main(){ exit(0); tgetnum("li"); }
417 if test -s conftest
; then
418 echo "#define HAVE_termcap" >> defines.h
419 echo "HAVE_TERMCAP=yes" >> make_include
420 echo "LIBTERMCAP=-ltermcap" >> make_include
421 echo "You have termcap"
423 echo "HAVE_TERMCAP=no" >> make_include
424 if [ $have_ncurses = 0 ]; then
425 echo "You don't have termcap - I will not make more."
427 echo "You don't have termcap"
430 rm -f conftest conftest.c
433 # 4. Do we need -lcrypt?
436 #define _XOPEN_SOURCE
438 int main(){ char *c = crypt("abc","pw"); exit(0); }
441 if test -s conftest
; then
442 echo "NEED_LIBCRYPT=no" >> make_include
443 echo "You don't need -lcrypt"
445 echo "NEED_LIBCRYPT=yes" >> make_include
446 echo "You need -lcrypt"
448 rm -f conftest conftest.c
451 # 5. Does static compilation work?
454 int main(){ return 0; }
457 if test -s conftest
; then
458 : OK
, nothing special
460 echo "CAN_DO_STATIC=no" >> make_include
461 echo "Strange... Static compilation fails here."
463 rm -f conftest.c conftest
466 # 6. For lib/nls.h: do we have <libintl.h> and gettext() ?
470 int main(int a, char **v){
471 if (a == -1) /* false */
472 gettext("There is no gettext man page\n");
477 if test -s conftest
; then
478 echo '#define HAVE_libintl_h' >> defines.h
479 echo "You have <libintl.h> and gettext()"
480 echo '#define MAY_ENABLE_NLS' >> defines.h
483 echo "You don't have native language support"
486 rm -f conftest conftest.c
490 # 7. Does xgettext exist and take the option --foreign-user?
492 # We use the bash builtin "type" here.
493 # I don't see an easy way to avoid it.
494 # Many Linux systems do not have "which". Maybe "env" can be used.
495 # Writing /usr/bin/xgettext is no good: one may have xgettext elsewhere.
497 if (test $MAY_ENABLE_NLS = yes && type xgettext
> /dev
/null
2>&1); then
498 msg
=`xgettext --foreign-user 2>&1 | grep unrecognized`
499 if test -n "$msg"; then
500 echo "FOREIGN = " >> make_include
502 echo "FOREIGN = --foreign-user" >> make_include
504 echo "HAVE_XGETTEXT=yes" >> make_include
506 echo "HAVE_XGETTEXT=no" >> make_include
511 # 8. For err.c: do we have __progname?
512 # [make sure gcc -O does not optimize the access away]
516 extern char *__progname;
517 int main(){ printf(__progname); exit(0); }
520 if test -s conftest
; then
521 echo "#define HAVE_progname" >> defines.h
522 echo "You have __progname"
524 echo "You don't have __progname"
526 rm -f conftest conftest.c
529 # 9. For script.c: do we have <pty.h> and openpty()?
533 int main(){ exit(0); openpty(0, 0, 0, 0, 0); }
538 if test -s conftest
; then
539 echo "HAVE_OPENPTY=yes" >> make_include
540 echo "#define HAVE_openpty" >> defines.h
541 echo "You have <pty.h> and openpty()"
543 echo "You don't have <pty.h> and openpty()"
545 rm -f conftest conftest.c
548 # 10. For lib/widechar.h: do we have wide character support?
549 # [Do we have the headers <wchar.h>, <wctype.h>, the types wchar_t, wint_t
550 # and the fgetwc, fputwc, WEOF functions/macros?]
560 if (w == WEOF) exit(1);
567 if test -s conftest
&& .
/conftest
< conftest.c
> /dev
/null
2>/dev
/null
; then
568 echo "#define ENABLE_WIDECHAR" >> defines.h
569 echo "You have wide character support"
571 echo "You don't have wide character support"
573 rm -f conftest conftest.c
576 # 11. For pivot_root.c: does <linux/unistd.h> define __NR_pivot_root?
579 #include <linux/unistd.h>
582 return __NR_pivot_root;
586 if test -s conftest
; then
587 echo "HAVE_PIVOT_ROOT=yes" >> make_include
588 echo "You have __NR_pivot_root"
590 echo "You don't have __NR_pivot_root"
592 rm -f conftest conftest.c
595 # 12. For hwclock.c: does struct tm have a field tm_gmtoff?
600 int main(int a, char **v)
602 struct tm *tm = localtime(0);
603 if (a == -1) /* false */
604 sleep(tm->tm_gmtoff);
609 if test -s conftest
; then
610 echo "#define HAVE_tm_gmtoff" >> defines.h
611 echo "You have a tm_gmtoff field in struct tm"
613 echo "You don't have a tm_gmtoff field in struct tm"
615 rm -f conftest conftest.c
618 # 13. For nfsmount: does the output of rpcgen compile?
620 # On some systems the output of rpcgen compiles with warnings
621 # Here we conclude "Your rpcgen output does not compile"
622 # and use pregenerated files. If one wishes to use rpcgen anyway,
623 # just add the line "HAVE_GOOD_RPC=yes" to make_include.
625 rm -f conftest conftestx.c conftestl.c conftest.h conftest.x
626 rm -f conftestx.o conftestl.o
629 %#include <string.h> /* for memset() */
631 %#include <asm/types.h>
632 typedef opaque fhandle[1];
633 union fhstatus switch (unsigned fhs_status) {
639 typedef string dirpath<1024>;
647 MOUNTPROC_MNT(dirpath) = 1;
651 if rpcgen
-h -o conftest.h conftest.x
2> conferrs
&& \
652 rpcgen
-c -o conftestx.c conftest.x
2>> conferrs
&& \
653 rpcgen
-l -o conftestl.c conftest.x
2>> conferrs
&& \
654 cc
-c conftestx.c
2>> conferrs
&& cc
-c conftestl.c
2>> conferrs
&& \
657 echo "HAVE_GOOD_RPC=yes" >> make_include
658 echo "Your rpcgen seems to work"
660 echo "Your rpcgen output does not compile - using pregenerated code"
662 rm -f conftest conftestx.c conftestl.c conftest.h conftest.x conferrs
663 rm -f conftestx.o conftestl.o
666 # 14. For fsck.cramfs, mkfs.cramfs: do we have libz?
670 int main(){ exit(0); crc32(0, 0, 0); }
675 if test -s conftest
; then
676 echo "HAVE_ZLIB=yes" >> make_include
679 echo "HAVE_ZLIB=no" >> make_include
680 echo "You don't have zlib"
682 rm -f conftest conftest.c