config.c 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372
  1. /* CHK=0x8848 */
  2. char *rev = "4.40";
  3. /* #define FORCE_DASH_G */
  4. #if defined(WHT) && !defined(FORCE_DASH_G)
  5. #define FORCE_DASH_G
  6. #endif
  7. /*+-------------------------------------------------------------------------
  8. config.c - Makefile configuration program for ECU
  9. wht@n4hgf.atl.ga.us
  10. This must be compiled with the *NATIVE* cc or else you must
  11. fake all of the predefines the native compiler supplies. The
  12. Configure script can pass stuff in CFLAGS to tickle config a
  13. bit.
  14. 'I love it. God help me, I love it so. I love it more than my
  15. life.' -- George C. Scott as Patton in _Patton_
  16. Defined functions:
  17. config_setup()
  18. find_string_in_file(fname, str)
  19. find_stuff()
  20. fix_libraries(libspec)
  21. gen_bsd_ldflags()
  22. gen_cc_cflags()
  23. gen_common_cflags()
  24. gen_freebsd_ldflags()
  25. gen_gcc_cflags()
  26. gen_hpux_ldflags()
  27. gen_isc_ldflags()
  28. gen_linux_ldflags()
  29. gen_motsvr3_ldflags()
  30. gen_sco_ldflags()
  31. gen_solaris2_ldflags()
  32. gen_sun_ldflags()
  33. gen_svr4_ldflags(include_socket)
  34. generate_config(mdir)
  35. goodbye(sig)
  36. main(argc, argv)
  37. tgetc()
  38. tgetopt(prompt, choices, deflt)
  39. tgets(buf)
  40. tputstrs(strs)
  41. tputstrsfp(strs)
  42. type (or the `nearest equivalent')
  43. --------------------------------------------------------------------------*/
  44. /*+:EDITS:*/
  45. /*:04-26-2000-11:15-wht@bob-RELEASE 4.42 */
  46. /*:03-24-2000-19:17-wht@blue-3.41-Linux uucp spool dir was wrong */
  47. /*:02-25-1998-21:30-wht@menlo-port to redhat5/linux2 */
  48. /*:12-22-1997-15:48-wht@kepler-use FIONREAD for SVR4 */
  49. /*:12-21-1997-13:50-wht@sidonia-add CFG_UseSetupterm and CFG_UseStructWinsize */
  50. /*:12-21-1997-00:18-wht@kepler-FIONREAD no good on OS5 console */
  51. /*:12-18-1997-18:58-wht@kepler-adjust solaris */
  52. /*:12-18-1997-06:05-wht@sidonia-port to AIX */
  53. /*:12-18-1997-16:18-wht@kepler-w/help from robertle@sco.com fixOS5/OS7 */
  54. /*:12-15-1997-21:14-wht@kepler-look for FIONREAD in linux/termios */
  55. /*:12-15-1997-19:57-wht@fep-find_string_in_file prints stat diagnostics */
  56. /*:12-15-1997-19:42-wht@fep-add CFG_FionreadInSocketH */
  57. /*:12-15-1997-19:34-wht@fep-rename CFG_FilioH to CFG_FionreadInFilioH */
  58. /*:12-12-1997-17:48-wht@kepler-minor minor tweak to add OS7 for Bob Lewis */
  59. /*:03-16-1997-02:36-rll@felton.felton.ca.us-make boxes for SCO Products */
  60. /*:01-24-1997-02:36-wht@yuriatin-SOURCE RELEASE 4.00 */
  61. /*:11-12-1996-12:57-wht@yuriatin-SCO UnixWare and Motorola SVR4 equivalent */
  62. /*:10-11-1996-02:09-wht@yuriatin-add CFG_FilioH */
  63. /*:09-20-1996-05:12-wht@yuriatin-more comprehensive inet support check */
  64. /*:09-17-1996-04:53-wht@yuriatin-autoconfig network for SCO */
  65. /*:09-11-1996-19:59-wht@yuriatin-3.48-major telnet,curses,structural overhaul */
  66. /*:09-05-1996-17:38-wht@kepler-WHT gets 132x85 */
  67. /*:09-05-1996-17:26-wht@kepler-ncurses: look_for_ncurses,DCFG_UseNcursesH */
  68. /*:09-04-1996-05:39-wht@kepler-use cua0, not ttyS0 for linux default */
  69. /*:08-29-1996-15:52-wht@yuriatin-my Motorola gcc can pipe */
  70. /*:08-22-1996-14:28-wht@fep-accommodate SVR4 socket */
  71. /*:08-21-1996-16:27-wht@fep-use CFG_ ident for all config */
  72. /*:07-31-1996-16:40-wht@kepler-use /etc/uucp for FreeBSD per dgy@rtd.com */
  73. /*:07-24-1996-20:37-wht@n4hgf-add NL to end of ecu_euid_test.c */
  74. /*:06-12-1996-19:17-wht@kepler-fix GCC_CFLAGS_EXTRA use */
  75. /*:04-02-1996-11:06-wht@kepler-apply ache FreeBSD fix: cc switches */
  76. /*:12-28-1995-12:54-wht@kepler-Andrey Chernov FreeBSD fixes */
  77. /*:12-04-1995-01:12-wht@kepler-SCO system() wont work with SIGCLD SIG_IGN */
  78. /*:12-03-1995-19:54-wht@gyro-add CFG_UseSeteuid */
  79. /*:11-23-1995-11:20-wht@kepler-source control 3.37 for tsx-11 */
  80. /*:11-23-1995-11:16-wht@kepler-default setuid uucp to yes */
  81. /*:11-14-1995-10:23-wht@kepler-3.37.80-source control point: SOCKETS */
  82. /*:11-12-1995-03:14-wht@kepler-CFG_TelnetOption good to go for SunOs & Linux */
  83. /*:11-12-1995-00:00-wht@gyro-NO_ANSI_EMULATION becomes CFG_NoAnsiEmulation */
  84. /*:11-04-1995-20:15-wht@kepler-24 lines are minimum ... what happened to fix? */
  85. /*:11-03-1995-17:00-wht@wwtp1-allow for LOCAL_LIBS */
  86. /*:11-03-1995-16:21-wht@wwtp1-v or 5 default for SCO */
  87. /*:10-18-1995-04:29-wht@kepler-always use select for nap */
  88. /*:10-15-1995-00:36-wht@n4hgf-drop SEAlink support */
  89. /*:10-14-1995-16:26-wht@kepler-remove pretense of 286 support */
  90. /*:09-02-1995-12:16-wht@n4hgf-runtime vs. ifdef for ecuungetty_appropriate */
  91. /*:09-02-1995-11:53-wht@n4hgf-add predefines 32v5ers abandoned */
  92. /*:09-01-1995-17:31-wht@n4hgf-OS5 gets -DSCO32v5 */
  93. /*:08-27-1995-07:15-wht@n4hgf-take queue on libdir based on bin subdir */
  94. /*:08-02-1995-19:13-wht@n4hgf-SCO engineer nice enough to finish OS5 port */
  95. /*:06-23-1995-01:01-wht@n4hgf-use ECUOWNER,ECUGROUP,ECUMODE */
  96. /*:06-15-1995-07:09-wht@kepler-dynamic CFG_HasStrerror */
  97. /*:06-14-1995-06:58-wht@n4hgf-no more SCO -nointl or obsolete cross-compile */
  98. /*:06-14-1995-06:32-wht@n4hgf-add SCO 3.2v5/Open Server 5 */
  99. /*:06-13-1995-22:14-wht@n4hgf-was overwriting screen_lines with columns */
  100. /*:04-09-1995-03:23-wht@gyro-add BSD_COMP to Solaris CFLAGS */
  101. /*:03-28-1995-21:35-wht@n4hgf-clean up lines/cols input */
  102. /*:03-11-1995-17:12-wht@kepler-auto-detect linux for 1st choice default */
  103. /*:03-11-1995-17:09-wht@kepler-check linux/types.h if found */
  104. /*:03-11-1995-17:08-wht@kepler-Linux can -pipe */
  105. /*:01-15-1995-02:00-wht@n4hgf-rid rubbish undoc switches + add gcc_wall */
  106. /*:01-15-1995-01:51-wht@n4hgf-patch the patch -- Andrew is patient with me */
  107. /*:01-12-1995-15:19-wht@n4hgf-apply Andrew Chernov 8-bit clean+FreeBSD patch */
  108. /*:06-10-1994-14:56-wht@kepler-was not including -g CFLAG on FORCE_DASH_G */
  109. /*:05-11-1994-16:03-wht@n4hgf-#define WHT causes -DWHT */
  110. /*:05-04-1994-04:38-wht@n4hgf-ECU release 3.30 */
  111. /*:05-02-1994-03:10-wht@fep-cannot fix for all: warn of gcc overflow warnings */
  112. /*:04-05-1994-17:11-wht@n4hgf-correct my first ever = for == substitution */
  113. /*:03-13-1994-16:28-wht@fep-add Motorola SVR4 */
  114. /*:01-25-1994-17:36-wht@n4hgf-USE_DECIMAL_PIDS->CFG_BinaryUucpPids */
  115. /*:01-04-1994-07:23-wht@fep-implement CFG_DialTimeout */
  116. /*:12-12-1993-13:44-wht@fep-use enum to catch missing cases */
  117. /*:12-12-1993-13:36-wht@fep-remove obsolete -DISC22 */
  118. /*:12-12-1993-13:31-wht@fep-MOTSVR3 == Motorola Delta SVR3 for 88k */
  119. /*:12-10-1993-22:09-wht@n4vu-more Linux fixes + add sun -DCFG_TermiosLineio */
  120. /*:12-02-1993-15:44-wht@n4hgf-some Linux includes may be root-readable only */
  121. /*:11-14-1993-12:33-wht@n4hgf-HP-UX port by Carl Wuebker at HP */
  122. /*:11-12-1993-11:00-wht@n4hgf-Linux changes by bob@vancouver.zadall.com */
  123. /*:10-04-1993-04:07-wht@n4hgf-simplify SCO optimization choice */
  124. /*:08-30-1993-11:44-wht@n4hgf-remove obsolete i86-specific gcc opts */
  125. /*:08-17-1993-04:14-wht@n4hgf-Wuninitialized always on */
  126. /*:08-17-1993-04:14-wht@n4hgf-remove -fforce-mem/-fforce-addr from gcc flags */
  127. /*:03-17-1993-14:55-wht@n4hgf-remove soon to be obsolete LNG353 warnings */
  128. /*:02-16-1993-13:18-wht@n4hgf-remove -Mlt128 from 286 per vancleef@netcom.com */
  129. /*:01-30-1993-13:20-wht@n4hgf-add -Wuninitialized */
  130. /*:01-30-1993-12:06-wht@n4hgf-gcc 2.3.3 gets -O6 */
  131. /*:01-21-1993-00:07-wht@n4hgf-3.2v4 now the SCO UNIX default */
  132. /*:01-21-1993-00:06-wht@n4hgf-augment gcc switches */
  133. /*:12-12-1992-12:22-wht@n4hgf-no built in functions when using gcc */
  134. /*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  135. /*:09-10-1992-04:39-wht@n4hgf-admonition about SunOS IPC config */
  136. /*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  137. /*:08-21-1992-13:46-wht@n4hgf-don't configure ecuungetty if not used on a sys */
  138. /*:08-11-1992-06:04-wht@n4hgf-FORCE_DASH_G and 3.2v4 LNG353 warnings */
  139. /*:07-12-1992-07:17-wht@n4hgf-3.2v4 has a fully functional nap and select */
  140. /*:07-02-1992-20:41-wht@n4hgf-rework for more options + 3.2v4 CFG_PidType */
  141. /*:06-18-1992-11:19-root@n4hgf-SCO 3.2v4 gcc CFLAG additions */
  142. /*:04-23-1992-14:04-wht@n4hgf-had XENIX curses lib paths wrong */
  143. /*:04-19-1992-21:55-wht@n4hgf-pressing return or enter gets tgeopt default */
  144. /*:04-19-1992-21:43-wht@n4hgf-add default for tgetopt */
  145. /*:04-19-1992-02:55-wht@n4hgf-add ESIX SVR4 config */
  146. /*:04-17-1992-20:08-wht@n4hgf-add tty, bit_rate and parity questions */
  147. /*:03-20-1992-03:08-wht@n4hgf-correct XENIX tcap/tlib test thanks to tbetz */
  148. /*:03-01-1992-13:36-wht@n4hgf-add -Wswitch to gcc compiles */
  149. /*:02-06-1992-15:23-wht@n4hgf-depressing ... SCO keeps chging their minds */
  150. /*:10-17-1991-14:51-wht@n4hgf-add can_pipe code */
  151. /*:09-03-1991-12:53-wht@n4hgf2-iron out sun gcc options */
  152. /*:09-01-1991-16:32-wht@n4hgf2-show package and config versions */
  153. /*:09-01-1991-15:59-wht@n4hgf2-generalize HDB Devices, etc. files location */
  154. /*:08-28-1991-14:07-wht@n4hgf2-SVR4 cleanup by aega84!lh */
  155. /*:08-25-1991-14:39-wht@n4hgf-SVR4 port thanks to aega84!lh */
  156. /*:08-23-1991-01:37-wht@n4hgf-sun port */
  157. /*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
  158. /*:07-12-1991-14:02-wht@n4hgf-GCC140 update */
  159. /*:05-02-1991-02:46-wht@n4hgf-take out M_TERMCAP in favor of ecucurses.h */
  160. /*:04-28-1991-03:44-wht@n4hgf-add -Dconst= for X286 under UNIX */
  161. /*:04-20-1991-17:26-wht@n4hgf-creation */
  162. #include <stdio.h>
  163. #include <ctype.h>
  164. #include <signal.h>
  165. #include <string.h>
  166. #include <errno.h>
  167. #include "ecu_config.h"
  168. #include "ecu_types.h"
  169. #include "ecu_stat.h"
  170. #include "patchlevel.h"
  171. /*
  172. * this definition must be made w/o the aid of config,
  173. * since we are just building it now
  174. */
  175. #if defined(SVR4) || defined(USE_TERMIOS) || defined(CFG_TermiosLineio)
  176. #include <termios.h>
  177. #define termio termios
  178. #define setty(arg) tcsetattr(0,TCSADRAIN,(arg) ? &tty1 : &tty0)
  179. #else
  180. #include <termio.h>
  181. #define setty(arg) ioctl(0,TCSETAW,(arg) ? (char *)&tty1 : (char *)&tty0)
  182. #endif
  183. struct termio tty0;
  184. struct termio tty1;
  185. #define CBUFSIZE 128
  186. enum sys_type
  187. {
  188. S_SCO,
  189. S_ISC,
  190. S_SUN,
  191. S_ISCSVR4,
  192. S_ESIXSVR4,
  193. S_LINUX,
  194. S_HPUX,
  195. S_MOTSVR3,
  196. S_SVR4,
  197. S_BSD,
  198. S_SOLARIS2,
  199. S_FREEBSD,
  200. S_AIX,
  201. };
  202. enum sco_type
  203. {
  204. X_X386,
  205. X_UNIX,
  206. X_32v4,
  207. X_32v5,
  208. X_OS7,
  209. };
  210. enum cc_type
  211. {
  212. C_CC,
  213. C_GCC,
  214. };
  215. char *makedirs[] =
  216. {
  217. ".",
  218. "./bperr",
  219. "./ecufriend",
  220. "./ecuungetty",
  221. "./gendial",
  222. "./help",
  223. "./z",
  224. (char *)0
  225. };
  226. char *strs_intro1[] =
  227. {
  228. "\n",
  229. ".-------------------.\n",
  230. "| ECU configuration |\n",
  231. "`-------------------'\n",
  232. (char *)0
  233. };
  234. char *strs_intro2[] =
  235. {
  236. #ifdef WHT
  237. "WHT features enabled.\n",
  238. "\n",
  239. #endif
  240. "Please answer these questions so that I can configure ECU.\n",
  241. "There are two types of answers, single character and string.\n",
  242. "Single character questions have the choices in () followed by a ?\n",
  243. "String questions are followed by a :\n",
  244. "Default answers appearing in [] are guesses. If you wish to use\n",
  245. "the default answer for a question, just press CR.\n",
  246. "\n",
  247. "Abort (DEL, ^C, etc.) now if you do not wish to continue.\n",
  248. (char *)0
  249. };
  250. char *strs_no_timeval[] =
  251. {
  252. "\n",
  253. "I am supposed to use select() for a nap() replacement, but I can't find\n",
  254. "a definition for `struct timeval' in sys/time.h nor sys/select.h\n",
  255. "By all means try a compile, but expect `unknown size', 'undefined' and\n",
  256. "other type error messages associated with missing struct definitions.\n",
  257. "Communicate your particulars to wht@n4hgf.atl.ga.us, PLEASE!\n",
  258. (char *)0
  259. };
  260. char *strs_mkdep[] =
  261. {
  262. "\n",
  263. "You are ready to make the program. It make take a while (now is a good\n",
  264. "time to Read The Fine Manual).\n",
  265. "\n",
  266. "You MAY wish to make depend first. It is not necessary to do this\n",
  267. "until you make source modifications or apply patches.\n",
  268. (char *)0
  269. };
  270. char *sco_cc_opts[] =
  271. {
  272. "\t-M3e -O \\\n", /* XENIX/386 */
  273. "\t-M3e -O \\\n", /* UNIX/386 3.2.0-3.2v2 */
  274. "\t-M3e -O \\\n", /* UNIX/386 3.2v4 */
  275. "\t-b elf -dy -O \\\n", /* 32v5 OS5 */
  276. "\t-b elf -dy -O \\\n" /* OS7 */
  277. };
  278. char *sco_sigtype[] =
  279. {
  280. "void", /* XENIX/386 */
  281. "void", /* UNIX/386 3.2.0-3.2v2 */
  282. "void", /* UNIX/386 3.2v4 */
  283. "void", /* UNIX/386 3.2v5 */
  284. "void" /* OS7 */
  285. };
  286. char *pid_type = "\t-DCFG_PidType=int \\\n";
  287. /*
  288. * GCC CFLAGS
  289. */
  290. char *gcc_opts[] =
  291. {
  292. #ifdef PEDANTIC
  293. "\t-pedantic -ansi -O2 -fno-builtin\\\n", /* UH OH: see ecu README */
  294. #else
  295. "\t-O2 -fno-builtin\\\n",
  296. #endif
  297. "\t-finline-functions\\\n",
  298. "\t-W -Wuninitialized -Wunused -Wshadow -Wcomment -Wswitch\\\n",
  299. "\t-Dconst=\\\n",
  300. (char *)0
  301. };
  302. char *sco_gcc_opts[] =
  303. {
  304. /*
  305. * XENIX/386
  306. */
  307. "\t-DM_XENIX -DM_SYSV -DM_SYS5 -DM_I386 \\\n\
  308. \t-DM_BITFIELDS -DM_COFF -DM_I386 -DM_I86 -DM_I86SM \\\n\
  309. \t-DM_INTERNAT -DM_SDATA -DM_STEXT -DM_SYS3 \\\n\
  310. \t-DM_SYSIII -DM_WORDSWAP -Di386\\\n",
  311. /*
  312. * UNIX/386 3.2.0..3.2v2
  313. */
  314. "\t-DM_BITFIELDS -DM_COFF -DM_I386 -DM_I86 -DM_I86SM \\\n\
  315. \t-DM_INTERNAT -DM_SDATA -DM_STEXT -DM_SYS3 -DM_SYS5 \\\n\
  316. \t-DM_SYSIII -DM_SYSV -DM_UNIX -DM_WORDSWAP -DM_XENIX -Dunix -Di386\\\n",
  317. /*
  318. * UNIX/386 3.2v4
  319. */
  320. "\t-D_SVID -D_KR -D__STDC__=0 \\\n\
  321. \t-DM_BITFIELDS -DM_COFF -DM_I386 -DM_I86 -DM_I86SM \\\n\
  322. \t-DM_INTERNAT -DM_SDATA -DM_STEXT -DM_SYS3 -DM_SYS5 \\\n\
  323. \t-DM_SYSIII -DM_SYSV -DM_UNIX -DM_WORDSWAP -DM_XENIX -Dunix -Di386\\\n",
  324. /*
  325. * 3.2v5 OS5
  326. */
  327. "\t-Wa,-belf -D_NO_STATIC \\\n\
  328. \t-DM_SDATA -DM_STEXT -DM_SYS3 -DM_SYS5 \\\n\
  329. \t-DM_SYSV -DM_UNIX -Dunix -Di386\\\n",
  330. /*
  331. * OS7
  332. */
  333. "\t-Wa,-belf \\\n",
  334. };
  335. char *motsvr3_cc_opts = "\t-O -DMOTSVR3 \\\n";
  336. char *motsvr3_gcc_opts = "\t-DMOTSVR3 \\\n";
  337. char *motsvr3_sigtype = "void";
  338. char *isc_cc_opts = "\t-O -DISC \\\n";
  339. char *isc_gcc_opts = "\t-DISC -Di386\\\n";
  340. char *isc_sigtype = "void";
  341. char *sun_cc_opts = "\t-O \\\n";
  342. char *sun_gcc_opts = "\t-Dsun=1 \\\n"; /* ansi gets __sun__ only */
  343. char *sun_sigtype = "void";
  344. char *solaris2_cc_opts = "\t-Dsun=1 -DSVR4 -DBSD_COMP -DCFG_GettodFtime \\\n";
  345. char *solaris2_gcc_opts = "\t-Dsun=1 -DSVR4 -DBSD_COMP -DCFG_GettodFtime \\\n";
  346. char *hpux_cc_opts = "\t-O -Dhpux=1\\\n";
  347. char *hpux_gcc_opts = "\t-Dhpux=1 \\\n";
  348. char *hpux_sigtype = "void";
  349. char *svr4_cc_opts = "\t-O -DSVR4 \\\n";
  350. char *svr4_gcc_opts = "\t-DSVR4 \\\n";
  351. char *svr4_sigtype = "void";
  352. char *aix_cc_opts = "\t-O -DAIX \\\n";
  353. char *aix_gcc_opts = "\t-DAIX \\\n";
  354. char *aix_sigtype = "void";
  355. /*
  356. * ncurses.h location varies on Linux;
  357. * this works for Slackware 1.1.59 and some previous port
  358. */
  359. char *linux_gcc_opts = "\t-Di386 -I/usr/include/ncurses \\\n";
  360. char *linux_sigtype = "void";
  361. char *bsd_gcc_opts = "\t-DBSD";
  362. char *bsd_sigtype = "void";
  363. #ifdef __FreeBSD__
  364. char *freebsd_gcc_opts = "";
  365. #else
  366. char *freebsd_gcc_opts = "\t-D__FreeBSD__ \\\n";
  367. #endif
  368. char *freebsd_sigtype = "void";
  369. int gcc_wall = 0;
  370. /*
  371. * LIBS
  372. */
  373. char *_sco_libs[] =
  374. {
  375. "-lcurses -lx",
  376. "-lcurses -lmalloc -lc_s -lc -lx",
  377. "-lcurses -lmalloc -lc_s -lc -lx",
  378. "-L/usr/lib -lcurses -lmalloc -lc -lx",
  379. "-L/usr/lib -lcurses -lmalloc", /* OS7 */
  380. };
  381. char *_sco2_libs[] =
  382. {
  383. "-lcurses -lx",
  384. "-lcurses -lmalloc -lc_s -lc -lx",
  385. "-lcurses -lmalloc -lc_s -lc -lx",
  386. "", /* not used for 3.2v5 */
  387. "", /* not used for OS7 */
  388. };
  389. char **sco_libs = _sco_libs;
  390. char *isc_libs = "-lcurses -ltelnet -lmalloc -lc_s -lc -lx";
  391. char *motsvr3_libs = "-lcurses -ltermcap";
  392. char *sun_libs = "-lcurses -ltermcap";
  393. char *solaris2_libs = "-lcurses -ltermcap -lmalloc -lsocket -lnsl";
  394. char *svr4_libs = "-lcurses -lmalloc";
  395. char *svr4socket_libs = "-lcurses -lmalloc -lsocket -lnsl";
  396. char *aix_libs = "-lcurses";
  397. char *linux_libs = "-lncurses";
  398. char *hpux_libs = "-lcurses -ltermcap";
  399. char *bsd_libs = "-lcurses -ltermcap";
  400. char *freebsd_libs = "-lncurses -lmytinfo -lcompat";
  401. char *sco_system[] =
  402. {
  403. "XENIX/386",
  404. "UNIX/386",
  405. "UNIX/386 3.2v4",
  406. "OS5/3.2v5",
  407. "OS7",
  408. };
  409. int intdial_to = 60;
  410. char *malloc_3x = "\t-DCFG_Malloc3X \\\n";
  411. char s256[256];
  412. char *tty = "tty1A";
  413. char *bit_rate = "9600";
  414. int parity = 0;
  415. char *bindir = "/usr/local/bin";
  416. char *libdir = "/usr/local/lib/ecu";
  417. char *symbolic = "";
  418. int ecuungetty_appropriate = 0;
  419. char *use_ecuungetty = "no";
  420. char *ecuungetty_all_lines = "no";
  421. char *ecu_owner = "bin";
  422. char *ecu_group = "bin";
  423. char *ecu_mode = "711";
  424. int major_version_number;
  425. int sys = -1;
  426. int compiler = -1;
  427. int sco_type = -1;
  428. int look_for_network = 0;
  429. char *libsocket_discovered = 0;
  430. int can_pipe = 0;
  431. int has_fd_set = 0;
  432. char cfg_fdset[128] = "fd_set";
  433. int seteuid_discovered = 0;
  434. int has_strerror = 0;
  435. int has_timeval = 0;
  436. int need_timeval = 0;
  437. int need_select_h = 0;
  438. int fionread_in_filio_h = 0;
  439. int fionread_in_socket_h = 0;
  440. int look_for_ncurses = 0;
  441. int need_ncurses_h = 0;
  442. #ifdef WHT
  443. int screen_lines = 85;
  444. int screen_columns = 132;
  445. #else
  446. int screen_lines = 50;
  447. int screen_columns = 80;
  448. #endif
  449. FILE *fpmake;
  450. /*+-------------------------------------------------------------------------
  451. goodbye(sig)
  452. --------------------------------------------------------------------------*/
  453. void
  454. goodbye(sig)
  455. int sig;
  456. {
  457. setty(0);
  458. printf("\r\n");
  459. exit(sig);
  460. } /* end of goodbye */
  461. /*+-------------------------------------------------------------------------
  462. tputstrs(strs)
  463. --------------------------------------------------------------------------*/
  464. void
  465. tputstrs(strs)
  466. char **strs;
  467. {
  468. while (*strs)
  469. fputs(*strs++, stdout);
  470. } /* end of tputstrs */
  471. /*+-------------------------------------------------------------------------
  472. tputstrsfp(strs)
  473. --------------------------------------------------------------------------*/
  474. void
  475. tputstrsfp(strs)
  476. char **strs;
  477. {
  478. while (*strs)
  479. fputs(*strs++, fpmake);
  480. } /* end of tputstrsfp */
  481. /*+-------------------------------------------------------------------------
  482. tgetc()
  483. --------------------------------------------------------------------------*/
  484. char
  485. tgetc()
  486. {
  487. char rtn;
  488. setty(1);
  489. read(0, &rtn, 1);
  490. rtn &= 0x7F;
  491. setty(0);
  492. if (rtn != 0x0A)
  493. printf("\n", rtn);
  494. return (rtn);
  495. } /* end of tgetc */
  496. /*+-------------------------------------------------------------------------
  497. tgets(buf)
  498. --------------------------------------------------------------------------*/
  499. void
  500. tgets(buf)
  501. char *buf;
  502. {
  503. char *tmp;
  504. if (!(fgets(buf, CBUFSIZE, stdin)))
  505. goodbye(1);
  506. if ((tmp = strchr(buf, '\n')))
  507. *tmp = '\0';
  508. } /* end of tgets */
  509. /*+-------------------------------------------------------------------------
  510. tgetopt(prompt, choices, deflt)
  511. --------------------------------------------------------------------------*/
  512. char
  513. tgetopt(prompt, choices, deflt)
  514. char *prompt;
  515. char *choices;
  516. char deflt;
  517. {
  518. char rtn = 0;
  519. char response;
  520. char *cp;
  521. printf("\n%s (", prompt);
  522. while (!rtn)
  523. {
  524. cp = choices;
  525. while (*cp)
  526. {
  527. if (cp - choices)
  528. putchar(',');
  529. if (*cp == deflt)
  530. putchar('[');
  531. putchar(*cp);
  532. if (*cp == deflt)
  533. putchar(']');
  534. cp++;
  535. }
  536. printf(")? ");
  537. response = tgetc();
  538. if (strchr(choices, response))
  539. rtn = response;
  540. else if ((response == 0x0D) || (response == 0x0A))
  541. rtn = deflt;
  542. else
  543. printf("Please answer with one of (");
  544. }
  545. return (rtn);
  546. } /* end of tgetopt */
  547. /*+-------------------------------------------------------------------------
  548. gen_cc_cflags()
  549. --------------------------------------------------------------------------*/
  550. void
  551. gen_cc_cflags()
  552. {
  553. fputs("CFLAGS = \\\n", fpmake);
  554. switch (sys)
  555. {
  556. case S_SCO:
  557. fputs(sco_cc_opts[sco_type], fpmake);
  558. if (sco_type >= X_32v4)
  559. {
  560. fprintf(fpmake, "\t-DSCO32v4%s%s \\\n",
  561. (sco_type >= X_32v5) ? " -DSCO32v5" : "",
  562. (sco_type >= X_OS7) ? " -DSCOOS7" : "");
  563. need_timeval = 1;
  564. }
  565. if (sco_type >= X_UNIX)
  566. fputs(malloc_3x, fpmake);
  567. fputs("\t-DCFG_LockDir='\"/usr/spool/uucp\"' \\\n", fpmake);
  568. fputs("\t-DCFG_GettodFtime \\\n", fpmake);
  569. if(sco_type >= X_OS7) /* FIONREAD no good on OS5 console */
  570. fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
  571. break;
  572. case S_ISC:
  573. fputs(isc_cc_opts, fpmake);
  574. fputs(malloc_3x, fpmake);
  575. need_timeval = 1;
  576. fputs("\t-DCFG_LockDir='\"/usr/spool/locks\"' \\\n", fpmake);
  577. break;
  578. case S_MOTSVR3:
  579. fputs(motsvr3_cc_opts, fpmake);
  580. fputs(malloc_3x, fpmake);
  581. fputs("\t-DCFG_GettodFtime -DCFG_FionreadRdchk \\\n",
  582. fpmake);
  583. need_timeval = 1;
  584. fputs("\t-DCFG_LockDir='\"/usr/spool/locks\"' \\\n", fpmake);
  585. break;
  586. case S_SUN:
  587. fputs(sun_cc_opts, fpmake);
  588. fputs(malloc_3x, fpmake);
  589. fputs("\t-DCFG_TermiosLineio -DCFG_TelnetOption \\\n", fpmake);
  590. need_timeval = 1;
  591. fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
  592. fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
  593. break;
  594. case S_SOLARIS2:
  595. fputs(solaris2_cc_opts, fpmake);
  596. fputs(malloc_3x, fpmake);
  597. fputs("\t-DCFG_TermiosLineio \\\n", fpmake);
  598. need_timeval = 1;
  599. fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
  600. fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
  601. break;
  602. case S_HPUX:
  603. fputs(hpux_cc_opts, fpmake);
  604. fputs(malloc_3x, fpmake);
  605. fputs("\t-DCFG_FionreadRdchk\\\n", fpmake);
  606. need_timeval = 1;
  607. fputs("\t-DCFG_BinaryUucpPids\\\n", fpmake);
  608. fputs("\t-DCFG_LockDir='\"/usr/spool/uucp\"' \\\n", fpmake);
  609. break;
  610. case S_ISCSVR4:
  611. fputs(svr4_cc_opts, fpmake);
  612. fputs("\t-DISCSVR4 \\\n", fpmake);
  613. fputs(malloc_3x, fpmake);
  614. need_timeval = 1;
  615. fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
  616. break;
  617. case S_ESIXSVR4:
  618. fputs(svr4_cc_opts, fpmake);
  619. fputs("\t-DESIXSVR4 \\\n", fpmake);
  620. fputs(malloc_3x, fpmake);
  621. need_timeval = 1;
  622. fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
  623. break;
  624. case S_SVR4:
  625. fputs(svr4_cc_opts, fpmake);
  626. fputs("\t-DSVR4 \\\n", fpmake);
  627. fputs(malloc_3x, fpmake);
  628. need_timeval = 1;
  629. fputs("\t-DCFG_FionreadRdchk\\\n", fpmake);
  630. fputs("\t-DCFG_TermiosLineio -DCFG_TelnetOption \\\n", fpmake);
  631. fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
  632. break;
  633. case S_AIX:
  634. fputs(aix_cc_opts, fpmake);
  635. fputs(malloc_3x, fpmake);
  636. need_timeval = 1;
  637. fputs("\t-DCFG_TelnetOption \\\n", fpmake);
  638. fputs("\t-DCFG_FionreadRdchk -DCFG_GettodFtime\\\n", fpmake);
  639. fputs("\t-DCFG_UseStructWinsize \\\n", fpmake);
  640. fputs("\t-DCFG_LockDir='\"/var/spool/uucp\"' \\\n", fpmake);
  641. fputs("\t-DCFG_NeedStdlibH -DCFG_GetpgrpVoidArg\\\n", fpmake);
  642. break;
  643. default:
  644. printf("\ngen_cc_flags logic error %d.\n",sys);
  645. exit(1);
  646. }
  647. fputs("\t$(CFLAGS_EXTRA) $(CC_CFLAGS_EXTRA) \\\n ", fpmake);
  648. } /* end of gen_cc_cflags */
  649. /*+-------------------------------------------------------------------------
  650. gen_gcc_cflags()
  651. --------------------------------------------------------------------------*/
  652. void
  653. gen_gcc_cflags()
  654. {
  655. char **strs;
  656. fputs("CFLAGS = \\\n", fpmake);
  657. strs = gcc_opts;
  658. while (*strs)
  659. fputs(*strs++, fpmake);
  660. if (can_pipe)
  661. fputs("\t-pipe \\\n", fpmake);
  662. if (gcc_wall)
  663. fputs("\t-Wall \\\n", fpmake);
  664. switch (sys)
  665. {
  666. case S_SCO:
  667. fputs(sco_gcc_opts[sco_type], fpmake);
  668. if (sco_type >= X_32v4)
  669. {
  670. fprintf(fpmake, "\t-DSCO32v4%s%s \\\n",
  671. (sco_type >= X_32v5) ? " -DSCO32v5" : "",
  672. (sco_type >= X_OS7) ? " -DSCOOS7" : "");
  673. need_timeval = 1;
  674. }
  675. if (sco_type >= X_UNIX)
  676. fputs(malloc_3x, fpmake);
  677. fputs("\t-DCFG_LockDir='\"/usr/spool/uucp\"' \\\n", fpmake);
  678. fputs("\t-DCFG_GettodFtime \\\n", fpmake);
  679. if(sco_type >= X_OS7) /* FIONREAD no good on OS5 console */
  680. fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
  681. break;
  682. case S_ISC:
  683. fputs(isc_gcc_opts, fpmake);
  684. fputs(malloc_3x, fpmake);
  685. need_timeval = 1;
  686. fputs("\t-DCFG_LockDir='\"/usr/spool/locks\"' \\\n", fpmake);
  687. break;
  688. case S_MOTSVR3:
  689. fputs(motsvr3_gcc_opts, fpmake);
  690. fputs(malloc_3x, fpmake);
  691. fputs("\t-DCFG_GettodFtime \\\n", fpmake);
  692. need_timeval = 1;
  693. fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
  694. fputs("\t-DCFG_LockDir='\"/usr/spool/locks\"' \\\n", fpmake);
  695. break;
  696. case S_SUN:
  697. fputs(sun_gcc_opts, fpmake);
  698. fputs(malloc_3x, fpmake);
  699. fputs("\t-DCFG_TermiosLineio -DCFG_TelnetOption \\\n", fpmake);
  700. need_timeval = 1;
  701. fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
  702. fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
  703. break;
  704. case S_SOLARIS2:
  705. fputs(solaris2_gcc_opts, fpmake);
  706. fputs(malloc_3x, fpmake);
  707. fputs("\t-DCFG_TermiosLineio \\\n", fpmake);
  708. need_timeval = 1;
  709. fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
  710. fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
  711. break;
  712. case S_ISCSVR4:
  713. fputs(svr4_gcc_opts, fpmake);
  714. fputs("\t-DISCSVR4 \\\n", fpmake);
  715. fputs(malloc_3x, fpmake);
  716. need_timeval = 1;
  717. fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
  718. break;
  719. case S_ESIXSVR4:
  720. fputs(svr4_gcc_opts, fpmake);
  721. fputs("\t-DESIXSVR4 \\\n", fpmake);
  722. fputs(malloc_3x, fpmake);
  723. need_timeval = 1;
  724. fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
  725. break;
  726. case S_SVR4:
  727. fputs(svr4_gcc_opts, fpmake);
  728. fputs("\t-DSVR4 \\\n", fpmake);
  729. fputs(malloc_3x, fpmake);
  730. fputs("\t-DCFG_FionreadRdchk\\\n", fpmake);
  731. fputs("\t-DCFG_TermiosLineio -DCFG_TelnetOption \\\n", fpmake);
  732. need_timeval = 1;
  733. fputs("\t-DCFG_LockDir='\"/var/spool/locks\"' \\\n", fpmake);
  734. break;
  735. case S_AIX:
  736. fputs(aix_gcc_opts, fpmake);
  737. fputs(malloc_3x, fpmake);
  738. need_timeval = 1;
  739. fputs("\t-DCFG_TelnetOption \\\n", fpmake);
  740. fputs("\t-DCFG_FionreadRdchk -DCFG_GettodFtime\\\n", fpmake);
  741. fputs("\t-DCFG_UseStructWinsize \\\n", fpmake);
  742. fputs("\t-DCFG_LockDir='\"/var/spool/uucp\"' \\\n", fpmake);
  743. break;
  744. case S_LINUX:
  745. fputs(linux_gcc_opts, fpmake);
  746. fputs("\t-DCFG_FionreadRdchk -DCFG_TelnetOption \\\n", fpmake);
  747. fputs("\t-DCFG_UseSetupterm -DCFG_UseStructWinsize \\\n", fpmake);
  748. need_timeval = 1;
  749. #if 0 /* no more -- redhat 5 complained bitterly */
  750. fputs("\t-DCFG_TermiosLineio \\\n", fpmake);
  751. #endif
  752. fputs("\t-DCFG_LockDir='\"/var/spool/uucp\"' \\\n", fpmake);
  753. break;
  754. case S_HPUX:
  755. fputs(hpux_gcc_opts, fpmake);
  756. fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
  757. need_timeval = 1;
  758. fputs("\t-DCFG_BinaryUucpPids\\\n", fpmake);
  759. fputs("\t-DCFG_LockDir='\"/usr/spool/uucp\"' \\\n", fpmake);
  760. break;
  761. case S_BSD:
  762. fputs(bsd_gcc_opts, fpmake);
  763. fputs("\t-DCFG_FionreadRdchk \\\n", fpmake);
  764. need_timeval = 1;
  765. fputs("\t-DCFG_TermiosLineio \\\n", fpmake);
  766. fputs("\t-DCFG_MmapSHM -DCFG_GettodFtime \\\n", fpmake);
  767. fputs("\t-DCFG_NoAnsiEmulation \\\n", fpmake);
  768. fputs("\t-DCFG_LockDir='\"/var/spool/lock\"' \\\n", fpmake);
  769. break;
  770. case S_FREEBSD:
  771. fputs(freebsd_gcc_opts, fpmake);
  772. fputs("\t-DCFG_FionreadRdchk -DCFG_NeedStdlibH\\\n", fpmake);
  773. need_timeval = 1;
  774. fputs("\t-DCFG_UseSetupterm \\\n", fpmake);
  775. fputs("\t-DCFG_TelnetOption \\\n", fpmake);
  776. fputs("\t-DCFG_TermiosLineio \\\n", fpmake);
  777. fputs("\t-DCFG_MmapSHM \\\n", fpmake);
  778. fputs("\t-DCFG_LockDir='\"/var/spool/lock\"' \\\n", fpmake);
  779. break;
  780. default:
  781. printf("\ngen_gcc_cflags logic error %d.\n",sys);
  782. exit(1);
  783. }
  784. fputs("\t$(CFLAGS_EXTRA) $(GCC_CFLAGS_EXTRA) \\\n ", fpmake);
  785. } /* end of gen_gcc_cflags */
  786. /*+-------------------------------------------------------------------------
  787. gen_common_cflags()
  788. --------------------------------------------------------------------------*/
  789. void
  790. gen_common_cflags()
  791. {
  792. fputs("\t-DCFG_SigType=$(SIGTYPE) \\\n", fpmake);
  793. if (has_fd_set || has_strerror || need_select_h || fionread_in_filio_h)
  794. {
  795. fprintf(fpmake, "\t%s%s%s%s%s\\\n",
  796. (has_strerror) ? "-DCFG_HasStrerror " : "",
  797. (need_select_h) ? "-DCFG_IncSelectH " : "",
  798. (fionread_in_filio_h) ? "-DCFG_FionreadInFilioH " : "",
  799. (fionread_in_socket_h) ? "-DCFG_FionreadInSocketH " : "",
  800. (has_fd_set) ? "-DCFG_HasFdSet " : "");
  801. if(has_fd_set)
  802. fprintf(fpmake,"\t-DCFG_FDSET='%s' \\\n",cfg_fdset);
  803. }
  804. if (need_ncurses_h == 1)
  805. fputs("\t-DCFG_UseNcursesH \\\n",fpmake);
  806. else if (need_ncurses_h == 2)
  807. fprintf(fpmake, "\t-DCFG_UseNcursesNcursesH \\\n");
  808. if (seteuid_discovered)
  809. fprintf(fpmake, "\t-DCFG_UseSeteuid \\\n");
  810. if (libsocket_discovered)
  811. fputs("\t-DCFG_TelnetOption \\\n", fpmake);
  812. if (*use_ecuungetty == 'y')
  813. fputs("\t-DCFG_UseUngetty -DCFG_UngettyChown \\\n", fpmake);
  814. if (*ecuungetty_all_lines == 'y')
  815. fputs("\t-DCFG_UngettyAllLines \\\n", fpmake);
  816. fprintf(fpmake, "\t-DCFG_ScreenLinesMax=%d -DCFG_ScreenColsMax=%d \\\n",
  817. screen_lines, screen_columns);
  818. fprintf(fpmake, "\t-DCFG_DefaultTty='\"/dev/%s\"' \\\n", tty);
  819. fprintf(fpmake, "\t-DCFG_DefaultBitRate=%s \\\n", bit_rate);
  820. fprintf(fpmake, "\t-DCFG_DefaultParity=\"'%c'\" \\\n", parity);
  821. fprintf(fpmake, "\t-DCFG_DialTimeout=%d \\\n", intdial_to);
  822. fputs("\t-DCFG_HdbLibDir='\"$(HDBLIBDIR)\"' \\\n", fpmake);
  823. fputs("\t-DCFG_EcuLibDir='\"$(ECULIBDIR)\"' \\\n", fpmake);
  824. fputs(pid_type, fpmake);
  825. fputs("\t-DCFG_LogXfer \\\n", fpmake);
  826. #ifdef WHT
  827. fputs("\t-DWHT \\\n", fpmake);
  828. #endif
  829. fputs("\t$(SYMBOLIC) $(LOCAL_CFLAGS)\n\n", fpmake);
  830. } /* end of gen_common_cflags */
  831. /*+-------------------------------------------------------------------------
  832. fix_libraries(libspec) - add libraries to template (maybe)
  833. We want to place -lsocket into an SVR3 library list if we have
  834. "discovered sockets" on the machine
  835. Look for -lc_s or -lc on the lib line and place -lsocket in front
  836. of it. If neither found, throw it on the end
  837. This is a kludge, but I don't have time to think.
  838. --------------------------------------------------------------------------*/
  839. char *
  840. fix_libraries(libspec)
  841. char *libspec;
  842. {
  843. static char fixed[256];
  844. int found;
  845. int pos;
  846. char *search;
  847. char *cp;
  848. char ch;
  849. if (!libsocket_discovered)
  850. return (libspec);
  851. found = 0;
  852. cp = libspec;
  853. while (*cp)
  854. {
  855. if (!strncmp(cp, "-lc_s", 5) && (!(ch = *(cp + 5)) || (ch == ' ')))
  856. {
  857. found = 1;
  858. break;
  859. }
  860. cp++;
  861. }
  862. if (!found)
  863. {
  864. cp = libspec;
  865. while (*cp)
  866. {
  867. if (!strncmp(cp, "-lc", 3) && (!(ch = *(cp + 3)) || (ch == ' ')))
  868. {
  869. found = 1;
  870. break;
  871. }
  872. cp++;
  873. }
  874. }
  875. if (!found)
  876. {
  877. strcpy(fixed, libspec);
  878. strcat(fixed, " ");
  879. strcat(fixed, libsocket_discovered);
  880. return (fixed);
  881. }
  882. pos = (int)(cp - libspec);
  883. memcpy(fixed, libspec, pos);
  884. strcpy(fixed + pos, libsocket_discovered);
  885. strcat(fixed, " ");
  886. strcat(fixed, cp);
  887. return (fixed);
  888. } /* end of fix_libraries */
  889. /*+-------------------------------------------------------------------------
  890. gen_sco_ldflags()
  891. --------------------------------------------------------------------------*/
  892. void
  893. gen_sco_ldflags()
  894. {
  895. char *fixlib = fix_libraries(sco_libs[sco_type]);
  896. fputs("LDFLAGS = \\\n", fpmake);
  897. if (compiler == C_CC)
  898. fputs(sco_cc_opts[sco_type], fpmake);
  899. fputs("\t$(SYMBOLIC) $(LDFLAGS_EXTRA)\n\n", fpmake);
  900. fprintf(fpmake, "LIBS= $(LOCAL_LIBS) %s\n\n", fixlib);
  901. } /* end of gen_sco_ldflags */
  902. /*+-------------------------------------------------------------------------
  903. gen_isc_ldflags()
  904. --------------------------------------------------------------------------*/
  905. void
  906. gen_isc_ldflags()
  907. {
  908. char *fixlib = fix_libraries(isc_libs);
  909. fputs("LDFLAGS = \\\n", fpmake);
  910. fputs("\t$(SYMBOLIC) $(LDFLAGS_EXTRA)\n\n", fpmake);
  911. fprintf(fpmake, "LIBS= $(LOCAL_LIBS) %s\n\n", fixlib);
  912. } /* end of gen_isc_ldflags */
  913. /*+-------------------------------------------------------------------------
  914. gen_motsvr3_ldflags()
  915. --------------------------------------------------------------------------*/
  916. void
  917. gen_motsvr3_ldflags()
  918. {
  919. char *fixlib = fix_libraries(motsvr3_libs);
  920. fputs("LDFLAGS = \\\n", fpmake);
  921. fputs("\t$(SYMBOLIC) $(LDFLAGS_EXTRA)\n\n", fpmake);
  922. fprintf(fpmake, "LIBS= $(LOCAL_LIBS) %s\n\n", fixlib);
  923. } /* end of gen_motsvr3_ldflags */
  924. /*+-------------------------------------------------------------------------
  925. gen_sun_ldflags()
  926. --------------------------------------------------------------------------*/
  927. void
  928. gen_sun_ldflags()
  929. {
  930. fputs("LDFLAGS = \\\n", fpmake);
  931. fputs("\t$(SYMBOLIC) $(LDFLAGS_EXTRA)\n\n", fpmake);
  932. fprintf(fpmake, "LIBS= $(LOCAL_LIBS) %s\n\n", sun_libs);
  933. } /* end of gen_sun_ldflags */
  934. /*+-------------------------------------------------------------------------
  935. gen_solaris2_ldflags()
  936. --------------------------------------------------------------------------*/
  937. void
  938. gen_solaris2_ldflags()
  939. {
  940. fputs("LDFLAGS = \\\n", fpmake);
  941. fputs("\t$(SYMBOLIC) $(LDFLAGS_EXTRA)\n\n", fpmake);
  942. fprintf(fpmake, "LIBS= $(LOCAL_LIBS) %s\n\n", solaris2_libs);
  943. } /* end of gen_solaris2_ldflags */
  944. /*+-------------------------------------------------------------------------
  945. gen_hpux_ldflags()
  946. --------------------------------------------------------------------------*/
  947. void
  948. gen_hpux_ldflags()
  949. {
  950. fputs("LDFLAGS = \\\n", fpmake);
  951. fputs("\t$(SYMBOLIC) $(LDFLAGS_EXTRA)\n\n", fpmake);
  952. fprintf(fpmake, "LIBS= $(LOCAL_LIBS) %s\n\n", hpux_libs);
  953. } /* end of gen_hpux_ldflags */
  954. /*+-------------------------------------------------------------------------
  955. gen_svr4_ldflags(include_socket)
  956. --------------------------------------------------------------------------*/
  957. void
  958. gen_svr4_ldflags(include_socket)
  959. int include_socket;
  960. {
  961. fputs("LDFLAGS = \\\n", fpmake);
  962. fputs("\t$(SYMBOLIC) $(LDFLAGS_EXTRA)\n\n", fpmake);
  963. fprintf(fpmake, "LIBS= $(LOCAL_LIBS) %s\n\n",
  964. (include_socket) ? svr4socket_libs : svr4_libs);
  965. } /* end of gen_svr4_ldflags */
  966. /*+-------------------------------------------------------------------------
  967. gen_aix_ldflags()
  968. --------------------------------------------------------------------------*/
  969. void
  970. gen_aix_ldflags()
  971. {
  972. fputs("LDFLAGS = \\\n", fpmake);
  973. fputs("\t$(SYMBOLIC) $(LDFLAGS_EXTRA)\n\n", fpmake);
  974. fprintf(fpmake, "LIBS= $(LOCAL_LIBS) %s\n\n",
  975. aix_libs);
  976. } /* end of gen_aix_ldflags */
  977. /*+-------------------------------------------------------------------------
  978. gen_linux_ldflags()
  979. --------------------------------------------------------------------------*/
  980. void
  981. gen_linux_ldflags()
  982. {
  983. fputs("LDFLAGS = \\\n", fpmake);
  984. fputs("\t$(SYMBOLIC) $(LDFLAGS_EXTRA)\n\n", fpmake);
  985. fprintf(fpmake, "LIBS= $(LOCAL_LIBS) %s\n\n", linux_libs);
  986. } /* end of gen_linux_ldflags */
  987. /*+-------------------------------------------------------------------------
  988. gen_bsd_ldflags()
  989. --------------------------------------------------------------------------*/
  990. void
  991. gen_bsd_ldflags()
  992. {
  993. fputs("LDFLAGS = \\\n", fpmake);
  994. fputs("\t$(SYMBOLIC) $(LDFLAGS_EXTRA)\n\n", fpmake);
  995. fprintf(fpmake, "LIBS= $(LOCAL_LIBS) %s\n\n", bsd_libs);
  996. } /* end of gen_bsd_ldflags */
  997. /*+-------------------------------------------------------------------------
  998. gen_freebsd_ldflags()
  999. --------------------------------------------------------------------------*/
  1000. void
  1001. gen_freebsd_ldflags()
  1002. {
  1003. fputs("LDFLAGS = \\\n", fpmake);
  1004. fputs("\t$(SYMBOLIC) $(LDFLAGS_EXTRA)\n\n", fpmake);
  1005. fprintf(fpmake, "LIBS= $(LOCAL_LIBS) %s\n\n", freebsd_libs);
  1006. } /* end of gen_freebsd_ldflags */
  1007. /*+-------------------------------------------------------------------------
  1008. generate_config(mdir)
  1009. --------------------------------------------------------------------------*/
  1010. void
  1011. generate_config(mdir)
  1012. char *mdir;
  1013. {
  1014. char mksrc[CBUFSIZE];
  1015. char mkfl[CBUFSIZE];
  1016. char s_cbuf[CBUFSIZE];
  1017. FILE *fpsrc;
  1018. FILE *local = fopen("config.local", "r");
  1019. static int reported_config_local = 0;
  1020. sprintf(mksrc, "%s/Make.src", mdir);
  1021. sprintf(mkfl, "%s/Makefile", mdir);
  1022. printf("Configuring %s from %s\n", mkfl, mksrc);
  1023. if (!(fpsrc = fopen(mksrc, "r")))
  1024. {
  1025. perror(mksrc);
  1026. return;
  1027. }
  1028. unlink(mkfl);
  1029. if (!(fpmake = fopen(mkfl, "w")))
  1030. {
  1031. perror(mkfl);
  1032. fclose(fpsrc);
  1033. if (local)
  1034. fclose(local);
  1035. return;
  1036. }
  1037. fprintf(fpmake, "\
  1038. #+-----------------------------------------------------------------\n");
  1039. fprintf(fpmake, "# Makefile built from %s\n", mksrc);
  1040. fprintf(fpmake, "#\n", mksrc);
  1041. fprintf(fpmake, "\
  1042. # Configured by Configure revision %s for ECU %d.%02d\n",
  1043. rev, major_version_number, PATCHLEVEL);
  1044. fprintf(fpmake, "\
  1045. # Edits to this file will not survive another Configure operation.\n");
  1046. fprintf(fpmake, "\
  1047. # Edit %s and rerun Configure to produce this file.\n",
  1048. mksrc);
  1049. fprintf(fpmake, "\
  1050. #+-----------------------------------------------------------------\n\n");
  1051. if (local)
  1052. {
  1053. fprintf(fpmake, "# config.local inclusions\n");
  1054. fprintf(fpmake, "# -----------------------\n");
  1055. if (!reported_config_local)
  1056. fputs("Found config.local:\n", stdout);
  1057. while (fgets(s_cbuf, sizeof(s_cbuf), local))
  1058. {
  1059. if (!reported_config_local)
  1060. fputs(s_cbuf, stdout);
  1061. fputs(s_cbuf, fpmake);
  1062. }
  1063. if (!reported_config_local)
  1064. fputs("\n", stdout);
  1065. reported_config_local = 1;
  1066. fclose(local);
  1067. fprintf(fpmake, "# -----------------------\n");
  1068. fputs("\n", fpmake);
  1069. }
  1070. switch (sys)
  1071. {
  1072. case S_SCO:
  1073. fprintf(fpmake, "SIGTYPE = %s\n\n", sco_sigtype[sco_type]);
  1074. break;
  1075. case S_ISC:
  1076. fprintf(fpmake, "SIGTYPE = %s\n\n", isc_sigtype);
  1077. break;
  1078. case S_MOTSVR3:
  1079. fprintf(fpmake, "SIGTYPE = %s\n\n", motsvr3_sigtype);
  1080. break;
  1081. case S_LINUX:
  1082. fprintf(fpmake, "SIGTYPE = %s\n\n", linux_sigtype);
  1083. break;
  1084. case S_SUN:
  1085. fprintf(fpmake, "SIGTYPE = %s\n\n", sun_sigtype);
  1086. break;
  1087. case S_ISCSVR4:
  1088. case S_ESIXSVR4:
  1089. case S_SVR4:
  1090. case S_SOLARIS2:
  1091. fprintf(fpmake, "SIGTYPE = %s\n\n", svr4_sigtype);
  1092. break;
  1093. case S_AIX:
  1094. fprintf(fpmake, "SIGTYPE = %s\n\n", aix_sigtype);
  1095. break;
  1096. case S_HPUX:
  1097. fprintf(fpmake, "SIGTYPE = %s\n\n", hpux_sigtype);
  1098. break;
  1099. case S_FREEBSD:
  1100. fprintf(fpmake, "SIGTYPE = %s\n\n", freebsd_sigtype);
  1101. break;
  1102. case S_BSD:
  1103. fprintf(fpmake, "SIGTYPE = %s\n\n", bsd_sigtype);
  1104. break;
  1105. default:
  1106. printf("\ngenerate_config logic error %d.\n",sys);
  1107. exit(1);
  1108. }
  1109. switch (compiler)
  1110. {
  1111. case C_CC:
  1112. fputs("CC = cc\n", fpmake);
  1113. gen_cc_cflags();
  1114. break;
  1115. case C_GCC:
  1116. if (sys == S_FREEBSD)
  1117. fputs("CC = cc\n", fpmake);
  1118. else
  1119. fputs("CC = gcc\n", fpmake);
  1120. gen_gcc_cflags();
  1121. break;
  1122. default:
  1123. printf("I cannot handle compiler type %d\n", compiler);
  1124. goodbye(1);
  1125. }
  1126. gen_common_cflags();
  1127. switch (sys)
  1128. {
  1129. case S_SCO:
  1130. gen_sco_ldflags();
  1131. break;
  1132. case S_ISC:
  1133. gen_isc_ldflags();
  1134. break;
  1135. case S_MOTSVR3:
  1136. gen_motsvr3_ldflags();
  1137. break;
  1138. case S_SUN:
  1139. gen_sun_ldflags();
  1140. break;
  1141. case S_SOLARIS2:
  1142. gen_solaris2_ldflags();
  1143. break;
  1144. case S_ISCSVR4:
  1145. case S_ESIXSVR4:
  1146. gen_svr4_ldflags(0);
  1147. break;
  1148. case S_SVR4:
  1149. gen_svr4_ldflags(1);
  1150. break;
  1151. case S_AIX:
  1152. gen_aix_ldflags();
  1153. break;
  1154. case S_LINUX:
  1155. gen_linux_ldflags();
  1156. break;
  1157. case S_HPUX:
  1158. gen_hpux_ldflags();
  1159. break;
  1160. case S_BSD:
  1161. gen_bsd_ldflags();
  1162. break;
  1163. case S_FREEBSD:
  1164. gen_freebsd_ldflags();
  1165. break;
  1166. }
  1167. fprintf(fpmake, "LBIN = %s\n", bindir);
  1168. fprintf(fpmake, "ECULIBDIR = %s\n", libdir);
  1169. /*
  1170. * we need this info in Makefiles, so it is put here rather than
  1171. * ecu.h; must also have this passed thru in CFLAGS
  1172. */
  1173. switch (sys)
  1174. {
  1175. case S_SCO:
  1176. fprintf(fpmake, "SYSTEM = %s\n", sco_system[sco_type]);
  1177. fputs("HDBLIBDIR = /usr/lib/uucp\n", fpmake);
  1178. break;
  1179. case S_ISC:
  1180. fputs("SYSTEM = ISC-SVR3\n", fpmake);
  1181. fputs("HDBLIBDIR = /usr/lib/uucp\n", fpmake);
  1182. break;
  1183. case S_SUN:
  1184. fputs("SYSTEM = SunOS-4.1\n", fpmake);
  1185. fputs("HDBLIBDIR = /etc/uucp\n", fpmake);
  1186. break;
  1187. case S_SOLARIS2:
  1188. fputs("SYSTEM = Solaris 2.x\n", fpmake);
  1189. fputs("HDBLIBDIR = /etc/uucp\n", fpmake);
  1190. break;
  1191. case S_MOTSVR3:
  1192. fputs("SYSTEM = MotSVR3\n", fpmake);
  1193. fputs("HDBLIBDIR = /usr/lib/uucp\n", fpmake);
  1194. break;
  1195. case S_ISCSVR4:
  1196. fputs("SYSTEM = ISC-SVR4\n", fpmake);
  1197. fputs("HDBLIBDIR = /etc/uucp\n", fpmake);
  1198. break;
  1199. case S_ESIXSVR4:
  1200. fputs("SYSTEM = ESIX-SVR4\n", fpmake);
  1201. fputs("HDBLIBDIR = /etc/uucp\n", fpmake);
  1202. break;
  1203. case S_SVR4:
  1204. fputs("SYSTEM = SVR4\n", fpmake);
  1205. fputs("HDBLIBDIR = /etc/uucp\n", fpmake);
  1206. break;
  1207. case S_AIX:
  1208. fputs("SYSTEM = AIX\n", fpmake);
  1209. fputs("HDBLIBDIR = /etc/uucp\n", fpmake);
  1210. break;
  1211. case S_LINUX:
  1212. fputs("SYSTEM = Linux\n", fpmake);
  1213. fputs("HDBLIBDIR = /usr/lib/uucp\n", fpmake);
  1214. break;
  1215. case S_HPUX:
  1216. fputs("SYSTEM = HP-UX\n", fpmake);
  1217. fputs("HDBLIBDIR = /usr/lib/uucp\n", fpmake);
  1218. break;
  1219. case S_BSD:
  1220. fputs("SYSTEM = BSD\n", fpmake);
  1221. break;
  1222. case S_FREEBSD:
  1223. fputs("SYSTEM = FreeBSD\n", fpmake);
  1224. fputs("HDBLIBDIR = /etc/uucp\n", fpmake);
  1225. break;
  1226. }
  1227. fprintf(fpmake, "USEUNGETTY = %s\n", use_ecuungetty);
  1228. fprintf(fpmake, "ECUOWNER = %s\n", ecu_owner);
  1229. fprintf(fpmake, "ECUGROUP = %s\n", ecu_group);
  1230. fprintf(fpmake, "ECUMODE = %s\n", ecu_mode);
  1231. /*
  1232. * I want /bin/time in front of my commands
  1233. */
  1234. #if !defined(WHT)
  1235. fputs("#", fpmake);
  1236. #endif
  1237. fputs("BINTIME = time\n", fpmake);
  1238. fprintf(fpmake, "\n#---- end of configured make variables\n");
  1239. while (fgets(s_cbuf, sizeof(s_cbuf), fpsrc))
  1240. fputs(s_cbuf, fpmake);
  1241. fclose(fpsrc);
  1242. fclose(fpmake);
  1243. } /* end of generate_config */
  1244. /*+-------------------------------------------------------------------------
  1245. find_string_in_file(fname, str)
  1246. --------------------------------------------------------------------------*/
  1247. int
  1248. find_string_in_file(fname, str)
  1249. char *fname;
  1250. char *str;
  1251. {
  1252. FILE *fp;
  1253. char s1024[1024];
  1254. int found = 0;
  1255. struct stat _st,*st = &_st;
  1256. printf(" Looking in %s ... ", fname);
  1257. #if 0
  1258. if(stat(fname,st))
  1259. {
  1260. if(errno == EEXIST)
  1261. printf("not on your system\n");
  1262. else
  1263. perror("\n cannot find it");
  1264. return(0);
  1265. }
  1266. #endif
  1267. sprintf(s1024, "fgrep %s %s 2>/dev/null", str, fname);
  1268. if (!(fp = popen(s1024, "r")))
  1269. {
  1270. printf("I cannot `%s'", s1024);
  1271. perror(" ");
  1272. return (0);
  1273. }
  1274. while (fgets(s1024, sizeof(s1024), fp))
  1275. {
  1276. char *cp = s1024;
  1277. int str_len = strlen(str);
  1278. while (*cp)
  1279. {
  1280. if (!strncmp(cp, str, str_len))
  1281. {
  1282. found = 1;
  1283. goto BREAK2;
  1284. }
  1285. cp++;
  1286. }
  1287. }
  1288. BREAK2:
  1289. fclose(fp);
  1290. if (found)
  1291. printf("found it!\n");
  1292. else
  1293. printf("not there.\n");
  1294. return (found);
  1295. } /* end of find_string_in_file */
  1296. /*+-------------------------------------------------------------------------
  1297. try_fd_set_shape(trial_definition)
  1298. --------------------------------------------------------------------------*/
  1299. int
  1300. try_fd_set_shape(trial_definition)
  1301. char *trial_definition;
  1302. {
  1303. FILE *fp;
  1304. int success = 0;
  1305. char *fn = "/tmp/ecu_fdset.c";
  1306. unlink(fn);
  1307. if (!(fp = fopen(fn, "w")))
  1308. {
  1309. perror(fn);
  1310. exit(1);
  1311. }
  1312. fputs("\
  1313. #include <stdio.h>\n\
  1314. #include <errno.h>\n\
  1315. #include <sys/types.h>\n\
  1316. ",fp);
  1317. if(need_select_h)
  1318. fputs("\t#include <sys/select.h>\n", fp);
  1319. fputs("\
  1320. #include <signal.h>\n\
  1321. #include <termio.h>\n\
  1322. \n\
  1323. main(argc,argv)\n\
  1324. int argc;\n\
  1325. char **argv;\n\
  1326. {\n\
  1327. ",fp);
  1328. fprintf(fp,"\t%s x;\n",trial_definition);
  1329. fprintf(fp,"\
  1330. printf(\"%s is the attempt\\n\");\n",trial_definition);
  1331. fputs("\
  1332. printf(\"success\\n\");\n\
  1333. exit(0);\n\
  1334. } /* end of main */\n\
  1335. ",fp);
  1336. fclose(fp);
  1337. unlink("/tmp/ecu_fdset.o");
  1338. unlink("/tmp/ecu_fdset");
  1339. system("cd /tmp; cc -o ecu_fdset ecu_fdset.c >/dev/null 2>&1");
  1340. if (!(fp = popen("/tmp/ecu_fdset 2>&1", "r")))
  1341. ;
  1342. else while (fgets(s256, sizeof(s256), fp))
  1343. {
  1344. if (!strncmp(s256, "success", 7))
  1345. {
  1346. success = 1;
  1347. break;
  1348. }
  1349. }
  1350. pclose(fp);
  1351. unlink("/tmp/ecu_fdset.c");
  1352. unlink("/tmp/ecu_fdset.o");
  1353. unlink("/tmp/ecu_fdset");
  1354. return(success);
  1355. } /* end of try_fd_set_shape */
  1356. /*+-------------------------------------------------------------------------
  1357. determine_fd_set_shape()
  1358. --------------------------------------------------------------------------*/
  1359. int
  1360. determine_fd_set_shape()
  1361. {
  1362. int success = 0;
  1363. int i;
  1364. #define DETERM_TRIAL_COUNT 2
  1365. static char *trial[DETERM_TRIAL_COUNT ] =
  1366. {
  1367. "fd_set",
  1368. "struct fd_set",
  1369. };
  1370. fputs("Let's see what shape fd_set takes ... \n",stdout);
  1371. for(i = 0; i < DETERM_TRIAL_COUNT; i++)
  1372. {
  1373. printf(" testing `%s' ... ",trial[i]);
  1374. success = try_fd_set_shape(trial[i]);
  1375. printf("%s\n",(success) ? "SUCCESS" : "failed");
  1376. if(success)
  1377. {
  1378. strcpy(cfg_fdset,trial[i]);
  1379. break;
  1380. }
  1381. }
  1382. return(success);
  1383. } /* end of determine_fd_set_shape */
  1384. /*+-------------------------------------------------------------------------
  1385. find_stuff()
  1386. --------------------------------------------------------------------------*/
  1387. void
  1388. find_stuff()
  1389. {
  1390. FILE *fp;
  1391. char *cp;
  1392. struct stat st;
  1393. static char *_socklibs[] =
  1394. {
  1395. "",
  1396. "-lsocket",
  1397. "-lsocket -lnsl",
  1398. "-lsocket -ldl",
  1399. 0
  1400. };
  1401. char **socklib;
  1402. static char *_headers[] =
  1403. {
  1404. "/usr/include/sys/socket.h",
  1405. "/usr/include/netdb.h",
  1406. "/usr/include/net/if.h",
  1407. "/usr/include/netinet/in.h",
  1408. "/usr/include/arpa/telnet.h",
  1409. "/usr/include/arpa/inet.h",
  1410. 0
  1411. };
  1412. char **header;
  1413. printf("Looking for fd_set ... \n");
  1414. if(has_fd_set = find_string_in_file("/usr/include/sys/select.h",
  1415. "fd_set"))
  1416. {
  1417. need_select_h = 1;
  1418. }
  1419. if (!has_fd_set)
  1420. {
  1421. has_fd_set = find_string_in_file("/usr/include/sys/types.h",
  1422. "fd_set");
  1423. }
  1424. if (!has_fd_set && !stat("/usr/include/linux/types.h", &st))
  1425. {
  1426. if (has_fd_set = find_string_in_file("/usr/include/linux/types.h",
  1427. "fd_set"))
  1428. {
  1429. printf(
  1430. " We trust sys/types.h will include linux/types.h.\n");
  1431. }
  1432. }
  1433. if (has_fd_set)
  1434. printf("We'll use fdset for select() arguments\n",cfg_fdset);
  1435. else
  1436. {
  1437. printf("There is no `fd_set' in my visual range.\n");
  1438. printf("So we'll use the old BSD int array bitmask for select().\n");
  1439. printf("If I've missed my guess, you'll get harmless warnings\n");
  1440. printf("about incorrect arguments to select().\n");
  1441. }
  1442. printf("\n");
  1443. if (has_fd_set)
  1444. {
  1445. int success = determine_fd_set_shape();
  1446. if(!success)
  1447. {
  1448. printf("\
  1449. I couldn't compile a program using fd_set with ways I know.\n");
  1450. printf("Things look grim, but we'll see.\n");
  1451. }
  1452. }
  1453. printf("We'll use `%s' for select() arguments\n",cfg_fdset);
  1454. printf("\n");
  1455. printf("Looking for `struct timeval' ... \n");
  1456. has_timeval = find_string_in_file("/usr/include/sys/time.h",
  1457. "struct timeval");
  1458. if (!has_timeval)
  1459. {
  1460. if (has_timeval = find_string_in_file("/usr/include/sys/select.h",
  1461. "struct timeval"))
  1462. {
  1463. need_select_h = 1;
  1464. }
  1465. }
  1466. if (has_timeval)
  1467. printf("We'll need `struct timeval' for select() arguments\n");
  1468. else
  1469. {
  1470. printf("There is no `struct timeval' in my visual range.\n");
  1471. printf("We can't use select() for a nap() replacement.\n");
  1472. }
  1473. printf("\n");
  1474. printf("Looking for `strerror' ... \n");
  1475. has_strerror = find_string_in_file("/usr/include/string.h",
  1476. "strerror");
  1477. if (has_strerror)
  1478. printf("We'll use it.\n");
  1479. else
  1480. {
  1481. printf("There is no `strerror' in my visual range.\n");
  1482. printf("We will fake it.\n");
  1483. }
  1484. printf("\n");
  1485. /*
  1486. * if the platform uses ncurses, lets's go looking for it
  1487. */
  1488. if (look_for_ncurses)
  1489. {
  1490. struct stat st;
  1491. char *ncurses = "<null>";
  1492. if ((!stat("/usr/include/ncurses.h", &st)) &&
  1493. ((st.st_mode & S_IFMT) == S_IFREG))
  1494. {
  1495. need_ncurses_h = 1;
  1496. ncurses = "ncurses";
  1497. }
  1498. else if ((!stat("/usr/include/ncurses/ncurses.h", &st)) &&
  1499. ((st.st_mode & S_IFMT) == S_IFREG))
  1500. {
  1501. need_ncurses_h = 2;
  1502. ncurses = "ncurses/ncurses";
  1503. }
  1504. else
  1505. {
  1506. ncurses = "curses"; /* wont work */
  1507. printf("I cannot find ncurses.h! TROUBLE predicted\n");
  1508. }
  1509. printf("We will look for ncurses in <%s.h> and -lncurses.\n\n",
  1510. ncurses);
  1511. }
  1512. /*
  1513. * if we are going to setuid to unix, find out if we should use setuid
  1514. * or seteuid
  1515. */
  1516. if (!strcmp(ecu_owner, "uucp"))
  1517. {
  1518. FILE *fp;
  1519. char *fn = "/tmp/ecu_euid_test.c";
  1520. printf("Looking for `seteuid' ... \n");
  1521. seteuid_discovered = 1;
  1522. unlink(fn);
  1523. if (!(fp = fopen(fn, "w")))
  1524. {
  1525. perror(fn);
  1526. exit(1);
  1527. }
  1528. fputs("main() { seteuid(0); printf(\"success\\n\"); exit(0); }\n", fp);
  1529. fclose(fp);
  1530. system("cd /tmp; cc -o ecu_euid_test ecu_euid_test.c >/dev/null 2>&1");
  1531. if (!(fp = popen("/tmp/ecu_euid_test 2>&1", "r")))
  1532. seteuid_discovered = 0;
  1533. else if (!fgets(s256, sizeof(s256), fp))
  1534. seteuid_discovered = 0;
  1535. else if (strncmp(s256, "success", 7))
  1536. seteuid_discovered = 0;
  1537. pclose(fp);
  1538. unlink("/tmp/ecu_euid_test.c");
  1539. unlink("/tmp/ecu_euid_test.o");
  1540. unlink("/tmp/ecu_euid_test");
  1541. if (seteuid_discovered)
  1542. printf("Found it.\n");
  1543. else
  1544. {
  1545. printf("It appears there is no seteuid() available.\n");
  1546. printf("We will use setuid().\n");
  1547. }
  1548. printf("\n");
  1549. }
  1550. /*
  1551. * do we need sys/filio.h for FIONREAD?
  1552. */
  1553. printf("Looking for `FIONREAD' ... \n");
  1554. fionread_in_filio_h = find_string_in_file("/usr/include/sys/filio.h",
  1555. "FIONREAD");
  1556. if (fionread_in_filio_h)
  1557. printf("We will include sys/filio.h.\n");
  1558. else if(fionread_in_socket_h =
  1559. find_string_in_file("/usr/include/sys/socket.h","FIONREAD"))
  1560. {
  1561. printf("We will include sys/socket.h.\n");
  1562. }
  1563. else if(find_string_in_file("/usr/src/linux/include/linux/termios.h",
  1564. "FIONREAD"))
  1565. {
  1566. printf("Linux (at least early ones) stash it here??! Go figure!\n");
  1567. printf("We already include this.\n");
  1568. }
  1569. else if(!find_string_in_file("/usr/include/sys/ioctl.h","FIONREAD"))
  1570. {
  1571. printf("I cannot find FIONREAD in places that I know to look.\n");
  1572. printf("This may be ok if your system supports rdchk(). We'll see.\n");
  1573. printf("This is expected wih Linux 2.0.\n");
  1574. }
  1575. printf("\n");
  1576. /*
  1577. * if we should look for libsocket.a presence, now is the time ...
  1578. * since there are too many places where libraries can hide, we will
  1579. * let cc do the looking
  1580. */
  1581. if (look_for_network)
  1582. {
  1583. FILE *fp;
  1584. int got_it;
  1585. char *fn = "/tmp/ecu_netld_test.c";
  1586. printf("Looking for development system support for telnet/inet ... \n");
  1587. libsocket_discovered = 0;
  1588. /*
  1589. * create temp source using -lsocket material
  1590. */
  1591. unlink(fn);
  1592. if (!(fp = fopen(fn, "w")))
  1593. {
  1594. perror(fn);
  1595. exit(1);
  1596. }
  1597. fputs("\
  1598. main()\n\
  1599. {\n\
  1600. printf(\"success\\n\");\n\
  1601. exit(0);\n\
  1602. gethostbyname();\n\
  1603. socket(0);\n\
  1604. connect();\n\
  1605. }\n", fp);
  1606. fclose(fp);
  1607. /*
  1608. * try "", "-lsocket", etc in turn
  1609. */
  1610. libsocket_discovered = 0;
  1611. for (socklib = _socklibs; !libsocket_discovered && *socklib; socklib++)
  1612. {
  1613. got_it = 1; /* assume success */
  1614. sprintf(s256, "\
  1615. cd /tmp; cc -o ecu_netld_test ecu_netld_test.c %s >/dev/null 2>&1", *socklib);
  1616. system(s256);
  1617. if (!(fp = popen("/tmp/ecu_netld_test 2>&1", "r")))
  1618. got_it = 0;
  1619. else if (!fgets(s256, sizeof(s256), fp))
  1620. got_it = 0;
  1621. else if (strncmp(s256, "success", 7))
  1622. got_it = 0;
  1623. pclose(fp);
  1624. if (got_it)
  1625. libsocket_discovered = *socklib;
  1626. else
  1627. printf(" Cannot link networking code with %s\n",
  1628. (**socklib) ? *socklib : "libc alone");
  1629. }
  1630. /*
  1631. * lose temporary files
  1632. */
  1633. #if 1
  1634. unlink("/tmp/ecu_netld_test.c");
  1635. unlink("/tmp/ecu_netld_test.o");
  1636. unlink("/tmp/ecu_netld_test");
  1637. #endif
  1638. if (libsocket_discovered)
  1639. printf(" Can link with \"%s\"!!!\n", libsocket_discovered);
  1640. /*
  1641. * now spot check headers
  1642. */
  1643. if (libsocket_discovered)
  1644. {
  1645. for (header = _headers; *header; header++)
  1646. {
  1647. int i = stat(*header, &st);
  1648. printf(" %s %s\n", (i) ? "Could not find" : "Found", *header);
  1649. if (i)
  1650. libsocket_discovered = 0;
  1651. }
  1652. }
  1653. /*
  1654. * good news
  1655. */
  1656. if (libsocket_discovered)
  1657. {
  1658. printf("\
  1659. You have networking ... linking with \"%s\".\n",
  1660. libsocket_discovered);
  1661. }
  1662. else
  1663. {
  1664. printf("I can find no network libraries I know about.\n");
  1665. printf("We will not attempt to include telnet support.\n");
  1666. }
  1667. printf("\n");
  1668. }
  1669. } /* end of find_stuff */
  1670. /*+-------------------------------------------------------------------------
  1671. config_setup()
  1672. --------------------------------------------------------------------------*/
  1673. void
  1674. config_setup()
  1675. {
  1676. int itmp;
  1677. /*
  1678. * set up raw/cooked tty setty() macro
  1679. */
  1680. #if defined(__NetBSD__) || defined(__FreeBSD__)
  1681. tcgetattr(0, &tty0);
  1682. #else
  1683. ioctl(0, TCGETA, &tty0);
  1684. #endif
  1685. tty1 = tty0;
  1686. tty1.c_lflag &= ~(ICANON);
  1687. tty1.c_cc[VMIN] = 1;
  1688. tty1.c_cc[VTIME] = 0;
  1689. /*
  1690. * any signal except death of a child causes abort
  1691. */
  1692. for (itmp = 1; itmp < NSIG; itmp++)
  1693. {
  1694. if (
  1695. #ifdef SIGCLD
  1696. (itmp == SIGCLD) ||
  1697. #endif /* SIGCLD */
  1698. #ifdef SIGCHLD /* duplicate work on some systems */
  1699. (itmp == SIGCHLD) ||
  1700. #endif /* SIGCLD */
  1701. 0)
  1702. {
  1703. ;
  1704. }
  1705. else
  1706. signal(itmp, goodbye);
  1707. }
  1708. } /* end of config_setup */
  1709. /*+-------------------------------------------------------------------------
  1710. main(argc, argv)
  1711. --------------------------------------------------------------------------*/
  1712. main(argc, argv)
  1713. int argc;
  1714. char **argv;
  1715. {
  1716. int itmp;
  1717. int opt;
  1718. char s_cbuf[CBUFSIZE];
  1719. char s2048[2048];
  1720. char **makedir;
  1721. char *tlib = "";
  1722. char *cp;
  1723. char *tcap = "";
  1724. struct stat fst;
  1725. extern int optind;
  1726. extern char *optarg;
  1727. setbuf(stdin, NULL);
  1728. setbuf(stdout, NULL);
  1729. /*
  1730. * a bit of foolishness that will come back to bite me one day
  1731. */
  1732. if (PATCHLEVEL < 49)
  1733. major_version_number = 4;
  1734. else
  1735. major_version_number = 3;
  1736. while ((itmp = getopt(argc, argv, "W")) != -1)
  1737. {
  1738. switch (itmp)
  1739. {
  1740. case 'W':
  1741. gcc_wall = 1;
  1742. break;
  1743. }
  1744. }
  1745. config_setup();
  1746. tputstrs(strs_intro1);
  1747. printf("ecu version = %d.%02d, config version %s\n\n",
  1748. major_version_number, PATCHLEVEL, rev);
  1749. tputstrs(strs_intro2);
  1750. /*
  1751. * try to make a stab at default some vendor compilers have
  1752. * thoughtfully provided a reliable built-in default to ISC if not one
  1753. * of those two
  1754. */
  1755. itmp = 's';
  1756. #ifdef M_SYSV
  1757. itmp = 's';
  1758. #endif
  1759. #if defined(hpux)
  1760. itmp = 'h';
  1761. #endif
  1762. #if defined(m68k) || defined(m88k)
  1763. itmp = 'M';
  1764. #endif
  1765. #if defined(MOTSVR3)
  1766. itmp = 'm';
  1767. #endif
  1768. #if defined(__NetBSD__)
  1769. itmp = 'N';
  1770. #endif
  1771. #if defined(__FreeBSD__)
  1772. itmp = 'F';
  1773. #endif
  1774. #if defined(linux)
  1775. itmp = 'l';
  1776. #endif
  1777. #ifdef sun
  1778. itmp = 'S';
  1779. #endif
  1780. #if defined (sun) && (defined (__svr4__) || defined(SVR4))
  1781. /*
  1782. * line 27 of gcc/config/sparc/sol2.h in CPP_PREDEFINES has __svr4__
  1783. * Your mileage may vary.....
  1784. */
  1785. itmp = 'O';
  1786. #endif
  1787. if (sys < 0)
  1788. {
  1789. switch (opt = tgetopt("\
  1790. Choose your system type (or the `nearest equivalent')\n\
  1791. s SCO family (incl. UnixWare) S SunOS 4.1.x\n\
  1792. h HP-UX 9.01 or later O Solaris 2.x\n\
  1793. 4 SVR4 i ISC SVR32 ** (2.2 or later)\n\
  1794. m Motorola Delta SVR32/[68]8k I ISC SVR4 **\n\
  1795. l Linux 1.1.58 or later E ESIX SVR4 **\n\
  1796. N NetBSD F FreeBSD\n\
  1797. A AIX\n\
  1798. Those marked ** have not been tested or verified in quite some time.\n\
  1799. \n\
  1800. ",
  1801. "shl4mNSOiIEFA", itmp))
  1802. {
  1803. case 's':
  1804. sys = S_SCO;
  1805. tty = "tty1A";
  1806. look_for_network = 1; /* old basic SCO DS has no inet */
  1807. break;
  1808. case 'i':
  1809. sys = S_ISC;
  1810. tty = "acu00";
  1811. look_for_network = 1; /* I dont have ISC; guess at config
  1812. * time */
  1813. break;
  1814. case 'm':
  1815. sys = S_MOTSVR3;
  1816. tty = "tty00";
  1817. look_for_network = 1; /* I dont have 1; guess at config
  1818. * time */
  1819. break;
  1820. case '4':
  1821. sys = S_SVR4;
  1822. tty = "ttys0";
  1823. break;
  1824. case 'A':
  1825. sys = S_AIX;
  1826. tty = "tty0";
  1827. break;
  1828. case 'S':
  1829. sys = S_SUN;
  1830. tty = "ttya";
  1831. printf("\
  1832. \nYou need System V IPC configured in your kernel. I didn't check for it.\n");
  1833. break;
  1834. case 'O':
  1835. sys = S_SOLARIS2;
  1836. tty = "ttya";
  1837. break;
  1838. case 'I':
  1839. sys = S_ISCSVR4;
  1840. tty = "tty00";
  1841. look_for_network = 1; /* I dont have 1; guess at config
  1842. * time */
  1843. break;
  1844. case 'E':
  1845. sys = S_ESIXSVR4;
  1846. tty = "tty00";
  1847. look_for_network = 1; /* I dont have 1; guess at config
  1848. * time */
  1849. break;
  1850. case 'l':
  1851. sys = S_LINUX;
  1852. tty = "cua0";
  1853. #if defined(WHT) /* it is good to be da king */
  1854. tty = "ttyS42";
  1855. #endif
  1856. compiler = C_GCC;
  1857. look_for_ncurses = 1;
  1858. can_pipe = 1;
  1859. break;
  1860. case 'h':
  1861. sys = S_HPUX;
  1862. tty = "cul00";
  1863. look_for_network = 1; /* I dont have 1; guess at config
  1864. * time */
  1865. break;
  1866. case 'N':
  1867. sys = S_BSD;
  1868. tty = "com1";
  1869. compiler = C_GCC;
  1870. printf("Gcc will be used for all compilations.\n");
  1871. can_pipe = 1;
  1872. break;
  1873. case 'F':
  1874. sys = S_FREEBSD;
  1875. tty = "cuaa0";
  1876. compiler = C_GCC;
  1877. can_pipe = 1;
  1878. look_for_ncurses = 1;
  1879. pid_type = "\t-DCFG_PidType=pid_t \\\n";
  1880. break;
  1881. }
  1882. }
  1883. if ((sys == S_SCO) && (sco_type < 0))
  1884. {
  1885. char defchar = 'v';
  1886. char choice;
  1887. struct stat st;
  1888. if (!stat("/stand", &st))
  1889. defchar = '5';
  1890. if (!stat("/etc/vfstab", &st))
  1891. defchar = 'U';
  1892. switch (choice = tgetopt("\
  1893. The most recent SCO platforms tested with this rev of ecu are\n\
  1894. SCO OpenServer 5.0.5\n\
  1895. UnixWare 7.1.1\n\
  1896. \n\
  1897. Choose between 3 XENIX/386,\n\
  1898. u ODT 1.0.x, ODT 1.1, UNIX 3.2.0-3.2v2 or\n\
  1899. v ODT 2.0, ODT 3.0, UNIX 3.2v4\n\
  1900. 5 OpenServer 5, UNIX 3.2v5\n\
  1901. U UnixWare 7.0.0 or later\n\
  1902. ",
  1903. "23uv5U",
  1904. defchar
  1905. ))
  1906. {
  1907. case '3':
  1908. ecuungetty_appropriate = 1;
  1909. need_select_h = 1;
  1910. sco_type = X_X386;
  1911. tlib = "/lib/386/Slibtermlib.a";
  1912. tcap = "/lib/386/Slibtermcap.a";
  1913. break;
  1914. case 'u':
  1915. ecuungetty_appropriate = 1;
  1916. sco_type = X_UNIX;
  1917. need_select_h = 1;
  1918. tlib = "/usr/ccs/lib/libcurses.a";
  1919. tcap = "LOGIC ERROR";
  1920. break;
  1921. case 'v':
  1922. ecuungetty_appropriate = 1;
  1923. sco_type = X_32v4;
  1924. pid_type = "\t-DCFG_PidType=pid_t\\\n";
  1925. tlib = "/usr/lib/libtermlib.a";
  1926. tcap = "/usr/lib/libtermcap.a";
  1927. break;
  1928. case '5':
  1929. #if 0
  1930. case '7':
  1931. #endif
  1932. if(choice == '5')
  1933. sco_type = X_32v5;
  1934. else if(choice == '7')
  1935. sco_type = X_OS7;
  1936. pid_type = "\t-DCFG_PidType=pid_t\\\n";
  1937. tlib = "LOGIC_ERROR";
  1938. tcap = tlib;
  1939. ecu_owner = "uucp";
  1940. ecu_group = "bin";
  1941. ecu_mode = "4711";
  1942. fputs("\
  1943. You will be able to access only lines writable by the user or by uucp.\n",
  1944. stdout);
  1945. fputs("\
  1946. ECU will be automatically installed to run setuid uucp.\n", stdout);
  1947. break;
  1948. case 'U':
  1949. tty = "tty00";
  1950. sys = S_SVR4;
  1951. ecu_owner = "uucp";
  1952. ecu_group = "bin";
  1953. ecu_mode = "4711";
  1954. break;
  1955. }
  1956. /*
  1957. * multivariate SCO development environment
  1958. */
  1959. if (sys == S_SVR4)
  1960. ;
  1961. else if(sco_type < 0)
  1962. {
  1963. printf("logic error in sco_type determination\n");
  1964. goodbye(255);
  1965. }
  1966. else if ((sco_type == X_32v5) || (sco_type == X_OS7))
  1967. sco_libs = _sco_libs;
  1968. else if (!access(tcap, 0))
  1969. sco_libs = _sco2_libs;
  1970. else if (!access(tlib, 0))
  1971. sco_libs = _sco_libs;
  1972. else
  1973. {
  1974. printf("\nI find neither %s nor %s.\n", tcap, tlib);
  1975. printf("Do you have curses support installed? I cannot proceed.\n");
  1976. goodbye(1);
  1977. }
  1978. }
  1979. if (compiler < 0)
  1980. {
  1981. switch (tgetopt("Do you wish to use cc or gcc", "cg", 'c'))
  1982. {
  1983. case 'c':
  1984. compiler = C_CC;
  1985. break;
  1986. case 'g':
  1987. compiler = C_GCC;
  1988. #ifdef PEDANTIC
  1989. printf("I see we are being brave, er pedantic.\n\n");
  1990. #endif
  1991. switch (sys)
  1992. {
  1993. case S_SUN:
  1994. case S_SOLARIS2:
  1995. case S_ISCSVR4:
  1996. case S_ESIXSVR4:
  1997. can_pipe = 1; /* native as reads from stdin ok */
  1998. break;
  1999. /*
  2000. * systems which use only GCC set can_pipe
  2001. * elsewhere
  2002. */
  2003. default:
  2004. break;
  2005. }
  2006. break;
  2007. }
  2008. }
  2009. if (compiler == C_GCC)
  2010. {
  2011. printf("\
  2012. \nYou may safely ignore a large number of `overflow in implicit constant\n\
  2013. conversion' and `empty body in else-statement' warnings that some versions\n\
  2014. of gcc may emit.\n");
  2015. }
  2016. /*
  2017. * ecuungetty support
  2018. */
  2019. if (ecuungetty_appropriate)
  2020. {
  2021. switch (tgetopt("\
  2022. If you have gettys running on any of your modem lines, you want to use\n\
  2023. ecuungetty to manage the shared dial-in/dial-out protocol (including\n\
  2024. changing ownership of ports to the requesting user when opening and\n\
  2025. restoring to uucp ownership upon closing). If you do not use UUCP nor\n\
  2026. have dial-in access to your computer, you may wish to omit ecuungetty\n\
  2027. support. Answer 'y' if you are not sure.\n\
  2028. Do you want ecuungetty support? ", "yn", 'y'))
  2029. {
  2030. case 'y':
  2031. use_ecuungetty = "yes";
  2032. break;
  2033. case 'n':
  2034. use_ecuungetty = "no";
  2035. break;
  2036. }
  2037. if (*use_ecuungetty == 'y')
  2038. {
  2039. switch (tgetopt("\
  2040. Generally speaking, serial lines appearing in your UUCP Devices file are\n\
  2041. associated with shared dial-in/dial-out use, while single use lines\n\
  2042. do not appear there; your customs may vary. You may wish to restrict\n\
  2043. ecuungetty operation only to serial lines which appear in your UUCP\n\
  2044. Devices file. If you answer yes below, ecuungetty will only manage\n\
  2045. serial lines appearing in Devices, leaving ownership and permissions\n\
  2046. alone on other lines. Answer 'y' if you are not sure.\n\
  2047. Do you want ecuungetty to manage only lines in Devices? ", "yn", 'y'))
  2048. {
  2049. case 'y':
  2050. ecuungetty_all_lines = "no";
  2051. break;
  2052. case 'n':
  2053. ecuungetty_all_lines = "yes";
  2054. break;
  2055. }
  2056. }
  2057. }
  2058. if (!strcmp(ecu_owner, "bin"))
  2059. {
  2060. switch (tgetopt("\
  2061. If you execute ecu with uid set to uucp lines, then uucp will be\n\
  2062. able to access any serial line owned by the user or owned by uucp.\n\
  2063. In addition, you need not provide for world-write access to the UUCP\n\
  2064. lock directory. Answer 'n' if you are not sure.\n\
  2065. Do you wish to run ecu setuid to uucp? ", "yn", 'y'))
  2066. {
  2067. case 'y':
  2068. ecu_owner = "uucp";
  2069. ecu_group = "bin";
  2070. ecu_mode = "4711";
  2071. break;
  2072. case 'n':
  2073. break;
  2074. }
  2075. }
  2076. printf("\nWhat do you want for a default tty? [%s]\n:", tty);
  2077. tgets(s_cbuf);
  2078. if (s_cbuf[0])
  2079. tty = strdup(s_cbuf);
  2080. printf("\nWhat do you want for a default bit rate? [%s]\n:", bit_rate);
  2081. tgets(s_cbuf);
  2082. if (s_cbuf[0])
  2083. bit_rate = strdup(s_cbuf);
  2084. parity = tgetopt("What do you want for default parity", "neo", 'n');
  2085. printf(
  2086. "\nWhere do you want the public executables placed? [%s]\n: ",
  2087. bindir);
  2088. tgets(s_cbuf);
  2089. if (s_cbuf[0])
  2090. bindir = strdup(s_cbuf);
  2091. strcpy(s2048, bindir);
  2092. if ((cp = strrchr(s2048, '/')) && !strncmp(cp + 1, "bin", 3))
  2093. {
  2094. *cp = 0;
  2095. strcat(s2048, "/lib/ecu");
  2096. libdir = strdup(s2048);
  2097. }
  2098. printf(
  2099. "\nWhere do you want the ECU library placed? [%s]\n: ", libdir);
  2100. tgets(s_cbuf);
  2101. if (s_cbuf[0])
  2102. libdir = strdup(s_cbuf);
  2103. printf("\nHow many seconds should the built-in dialer ");
  2104. printf("wait for carrier? [%d]\n: ", intdial_to);
  2105. tgets(s_cbuf);
  2106. if (s_cbuf[0])
  2107. intdial_to = atoi(s_cbuf);
  2108. itmp = 0;
  2109. while (!itmp)
  2110. {
  2111. printf("\nWhat is the maximum number of screen lines (>= 24)? ");
  2112. printf("[%d]\n: ", screen_lines);
  2113. tgets(s_cbuf);
  2114. if (s_cbuf[0] && (screen_lines = atoi(s_cbuf)) < 24)
  2115. fputs("\7", stderr);
  2116. else
  2117. itmp = 1;
  2118. }
  2119. itmp = 0;
  2120. while (!itmp)
  2121. {
  2122. printf("\nWhat is the maximum number of screen columns (>= 80)? ");
  2123. printf("[%d]\n: ", screen_columns);
  2124. tgets(s_cbuf);
  2125. if (s_cbuf[0] && (screen_columns = atoi(s_cbuf)) < 80)
  2126. fputs("\7", stderr);
  2127. else
  2128. itmp = 1;
  2129. }
  2130. printf("\nThank you.\n\n");
  2131. find_stuff();
  2132. makedir = makedirs;
  2133. while (*makedir)
  2134. {
  2135. if (!strcmp(*makedir, "./ecuungetty") && (*use_ecuungetty == 'n'))
  2136. {
  2137. makedir++;
  2138. continue;
  2139. }
  2140. generate_config(*makedir++);
  2141. }
  2142. /*
  2143. * check on our buddy timeval
  2144. */
  2145. if (need_timeval && !has_timeval)
  2146. {
  2147. tputstrs(strs_no_timeval);
  2148. goodbye(1);
  2149. }
  2150. #ifdef WHT
  2151. printf("\7Doing it anyway for WHT\n");
  2152. sleep(2);
  2153. for (itmp = 1; itmp < NSIG; itmp++)
  2154. signal(itmp, SIG_DFL);
  2155. system("make depend");
  2156. #endif
  2157. goodbye(0);
  2158. } /* end of main */
  2159. /* vi: set tabstop=4 shiftwidth=4: */
  2160. /* end of config.c */