📄 config.c
字号:
/* CHK=0xD40E */char *rev = "3.20";/* #define FORCE_DASH_G *//*+------------------------------------------------------------------------- config.c - Makefile configuration program for ECU wht@n4hgf.Mt-Park.GA.USThis must be compiled with the *NATIVE* cc or else you must fake allof the predefines the native compiler supplies. The Configurescript can pass stuff in CFLAGS to tickle config a bit.There are a few tricks in here for SCO multi-target developmentsystem. If you compile this on a UNIX system, but specify thetarget for a XENIX system, you get the cc -xenix switch. Youalso get -Dconst= to avoid banging into some problems with theXENIX stuff in the header files.To paraphrase Henry Spencer:"Those who do not understand imake are doomed to reinvent it - poorly."If this gets much more complicated, I'll make some imake rules.Very soon, most of the systems ECU gets used on will have imake already.We cannot assume that yet. Defined functions: gen_cc_cflags() gen_gcc_cflags() gen_isc_ldflags() gen_sco_ldflags() gen_sun_ldflags() gen_svr4_ldflags() 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:*//*: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 PID_T *//*: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, baud 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 <string.h>#include <termio.h>#include "ecu_types.h"#include "ecu_stat.h"#include "patchlevel.h"#define S_SCO 0#define S_ISC 1#define S_SUN 2#define S_ISCSVR4 3#define S_ESIXSVR4 4#define S_LINUX 5#define X_X286 0#define X_X386 1#define X_UNIX 2#define X_32v4 3#define C_CC 0#define C_GCC 1struct termio tty0;struct termio tty1;#define setty(arg) ioctl(0,TCSETAW,(arg) ? (char *)&tty1 : (char *)&tty0)char *makedirs[] = { ".", "./ecufriend", "./ecuungetty", "./gendial", "./help", "./sea", "./z", (char *)0};char *strs_intro1[] = { "\n", ".-------------------.\n", "| ECU configuration |\n", "`-------------------'\n", (char *)0};char *strs_intro2[] = {#ifdef WHT "WHT features enabled. ",#endif#if defined(FORCE_DASH_G) "-g compilation will be forced.",#endif "\n", "\n", "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_lng353[] = { "\n", "I see you have installed LNG353 for the development system.\n", "This fixed many things but introduced a new warning I cannot readily do\n", "anything about. Expect loads of \"warning C4200: previous declarator\n", "is not compatible with default argument promotion\" messages.\n", "They reflect little more than ECU isn't compliant with the latest\n", "ANSI throathold tightening.\n", (char *)0};char *strs_nolng353[] = { "\n", "You MUST use the 3.2v4 (or ODT 2.0) development system and you ought to\n", "LNG353 installed. If you have only an older DS, rerun ./config and\n", "specify 'u'. No promises. (This message may be obsolete after 1992).\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-M2let128 -LARGE \\\n", /* XENIX/286 */ "\t-M3e \\\n", /* XENIX/386 */ "\t-M3e \\\n", /* UNIX/386 3.2.0-3.2v2*/ "\t-M3e \\\n" /* UNIX/386 3.2v4 */};char *sco_cc_optim[] = {#ifdef FORCE_DASH_G "\t-Ot \\\n", /* XENIX/286 */ "\t-Oct -CSON \\\n", /* XENIX/386 */ "\t-g \\\n", /* UNIX/386 3.2.0-3.2v2 */ "\t-g \\\n" /* UNIX/386 3.2v4 */#else "\t-Ot \\\n", /* XENIX/286 */ "\t-Oct -CSON \\\n", /* XENIX/386 */ "\t-Oct -CSON \\\n", /* UNIX/386 3.2.0-3.2v2 */ "\t-Oct -CSON \\\n" /* UNIX/386 3.2v4 */#endif};char *sco_sigtype[] = { "int", /* XENIX/286 */ "void", /* XENIX/386 */ "void", /* UNIX/386 3.2.0-3.2v2 */ "void" /* UNIX/386 32v4 */};char *pid_type = "\t-DPID_T=int \\\n";/* * GCC CFLAGS */char *gcc_opts[] = {#ifdef PEDANTIC "\t-pedantic -ansi -O \\\n", /* UH OH: see ecu README */#else#ifdef linux "\t-O2 \\\n",#else "\t-traditional -O \\\n",#endif#endif#if defined(WHT) || defined(FORCE_DASH_G) "\t-g \\\n",#endif "\t-fstrength-reduce -fpcc-struct-return -fwritable-strings \\\n", "\t-finline-functions -fforce-mem -fforce-addr \\\n", "\t-W -Wunused -Wpointer-arith -Wcast-qual -Wshadow -Wcomment -Wswitch\\\n", (char *)0};char *i86_gcc_opts[] = {#if 0 "\t-fcall-used-bx \\\n",#endif (char *)0};char *sco_gcc_opts[] = { /* * XENIX/286 */ "\t........what-goes-here?......... \\\n", /* * 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.20..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_NO_PROTOTYPE -D_SVID -D_KR \\\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",};char *isc_cc_opts = "\t-O -DISC -DISC22 -DSYSV \\\n";char *isc_gcc_opts = "\t-DISC -DISC22 -DSYSV -Di386\\\n";char *isc_sigtype = "void";char *sun_cc_opts = "\t-O \\\n";char *sun_gcc_opts = "\t-O -Dsun=1 \\\n"; /* ansi gets __sun__ only */char *sun_sigtype = "void";char *svr4_cc_opts = "\t-O -DSVR4 -DSYSV \\\n";char *svr4_gcc_opts = "\t-DSVR4 -DSYSV \\\n";char *svr4_sigtype = "void";char *linux_cc_opts = "\t-m486 -DSYSV -Di386 -DNO_RDCHK \\\n";char *linux_gcc_opts = "\t-m486 -DSYSV -Di386 -DNO_RDCHK \\\n";char *linux_sigtype = "void";/* * LIBS */char *_sco_libs[] = { "-ltcap -ltermlib -lx", "-ltcap -ltermlib -lx", "-ltcap -ltermlib -lmalloc -lc_s -lc -lx", "-ltcap -ltermlib -lmalloc -lc_s -lc -lx"};char *_sco2_libs[] = { "-ltcap -ltermcap -lx", "-ltcap -ltermcap -lx", "-ltcap -ltermcap -lmalloc -lc_s -lc -lx", "-ltcap -ltermcap -lmalloc -lc_s -lc -lx"};char **sco_libs = _sco_libs;char *isc_libs = "-lcurses -linet -lx -lmalloc";char *sun_libs = "-lcurses -ltermcap";char *svr4_libs = "-lcurses -lx -lmalloc";char *linux_libs = "-lcurses -ltermcap";char *sco_system[] = { "XENIX/286", "XENIX/386", "UNIX/386", "UNIX/386 3.2v4"};char *malloc_3x = "\t-DMALLOC_3X \\\n";char *tty = "tty1a";char *baud = "9600";int parity = 0;char *bindir = "/usr/local/bin";char *libdir = "/usr/local/lib/ecu";char *symbolic = "";char *use_ecuungetty = "yes";int sys = -1;int compiler = -1;int have_gcc_140 = 0;int sco_type = -1;int debug = 0;int can_pipe = 0;FILE *fpmake;voidgoodbye(sig)int sig;{ setty(0); printf("\n"); exit(sig);}voidtputstrs(strs)char **strs;{ while(*strs) fputs(*strs++,stdout);}voidtputstrsfp(strs)char **strs;{ while(*strs) fputs(*strs++,fpmake);}chartgetc(){char rtn; setty(1); read(0,&rtn,1); rtn &= 0x7F; setty(0); if(rtn != 0x0A) printf("\n",rtn); return(rtn);}voidtgets(buf)char *buf;{ if(!gets(buf)) goodbye(1);}chartgetopt(prompt,choices,deflt)char *prompt;char *choices;char deflt;{ char rtn = 0; char response; char *cptr; printf("\n%s (",prompt); while(!rtn) { cptr = choices; while(*cptr) { if(cptr - choices) putchar(','); if(*cptr == deflt) putchar('['); putchar(*cptr); if(*cptr == deflt) putchar(']'); cptr++; } 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);}voidgen_cc_cflags(){ fputs("CFLAGS = \\\n",fpmake); switch(sys) { case S_SCO:#ifdef M_UNIX fputs("\t-nointl \\\n",fpmake); if((sco_type != X_UNIX) && (sco_type != X_32v4)) fputs("\t-xenix -Dconst= \\\n",fpmake);#endif fputs("\t-DLINT_ARGS \\\n",fpmake); fputs(sco_cc_optim[sco_type],fpmake); fputs(sco_cc_opts[sco_type],fpmake); if((sco_type == X_UNIX) || (sco_type == X_32v4)) fputs(malloc_3x,fpmake); fputs("\t-DUSE_ECUUNGETTY \\\n",fpmake); if(sco_type == X_32v4) fputs("\t-DWORKING_SELECT -DSCO32v4 \\\n",fpmake); fputs("\t-DSIGTYPE=$(SIGTYPE) \\\n",fpmake); fputs("\t-DLOCK_DIR_NAME='\"/usr/spool/uucp\"' \\\n",fpmake); break; case S_ISC: fputs(isc_cc_opts,fpmake); fputs(malloc_3x,fpmake); fputs("\t-DUSE_ECUUNGETTY \\\n",fpmake); fputs("\t-DWORKING_SELECT \\\n",fpmake); fputs("\t-DSIGTYPE=$(SIGTYPE) \\\n",fpmake); fputs("\t-DLOCK_DIR_NAME='\"/usr/spool/locks\"' \\\n",fpmake); break; case S_SUN: fputs(sun_cc_opts,fpmake); fputs(malloc_3x,fpmake); fputs("\t-DWORKING_SELECT \\\n",fpmake); fputs("\t-DSIGTYPE=$(SIGTYPE) \\\n",fpmake); fputs("\t-DLOCK_DIR_NAME='\"/var/spool/locks\"' \\\n",fpmake); break; case S_ISCSVR4: case S_ESIXSVR4: fputs(svr4_cc_opts,fpmake); if(sys == S_ISCSVR4) fputs("\t-DISCSVR4 \\\n",fpmake); else fputs("\t-DESIXSVR4 \\\n",fpmake); fputs(malloc_3x,fpmake); fputs("\t-DWORKING_SELECT \\\n",fpmake); fputs("\t-DSIGTYPE=$(SIGTYPE) \\\n",fpmake); fputs("\t-DLOCK_DIR_NAME='\"/var/spool/locks\"' \\\n",fpmake); break; case S_LINUX: fputs(linux_cc_opts,fpmake); fputs("\t-DWORKING_SELECT \\\n",fpmake); fputs("\t-DSIGTYPE=$(SIGTYPE) \\\n",fpmake); fputs("\t-DLOCK_DIR_NAME='\"/usr/spool/uucp\"' \\\n",fpmake); break; } fprintf(fpmake,"\t-DDEFAULT_TTY='\"/dev/%s\"' \\\n",tty); fprintf(fpmake,"\t-DDEFAULT_BAUD_RATE=%s \\\n",baud); fprintf(fpmake,"\t-DDEFAULT_PARITY=\"'%c'\" \\\n",parity); fputs("\t-DHDBLIBDIR='\"$(HDBLIBDIR)\"' \\\n",fpmake); fputs("\t-DECULIBDIR='\"$(ECULIBDIR)\"' -DECUUNGETTY_CHOWN \\\n",fpmake); fputs(pid_type,fpmake); fputs("\t$(SYMBOLIC) $(CFLAGS_EXTRA) $(CC_CFLAGS_EXTRA) $(LOCAL_CFLAGS)\n\n",fpmake);}voidgen_gcc_cflags(){ fputs("CFLAGS = \\\n",fpmake); tputstrsfp(gcc_opts); if(can_pipe) fputs("\t-pipe \\\n",fpmake); switch(sys) { case S_SCO: fputs(sco_gcc_opts[sco_type],fpmake); tputstrsfp(i86_gcc_opts); if((sco_type == X_UNIX) || (sco_type == X_32v4)) fputs(malloc_3x,fpmake); fputs("\t-DUSE_ECUUNGETTY \\\n",fpmake); fputs("\t-DSIGTYPE=$(SIGTYPE) \\\n",fpmake); if(sco_type == X_32v4) fputs("\t-DWORKING_SELECT -DSCO32v4 \\\n",fpmake); fputs("\t-DLOCK_DIR_NAME='\"/usr/spool/uucp\"' \\\n",fpmake); break; case S_ISC: fputs(isc_gcc_opts,fpmake); tputstrsfp(i86_gcc_opts); fputs(malloc_3x,fpmake); fputs("\t-DUSE_ECUUNGETTY \\\n",fpmake); fputs("\t-DWORKING_SELECT \\\n",fpmake); fputs("\t-DSIGTYPE=$(SIGTYPE) \\\n",fpmake); fputs("\t-DLOCK_DIR_NAME='\"/usr/spool/locks\"' \\\n",fpmake); break; case S_SUN: fputs(sun_gcc_opts,fpmake); fputs(malloc_3x,fpmake); fputs("\t-DWORKING_SELECT \\\n",fpmake); fputs("\t-DSIGTYPE=$(SIGTYPE) \\\n",fpmake); fputs("\t-DLOCK_DIR_NAME='\"/var/spool/locks\"' \\\n",fpmake); break; case S_ISCSVR4: case S_ESIXSVR4: fputs(svr4_gcc_opts,fpmake);#if defined(i386) tputstrsfp(i86_gcc_opts);#endif if(sys == S_ISCSVR4) fputs("\t-DISCSVR4 \\\n",fpmake); else fputs("\t-DESIXSVR4 \\\n",fpmake); fputs(malloc_3x,fpmake); fputs("\t-DWORKING_SELECT \\\n",fpmake); fputs("\t-DSIGTYPE=$(SIGTYPE) \\\n",fpmake); fputs("\t-DLOCK_DIR_NAME='\"/var/spool/locks\"' \\\n",fpmake); break; case S_LINUX: fputs(linux_cc_opts,fpmake); fputs("\t-DWORKING_SELECT \\\n",fpmake); fputs("\t-DSIGTYPE=$(SIGTYPE) \\\n",fpmake); fputs("\t-DLOCK_DIR_NAME='\"/usr/spool/uucp\"' \\\n",fpmake); break; } if(have_gcc_140) fputs("\t-DGCC140 \\\n",fpmake); fprintf(fpmake,"\t-DDEFAULT_TTY='\"/dev/%s\"' \\\n",tty); fprintf(fpmake,"\t-DDEFAULT_BAUD_RATE=%s \\\n",baud); fprintf(fpmake,"\t-DDEFAULT_PARITY=\"'%c'\" \\\n",parity); fputs("\t-DHDBLIBDIR='\"$(HDBLIBDIR)\"' \\\n",fpmake); fputs("\t-DECULIBDIR='\"$(ECULIBDIR)\"' -DECUUNGETTY_CHOWN \\\n",fpmake); fputs(pid_type,fpmake); fputs("\t$(SYMBOLIC) $(CFLAGS_EXTRA) $(GCC_CFLAGS_EXTRA) $(LOCAL_CFLAGS)\n\n",fpmake);}voidgen_sco_ldflags(){ fputs("LDFLAGS = \\\n",fpmake);#if defined(WHT) || defined(FORCE_DASH_G) fputs("\t-g \\\n",fpmake);#endif if(compiler == C_CC) {#ifdef M_UNIX fputs("\t-nointl \\\n",fpmake); if((sco_type != X_UNIX) && (sco_type != X_32v4)) fputs("\t-xenix \\\n",fpmake);#endif fputs(sco_cc_opts[sco_type],fpmake); if(sco_type == X_X286) fputs("\t-SEG 512 -F 5000 \\\n",fpmake); } fputs("\t$(SYMBOLIC) $(LDFLAGS_EXTRA)\n\n",fpmake); fprintf(fpmake,"LIBS = %s\n\n",sco_libs[sco_type]);}voidgen_isc_ldflags(){ fputs("LDFLAGS = \\\n",fpmake); fputs("\t$(SYMBOLIC) $(LDFLAGS_EXTRA)\n\n",fpmake);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -