summaryrefslogtreecommitdiff
blob: e3990b2acf88fe509584601210907407f45def88 (plain)
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
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
https://bugs.gentoo.org/869371

Upstream variant: https://lists.gnu.org/archive/html/screen-devel/2022-08/msg00000.html
--- a/configure.ac
+++ b/configure.ac
@@ -157,10 +157,11 @@ if test -n "$ULTRIX"; then
 fi
 AC_CHECKING(for POSIX.1)
 AC_EGREP_CPP(YES_IS_DEFINED,
 [#include <sys/types.h>
 #include <unistd.h>
+int
 main () {
 #ifdef _POSIX_VERSION
   YES_IS_DEFINED;
 #endif
 ], AC_NOTE(- you have a POSIX system) AC_DEFINE(POSIX) posix=1)
@@ -231,10 +232,11 @@ dnl
 
 AC_CHECKING(BSD job jontrol)
 AC_TRY_LINK(
 [#include <sys/types.h>
 #include <sys/ioctl.h>
+#include <unistd.h>
 ], [
 #ifdef POSIX
 tcsetpgrp(0, 0);
 #else
 int x = TIOCSPGRP;
@@ -248,48 +250,64 @@ int y = TIOCNOTTY;
 
 dnl
 dnl    ****  setresuid(), setreuid(), seteuid()  ****
 dnl
 AC_CHECKING(setresuid)
-AC_TRY_LINK(,[
+AC_TRY_LINK(
+[#include <unistd.h>
+], [
 setresuid(0, 0, 0);
 ], AC_DEFINE(HAVE_SETRESUID))
 AC_CHECKING(setreuid)
-AC_TRY_LINK(,[
+AC_TRY_LINK(
+[#include <unistd.h>
+], [
 setreuid(0, 0);
 ], AC_DEFINE(HAVE_SETREUID))
 dnl
 dnl seteuid() check:
 dnl   linux seteuid was broken before V1.1.11
 dnl   NeXT, AUX, ISC, and ultrix are still broken (no saved uid support)
 dnl   Solaris seteuid doesn't change the saved uid, bad for
 dnl     multiuser screen sessions
 AC_CHECKING(seteuid)
-AC_TRY_LINK(,[
+AC_TRY_LINK(
+[#include <unistd.h>
+],[
 #if defined(linux) || defined(NeXT) || defined(_AUX_SOURCE) || defined(AUX) || defined(ultrix) || (defined(sun) && defined(SVR4)) || defined(ISC) || defined(sony_news)
-seteuid_is_broken(0);
+int seteuid_is_broken(int); seteuid_is_broken(0);
 #else
 seteuid(0);
 #endif
 ], AC_DEFINE(HAVE_SETEUID))
 
 dnl execvpe
 AC_CHECKING(execvpe)
-AC_TRY_LINK(,[
+AC_TRY_LINK(
+[#include <unistd.h>
+],[
     execvpe(0, 0, 0);
 ], AC_DEFINE(HAVE_EXECVPE)
 CFLAGS="$CFLAGS -D_GNU_SOURCE")
 
 dnl
 dnl    ****  select()  ****
 dnl
 
 AC_CHECKING(select)
-AC_TRY_LINK(,[select(0, 0, 0, 0, 0);],, 
+AC_TRY_LINK(
+[#include <sys/select.h>
+],[
+    select(0, 0, 0, 0, 0);
+],, 
 LIBS="$LIBS -lnet -lnsl"
 AC_CHECKING(select with $LIBS)
-AC_TRY_LINK(,[select(0, 0, 0, 0, 0);],, 
+AC_TRY_LINK(
+[#include <sys/select.h>
+],[
+    select(0, 0, 0, 0, 0);
+],, 
 AC_MSG_ERROR(!!! no select - no screen))
 )
 dnl
 dnl    ****  FIFO tests  ****
 dnl
@@ -314,11 +332,11 @@ AC_TRY_RUN([
 #define S_IFIFO 0010000
 #endif
 
 char *fin = "/tmp/conftest$$";
 
-main()
+int main()
 {
   struct stat stb;
   fd_set f;
 
   (void)alarm(5);
@@ -326,40 +344,40 @@ main()
 #ifdef POSIX
   if (mkfifo(fin, 0777))
 #else
   if (mknod(fin, S_IFIFO|0777, 0))
 #endif
-    exit(1);
+    return 1;
   if (stat(fin, &stb) || (stb.st_mode & S_IFIFO) != S_IFIFO)
-    exit(1);
+    return 1;
   close(0);
 #ifdef __386BSD__
   /*
    * The next test fails under 386BSD, but screen works using fifos.
    * Fifos in O_RDWR mode are only used for the BROKEN_PIPE case and for
    * the select() configuration test.
    */
-  exit(0);
+  return 0;
 #endif
   if (open(fin, O_RDONLY | O_NONBLOCK))
-    exit(1);
+    return 1;
   if (fork() == 0)
     {
       close(0);
       if (open(fin, O_WRONLY | O_NONBLOCK))
-	exit(1);
+        return 1;
       close(0);
       if (open(fin, O_WRONLY | O_NONBLOCK))
-	exit(1);
+        return 1;
       if (write(0, "TEST", 4) == -1)
-	exit(1);
-      exit(0);
+        return 1;
+      return 0;
     }
   FD_SET(0, &f);
   if (select(1, &f, 0, 0, 0) == -1)
-    exit(1);
-  exit(0);
+    return 1;
+  return 0;
 }
 ], AC_NOTE(- your fifos are usable) fifo=1,
 AC_NOTE(- your fifos are not usable),
 AC_NOTE(- skipping check because we are cross compiling; assuming fifos are usable) fifo=1)
 rm -f /tmp/conftest*
@@ -385,30 +403,31 @@ AC_TRY_RUN([
 #define S_IFIFO 0010000
 #endif
 
 char *fin = "/tmp/conftest$$";
 
+int
 main()
 {
   struct timeval tv;
   fd_set f;
 
 #ifdef POSIX
   if (mkfifo(fin, 0600))
 #else
   if (mknod(fin, S_IFIFO|0600, 0))
 #endif
-    exit(1);
+    return 1;
   close(0);
   if (open(fin, O_RDONLY|O_NONBLOCK))
-    exit(1);
+    return 1;
   FD_SET(0, &f);
   tv.tv_sec = 1;
   tv.tv_usec = 0;
   if (select(1, &f, 0, 0, &tv))
-    exit(1);
-  exit(0);
+    return 1;
+  return 0;
 }
 ], AC_NOTE(- your implementation is ok), 
 AC_NOTE(- you have a broken implementation) AC_DEFINE(BROKEN_PIPE) fifobr=1,
 AC_NOTE(- skipping check because we are cross compiling; assuming fifo implementation is ok))
 rm -f /tmp/conftest*
@@ -432,46 +455,48 @@ AC_TRY_RUN([
 
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <signal.h>
 
 char *son = "/tmp/conftest$$";
 
+int
 main()
 {
   int s1, s2, l;
   struct sockaddr_un a;
   fd_set f;
 
   (void)alarm(5);
   if ((s1 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
-    exit(1);
+    return 1;
   a.sun_family = AF_UNIX;
   strcpy(a.sun_path, son);
   (void) unlink(son);
   if (bind(s1, (struct sockaddr *) &a, strlen(son)+2) == -1)
-    exit(1);
+    return 1;
   if (listen(s1, 2))
-    exit(1);
+    return 1;
   if (fork() == 0)
     {
       if ((s2 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
 	kill(getppid(), 3);
       (void)connect(s2, (struct sockaddr *)&a, strlen(son) + 2);
       if (write(s2, "HELLO", 5) == -1)
 	kill(getppid(), 3);
-      exit(0);
+      return 0;
     }
   l = sizeof(a);
   close(0);
   if (accept(s1, &a, &l))
-    exit(1);
+    return 1;
   FD_SET(0, &f);
   if (select(1, &f, 0, 0, 0) == -1)
-    exit(1);
-  exit(0);
+    return 1;
+  return 0;
 }
 ], AC_NOTE(- your sockets are usable) sock=1,
 AC_NOTE(- your sockets are not usable),
 AC_NOTE(- skipping check because we are cross compiling; assuming sockets are usable) sock=1)
 rm -f /tmp/conftest*
@@ -491,26 +516,27 @@ AC_TRY_RUN([
 #include <sys/socket.h>
 #include <sys/un.h>
 
 char *son = "/tmp/conftest$$";
 
+int
 main()
 {
   int s;
   struct stat stb;
   struct sockaddr_un a;
   if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
-    exit(0);
+    return 0;
   a.sun_family = AF_UNIX;
   strcpy(a.sun_path, son);
   (void) unlink(son);
   if (bind(s, (struct sockaddr *) &a, strlen(son)+2) == -1)
-    exit(0);
+    return 0;
   if (stat(son, &stb))
-    exit(1);
+    return 1;
   close(s);
-  exit(0);
+  return 0;
 }
 ],AC_NOTE(- you are normal),
 AC_NOTE(- unix domain sockets are not kept in the filesystem)
 AC_DEFINE(SOCK_NOT_IN_FS) socknofs=1,
 AC_NOTE(- skipping check because we are cross compiling; assuming sockets are normal))
@@ -545,122 +571,167 @@ char *nam = "/tmp/conftest$$";
 #endif
 #ifndef S_IFIFO
 #define S_IFIFO 0010000
 #endif
 
+int
 main()
 {
   fd_set f;
 
 #ifdef __FreeBSD__
 /* From Andrew A. Chernov (ache@astral.msk.su):
  * opening RDWR fifo fails in BSD 4.4, but select return values are
  * right.
  */
-  exit(0);
+  return 0;
 #endif
   (void)alarm(5);
 #ifdef POSIX
   if (mkfifo(nam, 0777))
 #else
   if (mknod(nam, S_IFIFO|0777, 0))
 #endif
-    exit(1);
+    return 1;
   close(0);
   if (open(nam, O_RDWR | O_NONBLOCK))
-    exit(1);
+    return 1;
   if (write(0, "TEST", 4) == -1)
-    exit(1);
+    return 1;
 
 #else
 
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <signal.h>
 
+int
 main()
 {
   int s1, s2, l;
   struct sockaddr_un a;
   fd_set f;
 
   (void)alarm(5);
   if ((s1 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
-    exit(1);
+    return 1;
   a.sun_family = AF_UNIX;
   strcpy(a.sun_path, nam);
   (void) unlink(nam);
   if (bind(s1, (struct sockaddr *) &a, strlen(nam)+2) == -1)
-    exit(1);
+    return 1;
   if (listen(s1, 2))
-    exit(1);
+    return 1;
   if (fork() == 0)
     {
       if ((s2 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
 	kill(getppid(), 3);
       (void)connect(s2, (struct sockaddr *)&a, strlen(nam) + 2);
       if (write(s2, "HELLO", 5) == -1)
 	kill(getppid(), 3);
-      exit(0);
+      return 0;
     }
   l = sizeof(a);
   close(0);
   if (accept(s1, (struct sockaddr *)&a, &l))
-    exit(1);
+    return 1;
 #endif
 
 
   FD_SET(0, &f);
   if (select(1, &f, 0, 0, 0) == -1)
-    exit(1);
+    return 1;
   if (select(1, &f, &f, 0, 0) != 2)
-    exit(1);
-  exit(0);
+    return 1;
+  return 0;
 }
 ],AC_NOTE(- select is ok),
 AC_NOTE(- select can't count) AC_DEFINE(SELECT_BROKEN),
 AC_NOTE(- skipping check because we are cross compiling; assuming select is ok))
 
 dnl
 dnl    ****  termcap or terminfo  ****
 dnl
 AC_CHECKING(for tgetent)
-AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
+AC_TRY_LINK([
+    #include <curses.h>
+    #include <term.h>
+], [
+    tgetent((char *)0, (char *)0);
+],,
 olibs="$LIBS"
 LIBS="-lcurses $olibs"
 AC_CHECKING(libcurses)
-AC_TRY_LINK(,[
+AC_TRY_LINK([#include <curses.h>
+    #include <term.h>
+],[
 #ifdef __hpux
 __sorry_hpux_libcurses_is_totally_broken_in_10_10();
 #else
 tgetent((char *)0, (char *)0);
 #endif
 ],,
 LIBS="-ltermcap $olibs"
 AC_CHECKING(libtermcap)
-AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
+AC_TRY_LINK(
+[#include <curses.h>
+    #include <term.h>
+],[
+    tgetent((char *)0, (char *)0);
+],,
 LIBS="-ltermlib $olibs"
 AC_CHECKING(libtermlib)
-AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
+AC_TRY_LINK(
+[#include <curses.h>
+    #include <term.h>
+],[
+    tgetent((char *)0, (char *)0);
+],,
 LIBS="-lncursesw $olibs"
 AC_CHECKING(libncursesw)
-AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
+AC_TRY_LINK(
+[#include <curses.h>
+    #include <term.h>
+],[
+    tgetent((char *)0, (char *)0);
+],,
 LIBS="-ltinfow $olibs"
 AC_CHECKING(libtinfow)
-AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
+AC_TRY_LINK(
+[#include <curses.h>
+    #include <term.h>
+],[
+    tgetent((char *)0, (char *)0);
+],,
 LIBS="-lncurses $olibs"
 AC_CHECKING(libncurses)
-AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
+AC_TRY_LINK(
+[#include <curses.h>
+    #include <term.h>
+],[
+    tgetent((char *)0, (char *)0);
+],,
 LIBS="-ltinfo $olibs"
 AC_CHECKING(libtinfo)
-AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
+AC_TRY_LINK(
+[#include <curses.h>
+    #include <term.h>
+],[
+    tgetent((char *)0, (char *)0);
+],,
 AC_MSG_ERROR(!!! no tgetent - no screen)))))))))
 
 AC_TRY_RUN([
+#include <curses.h>
+#include <string.h>
+#include <term.h>
+
+int
 main()
 {
- exit(strcmp(tgoto("%p1%d", 0, 1), "1") ? 0 : 1);
+ return(strcmp(tgoto("%p1%d", 0, 1), "1") ? 0 : 1);
 }], AC_NOTE(- you use the termcap database),
 AC_NOTE(- you use the terminfo database) AC_DEFINE(TERMINFO),
 AC_NOTE(- skipping check because we are cross compiling; assuming terminfo database is used) AC_DEFINE(TERMINFO))
 AC_CHECKING(ospeed)
 AC_TRY_LINK(extern short ospeed;,ospeed=5;,,AC_DEFINE(NEED_OSPEED))
@@ -677,11 +748,15 @@ fi
 
 if test "$cross_compiling" = no ; then
 AC_CHECKING(for SVR4 ptys)
 sysvr4ptys=
 if test -c /dev/ptmx ; then
-AC_TRY_LINK([],[ptsname(0);grantpt(0);unlockpt(0);],[AC_DEFINE(HAVE_SVR4_PTYS)
+AC_TRY_LINK([
+    #include <stdlib.h>
+], [
+    ptsname(0);grantpt(0);unlockpt(0);
+],[AC_DEFINE(HAVE_SVR4_PTYS)
 sysvr4ptys=1])
 fi
 fi
 
 AC_CHECK_FUNCS(getpt)
@@ -733,33 +808,36 @@ AC_CHECKING(default tty permissions/group)
 rm -f conftest_grp
 AC_TRY_RUN([
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+int
 main()
 {
   struct stat sb;
   char *x,*ttyname();
   int om, m;
   FILE *fp;
 
-  if (!(x = ttyname(0))) exit(1);
-  if (stat(x, &sb)) exit(1);
+  if (!(x = ttyname(0))) return 1;
+  if (stat(x, &sb)) return 1;
   om = sb.st_mode;
-  if (om & 002) exit(0);
+  if (om & 002) return 0;
   m = system("mesg y");
-  if (m == -1 || m == 127) exit(1);
-  if (stat(x, &sb)) exit(1);
+  if (m == -1 || m == 127) return 1;
+  if (stat(x, &sb)) return 1;
   m = sb.st_mode;
-  if (chmod(x, om)) exit(1);
-  if (m & 002) exit(0);
-  if (sb.st_gid == getgid()) exit(1);
+  if (chmod(x, om)) return 1;
+  if (m & 002) return 0;
+  if (sb.st_gid == getgid()) return 1;
   if (!(fp=fopen("conftest_grp", "w")))
-    exit(1);
+    return 1;
   fprintf(fp, "%d\n", sb.st_gid);
   fclose(fp);
-  exit(0);
+  return 0;
 }
 ],[
     if test -f conftest_grp; then
 	ptygrp=`cat conftest_grp`
 	AC_NOTE([- pty mode: $ptymode, group: $ptygrp])
@@ -869,17 +942,25 @@ AC_CHECKING(for libutil(s))
 test -f /usr/lib/libutils.a && LIBS="$LIBS -lutils"
 test -f /usr/lib/libutil.a && LIBS="$LIBS -lutil"
 fi
 
 AC_CHECKING(getloadavg)
-AC_TRY_LINK(,[getloadavg((double *)0, 0);],
+AC_TRY_LINK(
+[
+    #include <stdlib.h>
+],[
+    getloadavg((double *)0, 0);],
 AC_DEFINE(LOADAV_GETLOADAVG) load=1,
 if test "$cross_compiling" = no && test -f /usr/lib/libkvm.a ; then
 olibs="$LIBS"
 LIBS="$LIBS -lkvm"
 AC_CHECKING(getloadavg with -lkvm)
-AC_TRY_LINK(,[getloadavg((double *)0, 0);],
+AC_TRY_LINK(
+[
+    #include <stdlib.h>
+],[
+    getloadavg((double *)0, 0);],
 AC_DEFINE(LOADAV_GETLOADAVG) load=1, LIBS="$olibs")
 fi
 )
 
 if test -z "$load" ; then
@@ -931,10 +1012,11 @@ else
 
 $nlist64
 
 struct nlist nl[2];
 
+int
 main()
 {
 #if !defined(_AUX_SOURCE) && !defined(AUX)
 # ifdef NLIST_NAME_UNION
   nl[0].n_un.n_name = "$av";
@@ -944,12 +1026,12 @@ main()
 #else
   strncpy(nl[0].n_name, "$av", sizeof(nl[0].n_name));
 #endif
   nlist(LOADAV_UNIX, nl);
   if (nl[0].n_value == 0)
-    exit(1);
-  exit(0);
+    return 1;
+  return 0;
 }
   ],avensym=$av;break)
   if test "$av" = _Loadavg; then
     nlist64='#define nlist nlist64'
   fi
@@ -1068,21 +1150,22 @@ void
 hand()
 {
   got++;
 }
 
+int
 main()
 {
   /* on hpux we use sigvec to get bsd signals */
 #ifdef __hpux
   (void)signal(SIGCLD, hand);
   kill(getpid(), SIGCLD);
   kill(getpid(), SIGCLD);
   if (got < 2)
-    exit(1);
+    return 1;
 #endif
-  exit(0);
+  return 0;
 }
 ],,AC_DEFINE(SYSVSIGS),:)
 
 fi
 
@@ -1107,14 +1190,22 @@ oldlibs="$LIBS"
 LIBS="$LIBS -lsun"
 AC_CHECKING(IRIX sun library)
 AC_TRY_LINK(,,,LIBS="$oldlibs")
 
 AC_CHECKING(syslog)
-AC_TRY_LINK(,[closelog();], , [oldlibs="$LIBS"
+AC_TRY_LINK(
+[#include <syslog.h>
+], [
+    closelog();
+], , [oldlibs="$LIBS"
 LIBS="$LIBS -lbsd"
 AC_CHECKING(syslog in libbsd.a)
-AC_TRY_LINK(, [closelog();], AC_NOTE(- found.), [LIBS="$oldlibs"
+AC_TRY_LINK(
+[#include <syslog.h>
+], [
+    closelog();
+], AC_NOTE(- found.), [LIBS="$oldlibs"
 AC_NOTE(- bad news: syslog missing.) AC_DEFINE(NOSYSLOG)])])
 
 AC_EGREP_CPP(YES_IS_DEFINED,
 [#ifdef M_UNIX
    YES_IS_DEFINED;
@@ -1147,66 +1238,87 @@ fi
 dnl AC_CHECK_HEADER(shadow.h, AC_DEFINE(SHADOWPW))
 AC_CHECKING(getspnam)
 AC_TRY_LINK([#include <shadow.h>], [getspnam("x");],AC_DEFINE(SHADOWPW))
 
 AC_CHECKING(getttyent)
-AC_TRY_LINK(,[getttyent();], AC_DEFINE(GETTTYENT))
+AC_TRY_LINK(
+[
+    #include <ttyent.h>
+],[
+    getttyent();
+], AC_DEFINE(GETTTYENT))
 
 AC_CHECKING(fdwalk)
 AC_TRY_LINK([#include <stdlib.h>], [fdwalk(NULL, NULL);],AC_DEFINE(HAVE_FDWALK))
 
 AC_CHECKING(whether memcpy/memmove/bcopy handles overlapping arguments)
 AC_TRY_RUN([
+#include <string.h>
+
+int
 main() {
   char buf[10];
   strcpy(buf, "abcdefghi");
   bcopy(buf, buf + 2, 3);
   if (strncmp(buf, "ababcf", 6))
-    exit(1);
+    return 1;
   strcpy(buf, "abcdefghi");
   bcopy(buf + 2, buf, 3);
   if (strncmp(buf, "cdedef", 6))
-    exit(1);
-  exit(0); /* libc version works properly.  */
+    return 1;
+  return 0; /* libc version works properly.  */
 }], AC_DEFINE(USEBCOPY),,:)
 
 AC_TRY_RUN([
+#include <string.h>
+
 #define bcopy(s,d,l) memmove(d,s,l)
+int
 main() {
   char buf[10];
   strcpy(buf, "abcdefghi");
   bcopy(buf, buf + 2, 3);
   if (strncmp(buf, "ababcf", 6))
-    exit(1);
+    return 1;
   strcpy(buf, "abcdefghi");
   bcopy(buf + 2, buf, 3);
   if (strncmp(buf, "cdedef", 6))
-    exit(1);
-  exit(0); /* libc version works properly.  */
+    return 1;
+  return 0; /* libc version works properly.  */
 }], AC_DEFINE(USEMEMMOVE),,
   AC_NOTE(- skipping check because we are cross compiling; use memmove) AC_DEFINE(USEMEMMOVE))
 
 
 AC_TRY_RUN([
+#include <string.h>
+
 #define bcopy(s,d,l) memcpy(d,s,l)
+int
 main() {
   char buf[10];
   strcpy(buf, "abcdefghi");
   bcopy(buf, buf + 2, 3);
   if (strncmp(buf, "ababcf", 6))
-    exit(1);
+    return 1;
   strcpy(buf, "abcdefghi");
   bcopy(buf + 2, buf, 3);
   if (strncmp(buf, "cdedef", 6))
-    exit(1);
-  exit(0); /* libc version works properly.  */
+    return 1;
+  return 0; /* libc version works properly.  */
 }], AC_DEFINE(USEMEMCPY),,:)
 
 AC_SYS_LONG_FILE_NAMES
 
 AC_MSG_CHECKING(for vsprintf)
-AC_TRY_LINK([#include <stdarg.h>],[va_list valist; vsprintf(0,0,valist);], AC_MSG_RESULT(yes);AC_DEFINE(USEVARARGS), AC_MSG_RESULT(no))
+AC_TRY_LINK(
+[
+    #include <stdarg.h>
+    #include <stdio.h>
+],
+[
+    va_list valist; vsprintf(0,0,valist);
+], AC_MSG_RESULT(yes);AC_DEFINE(USEVARARGS), AC_MSG_RESULT(no))
 
 AC_HEADER_DIRENT
 
 AC_MSG_CHECKING(for setenv)
 if test -z "$ac_setenv_args"; then