-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.c
2371 lines (2160 loc) · 60.9 KB
/
config.c
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
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* CHK=0x8848 */
char *rev = "4.40";
/* #define FORCE_DASH_G */
#if defined(WHT) && !defined(FORCE_DASH_G)
#define FORCE_DASH_G
#endif
/*+-------------------------------------------------------------------------
config.c - Makefile configuration program for ECU
wht@n4hgf.atl.ga.us
This must be compiled with the *NATIVE* cc or else you must
fake all of the predefines the native compiler supplies. The
Configure script can pass stuff in CFLAGS to tickle config a
bit.
'I love it. God help me, I love it so. I love it more than my
life.' -- George C. Scott as Patton in _Patton_
Defined functions:
config_setup()
find_string_in_file(fname, str)
find_stuff()
fix_libraries(libspec)
gen_bsd_ldflags()
gen_cc_cflags()
gen_common_cflags()
gen_freebsd_ldflags()
gen_gcc_cflags()
gen_hpux_ldflags()
gen_isc_ldflags()
gen_linux_ldflags()
gen_motsvr3_ldflags()
gen_sco_ldflags()
gen_solaris2_ldflags()
gen_sun_ldflags()
gen_svr4_ldflags(include_socket)
generate_config(mdir)
goodbye(sig)
main(argc, argv)
tgetc()
tgetopt(prompt, choices, deflt)
tgets(buf)
tputstrs(strs)
tputstrsfp(strs)
type (or the `nearest equivalent')
--------------------------------------------------------------------------*/
/*+:EDITS:*/
/*:04-26-2000-11:15-wht@bob-RELEASE 4.42 */
/*:03-24-2000-19:17-wht@blue-3.41-Linux uucp spool dir was wrong */
/*:02-25-1998-21:30-wht@menlo-port to redhat5/linux2 */
/*:12-22-1997-15:48-wht@kepler-use FIONREAD for SVR4 */
/*:12-21-1997-13:50-wht@sidonia-add CFG_UseSetupterm and CFG_UseStructWinsize */
/*:12-21-1997-00:18-wht@kepler-FIONREAD no good on OS5 console */
/*:12-18-1997-18:58-wht@kepler-adjust solaris */
/*:12-18-1997-06:05-wht@sidonia-port to AIX */
/*:12-18-1997-16:18-wht@kepler-w/help from robertle@sco.com fixOS5/OS7 */
/*:12-15-1997-21:14-wht@kepler-look for FIONREAD in linux/termios */
/*:12-15-1997-19:57-wht@fep-find_string_in_file prints stat diagnostics */
/*:12-15-1997-19:42-wht@fep-add CFG_FionreadInSocketH */
/*:12-15-1997-19:34-wht@fep-rename CFG_FilioH to CFG_FionreadInFilioH */
/*:12-12-1997-17:48-wht@kepler-minor minor tweak to add OS7 for Bob Lewis */
/*:03-16-1997-02:36-rll@felton.felton.ca.us-make boxes for SCO Products */
/*:01-24-1997-02:36-wht@yuriatin-SOURCE RELEASE 4.00 */
/*:11-12-1996-12:57-wht@yuriatin-SCO UnixWare and Motorola SVR4 equivalent */
/*:10-11-1996-02:09-wht@yuriatin-add CFG_FilioH */
/*:09-20-1996-05:12-wht@yuriatin-more comprehensive inet support check */
/*:09-17-1996-04:53-wht@yuriatin-autoconfig network for SCO */
/*:09-11-1996-19:59-wht@yuriatin-3.48-major telnet,curses,structural overhaul */
/*:09-05-1996-17:38-wht@kepler-WHT gets 132x85 */
/*:09-05-1996-17:26-wht@kepler-ncurses: look_for_ncurses,DCFG_UseNcursesH */
/*:09-04-1996-05:39-wht@kepler-use cua0, not ttyS0 for linux default */
/*:08-29-1996-15:52-wht@yuriatin-my Motorola gcc can pipe */
/*:08-22-1996-14:28-wht@fep-accommodate SVR4 socket */
/*:08-21-1996-16:27-wht@fep-use CFG_ ident for all config */
/*:07-31-1996-16:40-wht@kepler-use /etc/uucp for FreeBSD per dgy@rtd.com */
/*:07-24-1996-20:37-wht@n4hgf-add NL to end of ecu_euid_test.c */
/*:06-12-1996-19:17-wht@kepler-fix GCC_CFLAGS_EXTRA use */
/*:04-02-1996-11:06-wht@kepler-apply ache FreeBSD fix: cc switches */
/*:12-28-1995-12:54-wht@kepler-Andrey Chernov FreeBSD fixes */
/*:12-04-1995-01:12-wht@kepler-SCO system() wont work with SIGCLD SIG_IGN */
/*:12-03-1995-19:54-wht@gyro-add CFG_UseSeteuid */
/*:11-23-1995-11:20-wht@kepler-source control 3.37 for tsx-11 */
/*:11-23-1995-11:16-wht@kepler-default setuid uucp to yes */
/*:11-14-1995-10:23-wht@kepler-3.37.80-source control point: SOCKETS */
/*:11-12-1995-03:14-wht@kepler-CFG_TelnetOption good to go for SunOs & Linux */
/*:11-12-1995-00:00-wht@gyro-NO_ANSI_EMULATION becomes CFG_NoAnsiEmulation */
/*:11-04-1995-20:15-wht@kepler-24 lines are minimum ... what happened to fix? */
/*:11-03-1995-17:00-wht@wwtp1-allow for LOCAL_LIBS */
/*:11-03-1995-16:21-wht@wwtp1-v or 5 default for SCO */
/*:10-18-1995-04:29-wht@kepler-always use select for nap */
/*:10-15-1995-00:36-wht@n4hgf-drop SEAlink support */
/*:10-14-1995-16:26-wht@kepler-remove pretense of 286 support */
/*:09-02-1995-12:16-wht@n4hgf-runtime vs. ifdef for ecuungetty_appropriate */
/*:09-02-1995-11:53-wht@n4hgf-add predefines 32v5ers abandoned */
/*:09-01-1995-17:31-wht@n4hgf-OS5 gets -DSCO32v5 */
/*:08-27-1995-07:15-wht@n4hgf-take queue on libdir based on bin subdir */
/*:08-02-1995-19:13-wht@n4hgf-SCO engineer nice enough to finish OS5 port */
/*:06-23-1995-01:01-wht@n4hgf-use ECUOWNER,ECUGROUP,ECUMODE */
/*:06-15-1995-07:09-wht@kepler-dynamic CFG_HasStrerror */
/*:06-14-1995-06:58-wht@n4hgf-no more SCO -nointl or obsolete cross-compile */
/*:06-14-1995-06:32-wht@n4hgf-add SCO 3.2v5/Open Server 5 */
/*:06-13-1995-22:14-wht@n4hgf-was overwriting screen_lines with columns */
/*:04-09-1995-03:23-wht@gyro-add BSD_COMP to Solaris CFLAGS */
/*:03-28-1995-21:35-wht@n4hgf-clean up lines/cols input */
/*:03-11-1995-17:12-wht@kepler-auto-detect linux for 1st choice default */
/*:03-11-1995-17:09-wht@kepler-check linux/types.h if found */
/*:03-11-1995-17:08-wht@kepler-Linux can -pipe */
/*:01-15-1995-02:00-wht@n4hgf-rid rubbish undoc switches + add gcc_wall */
/*:01-15-1995-01:51-wht@n4hgf-patch the patch -- Andrew is patient with me */
/*:01-12-1995-15:19-wht@n4hgf-apply Andrew Chernov 8-bit clean+FreeBSD patch */
/*:06-10-1994-14:56-wht@kepler-was not including -g CFLAG on FORCE_DASH_G */
/*:05-11-1994-16:03-wht@n4hgf-#define WHT causes -DWHT */
/*:05-04-1994-04:38-wht@n4hgf-ECU release 3.30 */
/*:05-02-1994-03:10-wht@fep-cannot fix for all: warn of gcc overflow warnings */
/*:04-05-1994-17:11-wht@n4hgf-correct my first ever = for == substitution */
/*:03-13-1994-16:28-wht@fep-add Motorola SVR4 */
/*:01-25-1994-17:36-wht@n4hgf-USE_DECIMAL_PIDS->CFG_BinaryUucpPids */
/*:01-04-1994-07:23-wht@fep-implement CFG_DialTimeout */
/*:12-12-1993-13:44-wht@fep-use enum to catch missing cases */
/*:12-12-1993-13:36-wht@fep-remove obsolete -DISC22 */
/*:12-12-1993-13:31-wht@fep-MOTSVR3 == Motorola Delta SVR3 for 88k */
/*:12-10-1993-22:09-wht@n4vu-more Linux fixes + add sun -DCFG_TermiosLineio */
/*:12-02-1993-15:44-wht@n4hgf-some Linux includes may be root-readable only */
/*:11-14-1993-12:33-wht@n4hgf-HP-UX port by Carl Wuebker at HP */
/*:11-12-1993-11:00-wht@n4hgf-Linux changes by bob@vancouver.zadall.com */
/*:10-04-1993-04:07-wht@n4hgf-simplify SCO optimization choice */
/*:08-30-1993-11:44-wht@n4hgf-remove obsolete i86-specific gcc opts */
/*:08-17-1993-04:14-wht@n4hgf-Wuninitialized always on */
/*:08-17-1993-04:14-wht@n4hgf-remove -fforce-mem/-fforce-addr from gcc flags */
/*:03-17-1993-14:55-wht@n4hgf-remove soon to be obsolete LNG353 warnings */
/*:02-16-1993-13:18-wht@n4hgf-remove -Mlt128 from 286 per vancleef@netcom.com */
/*:01-30-1993-13:20-wht@n4hgf-add -Wuninitialized */
/*:01-30-1993-12:06-wht@n4hgf-gcc 2.3.3 gets -O6 */
/*:01-21-1993-00:07-wht@n4hgf-3.2v4 now the SCO UNIX default */
/*:01-21-1993-00:06-wht@n4hgf-augment gcc switches */
/*:12-12-1992-12:22-wht@n4hgf-no built in functions when using gcc */
/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
/*:09-10-1992-04:39-wht@n4hgf-admonition about SunOS IPC config */
/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
/*:08-21-1992-13:46-wht@n4hgf-don't configure ecuungetty if not used on a sys */
/*:08-11-1992-06:04-wht@n4hgf-FORCE_DASH_G and 3.2v4 LNG353 warnings */
/*:07-12-1992-07:17-wht@n4hgf-3.2v4 has a fully functional nap and select */
/*:07-02-1992-20:41-wht@n4hgf-rework for more options + 3.2v4 CFG_PidType */
/*:06-18-1992-11:19-root@n4hgf-SCO 3.2v4 gcc CFLAG additions */
/*:04-23-1992-14:04-wht@n4hgf-had XENIX curses lib paths wrong */
/*:04-19-1992-21:55-wht@n4hgf-pressing return or enter gets tgeopt default */
/*:04-19-1992-21:43-wht@n4hgf-add default for tgetopt */
/*:04-19-1992-02:55-wht@n4hgf-add ESIX SVR4 config */
/*:04-17-1992-20:08-wht@n4hgf-add tty, bit_rate and parity questions */
/*:03-20-1992-03:08-wht@n4hgf-correct XENIX tcap/tlib test thanks to tbetz */
/*:03-01-1992-13:36-wht@n4hgf-add -Wswitch to gcc compiles */
/*:02-06-1992-15:23-wht@n4hgf-depressing ... SCO keeps chging their minds */
/*:10-17-1991-14:51-wht@n4hgf-add can_pipe code */
/*:09-03-1991-12:53-wht@n4hgf2-iron out sun gcc options */
/*:09-01-1991-16:32-wht@n4hgf2-show package and config versions */
/*:09-01-1991-15:59-wht@n4hgf2-generalize HDB Devices, etc. files location */
/*:08-28-1991-14:07-wht@n4hgf2-SVR4 cleanup by aega84!lh */
/*:08-25-1991-14:39-wht@n4hgf-SVR4 port thanks to aega84!lh */
/*:08-23-1991-01:37-wht@n4hgf-sun port */
/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
/*:07-12-1991-14:02-wht@n4hgf-GCC140 update */
/*:05-02-1991-02:46-wht@n4hgf-take out M_TERMCAP in favor of ecucurses.h */
/*:04-28-1991-03:44-wht@n4hgf-add -Dconst= for X286 under UNIX */
/*:04-20-1991-17:26-wht@n4hgf-creation */
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include <string.h>
#include <errno.h>
#include "ecu_config.h"
#include "ecu_types.h"
#include "ecu_stat.h"
#include "patchlevel.h"
/*
* this definition must be made w/o the aid of config,
* since we are just building it now
*/
#if defined(SVR4) || defined(USE_TERMIOS) || defined(CFG_TermiosLineio)
#include <termios.h>
#define termio termios
#define setty(arg) tcsetattr(0,TCSADRAIN,(arg) ? &tty1 : &tty0)
#else
#include <termio.h>
#define setty(arg) ioctl(0,TCSETAW,(arg) ? (char *)&tty1 : (char *)&tty0)
#endif
struct termio tty0;
struct termio tty1;
#define CBUFSIZE 128
enum sys_type
{
S_SCO,
S_ISC,
S_SUN,
S_ISCSVR4,
S_ESIXSVR4,
S_LINUX,
S_HPUX,
S_MOTSVR3,
S_SVR4,
S_BSD,
S_SOLARIS2,
S_FREEBSD,
S_AIX,
};
enum sco_type
{
X_X386,
X_UNIX,
X_32v4,
X_32v5,
X_OS7,
};
enum cc_type
{
C_CC,
C_GCC,
};
char *makedirs[] =
{
".",
"./bperr",
"./ecufriend",
"./ecuungetty",
"./gendial",
"./help",
"./z",
(char *)0
};
char *strs_intro1[] =
{
"\n",
".-------------------.\n",
"| ECU configuration |\n",
"`-------------------'\n",
(char *)0
};
char *strs_intro2[] =
{
#ifdef WHT
"WHT features enabled.\n",
"\n",
#endif
"Please answer these questions so that I can configure ECU.\n",
"There are two types of answers, single character and string.\n",
"Single character questions have the choices in () followed by a ?\n",
"String questions are followed by a :\n",
"Default answers appearing in [] are guesses. If you wish to use\n",
"the default answer for a question, just press CR.\n",
"\n",
"Abort (DEL, ^C, etc.) now if you do not wish to continue.\n",
(char *)0
};
char *strs_no_timeval[] =
{
"\n",
"I am supposed to use select() for a nap() replacement, but I can't find\n",
"a definition for `struct timeval' in sys/time.h nor sys/select.h\n",
"By all means try a compile, but expect `unknown size', 'undefined' and\n",
"other type error messages associated with missing struct definitions.\n",
"Communicate your particulars to wht@n4hgf.atl.ga.us, PLEASE!\n",
(char *)0
};
char *strs_mkdep[] =
{
"\n",
"You are ready to make the program. It make take a while (now is a good\n",
"time to Read The Fine Manual).\n",
"\n",
"You MAY wish to make depend first. It is not necessary to do this\n",
"until you make source modifications or apply patches.\n",
(char *)0
};
char *sco_cc_opts[] =
{
"\t-M3e -O \\\n", /* XENIX/386 */
"\t-M3e -O \\\n", /* UNIX/386 3.2.0-3.2v2 */
"\t-M3e -O \\\n", /* UNIX/386 3.2v4 */
"\t-b elf -dy -O \\\n", /* 32v5 OS5 */
"\t-b elf -dy -O \\\n" /* OS7 */
};
char *sco_sigtype[] =
{
"void", /* XENIX/386 */
"void", /* UNIX/386 3.2.0-3.2v2 */
"void", /* UNIX/386 3.2v4 */
"void", /* UNIX/386 3.2v5 */
"void" /* OS7 */
};
char *pid_type = "\t-DCFG_PidType=int \\\n";
/*
* GCC CFLAGS
*/
char *gcc_opts[] =
{
#ifdef PEDANTIC
"\t-pedantic -ansi -O2 -fno-builtin\\\n", /* UH OH: see ecu README */
#else
"\t-O2 -fno-builtin\\\n",
#endif
"\t-finline-functions\\\n",
"\t-W -Wuninitialized -Wunused -Wshadow -Wcomment -Wswitch\\\n",
"\t-Dconst=\\\n",
(char *)0
};
char *sco_gcc_opts[] =
{
/*
* XENIX/386
*/
"\t-DM_XENIX -DM_SYSV -DM_SYS5 -DM_I386 \\\n\
\t-DM_BITFIELDS -DM_COFF -DM_I386 -DM_I86 -DM_I86SM \\\n\
\t-DM_INTERNAT -DM_SDATA -DM_STEXT -DM_SYS3 \\\n\
\t-DM_SYSIII -DM_WORDSWAP -Di386\\\n",
/*
* UNIX/386 3.2.0..3.2v2
*/
"\t-DM_BITFIELDS -DM_COFF -DM_I386 -DM_I86 -DM_I86SM \\\n\
\t-DM_INTERNAT -DM_SDATA -DM_STEXT -DM_SYS3 -DM_SYS5 \\\n\
\t-DM_SYSIII -DM_SYSV -DM_UNIX -DM_WORDSWAP -DM_XENIX -Dunix -Di386\\\n",
/*
* UNIX/386 3.2v4
*/
"\t-D_SVID -D_KR -D__STDC__=0 \\\n\
\t-DM_BITFIELDS -DM_COFF -DM_I386 -DM_I86 -DM_I86SM \\\n\
\t-DM_INTERNAT -DM_SDATA -DM_STEXT -DM_SYS3 -DM_SYS5 \\\n\
\t-DM_SYSIII -DM_SYSV -DM_UNIX -DM_WORDSWAP -DM_XENIX -Dunix -Di386\\\n",
/*
* 3.2v5 OS5
*/
"\t-Wa,-belf -D_NO_STATIC \\\n\
\t-DM_SDATA -DM_STEXT -DM_SYS3 -DM_SYS5 \\\n\
\t-DM_SYSV -DM_UNIX -Dunix -Di386\\\n",
/*
* OS7
*/
"\t-Wa,-belf \\\n",
};
char *motsvr3_cc_opts = "\t-O -DMOTSVR3 \\\n";
char *motsvr3_gcc_opts = "\t-DMOTSVR3 \\\n";
char *motsvr3_sigtype = "void";
char *isc_cc_opts = "\t-O -DISC \\\n";
char *isc_gcc_opts = "\t-DISC -Di386\\\n";
char *isc_sigtype = "void";
char *sun_cc_opts = "\t-O \\\n";
char *sun_gcc_opts = "\t-Dsun=1 \\\n"; /* ansi gets __sun__ only */
char *sun_sigtype = "void";
char *solaris2_cc_opts = "\t-Dsun=1 -DSVR4 -DBSD_COMP -DCFG_GettodFtime \\\n";
char *solaris2_gcc_opts = "\t-Dsun=1 -DSVR4 -DBSD_COMP -DCFG_GettodFtime \\\n";
char *hpux_cc_opts = "\t-O -Dhpux=1\\\n";
char *hpux_gcc_opts = "\t-Dhpux=1 \\\n";
char *hpux_sigtype = "void";
char *svr4_cc_opts = "\t-O -DSVR4 \\\n";
char *svr4_gcc_opts = "\t-DSVR4 \\\n";
char *svr4_sigtype = "void";
char *aix_cc_opts = "\t-O -DAIX \\\n";
char *aix_gcc_opts = "\t-DAIX \\\n";
char *aix_sigtype = "void";
/*
* ncurses.h location varies on Linux;
* this works for Slackware 1.1.59 and some previous port
*/
char *linux_gcc_opts = "\t-Di386 -I/usr/include/ncurses \\\n";
char *linux_sigtype = "void";
char *bsd_gcc_opts = "\t-DBSD";
char *bsd_sigtype = "void";
#ifdef __FreeBSD__
char *freebsd_gcc_opts = "";
#else
char *freebsd_gcc_opts = "\t-D__FreeBSD__ \\\n";
#endif
char *freebsd_sigtype = "void";
int gcc_wall = 0;
/*
* LIBS
*/
char *_sco_libs[] =
{
"-lcurses -lx",
"-lcurses -lmalloc -lc_s -lc -lx",
"-lcurses -lmalloc -lc_s -lc -lx",
"-L/usr/lib -lcurses -lmalloc -lc -lx",
"-L/usr/lib -lcurses -lmalloc", /* OS7 */
};
char *_sco2_libs[] =
{
"-lcurses -lx",
"-lcurses -lmalloc -lc_s -lc -lx",
"-lcurses -lmalloc -lc_s -lc -lx",
"", /* not used for 3.2v5 */
"", /* not used for OS7 */
};
char **sco_libs = _sco_libs;
char *isc_libs = "-lcurses -ltelnet -lmalloc -lc_s -lc -lx";
char *motsvr3_libs = "-lcurses -ltermcap";
char *sun_libs = "-lcurses -ltermcap";
char *solaris2_libs = "-lcurses -ltermcap -lmalloc -lsocket -lnsl";
char *svr4_libs = "-lcurses -lmalloc";
char *svr4socket_libs = "-lcurses -lmalloc -lsocket -lnsl";
char *aix_libs = "-lcurses";
char *linux_libs = "-lncurses";
char *hpux_libs = "-lcurses -ltermcap";
char *bsd_libs = "-lcurses -ltermcap";
char *freebsd_libs = "-lncurses -lmytinfo -lcompat";
char *sco_system[] =
{
"XENIX/386",
"UNIX/386",
"UNIX/386 3.2v4",
"OS5/3.2v5",
"OS7",
};
int intdial_to = 60;
char *malloc_3x = "\t-DCFG_Malloc3X \\\n";
char s256[256];
char *tty = "tty1A";
char *bit_rate = "9600";
int parity = 0;
char *bindir = "/usr/local/bin";
char *libdir = "/usr/local/lib/ecu";
char *symbolic = "";
int ecuungetty_appropriate = 0;
char *use_ecuungetty = "no";
char *ecuungetty_all_lines = "no";
char *ecu_owner = "bin";
char *ecu_group = "bin";
char *ecu_mode = "711";
int major_version_number;
int sys = -1;
int compiler = -1;
int sco_type = -1;
int look_for_network = 0;
char *libsocket_discovered = 0;
int can_pipe = 0;
int has_fd_set = 0;
char cfg_fdset[128] = "fd_set";
int seteuid_discovered = 0;
int has_strerror = 0;
int has_timeval = 0;
int need_timeval = 0;
int need_select_h = 0;
int fionread_in_filio_h = 0;
int fionread_in_socket_h = 0;
int look_for_ncurses = 0;
int need_ncurses_h = 0;
#ifdef WHT
int screen_lines = 85;
int screen_columns = 132;
#else
int screen_lines = 50;
int screen_columns = 80;
#endif
FILE *fpmake;
/*+-------------------------------------------------------------------------
goodbye(sig)
--------------------------------------------------------------------------*/
void
goodbye(sig)
int sig;
{
setty(0);
printf("\r\n");
exit(sig);
} /* end of goodbye */
/*+-------------------------------------------------------------------------
tputstrs(strs)
--------------------------------------------------------------------------*/
void
tputstrs(strs)
char **strs;
{
while (*strs)
fputs(*strs++, stdout);
} /* end of tputstrs */
/*+-------------------------------------------------------------------------
tputstrsfp(strs)
--------------------------------------------------------------------------*/
void
tputstrsfp(strs)
char **strs;
{
while (*strs)
fputs(*strs++, fpmake);
} /* end of tputstrsfp */
/*+-------------------------------------------------------------------------
tgetc()
--------------------------------------------------------------------------*/
char
tgetc()
{
char rtn;
setty(1);
read(0, &rtn, 1);
rtn &= 0x7F;
setty(0);
if (rtn != 0x0A)
printf("\n", rtn);
return (rtn);
} /* end of tgetc */
/*+-------------------------------------------------------------------------
tgets(buf)
--------------------------------------------------------------------------*/
void
tgets(buf)
char *buf;
{
char *tmp;
if (!(fgets(buf, CBUFSIZE, stdin)))
goodbye(1);
if ((tmp = strchr(buf, '\n')))
*tmp = '\0';
} /* end of tgets */
/*+-------------------------------------------------------------------------
tgetopt(prompt, choices, deflt)
--------------------------------------------------------------------------*/
char
tgetopt(prompt, choices, deflt)
char *prompt;
char *choices;
char deflt;
{
char rtn = 0;
char response;
char *cp;
printf("\n%s (", prompt);
while (!rtn)
{
cp = choices;
while (*cp)
{
if (cp - choices)
putchar(',');
if (*cp == deflt)
putchar('[');
putchar(*cp);
if (*cp == deflt)
putchar(']');
cp++;
}
printf(")? ");
response = tgetc();
if (strchr(choices, response))
rtn = response;
else if ((response == 0x0D) || (response == 0x0A))
rtn = deflt;
else
printf("Please answer with one of (");
}
return (rtn);
} /* end of tgetopt */
/*+-------------------------------------------------------------------------
gen_cc_cflags()
--------------------------------------------------------------------------*/
void
gen_cc_cflags()
{
fputs("CFLAGS = \\\n", fpmake);
switch (sys)
{
case S_SCO:
fputs(sco_cc_opts[sco_type], fpmake);
if (sco_type >= X_32v4)
{
fprintf(fpmake, "\t-DSCO32v4%s%s \\\n",
(sco_type >= X_32v5) ? " -DSCO32v5" : "",
(sco_type >= X_OS7) ? " -DSCOOS7" : "");
need_timeval = 1;
}
if (sco_type >= X_UNIX)
fputs(malloc_3x, fpmake);
fputs("\t-DCFG_LockDir='\"/usr/spool/uucp\"' \\\n", fpmake);
fputs("\t-DCFG_GettodFtime \\\n", fpmake);
if(sco_type >= X_OS7) /* FIONREAD no good on OS5 console */
fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
break;
case S_ISC:
fputs(isc_cc_opts, fpmake);
fputs(malloc_3x, fpmake);
need_timeval = 1;
fputs("\t-DCFG_LockDir='\"/usr/spool/locks\"' \\\n", fpmake);
break;
case S_MOTSVR3:
fputs(motsvr3_cc_opts, fpmake);
fputs(malloc_3x, fpmake);
fputs("\t-DCFG_GettodFtime -DCFG_FionreadRdchk \\\n",
fpmake);
need_timeval = 1;
fputs("\t-DCFG_LockDir='\"/usr/spool/locks\"' \\\n", fpmake);
break;
case S_SUN:
fputs(sun_cc_opts, fpmake);
fputs(malloc_3x, fpmake);
fputs("\t-DCFG_TermiosLineio -DCFG_TelnetOption \\\n", fpmake);
need_timeval = 1;
fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
break;
case S_SOLARIS2:
fputs(solaris2_cc_opts, fpmake);
fputs(malloc_3x, fpmake);
fputs("\t-DCFG_TermiosLineio \\\n", fpmake);
need_timeval = 1;
fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
break;
case S_HPUX:
fputs(hpux_cc_opts, fpmake);
fputs(malloc_3x, fpmake);
fputs("\t-DCFG_FionreadRdchk\\\n", fpmake);
need_timeval = 1;
fputs("\t-DCFG_BinaryUucpPids\\\n", fpmake);
fputs("\t-DCFG_LockDir='\"/usr/spool/uucp\"' \\\n", fpmake);
break;
case S_ISCSVR4:
fputs(svr4_cc_opts, fpmake);
fputs("\t-DISCSVR4 \\\n", fpmake);
fputs(malloc_3x, fpmake);
need_timeval = 1;
fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
break;
case S_ESIXSVR4:
fputs(svr4_cc_opts, fpmake);
fputs("\t-DESIXSVR4 \\\n", fpmake);
fputs(malloc_3x, fpmake);
need_timeval = 1;
fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
break;
case S_SVR4:
fputs(svr4_cc_opts, fpmake);
fputs("\t-DSVR4 \\\n", fpmake);
fputs(malloc_3x, fpmake);
need_timeval = 1;
fputs("\t-DCFG_FionreadRdchk\\\n", fpmake);
fputs("\t-DCFG_TermiosLineio -DCFG_TelnetOption \\\n", fpmake);
fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
break;
case S_AIX:
fputs(aix_cc_opts, fpmake);
fputs(malloc_3x, fpmake);
need_timeval = 1;
fputs("\t-DCFG_TelnetOption \\\n", fpmake);
fputs("\t-DCFG_FionreadRdchk -DCFG_GettodFtime\\\n", fpmake);
fputs("\t-DCFG_UseStructWinsize \\\n", fpmake);
fputs("\t-DCFG_LockDir='\"/var/spool/uucp\"' \\\n", fpmake);
fputs("\t-DCFG_NeedStdlibH -DCFG_GetpgrpVoidArg\\\n", fpmake);
break;
default:
printf("\ngen_cc_flags logic error %d.\n",sys);
exit(1);
}
fputs("\t$(CFLAGS_EXTRA) $(CC_CFLAGS_EXTRA) \\\n ", fpmake);
} /* end of gen_cc_cflags */
/*+-------------------------------------------------------------------------
gen_gcc_cflags()
--------------------------------------------------------------------------*/
void
gen_gcc_cflags()
{
char **strs;
fputs("CFLAGS = \\\n", fpmake);
strs = gcc_opts;
while (*strs)
fputs(*strs++, fpmake);
if (can_pipe)
fputs("\t-pipe \\\n", fpmake);
if (gcc_wall)
fputs("\t-Wall \\\n", fpmake);
switch (sys)
{
case S_SCO:
fputs(sco_gcc_opts[sco_type], fpmake);
if (sco_type >= X_32v4)
{
fprintf(fpmake, "\t-DSCO32v4%s%s \\\n",
(sco_type >= X_32v5) ? " -DSCO32v5" : "",
(sco_type >= X_OS7) ? " -DSCOOS7" : "");
need_timeval = 1;
}
if (sco_type >= X_UNIX)
fputs(malloc_3x, fpmake);
fputs("\t-DCFG_LockDir='\"/usr/spool/uucp\"' \\\n", fpmake);
fputs("\t-DCFG_GettodFtime \\\n", fpmake);
if(sco_type >= X_OS7) /* FIONREAD no good on OS5 console */
fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
break;
case S_ISC:
fputs(isc_gcc_opts, fpmake);
fputs(malloc_3x, fpmake);
need_timeval = 1;
fputs("\t-DCFG_LockDir='\"/usr/spool/locks\"' \\\n", fpmake);
break;
case S_MOTSVR3:
fputs(motsvr3_gcc_opts, fpmake);
fputs(malloc_3x, fpmake);
fputs("\t-DCFG_GettodFtime \\\n", fpmake);
need_timeval = 1;
fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
fputs("\t-DCFG_LockDir='\"/usr/spool/locks\"' \\\n", fpmake);
break;
case S_SUN:
fputs(sun_gcc_opts, fpmake);
fputs(malloc_3x, fpmake);
fputs("\t-DCFG_TermiosLineio -DCFG_TelnetOption \\\n", fpmake);
need_timeval = 1;
fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
break;
case S_SOLARIS2:
fputs(solaris2_gcc_opts, fpmake);
fputs(malloc_3x, fpmake);
fputs("\t-DCFG_TermiosLineio \\\n", fpmake);
need_timeval = 1;
fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
break;
case S_ISCSVR4:
fputs(svr4_gcc_opts, fpmake);
fputs("\t-DISCSVR4 \\\n", fpmake);
fputs(malloc_3x, fpmake);
need_timeval = 1;
fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
break;
case S_ESIXSVR4:
fputs(svr4_gcc_opts, fpmake);
fputs("\t-DESIXSVR4 \\\n", fpmake);
fputs(malloc_3x, fpmake);
need_timeval = 1;
fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
break;
case S_SVR4:
fputs(svr4_gcc_opts, fpmake);
fputs("\t-DSVR4 \\\n", fpmake);
fputs(malloc_3x, fpmake);
fputs("\t-DCFG_FionreadRdchk\\\n", fpmake);
fputs("\t-DCFG_TermiosLineio -DCFG_TelnetOption \\\n", fpmake);
need_timeval = 1;
fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
break;
case S_AIX:
fputs(aix_gcc_opts, fpmake);
fputs(malloc_3x, fpmake);
need_timeval = 1;
fputs("\t-DCFG_TelnetOption \\\n", fpmake);
fputs("\t-DCFG_FionreadRdchk -DCFG_GettodFtime\\\n", fpmake);
fputs("\t-DCFG_UseStructWinsize \\\n", fpmake);
fputs("\t-DCFG_LockDir='\"/var/spool/uucp\"' \\\n", fpmake);
break;
case S_LINUX:
fputs(linux_gcc_opts, fpmake);
fputs("\t-DCFG_FionreadRdchk -DCFG_TelnetOption \\\n", fpmake);
fputs("\t-DCFG_UseSetupterm -DCFG_UseStructWinsize \\\n", fpmake);
need_timeval = 1;
#if 0 /* no more -- redhat 5 complained bitterly */
fputs("\t-DCFG_TermiosLineio \\\n", fpmake);
#endif
fputs("\t-DCFG_LockDir='\"/var/spool/uucp\"' \\\n", fpmake);
break;
case S_HPUX:
fputs(hpux_gcc_opts, fpmake);
fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
need_timeval = 1;
fputs("\t-DCFG_BinaryUucpPids\\\n", fpmake);
fputs("\t-DCFG_LockDir='\"/usr/spool/uucp\"' \\\n", fpmake);
break;
case S_BSD:
fputs(bsd_gcc_opts, fpmake);
fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
need_timeval = 1;
fputs("\t-DCFG_TermiosLineio \\\n", fpmake);
fputs("\t-DCFG_MmapSHM -DCFG_GettodFtime \\\n", fpmake);
fputs("\t-DCFG_NoAnsiEmulation \\\n", fpmake);
fputs("\t-DCFG_LockDir='\"/var/spool/lock\"' \\\n", fpmake);
break;
case S_FREEBSD:
fputs(freebsd_gcc_opts, fpmake);
fputs("\t-DCFG_FionreadRdchk -DCFG_NeedStdlibH\\\n", fpmake);
need_timeval = 1;
fputs("\t-DCFG_UseSetupterm \\\n", fpmake);
fputs("\t-DCFG_TelnetOption \\\n", fpmake);
fputs("\t-DCFG_TermiosLineio \\\n", fpmake);
fputs("\t-DCFG_MmapSHM \\\n", fpmake);
fputs("\t-DCFG_LockDir='\"/var/spool/lock\"' \\\n", fpmake);
break;
default:
printf("\ngen_gcc_cflags logic error %d.\n",sys);
exit(1);
}
fputs("\t$(CFLAGS_EXTRA) $(GCC_CFLAGS_EXTRA) \\\n ", fpmake);
} /* end of gen_gcc_cflags */
/*+-------------------------------------------------------------------------
gen_common_cflags()
--------------------------------------------------------------------------*/
void
gen_common_cflags()
{
fputs("\t-DCFG_SigType=$(SIGTYPE) \\\n", fpmake);
if (has_fd_set || has_strerror || need_select_h || fionread_in_filio_h)
{
fprintf(fpmake, "\t%s%s%s%s%s\\\n",
(has_strerror) ? "-DCFG_HasStrerror " : "",
(need_select_h) ? "-DCFG_IncSelectH " : "",
(fionread_in_filio_h) ? "-DCFG_FionreadInFilioH " : "",
(fionread_in_socket_h) ? "-DCFG_FionreadInSocketH " : "",
(has_fd_set) ? "-DCFG_HasFdSet " : "");
if(has_fd_set)
fprintf(fpmake,"\t-DCFG_FDSET='%s' \\\n",cfg_fdset);
}
if (need_ncurses_h == 1)
fputs("\t-DCFG_UseNcursesH \\\n",fpmake);
else if (need_ncurses_h == 2)
fprintf(fpmake, "\t-DCFG_UseNcursesNcursesH \\\n");
if (seteuid_discovered)
fprintf(fpmake, "\t-DCFG_UseSeteuid \\\n");
if (libsocket_discovered)
fputs("\t-DCFG_TelnetOption \\\n", fpmake);
if (*use_ecuungetty == 'y')
fputs("\t-DCFG_UseUngetty -DCFG_UngettyChown \\\n", fpmake);
if (*ecuungetty_all_lines == 'y')
fputs("\t-DCFG_UngettyAllLines \\\n", fpmake);
fprintf(fpmake, "\t-DCFG_ScreenLinesMax=%d -DCFG_ScreenColsMax=%d \\\n",
screen_lines, screen_columns);
fprintf(fpmake, "\t-DCFG_DefaultTty='\"/dev/%s\"' \\\n", tty);
fprintf(fpmake, "\t-DCFG_DefaultBitRate=%s \\\n", bit_rate);
fprintf(fpmake, "\t-DCFG_DefaultParity=\"'%c'\" \\\n", parity);
fprintf(fpmake, "\t-DCFG_DialTimeout=%d \\\n", intdial_to);
fputs("\t-DCFG_HdbLibDir='\"$(HDBLIBDIR)\"' \\\n", fpmake);
fputs("\t-DCFG_EcuLibDir='\"$(ECULIBDIR)\"' \\\n", fpmake);
fputs(pid_type, fpmake);
fputs("\t-DCFG_LogXfer \\\n", fpmake);
#ifdef WHT
fputs("\t-DWHT \\\n", fpmake);
#endif
fputs("\t$(SYMBOLIC) $(LOCAL_CFLAGS)\n\n", fpmake);
} /* end of gen_common_cflags */
/*+-------------------------------------------------------------------------
fix_libraries(libspec) - add libraries to template (maybe)
We want to place -lsocket into an SVR3 library list if we have
"discovered sockets" on the machine
Look for -lc_s or -lc on the lib line and place -lsocket in front
of it. If neither found, throw it on the end
This is a kludge, but I don't have time to think.
--------------------------------------------------------------------------*/
char *
fix_libraries(libspec)
char *libspec;
{
static char fixed[256];
int found;
int pos;
char *search;
char *cp;
char ch;
if (!libsocket_discovered)
return (libspec);
found = 0;
cp = libspec;
while (*cp)
{
if (!strncmp(cp, "-lc_s", 5) && (!(ch = *(cp + 5)) || (ch == ' ')))
{
found = 1;
break;
}
cp++;
}
if (!found)
{
cp = libspec;
while (*cp)
{
if (!strncmp(cp, "-lc", 3) && (!(ch = *(cp + 3)) || (ch == ' ')))
{
found = 1;
break;
}
cp++;
}
}
if (!found)
{
strcpy(fixed, libspec);
strcat(fixed, " ");
strcat(fixed, libsocket_discovered);
return (fixed);
}
pos = (int)(cp - libspec);
memcpy(fixed, libspec, pos);
strcpy(fixed + pos, libsocket_discovered);
strcat(fixed, " ");
strcat(fixed, cp);
return (fixed);
} /* end of fix_libraries */
/*+-------------------------------------------------------------------------
gen_sco_ldflags()
--------------------------------------------------------------------------*/
void
gen_sco_ldflags()
{
char *fixlib = fix_libraries(sco_libs[sco_type]);
fputs("LDFLAGS = \\\n", fpmake);
if (compiler == C_CC)
fputs(sco_cc_opts[sco_type], fpmake);
fputs("\t$(SYMBOLIC) $(LDFLAGS_EXTRA)\n\n", fpmake);
fprintf(fpmake, "LIBS= $(LOCAL_LIBS) %s\n\n", fixlib);
} /* end of gen_sco_ldflags */
/*+-------------------------------------------------------------------------
gen_isc_ldflags()
--------------------------------------------------------------------------*/
void