summaryrefslogtreecommitdiffstats
path: root/configure
blob: 75f754642ac5ae7db4ba6b2d5f59854d5c60af6a (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
#!/bin/sh
# Configure script for util-linux - aeb, 990205
#
# We need to find out the following things:
#
# 1. For mount/nfsmount.c: is inet_aton() available?
# 2. For fdisk/fdisksunlabel.c: is there a <scsi/scsi.h>?
#    For fdisk/fdisk.c: is there a <linux/blkpg.h>?
# 3. For sys-utils/ipcs.c: do we need __KERNEL__ and <linux/linkage.h>?
# 4. For sys-utils/cytune.c: do we need <linux/tqueue.h>?
# 5. For sys-utils/kbd_rate.c: does <linux/kd.h> exist?
# 6. For cfdisk, setterm, more, ul: do we have ncurses? How installed?
#    For more: do we have libtermcap?
# 7. For chfn, chsh, login, newgrp, passwd: do we need -lcrypt?
# 8. For sln: does static compilation work?
#  9. For lib/nls.h: do we have <locale.h>?
# 10. For lib/nls.h: do we have <libintl.h> and gettext()?
# 11. For xgettext: does it take the option --foreign-user?
# 12. For cal.c: do we have <langinfo.h>?
# 13. For err.c: do we have __progname?
# 14. For script.c: do we have <pty.h> and openpty()?

if test "$RANDOM" = "$RANDOM"; then
  # Plain old Bourne shell.
  echo checking for gcc
  test -z "$CC" -a -n "`gcc 2>&1`" && CC="gcc -O"
else
  # ksh, bash or zsh.  ksh and zsh write "command not found" to stderr.
  echo checking for gcc
  test -z "$CC" && type gcc && CC="gcc -O"
fi

CC=${CC-cc}
CFLAGS=${CFLAGS-"-O"}
DEFS=
LIBS=
compile='$CC $CFLAGS $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1'
static_compile='$CC -static $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1'

rm -f make_include defines.h conftest.c conftest

#
# 1. For mount/nfsmount.c: is inet_aton() available?
#
echo "
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
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 && ./conftest 2>/dev/null; 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

#
# 2. 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
main(){ exit(0); }
" > conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; 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

#
# 2A. For fdisk/fdisk.c: is <linux/blkpg.h> available?
#
echo "
#include <linux/blkpg.h>
main(){ exit(0); }
" > conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; then
        echo "#define HAVE_blkpg_h" >> defines.h
        echo "You have <linux/blkpg.h>"
else
        echo "You don't have <linux/blkpg.h>"
fi
rm -f conftest conftest.c

#
# 3. ipcs.c includes <sys/shm.h> and family
# Do we need __KERNEL__ and asmlinkage for SHM_DEST?
#
echo "
#include <sys/shm.h>
main(){ int i=SHM_DEST; exit(0); }
" > conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; then
	echo "You don't need <linux/linkage.h>"
else
	echo "#define NEED_linkage_h" >> defines.h
	echo "You need <linux/linkage.h>"
fi
rm -f conftest conftest.c

#
# 4. cytune.c may need struct tq_struct
#
echo "
#include <sys/types.h>
#include <linux/cyclades.h>
main(){ exit(0); }
" > conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; 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

#
# 5. Does <linux/kd.h> exist?
#
echo "
#include <linux/kd.h>
main(){ exit(0); }
" > conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; then
	echo "#define HAVE_kd_h" >> defines.h
	echo "You have <linux/kd.h>"
else
	echo "You don't have <linux/kd.h>"
fi
rm -f conftest conftest.c

#
# 6. How is [n]curses installed?
#
test_curses_h=0
have_ncurses=1
if [ -f /usr/include/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 [ -f /usr/include/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 [ -f /usr/include/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>
  main(){ char *c = NCURSES_VERSION; exit(0); }
  " > conftest.c
  eval $compile
  if test -s conftest && ./conftest 2>/dev/null; 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

#
# 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>
main(){ exit(0); tgetnum("li"); }
' > conftest.c
LIBS=-ltermcap
eval $compile
LIBS=
if test -s conftest && ./conftest 2>/dev/null; then
	echo "#define HAVE_termcap" >> defines.h
	echo "LIBTERMCAP=-ltermcap" >> make_include
	echo "You have termcap"
else
	echo "HAVE_TERMCAP=no" >> make_include
	echo "You don't have termcap"
fi
rm -f conftest conftest.c

#
# 7. Do we need -lcrypt?
#
echo '
#define _XOPEN_SOURCE
#include <unistd.h>
main(){ char *c = crypt("abc","pw"); exit(0); }
' > conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; 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

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

#
# 9. For lib/nls.h: do we have <locale.h>?
#
echo "
#include <locale.h>
main(){ exit(0); }
" > conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; then
        echo "#define HAVE_locale_h" >> defines.h
        echo "You have <locale.h>"
else
        echo "You don't have <locale.h>"
fi
rm -f conftest conftest.c


#
# 10. For lib/nls.h: do we have <libintl.h> and gettext() ?
#
echo '
#include <libintl.h>
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 && ./conftest 2>/dev/null; then
        echo '#define HAVE_libintl_h' >> defines.h
        echo "You have <libintl.h> and gettext()"
        echo '#define ENABLE_NLS' >> defines.h
        echo "Assuming that you want to enable NLS support."
        echo "(Otherwise, edit defines.h)"
        ENABLE_NLS=yes
else
        echo "You don't have <libintl.h>"
        ENABLE_NLS=no
fi
rm -f conftest conftest.c


#
# 11. Does xgettext exist and take the option --foreign-user?
#
if (test $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

#
# 12. For cal.c: do we have <langinfo.h>?
#
echo "
#include <langinfo.h>
main(){ exit(0); }
" > conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; then
        echo "#define HAVE_langinfo_h" >> defines.h
        echo "You have <langinfo.h>"
else
        echo "You don't have <langinfo.h>"
fi
rm -f conftest conftest.c


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


#
# 14. For script.c: do we have <pty.h> and openpty()?
#
echo "
#include <pty.h>
main(){ exit(0); openpty(0, 0, 0, 0, 0); }
" > conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; 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