]> git.ipfire.org Git - thirdparty/util-linux.git/blame - configure
Imported from util-linux-2.10s tarball.
[thirdparty/util-linux.git] / configure
CommitLineData
7eda085c
KZ
1#!/bin/sh
2# Configure script for util-linux - aeb, 990205
3#
4# We need to find out the following things:
5#
66ee8158
KZ
6# Existence of header files:
7# H1. For fdisksunlabel.c: is there a <scsi/scsi.h>?
8# H2. For fdisk.c: is there a <linux/blkpg.h>?
9# H3. For kbd_rate.c: does <linux/kd.h> exist?
10# H4. For nls.h: do we have <locale.h>?
11# H5. For cal.c: do we have <langinfo.h>?
12# H6. For mkswap.c: do we have <asm/page.h>?
13# H7. For nfsmount.h (nfsmount_xdr.c: int32_t): do we have <asm/types.h>?
14#
15# Existence of functions:
16# F1. For nfsmount.c: is inet_aton() available?
17# F2. For mkswap.c: is fsync() available?
18# F3. For agetty.c: is getdomainname() available?
19# F4. For hwclock/kd.c: do we have nanosleep()?
20# F5. For mkswap.c: do we have personality()?
21#
22# 1. For sys-utils/cytune.c: do we need <linux/tqueue.h>?
23# 2. For cfdisk, setterm, more, ul: do we have ncurses? How installed?
24# 3. For more: do we have libtermcap?
25# 4. For chfn, chsh, login, newgrp, passwd: do we need -lcrypt?
26# 5. For sln: does static compilation work?
27# 6. For lib/nls.h: do we have <libintl.h> and gettext()?
28# 7. For xgettext: does it take the option --foreign-user?
29# 8. For err.c: do we have __progname?
30# 9. For script.c: do we have <pty.h> and openpty()?
31# 10. For lib/widechar.h: do we have wide character support?
32# 11. For pivot_root.c: does <linux/unistd.h> define __NR_pivot_root?
33# 12. For hwclock.c: does struct tm have a field tm_gmtoff?
34# 13. For nfsmount: does the output of rpcgen compile?
eb63b9b8
KZ
35
36rm -f make_include defines.h
37
38VERSION=`cat VERSION`
39echo
40echo configuring util-linux-$VERSION
41echo
42echo "VERSION=$VERSION" > make_include
43echo '#define UTIL_LINUX_VERSION "'$VERSION'"' > defines.h
44echo '#define util_linux_version "util-linux-'$VERSION'"' >> defines.h
45echo >> defines.h
7eda085c 46
7eda085c
KZ
47CC=${CC-cc}
48CFLAGS=${CFLAGS-"-O"}
66ee8158
KZ
49LDFLAGS=${LDFLAGS-"-s"}
50echo CC=$CC >> make_include
51echo CFLAGS=$CFLAGS >> make_include
52echo LDFLAGS=$LDFLAGS >> make_include
53
7eda085c
KZ
54DEFS=
55LIBS=
56compile='$CC $CFLAGS $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1'
57static_compile='$CC -static $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1'
eb63b9b8
KZ
58eval COMPILE='"'$compile'"'
59export COMPILE
7eda085c 60
eb63b9b8 61rm -f conftest.c conftest
7eda085c 62
66ee8158
KZ
63
64#
65# Find out about the existence of header files
66#
67
7eda085c 68#
66ee8158
KZ
69# H1. For fdisk/fdisksunlabel.c: is <scsi/scsi.h> available?
70# Some kernels have <scsi/scsi.h> that uses u_char
71# But maybe there is already a typedef. Let us use a #define
72#
73echo "
74#define u_char unsigned char
75#include <scsi/scsi.h>
76#undef u_char
77main(){ exit(0); }
78" > conftest.c
79eval $compile
80if test -s conftest && ./conftest 2>/dev/null; then
81 echo "#define HAVE_scsi_h" >> defines.h
82 echo "You have <scsi/scsi.h>"
83else
84 echo "You don't have <scsi/scsi.h>"
85fi
86rm -f conftest conftest.c
87
88#
89# H2. For fdisk/fdisk.c: is <linux/blkpg.h> available?
90#
91if ./testincl "linux/blkpg.h"; then
92 echo "#define HAVE_blkpg_h" >> defines.h
93fi
94
95#
96# H3. Does <linux/kd.h> exist?
97#
98if ./testincl "linux/kd.h"; then
99 echo "#define HAVE_kd_h" >> defines.h
100fi
101
102#
103# H4. For lib/nls.h: do we have <locale.h>?
104#
105if ./testincl "locale.h"; then
106 echo "#define HAVE_locale_h" >> defines.h
107fi
108
109#
110# H5. For cal.c: do we have <langinfo.h>?
111#
112if ./testincl "langinfo.h"; then
113 echo "#define HAVE_langinfo_h" >> defines.h
114fi
115
116#
117# H6. For mkswap.c: do we have <asm/page.h>?
118#
119if ./testincl "asm/page.h"; then
120 echo "#define HAVE_asm_page_h" >> defines.h
121fi
122
123#
124# H7. For nfsmount.h: do we have <asm/types.h>?
125#
126if ./testincl "asm/types.h"; then
127 echo "#define HAVE_asm_types_h" >> defines.h
128fi
129
130
131#
132# Find out about the existence of functions
133#
134
135#
136# F1. For mount/nfsmount.c: is inet_aton() available?
7eda085c
KZ
137#
138echo "
139#include <sys/socket.h>
140#include <netinet/in.h>
141#include <arpa/inet.h>
142main(int a, char **v){
143 if (a == -1) /* false */
144 inet_aton((const char *) 0, (struct in_addr *) 0);
145 exit(0);
146}
147" > conftest.c
148eval $compile
149if test -s conftest && ./conftest 2>/dev/null; then
150 echo "#define HAVE_inet_aton" >> defines.h
151 echo "You have inet_aton()"
152else
153 echo "You don't have inet_aton()"
154fi
155rm -f conftest conftest.c
156
157#
66ee8158 158# F2. For mkswap.c: is fsync() available?
7eda085c
KZ
159#
160echo "
66ee8158
KZ
161#include <unistd.h>
162main(int a, char **v){
163 if (a == -1) /* false */
164 fsync(0);
165 exit(0);
166}
7eda085c
KZ
167" > conftest.c
168eval $compile
169if test -s conftest && ./conftest 2>/dev/null; then
66ee8158
KZ
170 echo "#define HAVE_fsync" >> defines.h
171 echo "You have fsync()"
7eda085c 172else
66ee8158 173 echo "You don't have fsync()"
7eda085c
KZ
174fi
175rm -f conftest conftest.c
176
177#
66ee8158 178# F3. For agetty.c: is getdomainname() available?
7eda085c 179#
66ee8158
KZ
180echo "
181#include <unistd.h>
182main(int a, char **v){
183 char buf[1];
184 if (a == -1) /* false */
185 getdomainname(buf, sizeof buf);
186 exit(0);
187}
188" > conftest.c
189eval $compile
190if test -s conftest && ./conftest 2>/dev/null; then
191 echo "#define HAVE_getdomainname" >> defines.h
192 echo "You have getdomainname()"
193else
194 echo "You don't have getdomainname()"
7eda085c 195fi
66ee8158 196rm -f conftest conftest.c
7eda085c
KZ
197
198#
66ee8158
KZ
199# F4. For hwclock/kd.c: do we have nanosleep?
200#
201echo "
202#include <time.h>
203int main () {
204 struct timespec sleep = { 0, 1 };
205 nanosleep( &sleep, NULL );
206 exit(0);
207}
208" > conftest.c
209eval $compile
210if test -s conftest && ./conftest 2>/dev/null; then
211 echo "#define HAVE_nanosleep" >> defines.h
212 echo "You have nanosleep()"
213else
214 echo "You don't have nanosleep()"
215fi
216rm -f conftest conftest.c
217
218#
219# F5. For mkswap.c: do we have personality()?
220#
221echo "
222int main () {
223 extern int personality(unsigned long);
224 personality(0);
225 exit(0);
226}
227" > conftest.c
228eval $compile
229if test -s conftest && ./conftest 2>/dev/null; then
230 echo "#define HAVE_personality" >> defines.h
231 echo "You have personality()"
232else
233 echo "You don't have personality()"
234fi
235rm -f conftest conftest.c
236
237
238#
239# 1. cytune.c may need struct tq_struct
7eda085c
KZ
240#
241echo "
242#include <sys/types.h>
243#include <linux/cyclades.h>
244main(){ exit(0); }
245" > conftest.c
246eval $compile
247if test -s conftest && ./conftest 2>/dev/null; then
248 echo "You don't need <linux/tqueue.h>"
249else
250 echo "#define NEED_tqueue_h" >> defines.h
251 echo "You need <linux/tqueue.h>"
252fi
253rm -f conftest conftest.c
254
255#
66ee8158 256# 2. How is [n]curses installed?
7eda085c
KZ
257#
258test_curses_h=0
259have_ncurses=1
eb63b9b8
KZ
260if ! ./testincl "term.h"; then
261 have_ncurses=0
262elif ./testincl -q "ncurses/curses.h"; then
7eda085c
KZ
263 echo "HAVE_NCURSES=yes" >> make_include
264 echo "CURSESFLAGS=-I/usr/include/ncurses -DNCH=0" >> make_include
265 echo "You have ncurses. Using <ncurses/curses.h>."
eb63b9b8 266elif ./testincl -q "ncurses.h"; then
7eda085c
KZ
267 echo "HAVE_NCURSES=yes" >> make_include
268 echo "CURSESFLAGS=-DNCH=1" >> make_include
269 echo "You have ncurses. Using <ncurses.h>."
270elif [ -f /usr/local/include/ncurses.h ]; then
271 echo "HAVE_NCURSES=yes" >> make_include
272 echo "CURSESFLAGS=-I/usr/local/include -DNCH=1" >> make_include
273 echo "You have ncurses. Using /usr/local/include/ncurses.h."
eb63b9b8 274elif ./testincl -q "curses.h"; then
7eda085c
KZ
275 test_curses_h=1
276else
277 have_ncurses=0
278fi
279#
280# If we found a curses.h, test whether it is ncurses
281# (It should define __NCURSES_H and NCURSES_VERSION and NCURSES_CONST ...)
282#
283if [ $test_curses_h = 1 ]; then
284 echo "
285 #include <curses.h>
286 main(){ char *c = NCURSES_VERSION; exit(0); }
287 " > conftest.c
288 eval $compile
289 if test -s conftest && ./conftest 2>/dev/null; then
290 echo "HAVE_NCURSES=yes" >> make_include
291 echo "CURSESFLAGS=-DNCH=0" >> make_include
292 echo "You have ncurses. Using <curses.h>."
293 else
294 have_ncurses=0
295 fi
296 rm -f conftest conftest.c
297fi
298
299if [ $have_ncurses = 0 ]; then
300 echo "HAVE_NCURSES=no" >> make_include
301 echo "You don't have ncurses - I will not make ul and setterm."
302else
303 echo "LIBCURSES=-lncurses" >> make_include
304fi
305
306#
307# Some systems have /usr/lib/termcap.so -> /usr/lib/termcap.so.2
308# where however the latter file does not exist. When termcap does
309# not exist, we can try to compile more with curses instead.
310#
311echo '
312#include <termcap.h>
313main(){ exit(0); tgetnum("li"); }
314' > conftest.c
315LIBS=-ltermcap
316eval $compile
317LIBS=
318if test -s conftest && ./conftest 2>/dev/null; then
319 echo "#define HAVE_termcap" >> defines.h
320 echo "LIBTERMCAP=-ltermcap" >> make_include
321 echo "You have termcap"
322else
323 echo "HAVE_TERMCAP=no" >> make_include
eb63b9b8
KZ
324 if [ $have_ncurses = 0 ]; then
325 echo "You don't have termcap - I will not make more."
326 else
327 echo "You don't have termcap"
328 fi
7eda085c
KZ
329fi
330rm -f conftest conftest.c
331
332#
66ee8158 333# 4. Do we need -lcrypt?
7eda085c
KZ
334#
335echo '
336#define _XOPEN_SOURCE
337#include <unistd.h>
338main(){ char *c = crypt("abc","pw"); exit(0); }
339' > conftest.c
340eval $compile
341if test -s conftest && ./conftest 2>/dev/null; then
342 echo "NEED_LIBCRYPT=no" >> make_include
343 echo "You don't need -lcrypt"
344else
345 echo "NEED_LIBCRYPT=yes" >> make_include
346 echo "You need -lcrypt"
347fi
348rm -f conftest conftest.c
349
350#
66ee8158 351# 5. Does static compilation work?
7eda085c
KZ
352#
353echo "
354main(){ return 0; }
355" > conftest.c
356eval $static_compile
357if test -s conftest && ./conftest 2>/dev/null; then
358 : OK, nothing special
359else
360 echo "CAN_DO_STATIC=no" >> make_include
361 echo "Strange... Static compilation fails here."
362fi
66ee8158 363rm -f conftest.c conftest
7eda085c
KZ
364
365#
66ee8158 366# 6. For lib/nls.h: do we have <libintl.h> and gettext() ?
7eda085c
KZ
367#
368echo '
369#include <libintl.h>
370main(int a, char **v){
371 if (a == -1) /* false */
372 gettext("There is no gettext man page\n");
373 exit(0);
374}
375' > conftest.c
376eval $compile
377if test -s conftest && ./conftest 2>/dev/null; then
378 echo '#define HAVE_libintl_h' >> defines.h
379 echo "You have <libintl.h> and gettext()"
380 echo '#define ENABLE_NLS' >> defines.h
381 echo "Assuming that you want to enable NLS support."
eb63b9b8 382 echo "(Otherwise, edit defines.h and remove the line with ENABLE_NLS)"
7eda085c
KZ
383 ENABLE_NLS=yes
384else
385 echo "You don't have <libintl.h>"
386 ENABLE_NLS=no
387fi
388rm -f conftest conftest.c
389
390
391#
66ee8158 392# 7. Does xgettext exist and take the option --foreign-user?
7eda085c
KZ
393#
394if (test $ENABLE_NLS = yes && type xgettext > /dev/null 2>&1); then
395 msg=`xgettext --foreign-user 2>&1 | grep unrecognized`
396 if test -n "$msg"; then
397 echo "FOREIGN = " >> make_include
398 else
399 echo "FOREIGN = --foreign-user" >> make_include
400 fi
401 echo "HAVE_XGETTEXT=yes" >> make_include
402else
403 echo "HAVE_XGETTEXT=no" >> make_include
404fi
405
7eda085c
KZ
406
407#
66ee8158 408# 8. For err.c: do we have __progname?
7eda085c
KZ
409# [make sure gcc -O does not optimize the access away]
410#
411echo "
412#include <stdio.h>
413extern char *__progname;
414main(){ printf(__progname); exit(0); }
415" > conftest.c
416eval $compile
417if test -s conftest && ./conftest > /dev/null 2>/dev/null; then
418 echo "#define HAVE_progname" >> defines.h
419 echo "You have __progname"
420else
421 echo "You don't have __progname"
422fi
423rm -f conftest conftest.c
424
7eda085c 425#
66ee8158 426# 9. For script.c: do we have <pty.h> and openpty()?
7eda085c
KZ
427#
428echo "
429#include <pty.h>
430main(){ exit(0); openpty(0, 0, 0, 0, 0); }
431" > conftest.c
22853e4a 432LIBS=-lutil
7eda085c 433eval $compile
22853e4a 434LIBS=
7eda085c
KZ
435if test -s conftest && ./conftest 2>/dev/null; then
436 echo "HAVE_OPENPTY=yes" >> make_include
437 echo "#define HAVE_openpty" >> defines.h
438 echo "You have <pty.h> and openpty()"
439else
440 echo "You don't have <pty.h> and openpty()"
441fi
442rm -f conftest conftest.c
eb63b9b8
KZ
443
444#
66ee8158 445# 10. For lib/widechar.h: do we have wide character support?
eb63b9b8
KZ
446# [Do we have the headers <wchar.h>, <wctype.h>, the types wchar_t, wint_t
447# and the fgetwc, fputwc, WEOF functions/macros?]
448#
449echo "
450#include <wchar.h>
451#include <wctype.h>
452#include <stdio.h>
453int main () {
454 wchar_t wc;
455 wint_t w;
456 w = fgetwc(stdin);
457 if (w == WEOF) exit(1);
458 wc = w;
459 fputwc(wc,stdout);
460 exit(0);
461}
462" > conftest.c
463eval $compile
464if test -s conftest && ./conftest < conftest.c > /dev/null 2>/dev/null; then
465 echo "#define ENABLE_WIDECHAR" >> defines.h
466 echo "You have wide character support"
467else
468 echo "You don't have wide character support"
469fi
470rm -f conftest conftest.c
471
472#
66ee8158 473# 11. For pivot_root.c: does <linux/unistd.h> define __NR_pivot_root?
22853e4a
KZ
474#
475echo "
476#include <linux/unistd.h>
477int main(void)
478{
479 return __NR_pivot_root;
480}
481" >conftest.c
482eval $compile
483if test -s conftest; then
484 echo "HAVE_PIVOT_ROOT=yes" >> make_include
485 echo "You have __NR_pivot_root"
486else
487 echo "You don't have __NR_pivot_root"
488fi
489rm -f conftest conftest.c
490
491#
66ee8158 492# 12. For hwclock.c: does struct tm have a field tm_gmtoff?
22853e4a
KZ
493#
494echo "
495#include <time.h>
496#include <unistd.h>
497int main(int a, char **v)
498{
499 struct tm *tm = localtime(0);
500 if (a == -1) /* false */
501 sleep(tm->tm_gmtoff);
502 exit(0);
503}
504" >conftest.c
505eval $compile
506if test -s conftest; then
507 echo "#define HAVE_tm_gmtoff" >> defines.h
508 echo "You have a tm_gmtoff field in struct tm"
509else
510 echo "You don't have a tm_gmtoff field in struct tm"
511fi
512rm -f conftest conftest.c
513
514#
66ee8158
KZ
515# 13. For nfsmount: does the output of rpcgen compile?
516#
517# On some systems the output of rpcgen compiles with warnings
518# Here we conclude "Your rpcgen output does not compile"
519# and use pregenerated files. If one wishes to use rpcgen anyway,
520# just add the line "HAVE_GOOD_RPC=yes" to make_include.
22853e4a
KZ
521#
522rm -f conftest conftestx.c conftestl.c conftest.h conftest.x
66ee8158 523rm -f conftestx.o conftestl.o
22853e4a
KZ
524echo "
525#ifdef RPC_CLNT
526%#include <string.h> /* for memset() */
527#endif
528%#include <asm/types.h>
529typedef opaque fhandle[1];
530union fhstatus switch (unsigned fhs_status) {
531case 0:
532 fhandle fhs_fhandle;
533default:
534 void;
535};
536typedef string dirpath<1024>;
537struct ppathcnf {
538 short pc_mask[2];
539};
540
541program MOUNTPROG {
542 version MOUNTVERS {
543 fhstatus
544 MOUNTPROC_MNT(dirpath) = 1;
545 } = 2;
546} = 100005;
547" > conftest.x
66ee8158
KZ
548if rpcgen -h -o conftest.h conftest.x 2> conferrs && \
549 rpcgen -c -o conftestx.c conftest.x 2>> conferrs && \
550 rpcgen -l -o conftestl.c conftest.x 2>> conferrs && \
551 cc -c conftestx.c 2>> conferrs && cc -c conftestl.c 2>> conferrs && \
22853e4a
KZ
552 test ! -s conferrs
553then
554 echo "HAVE_GOOD_RPC=yes" >> make_include
555 echo "Your rpcgen seems to work"
556else
557 echo "Your rpcgen output does not compile"
558fi
559rm -f conftest conftestx.c conftestl.c conftest.h conftest.x conferrs
66ee8158 560rm -f conftestx.o conftestl.o