/* File: install.c - performs the PMON/IMON installation * Author: Phil Bunce (pjb@carmel.com) * Revision History: * 931010 Converted from Unix csh script * 960722 Added all-be and all-le * 961223 Added atm2 host and sar * 960810 Added l64008 * 970206 Added l9a0084 DCAM * 970224 Added "was generated automatically.." for devinfo.c * 970307 EPI - changed HCINC to '.' - see email * 970311 Changed DBX_SUPPORT to GDB_SUPPORT * 970313 Fixedup the file fixup list for bsps and imon * 970314 Removed '-' and '+' symbols from 'board' names (DOS). * 970317 Modified the dos file fixup logic to add names that are * appended to the $(AR) command. * 970317 Removed 'stand' directory from pmon/examples * 970317 Removed SEDPAT. No longer required for 'make depend'. * 970317 Added pkg_rev. * 970318 Added LIB_ONLY to support lib-only target. Removed BUILD_DIRS. * 970324 Added support for Cygnus Elf tools * 970324 Added LR4001_RevA switch * 970331 Switched over to targList[] and toolList[]. * 970418 Created a separate target for 4010 Nitro. * 970422 Changed defaults to hostport=tty0 -srec and dlproto=none * 970515 Removed endianDef(0) from if statement * 970515 Added stuff for etheripaddr * 970525 Removed skipask1: and mdem = "NONE" * 970526 Added 4101 to all-be and all-le * 970526 Corrected CYGUNIX names * 970529 Corrected ALGUNIX and EPIUNIX names * 970530 Corrected BSOUNIX name * 970624 Added support for CYGELFDOS * 970630 Added win95 switch * 970703 Fixed prob with fixup files (line cont) * 970703 Cygnus EXEC_PREFIX needs all backslashes * 970703 Added _WIN32 switch for Win95 and WinNT * 970704 Added HOSTCCEXTRA and TOOLOBJS - also edited dosit * 970718 Added GCC_EXEC_PREFIX to CYGUNIXELF * 970731 Added Hamilton csh stuff for Win32 * 970731 Changed close to fclose in a couple of places. * 970821 Updated to permit pttys to be added. * 970912 Rewrote frecDef (now recDef) * 970927 Added code to conditionally create TMPDIR * 970927 Added dblqts around %path% in unsetenv.bat for win95 * 971002 Changed TMPDIR (cygelfdos) to use /cygnus * 971003 Fixed TMPDIR for algo and cygelfdos. * 971003 Added examples/xflash to fileLst. * 980113 Added code to selectively build be and le targets in bsps * 980120 Added LR4011 to all-be and all-le lists. * 980202 Enabled nvram on sdp1000. * 980202 Added LR4001 to sdp1000. * 980220 Added COMP_LIBGCC and COMP_LIBLSI to cygelf dos tools. * 980226 Added COMP_LIBGCC and COMP_LIBLSI to cygunixelf. * 980322 Changed winbootdir to windir. NT doesn't have winbootdir. * 980322 Changed win95 to win32. win32 is win95 + winNT. * 980327 NT doesn't like the dbl quotes in path that win95 needs. * set win32 if windir (NTor95) * set win95 if winbootdir (95 only) * 980402 Added ALGDOS3. * 980412 Added mdem=no to targ_sdp1000. * 980414 Removed a case from bso file fixup. Better for long paths. * 980414 Don't call getAlgoToolRev for ALGUNIX3. * 980414 Added NOANSI switch in support of old Sun cc command. * 980420 Added 90084 device info * 980615 Added 4102 and 16550. * 980616 Large change. Eliminate devinfo.c. * 980619 Added quotes to sde2-dos-csh-bg COMPILER_PATH * 980624 Added ATMizer-II+ (64364). * 980704 Added 64388 RAP. * 980724 Added "export PATH" to all UNIX Bourne-shell configs. * 980726 Moved chkfile into loop in ALGDOS. * 980817 Changed RMFOBJS to use rm-f. * 980820 Removed LR4001_RevA flag. * 980901 Added ALL_TARG so as to not build imon w sdp1000. * 981006 Added html/makefile to list. * 981019 Removed BSPTARGETS. Added MKDIR for bsps/{lg,bg}. * 981020 Added bsps/target.mk to fixup list. * 981022 Added leading nl to include/defines.h. * 981025 Removed NMOD from GHS. Added COMP_ROOT. * 981030 Added examples/stand. Removed several out-of-date dirs. * 981101 Added EDIR to defines.mk. * 981203 Fixed potential for crash if lsi not found. * 981204 Fixed duplicate BGd in PMON_TARG * 981204 Removed mkdir for examples/xflash/{bg,lg} */ /* * This install program is used in both Unix and MSDOS environments. ifdef * MSDOS is used to bracket all MSDOS specific code. At present you MUST * use the Microsoft Visual C++ Pro package to compile this program in * an MSDOS environment. * For Win32 compile with: cl /DMSDOS install.c /link /stack:8192 */ #include #include #include #ifdef host_mips #include char *strstr(); #endif #define strNcpy(x,y,z) strncpy(x,y,z),(x)[z]=0 char *strstr(),*rstrstr(); char *strichr(),*strchr(),*strrchr(); char *readFile(); #ifdef MSDOS #define MKDIR(x,y) _mkdir(x) typedef void VOID; int findit(); #ifdef _WIN32 #include #include #else #include #endif #define strequ(x,y) ((_stricmp(x,y)==0)?1:0) #else /* not MSDOS */ #define MKDIR(x,y) mkdir(x,y) typedef int VOID; #include #define strequ(x,y) ((strcmp(x,y)==0)?1:0) #endif #define BUFSZ 200 #define AVSIZE 40 #define CWDSZ 500 #define bufnl() bufptr=prnbuf[lstnadd(prnbuf,"",45)],bufcol=0 #define BUFINDSZ 9 #define DODOTS /* insert dots in the display output */ /* IMPORTANT: * You must use a unique hardware address for each board that may be * simultaneously connected to your network. I recommend simply * incrementing this value. For example, your second board would * use aa:bb:cc:00:00:01. */ #define ETHERNET_HW_ADDRESS "aa:bb:cc:00:00:00" #define ETHERNET_IP_ADDRESS "71.0.0.211" typedef VOID vFunc(); typedef int iFunc(); typedef char *Lst; char pkg_rev[20]; char pmon_rev[20]; char imon_rev[20]; char bsps_rev[20]; char mon_rev[20]; char clib_rev[20]; char fpem_rev[20]; char optfpem_rev[20]; #ifdef MSDOS struct FileLst { char *src; char *dst; }; /* list of files that get fixed up */ struct FileLst fileLst[] = { {"makefile.dst","makefile"}, {"include/makefile.dst","include/makefile"}, {"tools/makefile.dst","tools/makefile"}, {"mon/makefile.dst","mon/makefile"}, {"mon/target.dst","mon/target.mk"}, {"pmon/makefile.dst","pmon/makefile"}, {"pmon/target.dst","pmon/target.mk"}, {"imon/makefile.dst","imon/makefile"}, {"imon/target.dst","imon/target.mk"}, {"bsps/makefile.dst","bsps/makefile"}, {"lib/makefile.dst","lib/makefile"}, {"lib/target.dst","lib/target.mk"}, {"libsa/makefile.dst","libsa/makefile"}, {"libsa/target.dst","libsa/target.mk"}, {"html/makefile.dst","html/makefile"}, {"examples/makefile.dst","examples/makefile"}, {"examples/pmon/makefile.dst","examples/pmon/makefile"}, {"examples/bench/makefile.dst","examples/bench/makefile"}, {"examples/misc/makefile.dst","examples/misc/makefile"}, {"examples/xflash/makefile.dst","examples/xflash/makefile"}, {"examples/stand/makefile.dst","examples/stand/makefile"}, {0}}; #endif struct TargList { char *name; vFunc *func; }; struct TargList *targList; extern struct TargList targList_lsi[]; extern struct TargList targList_cma[]; char *defines[] = { "######################################################################", "# This file contains information about your configuration. #", "######################################################################", "", "CFLAGS = $(TFLAG) $(OPTLEV)", "ASFLAGS = $(TFLAG) $(OPTLEV)", "", ".c.o:", " pmcc -c $(CFLAGS) $<", "", ".s.o:", " pmcc -c $(ASFLAGS) $<", "", ".SUFFIXES: .o .s", 0}; char *defbaud = "9600"; char *bauds[] = { "75","110","134","150","200","300","600","1200", "1800","2400","4800","9600","19200","38400",0}; /* * This program has far too many global variables, but that's because * it was converted into C from a csh script. That also accounts for * its really horrible structure! */ Lst prnbuf[50]; char *bufptr; char mach[80],*FPEM_DIR; char manpath[200]; Lst cfg[20],pkgsw[20]; int Argc,Argcnt; char **Argv; char *devtypes[] = {"2681","8251","PS2","ptty","16c552","90084","16550",0}; int bufcol; int win32,win95; char *ALL_TARG; FILE *sfp; /* dot.sh or setenv.bat */ FILE *dfp; /* defines.mk */ FILE *hfp; /* include/defines.h */ FILE *rfp; /* root.sh */ FILE *cfp; /* source.csh */ char *getenv(); char *lststr(),*lstnstr(); int do_bso(),do_epi(),do_ghs(),do_algor(),do_algor3(),do_cyg(); VOID padnprt(); VOID cpuTypeCfg(),devCfg(),ramRomCfg(), autoMemCfg(), autoClkCfg(), hostDevCfg(), dbgCfg(), frecCfg(), recDef(), timingCfg(), etherCfg(), dlDevCfg(),protoCfg(), nvRamChk(), fpCfg(), promptSet(), memTypeCfg(),endianCfg(),endianDef(),SelectTools(),dlmodeCfg(), mdCfg(); #define FFLAG_PMON 1 #define FFLAG_IMON 3 struct FuncEntry { vFunc *func; int flags; } funcList[] = { {SelectTools, FFLAG_PMON|FFLAG_IMON}, {cpuTypeCfg, FFLAG_PMON|FFLAG_IMON}, {devCfg, FFLAG_PMON|FFLAG_IMON}, {ramRomCfg, FFLAG_PMON|FFLAG_IMON}, {autoMemCfg, FFLAG_PMON|FFLAG_IMON}, {nvRamChk, FFLAG_PMON|FFLAG_IMON}, {memTypeCfg, FFLAG_PMON|FFLAG_IMON}, {fpCfg, FFLAG_PMON}, {mdCfg, FFLAG_PMON|FFLAG_IMON}, {autoClkCfg, FFLAG_PMON|FFLAG_IMON}, {timingCfg, FFLAG_PMON}, {dbgCfg, FFLAG_PMON|FFLAG_IMON}, {etherCfg, FFLAG_PMON|FFLAG_IMON}, {hostDevCfg, FFLAG_PMON|FFLAG_IMON}, {dlmodeCfg, FFLAG_PMON|FFLAG_IMON}, {dlDevCfg, FFLAG_PMON|FFLAG_IMON}, {protoCfg, FFLAG_PMON|FFLAG_IMON}, {recDef, FFLAG_PMON|FFLAG_IMON}, {frecCfg, FFLAG_PMON|FFLAG_IMON}, {promptSet, FFLAG_PMON|FFLAG_IMON}, {endianCfg, FFLAG_PMON|FFLAG_IMON}, {endianDef, FFLAG_PMON|FFLAG_IMON}, {0}}; /* set by SelectTools */ char COMP_ROOT[80],*NMOD, *tools; char dlport[10], *dlport_def; char cygbin[400], cygroot[400], libgcc[400], *remote; iFunc *fileFixer; int toolrev, MIPSTOOLS,CROSSTOOLS; char targets[80]; char *board; /* SelectBoard */ Lst cpu[20]; /* cpuTypeCfg */ char ftext[10],fdata[10],clientpc[10]; /* ramRomCfg */ long memsize; /* autoMemCfg */ int clkfreq; /* autoClkCfg */ char hostport[16]; /* hostDevCfg */ int no_chksum; /* frecCfg */ Lst srcdebug[4]; /* dbgCfg */ char etheraddr[12],etherhwaddr[20],*ethernet,etheripaddr[20]; /* etherCfg */ int sonic_dw32; char *dlproto,*dlecho; /* protoCfg */ char *nvram; /* nvRamChk */ char *fpem; /* fpCfg */ char *mdem; /* mdCfg */ char prompt[20]; /* promptSet */ char *memtype; /* memTypeCfg */ char endian[16]; /* endianCfg */ char *defEndian; /* endianDef */ char *defRecords; /* recDef */ char buf[80],tmp[80],tmp2[80]; char *d,*def,*adr; char *msg1[] = { "", "", "This is the LSIPKG installation program. Use it to specify your tools", "and target environment.", "", "For support Call 800-232-MIPS, Fax 408-954-4874, email pjb@lsil.com,", "or point your web browser at 'http://www.mbay.net/~pjb/pmon/'.", "", "For each of the questions that follow, the possible choices available", "are shown in square brackets and the default is shown in parentheses.", "When given as an option, 'q' allows you to cancel the selection.", "", 0}; /************************************************************* * main(argc,argv) */ main(argc,argv) int argc; char *argv[]; { int n; char tmp[200]; Argc = argc; Argv = argv; Argcnt = 1; #ifdef MSDOS if (getenv("windir")) win32 = 1; if (getenv("winbootdir")) win95 = 1; #endif if (Argc > 1 && strequ(Argv[Argcnt],"cogent")) { targList = targList_cma; Argcnt++; } else targList = targList_lsi; for (n=0;msg1[n];n++) printf("%s\n",msg1[n]); printf("This is PMON %s\n",readFile(pkg_rev,"version")); printf("The following subpackages have been found:\n\n"); if (fileExists("pmon")) printf("\tPMON - The Prom Monitor (V%s)\n", readFile(pmon_rev,"pmon/version")); if (fileExists("imon")) printf("\tIMON - The Serial-ICE Ice Manager (V%s)\n", readFile(imon_rev,"imon/version")); if (fileExists("mon")) printf("\tMON - The Core Debug Monitor (V%s)\n", readFile(mon_rev,"mon/version")); if (fileExists("lib")) printf("\tCLIB - The C Run-time Library (V%s)\n", readFile(clib_rev,"lib/version")); if (fileExists("bsps")) printf("\tBSPS - The Serial-ICE Board Support Packages (V%s)\n", readFile(bsps_rev,"bsps/version")); if (fileExists("fpem")) printf("\tFPEM - The Standard Floating-point Emulator (V%s)\n", readFile(fpem_rev,"fpem/version")); if (fileExists("optfpem")) printf("\tOPTFPEM - The Optimized Floating-point Emulator (V%s)\n", readFile(optfpem_rev,"optfpem/version")); printf("\n"); printf("Is this correct? [y n] (y) > "); Gets(tmp); printf("\n"); if (tmp[0] == 0) strcpy(tmp,"y"); if (tmp[0] != 'y') exit(1); lstclr(cfg); lstclr(cpu); lstclr(pkgsw); fpem = ""; SelectTools(0); SelectBoard(); for (;;) { n = displayCfg(); if (n == 0) break; if (n == -1) exit(1); (* funcList[n-1].func)(0); } doInstall(); exit(0); } /************************************************************* * displayCfg() */ displayCfg() { int i,n,col1,col2,len,maxopt; char *p; printf("Your current selections are:\n"); printf("\n"); for (i=0;funcList[i].func;i++) { if ( (funcList[i].flags&FFLAG_PMON && *pmon_rev) || (funcList[i].flags&FFLAG_IMON && *imon_rev) ) { bufnl(); sprintf(tmp," %2d. ",i+1); bufprt(tmp); (* funcList[i].func)(1); } } maxopt = i; #if 0 for (i=0;prnbuf[i];i++) printf("%d: %s\n",i,prnbuf[i]); #endif len = lstlen(prnbuf); col1 = 0; col2 = (len/2)+(len%2); for (i=col2;col1 < col2;) { padnprt(prnbuf[col1++]); if (i < len) padnprt(prnbuf[i++]); printf("\n"); } printf("\n"); lstclr(prnbuf); for (;;) { printf("Is this correct? [y n 1-%d q] (y) > ",maxopt); Gets(buf); printf("\n"); if (*buf == 0) strcpy(buf,"y"); if (striequ(buf,"q")) return(-1); if (striequ(buf,"y")) return(0); if (sscanf(buf,"%d",&n) == 1) break; printf("If this is not correct you can change the configuration\n"); printf("by entering the number of the item you wish to change.\n"); } return(n); } /************************************************************* * padnprt(str) */ VOID padnprt(str) char *str; { char *p; int n; n = 39 - strlen(str); #ifdef DODOTS if (p=strchr(str,':')) { p++; if (!strempty(p) && p[strlen(p)-1] != ' ') { for (;n>0;n--) strichr(p,'.'); printf("%s",str); return; } } #endif printf("%s%*s",str,n,""); } #ifdef MSDOS tool_bso() { char *chkfile; tools = "BSODOS"; printf("Enter location of %s tools (/r3000) > ",tools); for (;;) { Gets(buf); printf("\n"); if (strempty(buf)) strcpy(buf,"/r3000"); chkfile = "bin386/cc3.exe"; sprintf(tmp,"%s/%s",buf,chkfile); if (fileExists(tmp)) break; chkfile = "bin/cc3.exe"; sprintf(tmp,"%s/%s",buf,chkfile); if (fileExists(tmp)) break; printf("%s: not found, reenter the path > ",tmp); } fileFixer = do_bso; dlport_def = "com1"; strcpy(COMP_ROOT,buf); } tool_alg() { char *chkfile; tools = "ALGDOS"; printf("Enter location of %s tools (/) > ",tools); for (;;) { Gets(buf); printf("\n"); if (strempty(buf)) strcpy(buf,"/."); chkfile = "bin/gcc-sde.exe"; sprintf(tmp,"%s/%s",buf,chkfile); if (fileExists(tmp)) { printf("Have identified sde2 tools.\n"); break; } chkfile = "bin/sde-gcc.exe"; sprintf(tmp,"%s/%s",buf,chkfile); if (fileExists(tmp)) { printf("Have identified sde3 tools.\n"); tools = "ALGDOS3"; break; } printf("%s: not found, reenter the path > ",tmp); } dlport_def = "com1"; strcpy(COMP_ROOT,buf); if (strequ(tools,"ALGDOS3")) { toolrev = 30000; fileFixer = do_algor3; } else { toolrev = getAlgoToolRev(COMP_ROOT); fileFixer = do_algor; } } tool_cygelf() { char *chkfile; char *p; tools = "CYGELFDOS"; chkfile = "mips-lsi-elf-gcc.exe"; while (1) { printf("Where are the tools located? (\\cygnus) > "); Gets(buf); printf("\n"); if (strempty(buf)) strcpy(buf,"\\cygnus"); findit(buf,chkfile,cygbin,1); if (*cygbin) break; printf("%s/*/%s: File not found.\n",buf,chkfile); } printf("Found %s/%s.\n",cygbin,chkfile); fileFixer = do_cyg; dlport_def = "com1"; strcpy(COMP_ROOT,buf); findit(COMP_ROOT,"man1",manpath,1); findit(buf,"libgcc.a",libgcc,1); p = rstrstr(libgcc,"lsi"); if (p) { /* 981203 */ for (;*p && *p != '/' && *p != '\\';p++) ; *p = 0; } printf("Found %s/%s.\n",libgcc,"libgcc.a"); } tool_epi() { char *chkfile; tools = "EPIDOS"; printf("Enter location of %s tools (/) > ",tools); chkfile = "bin/hc.exe"; for (;;) { Gets(buf); printf("\n"); if (strempty(buf)) strcpy(buf,"/."); sprintf(tmp,"%s/%s",buf,chkfile); if (fileExists(tmp)) break; printf("%s: not found, reenter the path > ",tmp); } fileFixer = do_epi; dlport_def = "com1"; strcpy(COMP_ROOT,buf); } tool_ghs() { char *chkfile; tools = "GHSDOS"; printf("Enter location of %s tools (\\green) > ",tools); chkfile = "ccmipe.exe"; for (;;) { Gets(buf); printf("\n"); if (strempty(buf)) strcpy(buf,"\\green"); sprintf(tmp,"%s/%s",buf,chkfile); if (fileExists(tmp)) break; printf("%s: not found, reenter the path > ",tmp); } fileFixer = do_ghs; dlport_def = "com1"; strcpy(COMP_ROOT,buf); } tool_cyg() { char *chkfile; #if 0 /* untested, I don't have these tools */ tools = "CYGNUS"; printf("Enter location of %s tools (/) > ",tools); chkfile = "xxxx/bin/mips-idt-ecoff-as"; for (;;) { Gets(buf); printf("\n"); if (strempty(buf)) strcpy(buf,"/."); sprintf(tmp,"%s/%s",buf,chkfile); if (fileExists(tmp)) break; printf("%s: not found, reenter the path > ",tmp); } fileFixer = do_cygnus; dlport_def = "com1"; strcpy(COMP_ROOT,buf); #endif } #else /* ======================= Unix ========================= */ tool_mips() { #if 0 /* assume the user knows what he is doing */ backtick(buf,"uname -m"); if (!strstr(buf,"sun4")) { printf("Are you sure this is a SPARCstation? [y n] (n) >"); Gets(buf); if (striequ(buf,"n") || buf[0] == 0) exit(1); } #endif tools = "MIPSSUN"; MIPSTOOLS = 1; CROSSTOOLS = 1; remote = "/etc/remote.pdbx"; dlport_def = "ttyb"; while (1) { printf("Where are the tools located? > "); Gets(buf); printf("\n"); sprintf(tmp,"%s/usr/bin/ccr3000",buf); if (fileExists(tmp)) { NMOD = "r3000"; break; } sprintf(tmp,"%s/usr/bin/ccx",buf); if (fileExists(tmp)) { NMOD = "x"; break; } printf("%s/usr/bin/cc{r3000,x}: File not found.\n",buf); } strcpy(COMP_ROOT,buf); } tool_bso() { /* BSO */ #if 0 /* assume the user knows what he is doing */ backtick(buf,"uname -m"); if (!strstr(buf,"sun4")) { printf("Are you sure this is a SPARCstation? [y n] (n) >"); Gets(buf); if (striequ(buf,"n") || buf[0] == 0) exit(1); } #endif tools = "BSOUNIX"; CROSSTOOLS = 1; while (1) { printf("Where are the tools located? > "); Gets(buf); printf("\n"); sprintf(tmp,"%s/r3000/bin/cc3",buf); if (fileExists(tmp)) break; printf("%s: File not found.",tmp); } strcpy(COMP_ROOT,buf); dlport_def = "ttyb"; } tool_epi() { #if 0 /* assume the user knows what he is doing */ backtick(buf,"uname -m"); if (!strstr(buf,"sun4")) { printf("Are you sure this is a SPARCstation? [y n] (n) >"); Gets(buf); if (striequ(buf,"n") || buf[0] == 0) exit(1); } #endif tools = "EPIUNIX"; CROSSTOOLS = 1; while (1) { printf("Where are the tools located? > "); Gets(buf); printf("\n"); sprintf(tmp,"%s/bin/hc",buf); if (fileExists(tmp)) break; printf("%s: File not found.",tmp); } strcpy(COMP_ROOT,buf); dlport_def = "ttyb"; } tool_alg() { /* ALGUNIX */ #if 0 /* assume the user knows what he is doing */ backtick(buf,"uname -m"); if (!strstr(buf,"sun4")) { printf("Are you sure this is a SPARCstation? [y n] (n) >"); Gets(buf); if (striequ(buf,"n") || buf[0] == 0) exit(1); } #endif tools = "ALGUNIX"; CROSSTOOLS = 1; strcpy(COMP_ROOT,"/usr/local/sde"); while (1) { printf("Where are the tools located? (%s) > ", COMP_ROOT); Gets(buf); printf("\n"); if (buf[0] == 0) strcpy(buf,COMP_ROOT); sprintf(tmp,"%s/bin/gcc-sde",buf); if (fileExists(tmp)) { printf("Have identified sde2 tools.\n"); break; } sprintf(tmp,"%s/bin/sde-gcc",buf); if (fileExists(tmp)) { printf("Have identified sde3 tools.\n"); tools = "ALGUNIX3"; break; } printf("%s: File not found.",tmp); } strcpy(COMP_ROOT,buf); dlport_def = "ttyb"; if (strequ(tools,"ALGUNIX3")) toolrev = 30000; else toolrev = getAlgoToolRev(COMP_ROOT); } tool_ghs() { char *chkfile; tools = "GHSUNIX"; CROSSTOOLS = 1; printf("Enter location of %s tools (/) > ",tools); chkfile = "ccmipe"; for (;;) { Gets(buf); printf("\n"); if (strempty(buf)) strcpy(buf,"/"); sprintf(tmp,"%s/%s",buf,chkfile); if (fileExists(tmp)) break; printf("%s: not found, reenter the path > ",tmp); } dlport_def = "ttyb"; strcpy(COMP_ROOT,buf); } tool_cygelf() { char *chkfile,*p; tools = "CYGUNIXELF"; CROSSTOOLS = 1; while (1) { chkfile = "mips-lsi-elf-as"; printf("Where are the tools located? > "); Gets(buf); printf("\n"); findit(buf,chkfile,cygbin,1); if (*cygbin) break; printf("%s/*/%s: File not found.",buf,chkfile); } printf("Found %s/%s.\n",cygbin,chkfile); strcpy(COMP_ROOT,buf); findit(COMP_ROOT,"man1",manpath,1); findit(buf,"libgcc.a",libgcc,1); p = rstrstr(libgcc,"lsi"); for (;*p && *p != '/' && *p != '\\';p++) ; *p = 0; printf("Found %s/%s.\n",libgcc,"libgcc.a"); } tool_cygcoff() { char *chkfile; #if 0 /* assume the user knows what he is doing */ backtick(buf,"uname -m"); if (!strstr(buf,"sun4")) { printf("Are you sure this is a SPARCstation? [y n] (n) >"); Gets(buf); if (striequ(buf,"n") || buf[0] == 0) exit(1); } #endif tools = "CYGUNIXCOFF"; CROSSTOOLS = 1; while (1) { chkfile = "mips-idt-ecoff-as"; printf("Where are the tools located? > "); Gets(buf); printf("\n"); findit(buf,chkfile,cygbin,1); if (*cygbin) break; printf("%s/*/%s: File not found.",buf,chkfile); } strcpy(COMP_ROOT,buf); findit(COMP_ROOT,"man1",manpath,1); } tool_mipsnative() { /* MIPSNATIVE */ backtick(buf,"uname -m"); if (!strstr(buf,"mips")) { printf("Are you sure this is a MIPS computer? [y n] (n) >"); Gets(buf); if (striequ(buf,"n") || buf[0] == 0) exit(1); } backtick(buf,"uname -r"); if (strstr(buf,"4_0")) { printf("uname -r=[%s]\n",buf); printf("Due to problems with the assembler,\n"); printf("this package will not build on RISC/os 4.0\n"); printf("exiting.\n"); exit(1); } if (strstr(buf,"5.")) lstadd(cfg,"RISC5"); if (strstr(buf,"4_5")) lstadd(cfg,"RISC45"); tools = "MIPSNATIVE"; remote = "/etc/remote.pdbx"; dlport_def = "tty1"; strcpy(COMP_ROOT,"native"); MIPSTOOLS = 1; } tool_dec() { /* DECSTATION */ backtick(buf,"uname -m"); if (!strequ(buf,"RISC")) { printf("Are you sure this is a DecStation? [y n] (n) >"); Gets(buf); if (striequ(buf,"n") || buf[0] == 0) exit(1); } lstadd(cfg,"DECRISC"); tools = "DECSTATION"; remote = "/etc/remote"; dlport_def = "tty01"; strcpy(COMP_ROOT,"native"); MIPSTOOLS = 1; } tool_sgi() { /* SGI */ backtick(buf,"uname -m"); if (!strequ(buf,"IRIS")) { printf("Are you sure this is an SGI computer? [y n] (n) >"); Gets(buf); if (striequ(buf,"n") || buf[0] == 0) exit(1); } lstadd(cfg,"SGIRISC"); tools = "SGI"; remote = "/etc/remote"; dlport_def = "ttyd2"; strcpy(COMP_ROOT,"native"); MIPSTOOLS = 1; } #endif struct ToolList { char *name; vFunc *func; } toolList[] = { #ifdef MSDOS {"BSO tools - tested with 4.0rb",tool_bso}, {"Algorithmics tools - tested with 3.0",tool_alg}, {"Cygnus Solutions tools (ELF) - tested with lsi-970730",tool_cygelf}, {"Green Hills tools - tested with 1.8.9",tool_ghs}, #else /* UNIX */ {"BSO/Tasking tools",tool_bso}, {"Algorithmics tools",tool_alg}, {"EPI tools",tool_epi}, {"Cygnus Solutions tools (ELF)",tool_cygelf}, {"Green Hills tools",tool_ghs}, #if 0 /* no longer supported or untested */ {"EPI tools",tool_epi}, {"Cygnus Solutions tools (COFF)",tool_cygcoff}, {"MIPS tools hosted on a SPARCstation",tool_mips}, {"MIPS tools hosted on a MIPS system",tool_mipsnative}, {"A MIPS-based Decstation",tool_dec}, {"A MIPS-based SGI workstation",tool_sgi}, #endif #endif {0}}; /************************************************************* * SelectTools(cmd) */ VOID SelectTools(cmd) int cmd; { int r,i; char *chkfile; if (cmd) { sprintf(tmp,"Tools: %s",tools); bufprt(tmp); if (toolrev) { sprintf(tmp," (%d)",toolrev); bufprt(tmp); } return; } printf("This package can be built using a number of different MIPS\n"); printf("cross compilers. Select one of the following tool types:\n\n"); printf("\n"); for (i=0;toolList[i].name;i++) printf("%d. %s\n",i+1,toolList[i].name); printf("\nEnter one of the above tool types [1-%d q] (q) > ",i); for (;;) { Gets(buf); printf("\n"); if (*buf == 0) exit(1); if (striequ(buf,"q")) exit(1); sscanf(buf,"%d",&r); if (r >= 1 && r <= i) break; printf("BAD value, reenter your selection > "); } (* toolList[r-1].func)(); } targ_prock() { /* Pocket Rocket */ board = "PRock"; lstadd(cpu,"LR33000"); lstadd(cpu,"LR33050"); ethernet = "NO"; nvram = "NO"; strcpy(ftext,"9fc00000"); strcpy(fdata,"80000100"); strcpy(clientpc,"80020000"); lstadd(pkgsw,"TIMING"); strcpy(endian,"Big"); defEndian = "Big"; ALL_TARG = "lib-only MONd PMONd"; } targ_racerx() { int r; /* RacerX */ board = "RacerX"; lstadd(cpu,"LR33000"); lstadd(cpu,"LR33050"); lstadd(cpu,"LR33020"); r = 2; if (fileExists("fpem") || fileExists("optfpem")) { printf("You must choose between floating-point"); printf(" emulation and Ethernet download.\n"); printf("\n"); while (1) { printf("fp-emulation(1) Ethernet(2) [1 2] (1) > "); Gets(buf); if (buf[0] == 0) strcpy(buf,"1"); if (sscanf(buf,"%ld",&r) == 1) { if (r == 1 || r == 2) break; } printf("BAD input, please reenter your selection\n"); } } if (r == 1) ethernet = "NO"; else { ethernet = "YES"; strcpy(etheraddr,"0xbc000000"); sonic_dw32 = 1; fpem = "CP1"; } nvram = "NO"; fpem = "NONE"; strcpy(ftext,"9fc00000"); strcpy(fdata,"80000100"); strcpy(clientpc,"80020000"); lstadd(pkgsw,"TIMING"); strcpy(endian,"Big"); defEndian = "Big"; ALL_TARG = "lib-only MONd PMONd"; } targ_trock_racerx() { /* Turbo Rocket or RacerXc */ board = "TRockRacerXc"; lstadd(cpu,"LR33000"); lstadd(cpu,"LR33050"); lstadd(cpu,"LR33020"); lstadd(cpu,"LR33120"); lstadd(cpu,"LR33300"); ethernet = "YES"; strcpy(etheraddr,"0xbc000000"); sonic_dw32 = 1; nvram = "YES"; fpem = "NONE"; strcpy(ftext,"9fc00000"); strcpy(fdata,"80000100"); strcpy(clientpc,"80020000"); lstadd(pkgsw,"TIMING"); lstadd(srcdebug,"GDB_SUPPORT"); lstadd(srcdebug,"CROSSVIEW"); memtype = "TURBORKT"; strcpy(endian,"Big"); defEndian = "Big"; ALL_TARG = "lib-only MONd PMONd"; } #if 0 targ_racerx_ps2() { /* RacerX with console on PS2 port plus 8-bit..*/ board = "RacerX"; lstadd(devtyp,"ps2"); lstadd(devtyp,"2681"); lstadd(devtyp,"2681"); lstadd(devadr,"NONE"); lstadd(devadr,"0"); lstadd(devadr,"0xbe000000"); lstadd(devaux,"NONE"); lstadd(devaux,"9600"); lstadd(devaux,"9600"); lstadd(cpu,"LR33000"); lstadd(cpu,"LR33050"); lstadd(cpu,"LR33020"); lstadd(cpu,"LR33120"); lstadd(cpu,"LR33300"); ethernet = "ask"; strcpy(etheraddr,"0xbc000000"); sonic_dw32 = 1; nvram = "YES"; fpem = "NONE"; strcpy(ftext,"9fc00000"); strcpy(fdata,"80000100"); strcpy(clientpc,"80020000"); lstadd(pkgsw,"TIMING"); strcpy(endian,"Big"); defEndian = "Big"; } targ_atm1host() { /* Single ATMizer R-T or Host ATMizer R-T */ board = "ATMRTHost"; lstadd(devtyp,"2681"); lstadd(devtyp,"2681"); lstadd(devtyp,"ptty"); lstadd(devtyp,"ptty"); lstadd(devadr,"0"); lstadd(devadr,"0xa0e00000"); lstadd(devadr,"0xa0800000"); lstadd(devadr,"0xa0800010"); lstadd(devaux,"9600"); lstadd(devaux,"9600"); lstadd(devaux,"0"); lstadd(devaux,"0"); lstadd(cpu,"LR64360"); ethernet = "NO"; nvram = "NO"; fpem = "NONE"; strcpy(ftext,"a0c00000"); strcpy(fdata,"a0d00000"); strcpy(clientpc,"a0d80000"); lstadd(srcdebug,"GDB_SUPPORT"); lstadd(srcdebug,"CROSSVIEW"); strcpy(endian,"Big"); defEndian = "Big"; ALL_TARG = "lib-only MONd PMONd"; } targ_atm1sar() { /* ATMizer R-T SAR engine */ board = "ATMRTEng"; lstadd(devtyp,"ptty"); lstadd(devtyp,"ptty"); lstadd(devtyp,"2681"); lstadd(devtyp,"2681"); lstadd(devadr,"0xa0800000"); lstadd(devadr,"0xa0800010"); lstadd(devadr,"0"); lstadd(devadr,"0xa0e00000"); lstadd(devaux,"1"); lstadd(devaux,"1"); lstadd(devaux,"9600"); lstadd(devaux,"9600"); lstadd(cpu,"LR64360"); strcpy(prompt,"SAR> "); ethernet = "NO"; nvram = "NO"; fpem = "NONE"; strcpy(ftext,"a0c00000"); strcpy(fdata,"a0d00000"); strcpy(clientpc,"a0d80000"); lstadd(srcdebug,"GDB_SUPPORT"); lstadd(srcdebug,"CROSSVIEW"); strcpy(endian,"Big"); defEndian = "Big"; } #endif targ_all_be() { /* All Processors (except ATMizer) Big Endian */ board = "Allbe"; lstadd(cpu,"LR33000"); lstadd(cpu,"LR33050"); lstadd(cpu,"LR33020"); lstadd(cpu,"LR33120"); lstadd(cpu,"LR33300"); lstadd(cpu,"LR33310"); lstadd(cpu,"LR4001"); lstadd(cpu,"LR4002"); lstadd(cpu,"LR4003"); lstadd(cpu,"LR4101"); lstadd(cpu,"LR4010"); lstadd(cpu,"LR4011"); lstadd(cpu,"LR4102"); lstadd(cpu,"L9A0084"); ethernet = "YES"; sonic_dw32 = 1; nvram = "YES"; fpem = "NONE"; mdem = "YES"; /* required for 4002/3 */ strcpy(ftext,"9fc00000"); strcpy(fdata,"80000100"); strcpy(clientpc,"80020000"); lstadd(pkgsw,"TIMING"); lstadd(srcdebug,"GDB_SUPPORT"); lstadd(srcdebug,"CROSSVIEW"); memtype = "TURBORKT"; strcpy(endian,"Big"); defEndian = "Big"; ALL_TARG = "lib-only MONd IMONd PMONd bsps-only"; } targ_all_le() { /* All Processors (except ATMizer) Little Endian */ board = "Allle"; lstadd(cpu,"LR33000"); lstadd(cpu,"LR33050"); lstadd(cpu,"LR33020"); lstadd(cpu,"LR33120"); lstadd(cpu,"LR33300"); lstadd(cpu,"LR33310"); lstadd(cpu,"LR4001"); lstadd(cpu,"LR4002"); lstadd(cpu,"LR4003"); lstadd(cpu,"LR4101"); lstadd(cpu,"LR4010"); lstadd(cpu,"LR4011"); lstadd(cpu,"LR4102"); ethernet = "YES"; sonic_dw32 = 1; nvram = "YES"; fpem = "NONE"; mdem = "YES"; /* required for 4002/3 */ strcpy(ftext,"9fc00000"); strcpy(fdata,"80000100"); strcpy(clientpc,"80020000"); lstadd(pkgsw,"TIMING"); lstadd(srcdebug,"GDB_SUPPORT"); lstadd(srcdebug,"CROSSVIEW"); memtype = "TURBORKT"; strcpy(endian,"Little"); defEndian = "Little"; ALL_TARG = "lib-only MONd PMONd bsps-only"; } #if 0 targ_4010_nitro() { /* 4010 Nitro */ board = "Nitro"; lstadd(devtyp,"2681"); lstadd(devtyp,"2681"); lstadd(devadr,"0"); lstadd(devadr,"0xbe000000"); lstadd(devaux,"9600"); lstadd(devaux,"9600"); lstadd(cpu,"LR4010"); ethernet = "YES"; strcpy(etheraddr,"0xbc000000"); sonic_dw32 = 1; nvram = "YES"; fpem = "NONE"; strcpy(ftext,"9fc00000"); strcpy(fdata,"80000100"); strcpy(clientpc,"80020000"); lstadd(pkgsw,"TIMING"); lstadd(srcdebug,"GDB_SUPPORT"); lstadd(srcdebug,"CROSSVIEW"); strcpy(endian,"Little"); defEndian = "Little"; lstadd(pkgsw,"INCLUDE_4010_BRKINSTR_BUGFIX"); } #endif targ_atm2host() { /* HOST for ATMizer-II R-T */ board = "ATM2HOST"; /* enable the ptty connection in lib/c64363.c */ #if 0 /* enable the ptty connection here */ lstadd(devtyp,"ptty"); lstadd(devtyp,"ptty"); lstadd(devadr,"0xb4600000"); lstadd(devadr,"0xb4600010"); lstadd(devaux,"0"); lstadd(devaux,"0"); #endif lstadd(cpu,"LR4010"); strcpy(prompt,"PMON> "); ethernet = "YES"; strcpy(etheraddr,"0xbc000000"); sonic_dw32 = 1; nvram = "NO"; fpem = "NONE"; strcpy(ftext,"9fc00000"); strcpy(fdata,"80000100"); strcpy(clientpc,"80020000"); lstadd(srcdebug,"GDB_SUPPORT"); lstadd(srcdebug,"CROSSVIEW"); strcpy(endian,"Little"); defEndian = "Little"; lstadd(pkgsw,"INCLUDE_4010_BRKINSTR_BUGFIX"); ALL_TARG = "lib-only MONd PMONd"; } targ_atm2sar() { /* ATMizer2 SAR engine */ board = "ATM2SAR"; /* enable the ptty connection in lib/c64363.c */ #if 0 /* enable this to use the ptty connection as console */ lstadd(devtyp,"ptty"); lstadd(devtyp,"ptty"); lstadd(devadr,"0xa0600000"); lstadd(devadr,"0xa0600010"); lstadd(devaux,"1"); lstadd(devaux,"1"); #endif lstadd(cpu,"LR64363"); strcpy(prompt,"PMON> "); ethernet = "NO"; nvram = "NO"; fpem = "NONE"; mdem = "NO"; memsize = (128*1024)-32; /* -32 for 2 pttys */ clkfreq = 66; strcpy(ftext,"a0000000"); strcpy(fdata,"a0400100"); strcpy(clientpc,"a0600020"); lstadd(srcdebug,"GDB_SUPPORT"); lstadd(srcdebug,"CROSSVIEW"); strcpy(endian,"Big"); defEndian = "Big"; lstadd(pkgsw,"INCLUDE_4010_BRKINSTR_BUGFIX"); ALL_TARG = "lib-only MONd PMONd"; } targ_atm2psar() { /* ATMizer2+ SAR engine */ board = "ATM2SAR"; lstadd(cpu,"LR64364"); strcpy(prompt,"PMON> "); ethernet = "NO"; nvram = "YES"; fpem = "NONE"; mdem = "NO"; memsize = 128*1024; clkfreq = 80; strcpy(ftext,"80000000"); strcpy(fdata,"80400100"); strcpy(clientpc,"80600000"); lstadd(srcdebug,"GDB_SUPPORT"); lstadd(srcdebug,"CROSSVIEW"); strcpy(endian,"Big"); defEndian = "Big"; ALL_TARG = "lib-only MONd PMONd"; } targ_64388() { /* 64388 RAP */ board = "RAP64388"; lstadd(cpu,"LR64388"); strcpy(prompt,"PMON> "); ethernet = "NO"; nvram = "YES"; fpem = "NONE"; mdem = "NO"; memsize = 7*1024*1024; strcpy(ftext,"9fc00000"); strcpy(fdata,"80001000"); strcpy(clientpc,"80100000"); lstadd(srcdebug,"GDB_SUPPORT"); lstadd(srcdebug,"CROSSVIEW"); strcpy(endian,"Big"); defEndian = "Big"; ALL_TARG = "lib-only MONd PMONd"; } targ_sdp1000() { /* L64008 eval board */ board = "evb64008"; lstadd(cpu,"LR64008"); lstadd(cpu,"LR4001"); ethernet = "YES"; strcpy(etheraddr,"0xa1100000"); nvram = "YES"; fpem = "NONE"; mdem = "NO"; clkfreq = 54; strcpy(ftext,"9fc00000"); strcpy(fdata,"80000100"); strcpy(clientpc,"80020000"); lstadd(pkgsw,"TIMING"); lstadd(srcdebug,"GDB_SUPPORT"); lstadd(srcdebug,"CROSSVIEW"); strcpy(endian,"Big"); defEndian = "Big"; ALL_TARG = "lib-only MONd PMONd"; } targ_cma257() { /* Cogent board with a VR4300 CMA257 */ board = "cma257"; lstadd(cpu,"VR4300"); ethernet = "NO"; nvram = "NO"; fpem = "NONE"; mdem = "NO"; strcpy(ftext,"bfc00000"); strcpy(fdata,"a0000100"); strcpy(clientpc,"a0020000"); lstadd(pkgsw,"NON_CACHED"); lstadd(pkgsw,"R4KEXCEPTIONS"); lstadd(srcdebug,"GDB_SUPPORT"); lstadd(srcdebug,"CROSSVIEW"); strcpy(endian,"Big"); defEndian = "Big"; ALL_TARG = "lib-only MONd PMONd"; } struct TargList targList_lsi[] = { {"All Processors Big Endian - incl 4101, 4011, DCAM, 4102",targ_all_be}, {"All Processors Little Endian - incl 4101, 4011, 4102",targ_all_le}, {"ATMizer-2 R-T Host (4010)",targ_atm2host}, {"ATMizer-2 R-T SAR engine",targ_atm2sar}, {"ATMizer-2+ R-T SAR engine",targ_atm2psar}, {"SDP1000 (L64008 MPEG-2 Transport)",targ_sdp1000}, {"64388 RAP Evaluation board",targ_64388}, #if 0 /* old stuff */ {"ATMizer-1 R-T Host",targ_atm1host}, {"ATMizer-1 R-T SAR engine",targ_atm1sar}, {"Pocket Rocket (128KB PROM)",targ_prock}, {"RacerX + Pocket Rocket (128KB PROM)",targ_racerx}, {"Turbo Rocket + RacerX/Xc + Pocket Rocket (256KB PROM)", targ_trock_racerx}, {"RacerX/Xc with console on PS2 port plus 8-bit color video interface", targ_racerx_ps2}, /* {"L9A0084 DCAM Evaluation board",targ_l9a0084}, */ /* {"4010 Nitro",targ_4010_nitro}, */ #endif {0}}; struct TargList targList_cma[] = { {"CMA257 (VR4300)",targ_cma257}, {0}}; /************************************************************* * SelectBoard() */ SelectBoard() { int r,i; def = "1"; printf("Select one of the following target configurations:\n"); printf("\n"); for (i=0;targList[i].name;i++) printf("%d. %s\n",i+1,targList[i].name); printf("\n"); printf("Enter your selection [1-%d] (%s) > ",i,def); while (1) { Gets(buf); printf("\n"); if (buf[0] == 0) strcpy(buf,def); r = 0; sscanf(buf,"%d",&r); if (r >= 1 && r <= i) break; printf("BAD INPUT, reenter your selection > "); } (* targList[r-1].func)(); if (strequ(ethernet,"YES")) { strcpy(etherhwaddr,ETHERNET_HW_ADDRESS); strcpy(etheripaddr,ETHERNET_IP_ADDRESS); } if (fileExists("optfpem")) fpem = "OPT"; else if (fileExists("fpem")) fpem = "STD"; #ifdef MSDOS if (lststr(cpu,"LR64360")) dlecho = "lfeed"; #endif strcpy(hostport,"tty0"); defRecords = "SREC"; } /************************************************************* * dlmodeCfg(cmd) */ VOID dlmodeCfg(cmd) int cmd; { int r; if (cmd) { bufprt("Download mode: "); if (strequ(hostport,"tty0")) bufprt("Single-port"); else if (strequ(hostport,"ethernet")) bufprt("Ethernet"); else bufprt("Two-port"); return; } printf("You can download to PMON using a number of techniques.\n"); printf("\n"); printf("1. Single-port mode (using tip or a terminal emulator)\n"); printf("2. Dual-port mode (using edown)\n"); if (strequ(ethernet,"YES")) printf("3. Ethernet (using tftp)\n"); printf("\n"); printf("Select default download technique [1-n] (%s) > ",def); while (1) { Gets(buf); printf("\n"); if (buf[0] == 0) strcpy(buf,def); r = 0; sscanf(buf,"%d",&r); switch (r) { case 1 : strcpy(hostport,"tty0"); defRecords = "SREC"; if (lststr(cpu,"LR64360")) dlecho = "lfeed"; dlproto = "NONE"; break; case 2 : strcpy(hostport,"tty1"); dlproto = "EtxAck"; break; case 3 : if (strequ(ethernet,"YES")) { strcpy(hostport,"ethernet"); dlproto = "EtxAck"; break; } /* else fall through */ default : printf("BAD input, please reenter your selection > "); continue; break; } break; } } /************************************************************* * endianDef(cmd) */ VOID endianDef(cmd) int cmd; { if (cmd) { sprintf(tmp,"Default Endian: %s",defEndian); bufprt(tmp); return; } if (! strchr(endian,' ')) { printf("Only one endianness selected, return to continue > "); Gets(buf); return; } if (strequ(defEndian,"Big")) def = "1"; else if (strequ(defEndian,"Little")) def = "2"; else printf("install: error 902\n"); defEndian = 0; printf("The pmcc command can be used to build programs with either big or\n"); printf("little byte ordering. This can be selected via the -EB and -EL\n"); printf("options, but it may be more convenient to set the default to\n"); printf("refect the ordering that you will normally use.\n"); printf("\n"); printf("1. Big Endian\n"); printf("2. Little Endian\n"); printf("\n"); printf("Select a byte ordering [1 2] (%s) > ",def); while (1) { Gets(buf); printf("\n"); if (strempty(buf)) strcpy(buf,def); if (strequ(buf,"1")) defEndian = "Big"; else if (strequ(buf,"2")) defEndian = "Little"; if (defEndian) break; printf("BAD input, please reenter your selection > "); } } /************************************************************* * endianCfg(cmd) * specifies which versions of PMON will be built. */ VOID endianCfg(cmd) int cmd; { char *av[10],def[8]; int ac,i,err; if (cmd) { sprintf(tmp,"Endian support: %s",endian); bufprt(tmp); return; } *def = 0; if (strstr(endian,"Big")) strcat(def,"1 "); if (strstr(endian,"Little")) strcat(def,"2 "); if (*def) def[strlen(def)-1] = 0; /* kill trailing space */ *endian = 0; printf("This package can be used to build binaries for execution on big- or\n"); printf("little-endian target systems. You may select both options.\n"); printf("\n"); printf("1. Big Endian\n"); printf("2. Little Endian\n"); printf("\n"); printf("Select one target type [1 2] (%s) > ",def); while (1) { err = 0; Gets(buf); printf("\n"); if (strempty(buf)) strcpy(buf,def); ac = argvize(av,buf); for (i=0;i "); } if (lststr(cpu,"LR64360") && strstr(endian,"Little")) printf("Warning: the ATMizer-1 only operates in Big Endian mode\n"); if (lststr(cpu,"LR64363") && strstr(endian,"Little")) printf("Warning: the ATMizer-2 only operates in Big Endian mode\n"); #if 0 /* 4011 supports big and little */ if (lststr(cpu,"LR4010") && strstr(endian,"Big")) printf("Warning: the 4010 only operates in Little Endian mode\n"); #endif } /************************************************************* * doInstall() * Now implement the selections */ doInstall() { char CLEAN_DIRS[80],PMON_TARG[80],LIB_TARG[80]; char MON_TARG[80],LIB_ONLY[80]; char cpppath[400]; int i; int umsk = 0777; char cwdstr[CWDSZ+2]; char tmp[80],*s,*d,*p,*cwd; *cpppath = 0; if (COMP_ROOT[0] == 0) { printf("COMP_ROOT unknown, exiting\n"); exit(1); } /* get the cwd. This must work for csh, sh, automount, and MSDOS */ cwd = getenv("cwd"); /* csh */ if (!cwd) { cwd = getenv("PWD"); /* sh */ if (!cwd) { getcwd(cwdstr,CWDSZ); /* catch all */ cwd = cwdstr; } } printf("Please confirm your current path [%s] > ",cwd); Gets(buf); if (buf[0] != 0) { strcpy(cwdstr,buf); cwd = cwdstr; } if (fileExists("defines.mk")) { printf("Saving existing defines.mk in defines.old.\n"); unlink("defines.old"); rename("defines.mk","defines.old"); } else printf("Creating defines.mk.\n"); dfp = fopen("defines.mk","w"); if (dfp == 0) { fprintf(stderr,"can't open defines.mk\n"); exit(1); } *targets = 0; if (strstr(endian,"Big")) strcat(targets," BG BO"); if (strstr(endian,"Little")) strcat(targets," LG LO"); /* set BUILD & CLEAN DIRS, also PMON & LIB TARG */ strcpy(LIB_ONLY,"TOOLSd"); CLEAN_DIRS[0] = 0; PMON_TARG[0] = 0; MON_TARG[0] = 0; LIB_TARG[0] = 0; FPEM_DIR = "lib"; if (strequ(fpem,"STD")) { strcat(LIB_ONLY," FPEMd"); strcat(CLEAN_DIRS," FPEMd"); FPEM_DIR = "fpem"; } if (strequ(fpem,"OPT")) { strcat(LIB_ONLY," OPTFPEMd"); strcat(CLEAN_DIRS," OPTFPEMd"); FPEM_DIR = "optfpem"; } if (*clib_rev) { strcat(LIB_ONLY," LIBd"); strcat(CLEAN_DIRS," LIBd"); if (strstr(endian,"Big")) { MKDIR("lib/bo",umsk); strcat(LIB_TARG," BOd"); } if (strstr(endian,"Little")) { MKDIR("lib/lo",umsk); strcat(LIB_TARG," LOd"); } if (MIPSTOOLS) { strcat(LIB_ONLY," LIBSAd"); strcat(CLEAN_DIRS," LIBSAd"); if (strstr(endian,"Big")) MKDIR("libsa/bo",umsk); if (strstr(endian,"Little")) MKDIR("libsa/lo",umsk); if (*pmon_rev || *imon_rev) { if (strstr(endian,"Big")) MKDIR("libsa/bg",umsk); if (strstr(endian,"Little")) MKDIR("libsa/lg",umsk); } } } if (*mon_rev) { strcat(CLEAN_DIRS," MONd"); } if (*imon_rev) { strcat(CLEAN_DIRS," IMONd BSPSd"); if (strstr(endian,"Big")) { if (!strstr(PMON_TARG,"BGd")) strcat(PMON_TARG," BGd"); MKDIR("imon/bg",umsk); if (!strstr(MON_TARG,"BGd")) strcat(MON_TARG," BGd"); MKDIR("mon/bg",umsk); if (!strstr(LIB_TARG,"BGd")) strcat(LIB_TARG," BGd"); MKDIR("lib/bg",umsk); } if (strstr(endian,"Little")) { if (!strstr(PMON_TARG,"LGd")) strcat(PMON_TARG," LGd"); MKDIR("imon/lg",umsk); if (!strstr(MON_TARG,"LGd")) strcat(MON_TARG," LGd"); MKDIR("mon/lg",umsk); if (!strstr(LIB_TARG,"LGd")) strcat(LIB_TARG," LGd"); MKDIR("lib/lg",umsk); } } if (*pmon_rev) { strcat(CLEAN_DIRS," PMONd"); if (strstr(endian,"Big")) { if (!strstr(PMON_TARG,"BGd")) strcat(PMON_TARG," BGd"); MKDIR("pmon/bg",umsk); if (!strstr(MON_TARG,"BGd")) strcat(MON_TARG," BGd"); MKDIR("mon/bg",umsk); if (!strstr(LIB_TARG,"BGd")) strcat(LIB_TARG," BGd"); MKDIR("lib/bg",umsk); } if (strstr(endian,"Little")) { if (!strstr(PMON_TARG,"LGd")) strcat(PMON_TARG," LGd"); MKDIR("pmon/lg",umsk); if (!strstr(MON_TARG,"LGd")) strcat(MON_TARG," LGd"); MKDIR("mon/lg",umsk); if (!strstr(LIB_TARG,"LGd")) strcat(LIB_TARG," LGd"); MKDIR("lib/lg",umsk); } } for (i=0;defines[i];i++) fprintf(dfp,"%s\n",defines[i]); fprintf(dfp,"LIB_ONLY = %s\n",LIB_ONLY); fprintf(dfp,"CLEAN_DIRS = %s\n",CLEAN_DIRS); if (*PMON_TARG != 0) fprintf(dfp,"PMON_TARG = %s\n",PMON_TARG); if (*MON_TARG != 0) fprintf(dfp,"MON_TARG = %s\n",MON_TARG); fprintf(dfp,"LIB_TARG = %s\n",LIB_TARG); fprintf(dfp,"ALL_TARG = %s\n",ALL_TARG); fprintf(dfp,"FPEM_DIR = %s\n",FPEM_DIR); fprintf(dfp,"FTEXT = %s\n",ftext); fprintf(dfp,"FDATA = %s\n",fdata); if (strequ(defEndian,"Big")) fprintf(dfp,"EDIR = bg\n"); if (strequ(defEndian,"Little")) fprintf(dfp,"EDIR = lg\n"); if (strstr(LIB_ONLY,"FPEM")) { if (strstr(LIB_TARG,"BG")) { sprintf(tmp,"%s/bg",FPEM_DIR); MKDIR(tmp,umsk); } if (strstr(LIB_TARG,"BO")) { sprintf(tmp,"%s/bo",FPEM_DIR); MKDIR(tmp,umsk); } if (strstr(LIB_TARG,"LG")) { sprintf(tmp,"%s/lg",FPEM_DIR); MKDIR(tmp,umsk); } if (strstr(LIB_TARG,"LO")) { sprintf(tmp,"%s/lo",FPEM_DIR); MKDIR(tmp,umsk); } } #if 0 /* 970317 */ for (s=cwd,d=tmp;*s;) { if (*s == '/') *d++ = '\\'; *d++ = *s++; } *d = 0; fprintf(dfp,"SEDPAT = %s\n",tmp); #endif #ifdef MSDOS /* ================= MSDOS ================== */ fprintf(dfp,"MAKE = nmake /nologo\n"); fprintf(dfp,"EXE = .exe\n"); fprintf(dfp,"O = bj\n"); fprintf(dfp,"RMF = rm-f\n"); fprintf(dfp,"CC = cl /w /nologo /DMSDOS\n"); fprintf(dfp,"HOSTCCEXTRA = /link /stack:8192\n"); fprintf(dfp,"TOOLOBJS = $(CFILES:.c=.exe)\n"); fprintf(dfp,"RMFOBJS = mklist -O ../files.mk . ASFILES CFILES|rm-f -f-\n"); unlink("setenv.bat"); sfp = fopen("setenv.bat","w"); if (sfp == 0) { fprintf(stderr,"can't open setenv.bat\n"); exit(1); } fprintf(sfp,"@echo off\n"); fprintf(sfp,"echo Connecting with pmcc version %s using %s tools\n", pkg_rev,tools); if (win95) fprintf(sfp,"echo path \"%%path%%\" > unsetenv.bat\n"); else fprintf(sfp,"echo path %%path%% > unsetenv.bat\n"); unlink("source.csh"); cfp = fopen("source.csh","w"); if (cfp == 0) { fprintf(stderr,"can't open source.csh\n"); exit(1); } fprintf(cfp,"# This file is compatible with the Hamilton Csh (www.hamiltonlabs.com)\n"); fprintf(cfp,"echo \"Connecting with pmcc version %s using %s tools\"\n", pkg_rev,tools); if (strequ(tools,"BSODOS")) { /* setenv.bat */ fprintf(sfp,"set LSIPKG=%s\n",cwd); fprintf(sfp,"set BSO_TASKING=%s\n",COMP_ROOT); if (win95) fprintf(sfp,"path \"%%path%%\";%s/bin386;%s/bin;%s/tools\n", COMP_ROOT,COMP_ROOT,cwd); else fprintf(sfp,"path %%path%%;%s/bin386;%s/bin;%s/tools\n", COMP_ROOT,COMP_ROOT,cwd); /* source.csh */ fprintf(cfp,"setenv LSIPKG %s\n",cwd); fprintf(cfp,"setenv BSO_TASKING %s\n",COMP_ROOT); fprintf(cfp,"set PATH=\"$PATH;%s/bin386;%s/bin;%s/tools\"\n", COMP_ROOT,COMP_ROOT,cwd); /* create defines.mk */ fprintf(dfp,"# tools type BSODOS\n"); fprintf(dfp,"TOOLSET = BSODOS\n"); fprintf(dfp,"PMCC = bso.c\n"); fprintf(dfp,"OPTLEV = -O\n"); fprintf(dfp,"\n"); } else if (strequ(tools,"ALGDOS")) { /* sde2 */ /* setenv.bat */ fprintf(sfp,"set LSIPKG=%s\n",cwd); if (strstr(targets,"BG")) { fprintf(sfp,"set COMPILER_PATH=%s/libeb;%s/bin\n",COMP_ROOT,COMP_ROOT); fprintf(sfp,"set LIBRARY_PATH=%s/libeb\n",COMP_ROOT); if (toolrev < 20000) fprintf(sfp,"set GNUTARGET=elf-big\n"); else fprintf(sfp,"set GNUTARGET=elf32-bigmips\n"); } else { fprintf(sfp,"set COMPILER_PATH=%s/libel;%s/bin\n",COMP_ROOT,COMP_ROOT); fprintf(sfp,"set LIBRARY_PATH=%s/libel\n",COMP_ROOT); if (toolrev < 20000) fprintf(sfp,"set GNUTARGET=elf-little\n"); else fprintf(sfp,"set GNUTARGET=elf32-littlemips\n"); } if (!getenv("TMPDIR")) { /* 970927 */ fprintf(sfp,"set TMPDIR=/tmp\n"); if (!fileExists("/tmp")) MKDIR("/tmp",umsk); } fprintf(sfp,"set GO32TMP=/tmp\n"); fprintf(sfp,"set GO32=2r1\n"); /* merge stdout and stderr */ if (win95) fprintf(sfp,"path \"%%path%%\";%s/bin;%s/tools\n", COMP_ROOT,cwd); else fprintf(sfp,"path %%path%%;%s/bin;%s/tools\n", COMP_ROOT,cwd); /* source.csh */ fprintf(cfp,"setenv LSIPKG %s\n",cwd); if (strstr(targets,"BG")) { fprintf(cfp,"setenv COMPILER_PATH '%s/libeb;%s/bin'\n",COMP_ROOT,COMP_ROOT); fprintf(cfp,"setenv LIBRARY_PATH %s/libeb\n",COMP_ROOT); fprintf(cfp,"setenv GNUTARGET elf32-bigmips\n"); } else { fprintf(cfp,"setenv COMPILER_PATH '%s/libel;%s/bin'\n",COMP_ROOT,COMP_ROOT); fprintf(cfp,"setenv LIBRARY_PATH %s/libel\n",COMP_ROOT); fprintf(cfp,"setenv GNUTARGET elf32-littlemips\n"); } if (!getenv("TMPDIR")) { /* 970927 */ fprintf(cfp,"setenv TMPDIR=/tmp\n"); if (!fileExists("/tmp")) MKDIR("/tmp",umsk); } fprintf(cfp,"setenv GO32TMP /tmp\n"); fprintf(cfp,"setenv GO32 2r1\n"); /* merge stdout and stderr */ fprintf(cfp,"set PATH=\"$PATH;%s/bin;%s/tools\"\n", COMP_ROOT,cwd); /* create defines.mk */ fprintf(dfp,"# tools type ALGDOS\n"); fprintf(dfp,"TOOLSET = ALGDOS\n"); fprintf(dfp,"PMCC = algo.c\n"); fprintf(dfp,"OPTLEV = -O\n"); fprintf(dfp,"\n"); findit(COMP_ROOT,"cpp.exe",cpppath,1); if (! *cpppath) printf("error: cpp not found\n"); } else if (strequ(tools,"ALGDOS3")) { /* sde3 */ /* setenv.bat */ fprintf(sfp,"set LSIPKG=%s\n",cwd); fprintf(sfp,"set GCC_EXEC_PREFIX=%s/lib/gcc-lib/\n",COMP_ROOT); fprintf(sfp,"set COMPILER_PATH=%s/sde;%s/sde/bin\n", COMP_ROOT,COMP_ROOT); fprintf(sfp,"set LIBRARY_PATH=%s/lib\n",COMP_ROOT); if (!getenv("TMPDIR")) { /* 970927 */ fprintf(sfp,"set TMPDIR=/tmp\n"); if (!fileExists("/tmp")) MKDIR("/tmp",umsk); } if (win95) fprintf(sfp,"path \"%%path%%\";%s/bin;%s/sde/bin;%s/tools\n", COMP_ROOT,COMP_ROOT,cwd); else fprintf(sfp,"path %%path%%;%s/bin;%s/sde/bin;%s/tools\n", COMP_ROOT, COMP_ROOT,cwd); /* source.csh */ fprintf(cfp,"setenv LSIPKG %s\n",cwd); fprintf(cfp,"setenv GCC_EXEC_PREFIX %s/lib/gcc-lib/\n",COMP_ROOT); fprintf(cfp,"setenv COMPILER_PATH '%s/sde;%s/sde/bin'\n", COMP_ROOT,COMP_ROOT); fprintf(cfp,"setenv LIBRARY_PATH %s/lib\n",COMP_ROOT); if (!getenv("TMPDIR")) { /* 970927 */ fprintf(cfp,"setenv TMPDIR=/tmp\n"); if (!fileExists("/tmp")) MKDIR("/tmp",umsk); } fprintf(cfp,"set PATH=\"$PATH;%s/bin;%s/sde/bin;%s/tools\"\n", COMP_ROOT,COMP_ROOT,cwd); /* create defines.mk */ fprintf(dfp,"# tools type ALGDOS\n"); fprintf(dfp,"TOOLSET = ALGDOS3\n"); fprintf(dfp,"PMCC = algo.c\n"); fprintf(dfp,"OPTLEV = -O\n"); fprintf(dfp,"AR = sde-ar -r\n"); fprintf(dfp,"\n"); } else if (strequ(tools,"EPIDOS")) { /* setenv.bat */ fprintf(sfp,"set LSIPKG=%s\n",cwd); fprintf(sfp,"set HCDIR=%s\n",COMP_ROOT); #if 0 /* 970307 */ fprintf(sfp,"set HCINC=%s/include\n",COMP_ROOT); #else fprintf(sfp,"set HCINC=.\n"); #endif fprintf(sfp,"set LIBDIR=%s/lib\n",COMP_ROOT); if (win95) fprintf(sfp,"path \"%%path%%\";%s/bin;%s/tools\n", COMP_ROOT,cwd); else fprintf(sfp,"path %%path%%;%s/bin;%s/tools\n", COMP_ROOT,cwd); /* source.csh */ fprintf(cfp,"setenv LSIPKG %s\n",cwd); fprintf(cfp,"setenv HCDIR %s\n",COMP_ROOT); fprintf(cfp,"setenv HCINC .\n"); fprintf(cfp,"setenv LIBDIR %s/lib\n",COMP_ROOT); fprintf(cfp,"set PATH=\"$PATH;%s/bin;%s/tools\"\n", COMP_ROOT,cwd); /* create defines.mk */ fprintf(dfp,"# tools type EPIDOS\n"); fprintf(dfp,"TOOLSET = EPIDOS\n"); fprintf(dfp,"PMCC = epi.c\n"); fprintf(dfp,"OPTLEV = -O\n"); fprintf(dfp,"\n"); } else if (strequ(tools,"CYGELFDOS")) { path2dos(cygbin); strNcpy(cygroot,cygbin,strrchr(cygbin,'\\')-cygbin); /* setenv.bat */ fprintf(sfp,"set LSIPKG=%s\n",cwd); fprintf(sfp,"set COMP_LIBGCC=%s\n",libgcc); fprintf(sfp,"set COMP_LIBLSI=%s/mips-lsi-elf/lib\n",cygroot); fprintf(sfp,"set GCC_EXEC_PREFIX=%s\\lib\\gcc-lib\\\n",cygroot); if (win95) fprintf(sfp,"path \"%%path%%\";%s;%s/tools\n",cygbin,cwd); else fprintf(sfp,"path %%path%%;%s;%s/tools\n",cygbin,cwd); if (!getenv("TMPDIR")) { /* 970927 */ fprintf(sfp,"set TMPDIR=/cygnus\n"); if (!fileExists("/cygnus")) MKDIR("/cygnus",umsk); } /* source.csh */ fprintf(cfp,"setenv LSIPKG %s\n",cwd); fprintf(cfp,"setenv COMP_LIBGCC %s\n",libgcc); fprintf(cfp,"setenv COMP_LIBLSI %s/mips-lsi-elf/lib\n",cygroot); fprintf(cfp,"setenv GCC_EXEC_PREFIX %s\\lib\\gcc-lib\\\n",cygroot); fprintf(cfp,"set PATH=\"$PATH;%s;%s/tools\"\n",cygbin,cwd); if (!getenv("TMPDIR")) { /* 970927 */ fprintf(cfp,"setenv TMPDIR=/cygnus\n"); if (!fileExists("/cygnus")) MKDIR("/cygnus",umsk); } /* create defines.mk */ fprintf(dfp,"# tools type CYGELFDOS\n"); fprintf(dfp,"TOOLSET = CYGELFDOS\n"); fprintf(dfp,"PMCC = cygelf.c\n"); fprintf(dfp,"OPTLEV = -O\n"); fprintf(dfp,"NMOD = x\n"); fprintf(dfp,"AR = mips-lsi-elf-ar r\n"); fprintf(dfp,"\n"); } else if (strequ(tools,"GHSDOS")) { /* setenv.bat */ fprintf(sfp,"set LSIPKG=%s\n",cwd); if (win95) fprintf(sfp,"path \"%%path%%\";%s;%s/tools\n",COMP_ROOT,cwd); else fprintf(sfp,"path %%path%%;%s;%s/tools\n",COMP_ROOT,cwd); /* source.csh */ fprintf(cfp,"setenv LSIPKG %s\n",cwd); fprintf(cfp,"set PATH=\"$PATH;%s;%s/tools\"\n",COMP_ROOT,cwd); /* create defines.mk */ fprintf(dfp,"# tools type GHSDOS\n"); fprintf(dfp,"TOOLSET = GHSDOS\n"); fprintf(dfp,"PMCC = ghs.c\n"); fprintf(dfp,"OPTLEV = -O\n"); /* fprintf(dfp,"NMOD = x\n"); 981025 */ fprintf(dfp,"AR = ax r\n"); fprintf(dfp,"\n"); } #else /* ================= must be Unix ================= */ #ifdef __GNUC__ fprintf(dfp,"CC = gcc -traditional\n"); #else fprintf(dfp,"CC = cc -DNOANSI\n"); #endif fprintf(dfp,"RMF = rm -f\n"); fprintf(dfp,"TOOLOBJS = $(CFILES:.c=)\n"); fprintf(dfp,"RMFOBJS = rm -f $(OBJS)\n"); sfp = fopen("dot.sh","w"); if (sfp == 0) { fprintf(stderr,"can't open dot.sh\n"); exit(1); } cfp = fopen("source.csh","w"); if (cfp == 0) { fprintf(stderr,"can't open source.csh\n"); exit(1); } rfp = fopen("root.sh","w"); if (rfp == 0) { fprintf(stderr,"can't open root.sh\n"); exit(1); } fprintf(sfp,"echo Connecting with pmcc version %s using %s tools\n", pkg_rev,tools); fprintf(cfp,"echo Connecting with pmcc version %s using %s tools\n", pkg_rev,tools); if (strequ(tools,"MIPSNATIVE")) { /* Bourne shell */ fprintf(sfp,"LSIPKG=%s;export LSIPKG\n",cwd); fprintf(sfp,"PATH=$PATH:$LSIPKG/tools;export PATH\n"); /* C shell */ fprintf(cfp,"setenv LSIPKG %s\n",cwd); fprintf(cfp,"set path = ($path $LSIPKG/tools)\n"); /* create defines.mk */ fprintf(dfp,"# tools type MIPSNATIVE\n"); fprintf(dfp,"TOOLSET = MIPSNATIVE\n"); fprintf(dfp,"AR = ar crs\n"); fprintf(dfp,"PMCC = mips.c\n"); fprintf(dfp,"SPCLTOOLS = edown promize\n"); backtick(tmp,"ls -l /usr/bin/cc"); if (!(strstr(tmp,"cc2.20") && strstr(targets,"LO"))) fprintf(dfp,"OPTLEV = -O\n"); fprintf(dfp,"\n"); if (!lststr(cfg,"RISC5")) { if (strstr(targets,"BO") && !fileExists("/lsipkgbo/usr/lib")) { if (! fileExists("/lsipkgbo/usr")) fprintf(rfp,"mkdir -p /lsipkgbo/usr\n"); fprintf(rfp,"ln -s %s/lib/bo /lsipkgbo/usr/lib\n",cwd); } if (strstr(targets,"LO") && !fileExists("/lsipkglo/usr/lib")) { if (! fileExists("/lsipkglo/usr")) fprintf(rfp,"mkdir -p /lsipkglo/usr\n"); fprintf(rfp,"ln -s %s/lib/lo /lsipkglo/usr/lib\n",cwd); } } } else if (strequ(tools,"DECSTATION")) { /* Bourne shell */ fprintf(sfp,"LSIPKG=%s;export LSIPKG\n",cwd); fprintf(sfp,"PATH=$PATH:$LSIPKG/tools;export PATH\n"); /* C shell */ fprintf(cfp,"setenv LSIPKG %s\n",cwd); fprintf(cfp,"set path = ($path $LSIPKG/tools)\n"); /* create defines.mk */ fprintf(dfp,"# tools type DECSTATION\n"); fprintf(dfp,"TOOLSET = DECSTATION\n"); fprintf(dfp,"AR = ar crs\n"); fprintf(dfp,"PMCC = mips.c\n"); fprintf(dfp,"SPCLTOOLS = edown promize\n"); fprintf(dfp,"OPTLEV = -O\n"); fprintf(dfp,"\n"); if (!fileExists("/lsipkg")) fprintf(rfp,"mkdir /lsipkg\n"); if (strstr(targets,"LO") && !fileExists("/lsipkg/lib")) fprintf(rfp,"ln -s %s/lib/lo /lsipkg/lib\n",cwd); if (strstr(targets,"BO") && !fileExists("/lsipkg/libeb")) fprintf(rfp,"ln -s %s/lib/bo /lsipkg/libeb\n",cwd); } else if (strequ(tools,"SGI")) { /* Bourne shell */ fprintf(sfp,"LSIPKG=%s;export LSIPKG\n",cwd); fprintf(sfp,"PATH=$PATH:$LSIPKG/tools;export PATH\n"); /* C shell */ fprintf(cfp,"setenv LSIPKG %s\n",cwd); fprintf(cfp,"set path = ($path $LSIPKG/tools)\n"); /* create defines.mk */ fprintf(dfp,"# tools type SGI\n"); fprintf(dfp,"TOOLSET = SGI\n"); fprintf(dfp,"AR = ar crs\n"); fprintf(dfp,"PMCC = mips.c\n"); fprintf(dfp,"SPCLTOOLS = edown promize\n"); fprintf(dfp,"OPTLEV = -O\n"); fprintf(dfp,"\n"); } else if (strequ(tools,"BSOUNIX")) { /* Bourne shell */ fprintf(sfp,"BSO_TASKING=%s/r3000;export BSO_TASKING\n",COMP_ROOT); fprintf(sfp,"LM_LICENSE_FILE=%s/flexlm/licenses/license.dat\n", COMP_ROOT); fprintf(sfp,"LSIPKG=%s;export LSIPKG;export LM_LICENSE_FILE\n", cwd); fprintf(sfp,"PATH=$PATH:%s/r3000/bin:$LSIPKG/tools;export PATH\n", COMP_ROOT); /* C shell */ fprintf(cfp,"setenv LSIPKG %s\n",cwd); fprintf(cfp,"setenv LM_LICENSE_FILE %s/flexlm/licenses/license.dat\n", COMP_ROOT); fprintf(cfp,"setenv BSO_TASKING %s/r3000\n",COMP_ROOT); fprintf(cfp,"set path = ($path %s/r3000/bin $LSIPKG/tools)\n", COMP_ROOT); #if 0 # create links for floating-point libs #if (! -d $cwd/fpem/bg) then # mkdir -p $cwd/fpem/{bg,lg} # echo "all:" > $cwd/fpem/Makefile # echo "clean:" >> $cwd/fpem/Makefile # echo " @rm -f bg/libf.a" >> $cwd/fpem/Makefile # echo " @rm -f lg/libf.a" >> $cwd/fpem/Makefile # ln -s $COMP_ROOT/r3000/lib/libfb.a $cwd/fpem/bg/libf.a # ln -s $COMP_ROOT/r3000/lib/libfl.a $cwd/fpem/lg/libf.a #endif #if (! -d $cwd/optfpem/bg) then # mkdir -p $cwd/optfpem/{bg,lg} # echo "all:" > $cwd/optfpem/Makefile # echo "clean:" >> $cwd/optfpem/Makefile # echo " @rm -f bg/libf.a" >> $cwd/optfpem/Makefile # echo " @rm -f lg/libf.a" >> $cwd/optfpem/Makefile # ln -s $COMP_ROOT/r3000/lib/libfntb.a $cwd/optfpem/bg/libf.a # ln -s $COMP_ROOT/r3000/lib/libfntl.a $cwd/optfpem/lg/libf.a #endif #endif /* create defines.mk */ fprintf(dfp,"# tools type BSOUNIX\n"); fprintf(dfp,"TOOLSET = BSOUNIX\n"); fprintf(dfp,"AR = ar3 r\n"); fprintf(dfp,"PMCC = bso.c\n"); fprintf(dfp,"SPCLTOOLS = edown\n"); fprintf(dfp,"OPTLEV = -O\n"); fprintf(dfp,"\n"); } else if (strequ(tools,"MIPSSUN")) { sprintf(manpath,"%s/usr/man",COMP_ROOT); /* Bourne shell */ fprintf(sfp,"COMP_HOST_ROOT=%s\n",COMP_ROOT); fprintf(sfp,"COMP_TARGET_ROOT=%s\n",COMP_ROOT); fprintf(sfp,"LSIPKG=%s\n",cwd); fprintf(sfp,"PATH=$PATH:%s/usr/bin:$LSIPKG/tools\n",COMP_ROOT); fprintf(sfp,"export COMP_HOST_ROOT COMP_TARGET_ROOT\n"); fprintf(sfp,"export LSIPKG PATH\n"); /* C shell */ fprintf(cfp,"setenv COMP_HOST_ROOT %s\n",COMP_ROOT); fprintf(cfp,"setenv COMP_TARGET_ROOT %s\n",COMP_ROOT); fprintf(cfp,"setenv LSIPKG %s\n",cwd); fprintf(cfp,"set path = ($path %s/usr/bin $LSIPKG/tools)\n", COMP_ROOT); /* create defines.mk */ fprintf(dfp,"# tools type MIPSSUN\n"); fprintf(dfp,"TOOLSET = MIPSSUN\n"); fprintf(dfp,"AR = ar%s crs\n",NMOD); fprintf(dfp,"PMCC = mips.c\n"); fprintf(dfp,"EXTRA_LIB_OBJS = lib$(NMOD)c_mips2.a\n"); fprintf(dfp,"SPCLTOOLS = edown promize\n"); fprintf(dfp,"OPTLEV = -O\n"); if (strequ(NMOD,"r3000")) { fprintf(dfp,"NMOD = r3000\n"); sprintf(tmp,"%s/lsipkg",COMP_ROOT); if (!fileExists(tmp)) { fprintf(rfp,"mkdir %s/lsipkg",COMP_ROOT); } sprintf(tmp,"%s/lsipkg/lib",COMP_ROOT); if (strstr(targets,"BO") && !fileExists(tmp)) { fprintf(rfp,"ln -s %s/lib/bo %s/lsipkg/lib\n", cwd,COMP_ROOT); } sprintf(tmp,"%s/lsipkg/libel",COMP_ROOT); if (strstr(targets,"LO") && !fileExists(tmp)) { fprintf(rfp,"ln -s %s/lib/lo %s/lsipkg/libel\n", cwd,COMP_ROOT); } } fprintf(dfp,"\n"); } else if (strequ(tools,"EPIUNIX")) { /* Bourne shell */ fprintf(sfp,"LSIPKG=%s;export LSIPKG\n",cwd); fprintf(sfp,"HCDIR=%s;export HCDIR\n",COMP_ROOT); #if 0 /* 970307 */ fprintf(sfp,"HCINC=%s/include;export HCINC\n",COMP_ROOT); #else fprintf(sfp,"HCINC=.;export HCINC\n"); #endif fprintf(sfp,"LIBDIR=%s/lib;export LIBDIR\n",COMP_ROOT); fprintf(sfp,"PATH=$PATH:$LSIPKG/tools:%s/bin;export PATH\n",COMP_ROOT); /* C shell */ fprintf(cfp,"setenv LSIPKG %s\n",cwd); fprintf(cfp,"setenv HCDIR %s\n",COMP_ROOT); #if 0 /* 970307 */ fprintf(cfp,"setenv HCINC %s/include\n",COMP_ROOT); #else fprintf(cfp,"setenv HCINC .\n"); #endif fprintf(cfp,"setenv LIBDIR %s/lib\n",COMP_ROOT); fprintf(cfp,"set path = ($path $LSIPKG/tools %s/bin)\n",COMP_ROOT); /* create defines.mk */ fprintf(dfp,"# tools type EPIUNIX\n"); fprintf(dfp,"TOOLSET = EPIUNIX\n"); fprintf(dfp,"AR = elib -q\n"); fprintf(dfp,"PMCC = epi.c\n"); fprintf(dfp,"SPCLTOOLS = edown\n"); fprintf(dfp,"OPTLEV = -O\n"); fprintf(dfp,"\n"); } else if (strequ(tools,"ALGUNIX")) { /* Bourne shell */ sprintf(manpath,"%s/man",COMP_ROOT); fprintf(sfp,"SDEROOT=%s;export SDEROOT\n",COMP_ROOT); fprintf(sfp,"LSIPKG=%s;export LSIPKG\n",cwd); if (strequ(endian,"Little")) { if (toolrev < 20000) fprintf(sfp,"GNUTARGET=elf-little\n"); else fprintf(sfp,"GNUTARGET=elf32-littlemips\n"); fprintf(sfp,"export GNUTARGET\n"); } fprintf(sfp,"PATH=$PATH:%s/bin:$LSIPKG/tools;export PATH\n",COMP_ROOT); /* C shell */ fprintf(cfp,"setenv SDEROOT %s\n",COMP_ROOT); fprintf(cfp,"setenv LSIPKG %s\n",cwd); if (strequ(endian,"Little")) { if (toolrev < 20000) fprintf(cfp,"setenv GNUTARGET elf-little\n"); else fprintf(cfp,"setenv GNUTARGET elf32-littlemips\n"); } fprintf(cfp,"set path = ($path %s/bin $LSIPKG/tools)\n",COMP_ROOT); /* defines.mk */ fprintf(dfp,"# tools type ALGUNIX\n"); fprintf(dfp,"TOOLSET = ALGUNIX\n"); fprintf(dfp,"AR = ar-sde cr\n"); fprintf(dfp,"PMCC = algo.c\n"); fprintf(dfp,"SPCLTOOLS = edown\n"); fprintf(dfp,"OPTLEV = -O\n"); sprintf(tmp,"%s/lib/gcc-lib/sdebig",COMP_ROOT); findit(tmp,"cpp",cpppath,1); if (! *cpppath) printf("error: cpp not found\n"); } else if (strequ(tools,"ALGUNIX3")) { /* sde3 */ /* Bourne shell */ sprintf(manpath,"%s/man",COMP_ROOT); fprintf(sfp,"SDEROOT=%s;export SDEROOT\n",COMP_ROOT); fprintf(sfp,"LSIPKG=%s;export LSIPKG\n",cwd); fprintf(sfp,"PATH=$PATH:%s/bin:%s/sde/bin:$LSIPKG/tools;export PATH\n", COMP_ROOT,COMP_ROOT); fprintf(sfp,"GCC_EXEC_PREFIX=%s/lib/gcc-lib/\n", COMP_ROOT); fprintf(sfp,"COMPILER_PATH=%s/sde:%s/sde/bin\n", COMP_ROOT,COMP_ROOT); fprintf(sfp,"LIBRARY_PATH=%s/lib\n",COMP_ROOT); fprintf(sfp,"export GCC_EXEC_PREFIX;export LIBRARY_PATH\n"); fprintf(sfp,"export COMPILER_PATH\n"); /* C shell */ fprintf(cfp,"setenv SDEROOT %s\n",COMP_ROOT); fprintf(cfp,"setenv LSIPKG %s\n",cwd); fprintf(cfp,"set path=($path %s/bin %s/sde/bin $LSIPKG/tools)\n", COMP_ROOT,COMP_ROOT); fprintf(cfp,"setenv GCC_EXEC_PREFIX %s/lib/gcc-lib/\n", COMP_ROOT); fprintf(cfp,"setenv COMPILER_PATH %s/sde:%s/sde/bin\n", COMP_ROOT,COMP_ROOT); fprintf(cfp,"setenv LIBRARY_PATH %s/lib\n",COMP_ROOT); /* defines.mk */ fprintf(dfp,"# tools type ALGUNIX3\n"); fprintf(dfp,"TOOLSET = ALGUNIX3\n"); fprintf(dfp,"AR = ar-sde cr\n"); fprintf(dfp,"PMCC = algo.c\n"); fprintf(dfp,"SPCLTOOLS = edown\n"); fprintf(dfp,"OPTLEV = -O\n"); fprintf(dfp,"AR = sde-ar -r\n"); } else if (strequ(tools,"GHSUNIX")) { /* Bourne shell */ fprintf(sfp,"LSIPKG=%s\n",cwd); fprintf(sfp,"PATH=$PATH:%s/bin:$LSIPKG/tools;export PATH\n",COMP_ROOT); /* C shell */ fprintf(cfp,"setenv LSIPKG %s\n",cwd); fprintf(cfp,"set path = ($path %s %s/tools)\n",COMP_ROOT,cwd); /* create defines.mk */ fprintf(dfp,"# tools type GHSUNIX\n"); fprintf(dfp,"TOOLSET = GHSUNIX\n"); fprintf(dfp,"PMCC = ghs.c\n"); fprintf(dfp,"SPCLTOOLS = edown\n"); fprintf(dfp,"OPTLEV = -O\n"); /* fprintf(dfp,"NMOD = x\n"); 981025 */ fprintf(dfp,"AR = ax r\n"); fprintf(dfp,"\n"); } else if (strequ(tools,"GHSMIPS")) { /* Bourne shell */ fprintf(sfp,"LSIPKG=%s;export LSIPKG\n",cwd); fprintf(sfp,"PATH=$PATH:%s:$LSIPKG/tools;export PATH\n",COMP_ROOT); /* C shell */ fprintf(cfp,"setenv LSIPKG %s\n",cwd); fprintf(cfp,"set path = ($path %s $LSIPKG/tools)\n",COMP_ROOT); /* defines.mk */ fprintf(dfp,"# tools type GHSMIPS\n"); fprintf(dfp,"TOOLSET = GHSMIPS\n"); fprintf(dfp,"AR = ax q\n"); fprintf(dfp,"PMCC = ghs.c\n"); fprintf(dfp,"SPCLTOOLS = edown\n"); fprintf(dfp,"OPTLEV = -O\n"); } else if (strequ(tools,"CYGUNIXCOFF")) { /* Bourne shell */ fprintf(sfp,"LSIPKG=%s;export LSIPKG\n",cwd); fprintf(sfp,"CYGROOT=%s;export CYGROOT\n",COMP_ROOT); fprintf(sfp,"PATH=$PATH:%s:$LSIPKG/tools;export PATH\n",cygbin); /* C shell */ fprintf(cfp,"setenv LSIPKG %s\n",cwd); fprintf(cfp,"setenv CYGROOT %s\n",COMP_ROOT); fprintf(cfp,"set path = ($path %s $LSIPKG/tools)\n",cygbin); /* defines.mk */ fprintf(dfp,"# tools type CYGUNIXCOFF\n"); fprintf(dfp,"TOOLSET = CYGUNIXCOFF\n"); fprintf(dfp,"AR = mips-idt-ecoff-ar cr\n"); fprintf(dfp,"PMCC = cygnus.c\n"); fprintf(dfp,"SPCLTOOLS = edown\n"); fprintf(dfp,"OPTLEV = -O\n"); fprintf(dfp,"NMOD = x\n"); findit(COMP_ROOT,"cpp",cpppath,1); if (! *cpppath) printf("error: cpp not found\n"); } else if (strequ(tools,"CYGUNIXELF")) { strNcpy(cygroot,cygbin,strrchr(cygbin,'/')-cygbin); /* Bourne shell */ fprintf(sfp,"LSIPKG=%s;export LSIPKG\n",cwd); fprintf(sfp,"COMP_LIBGCC=%s\n",libgcc); fprintf(sfp,"COMP_LIBLSI=%s/mips-lsi-elf/lib\n",cygroot); fprintf(sfp,"export COMP_LIBGCC;export COMP_LIBLSI\n"); fprintf(sfp,"CYGROOT=%s;export CYGROOT\n",COMP_ROOT); fprintf(sfp,"GCC_EXEC_PREFIX=%s/lib/gcc-lib/\n",cygroot); fprintf(sfp,"export GCC_EXEC_PREFIX\n"); fprintf(sfp,"PATH=$PATH:%s:$LSIPKG/tools;export PATH\n",cygbin); /* C shell */ fprintf(cfp,"setenv LSIPKG %s\n",cwd); fprintf(cfp,"setenv COMP_LIBGCC %s\n",libgcc); fprintf(cfp,"setenv COMP_LIBLSI %s/mips-lsi-elf/lib\n",cygroot); fprintf(cfp,"setenv CYGROOT %s\n",COMP_ROOT); fprintf(cfp,"setenv GCC_EXEC_PREFIX %s/lib/gcc-lib/\n",cygroot); fprintf(cfp,"set path = ($path %s $LSIPKG/tools)\n",cygbin); /* defines.mk */ fprintf(dfp,"# tools type CYGUNIXELF\n"); fprintf(dfp,"TOOLSET = CYGUNIXELF\n"); fprintf(dfp,"AR = mips-lsi-elf-ar cr\n"); fprintf(dfp,"PMCC = cygelf.c\n"); fprintf(dfp,"SPCLTOOLS = edown\n"); fprintf(dfp,"OPTLEV = -O\n"); fprintf(dfp,"NMOD = x\n"); } #endif /* Unix */ else { printf("BAD tools type. Exiting\n"); exit(1); } if (mdem == 0) mdem = "NONE"; if (strequ(mdem,"YES")) lstadd(pkgsw,"INCLUDE_MDEM"); if (*fpem == 0) fpem = "NONE"; if (strequ(fpem,"STD")) { fprintf(dfp,"# fp emulation type STD\n"); lstadd(pkgsw,"FLOATINGPT"); lstadd(pkgsw,"FPEM"); fprintf(dfp,"FPEM_DEP = $(LSIPKG)/$(FPEM_DIR)/$(ENDIAN)/lib$(NMOD)f.a\n"); fprintf(dfp,"LIBF = -lf\n"); } else if (strequ(fpem,"OPT")) { fprintf(dfp,"# fp emulation type OPT\n"); lstadd(pkgsw,"FLOATINGPT"); lstadd(pkgsw,"FPEM"); lstadd(pkgsw,"NEWFP"); fprintf(dfp,"FPEM_DEP = $(LSIPKG)/$(FPEM_DIR)/$(ENDIAN)/lib$(NMOD)f.a\n"); fprintf(dfp,"LIBF = -lf\n"); } else if (strequ(fpem,"CP1")) { fprintf(dfp,"# fp support via cp1\n"); lstadd(pkgsw,"FLOATINGPT"); } else if (strequ(fpem,"NONE")) { fprintf(dfp,"# fp emulation type NONE\n"); } else { printf("%s: BAD emulation type. Exiting\n",fpem); exit(1); } fprintf(dfp,"\n"); if (! fileExists("pmon")) goto skippmon3; if (lststr(cpu,"LR33120") && !lststr(cpu,"LR33020")) lstadd(cpu,"LR33020"); if (lststr(cpu,"LR64360") && !lststr(cpu,"LR33300")) lstadd(cpu,"LR33300"); if (lststr(cpu,"LR33300") && !lststr(cpu,"LR33000")) lstadd(cpu,"LR33000"); if (lststr(cpu,"LR33050") && !lststr(cpu,"LR33000")) lstadd(cpu,"LR33000"); if (lststr(cpu,"LR33020") && !lststr(cpu,"LR33000")) lstadd(cpu,"LR33000"); skippmon3: if (mach[0] == 0) strcpy(mach,"-DLR33000"); /* do defines.h */ if (fileExists("include/defines.h")) { printf("Saving include/defines.h as include/defines.old\n"); unlink("include/defines.old"); /* for DOS */ rename("include/defines.h","include/defines.old"); } hfp = fopen("include/defines.h","w"); if (hfp == 0) { fprintf(stderr,"can't open include/defines.h\n"); exit(1); } fprintf(hfp,"\n"); /* 981022 needed to allow browser to view file */ for (p=COMP_ROOT;*p;p++) if (*p == '\\') *p = '/'; fprintf(hfp,"#define COMP_ROOT \"%s\"\n",COMP_ROOT); fprintf(hfp,"#define %s\n",board); fprintf(hfp,"#define DEFBAUD B%s\n",defbaud); if (strequ(defRecords,"SREC")) fprintf(hfp,"#define SREC\n"); if (strequ(defEndian,"Little")) fprintf(hfp,"#define LENDEF\n"); if (toolrev) fprintf(hfp,"#define TOOLREV %d\n",toolrev); if (*cpppath) fprintf(hfp,"#define CPPPATH \"%s\"\n",cpppath); if (*prompt) fprintf(hfp,"#define PROMPT \"%s\"\n",prompt); if (*hostport) fprintf(hfp,"#define HOSTPORT \"%s\"\n",hostport); if (dlproto) fprintf(hfp,"#define DLPROTO \"%s\"\n",dlproto); if (dlecho) fprintf(hfp,"#define DLECHO \"%s\"\n",dlecho); if (memtype) fprintf(hfp,"#define %s\n",memtype); if (memsize) fprintf(hfp,"#define MEMSIZE %ld\n",memsize); if (clkfreq) fprintf(hfp,"#define CLKFREQ %d\n",clkfreq); if (no_chksum) fprintf(hfp,"#define NO_CHKSUM\n"); if (strequ(nvram,"YES")) fprintf(hfp,"#define NVRAM\n"); if (strequ(ethernet,"YES")) { fprintf(hfp,"#define ETHERNET\n"); fprintf(hfp,"#define ETHERHWADDR \"%s\"\n",etherhwaddr); fprintf(hfp,"#define ETHERIPADDR \"%s\"\n",etheripaddr); if (sonic_dw32) fprintf(hfp,"#define SONIC_DW32\n"); } for (i=0;pkgsw[i];i++) fprintf(hfp,"#define %s\n",pkgsw[i]); for (i=0;srcdebug[i];i++) fprintf(hfp,"#define %s\n",srcdebug[i]); fprintf(hfp,"#define CLIENTPC 0x%s\n",clientpc); fprintf(hfp,"#define FTEXT 0x%s\n",ftext); fprintf(hfp,"#define FDATA 0x%s\n",fdata); for (i=0;cpu[i];i++) { fprintf(hfp,"#define %s\n",cpu[i]); if (strequ(cpu[i],"LR64360")) fprintf(hfp,"#define NON_CACHED\n"); } #ifdef MSDOS /* finish up setenv.bat */ if (fileExists("pmon") && *dlport) fprintf(sfp,"set DLPORT=%s\n",dlport); #else /* finish up dot.sh */ if (fileExists("pmon") && *dlport) fprintf(sfp,"DLPORT=/dev/%s;export DLPORT\n",dlport); /* finish up source.csh */ if (fileExists("pmon") && *dlport) fprintf(cfp,"setenv DLPORT /dev/%s\n",dlport); #endif fclose(dfp); fclose(sfp); fclose(hfp); fclose(cfp); #ifdef MSDOS /* ================ MSDOS ======================= */ printf("fixing up files\n"); fixupfiles(); printf("\n"); printf("To complete the installation:\n"); printf("\n"); printf(" - type \"setenv\"\n"); printf("\n"); printf(" - type \"nmake\" -- to build the libraries\n"); printf(" - type \"nmake pmon-only\" -- to build PMON\n"); printf("\n"); #else /* ======================= Unix ======================= */ fclose(rfp); if (fileSize("root.sh") < 5) unlink("root.sh"); printf("\n"); printf("To complete the installation:\n"); printf("\n"); if (fileExists("root.sh")) printf(" - As root, type \"sh root.sh\"\n\n"); printf(" - C-shell users type \"source source.csh\"\n"); printf(" - Bourne shell users type \". dot.sh\"\n"); printf("\n"); printf(" - type \"make\" -- to build the libraries\n"); printf(" - type \"make pmon-only\" -- to build PMON\n"); printf("\n"); #endif } #ifdef MSDOS /************************************************************* * fixupfiles() */ fixupfiles() { int i; FILE *ifp,*ofp; for (i=0;fileLst[i].src;i++) { ifp = fopen(fileLst[i].src,"r"); if (!ifp) continue; ofp = fopen(fileLst[i].dst,"w"); if (!ofp) { printf("can't open %s\n",fileLst[i].dst); exit(1); } if ((* fileFixer)(ifp,ofp)) { printf("Fixup error in %s.\n",fileLst[i].src); exit(1); } fclose(ifp); fclose(ofp); } } /************************************************************* * do_algor(ifp,ofp) */ do_algor(ifp,ofp) FILE *ifp,*ofp; { char *arlist,buf[BUFSZ],*av[AVSIZE],tmp[BUFSZ]; int ac,i,j; arlist = "\tmklist -o files.lst -O ../files.mk . CFILES ASFILES"; while (fgets(buf,BUFSZ,ifp)) { if (buf[strlen(buf)-1] != '\n') return(2); buf[strlen(buf)-1] = 0; if (strempty(buf)) { fprintf(ofp,"\n"); continue; } if (argvize(NULL,buf) > AVSIZE) return(1); strcpy(tmp,buf); ac = argvize(av,tmp); if (strequ(av[0],"include")) fprintf(ofp,"!include \"%s\"\n",av[1]); else if (strequ(av[0],"$(AR)")) { fprintf(ofp,arlist); for (i=3;i> files.lst\n",av[j]); } fprintf(ofp,"\tpmcc $(PROM) -ffiles.lst\n"); } #if 1 else fprintf(ofp,"%s\n",buf); #else else { if (*buf == '\t') fprintf(ofp,"\t"); for (i=0;i AVSIZE) return(1); strcpy(tmp,buf); ac = argvize(av,tmp); if (strequ(av[0],"include")) fprintf(ofp,"!include \"%s\"\n",av[1]); else if (strequ(av[0],"@cd")) { strcpy(tmp,buf); for (i=0;tmp[i];i++) if (tmp[i] == ';') tmp[i] = ' '; ac = argvize(av,tmp); fprintf(ofp,"\t@cd %s\n\t@",av[1]); for (i=2;i> files.lst\n",av[j]); } fprintf(ofp,"\tpmcc $(PROM) -ffiles.lst\n"); } #if 1 else fprintf(ofp,"%s\n",buf); #else else { if (*buf == '\t') fprintf(ofp,"\t"); for (i=0;i AVSIZE) return(1); strcpy(tmp,buf); ac = argvize(av,tmp); if (strequ(av[0],"include")) fprintf(ofp,"!include \"%s\"\n",av[1]); else if (strequ(av[0],"@cd")) { strcpy(tmp,buf); for (i=0;tmp[i];i++) if (tmp[i] == ';') tmp[i] = ' '; ac = argvize(av,tmp); fprintf(ofp,"\t@cd %s\n\t@",av[1]); for (i=2;i AVSIZE) return(1); strcpy(tmp,buf); ac = argvize(av,tmp); if (strequ(av[0],"include")) fprintf(ofp,"!include \"%s\"\n",av[1]); else if (strequ(av[0],"$(AR)")) { fprintf(ofp,arlist); for (i=3;i 80 chars */ else if (strequ(av[0],"pmcc") && strequ(av[1],"$(PROM)")) { /* 970704 */ fprintf(ofp,"\t@mklist -o files.lst -O ../files.mk . ASFILES CFILES\n"); for (j=2;j> files.lst\n",av[j]); } fprintf(ofp,"\tpmcc $(PROM) -ffiles.lst\n"); } #endif #if 1 else fprintf(ofp,"%s\n",buf); #else else { if (*buf == '\t') fprintf(ofp,"\t"); for (i=0;i AVSIZE) return(1); strcpy(tmp,buf); ac = argvize(av,tmp); if (strequ(av[0],"include")) fprintf(ofp,"!include \"%s\"\n",av[1]); else if (strequ(av[0],"$(AR)")) { fprintf(ofp,arlist); for (i=3;i> files.lst\n",av[j]); } fprintf(ofp,"\npmcc $(PROM) -ffiles.lst\n"); } #if 1 else fprintf(ofp,"%s\n",buf); #else else { if (*buf == '\t') fprintf(ofp,"\t"); for (i=0;i sz) sz = strlen(str); *p = (char *)malloc(sz+1); strcpy(*p,str); p++; *p = 0; return(n); } /************************************************************* * lstlen(lst) * Returns the list length. */ lstlen(lst) Lst *lst; { char **p; int n; for (p=lst,n=0;*p;p++,n++) ; return(n); } /************************************************************* * lstclr(lst) * delete all the items in a list */ lstclr(lst) Lst *lst; { int i; for (i=0;lst[i];i++) free(lst[i]); lst[0] = 0; } /************************************************************* * backtick(dst,cmd) * places the result of command execution into dst */ backtick(dst,cmd) char *dst,*cmd; { #ifdef MSDOS char *tname = "instaAXXXXXX"; #else char *tname = "/tmp/instaAXXXXXX"; #endif char tmp[200],*p; FILE *fp; int c; mktemp(tname); #ifdef MSDOS sprintf(tmp,"%s > %s\n",cmd,tname); #else sprintf(tmp,"%s 2>&1|cat > %s",cmd,tname); #endif system(tmp); fp = fopen(tname,"r"); if (fp == 0) { printf("can't open %s\n",tname); exit(1); } p = dst; while ((c=getc(fp)) != EOF) { if (c == '\n') c = ' '; *p++ = c; } *p = 0; fclose(fp); unlink(tname); } /************************************************************* * int striequ(s1,s2) * returns 1 if s1 matches s2 ignoring case, else 0 */ int striequ(s1,s2) char *s1,*s2; { if (!s1 || !s2) return(0); for (;*s1;s1++,s2++) { if (toupper(*s1) != toupper(*s2)) return(0); } if (*s2) return(0); return(1); } /************************************************************* * Gets(p) * This feature permits completely automatic installs */ Gets(p) char *p; { if (Argcnt < Argc) { strcpy(p,Argv[Argcnt++]); printf("%s\n",p); } else gets(p); } #ifdef host_mips /************************************************************* * char *strstr(p,q) * Returns a ptr to q in p, else 0 if not found. * The strstr() supplied with the MIPS box is broken. */ char *strstr(p,q) char *p,*q; { char *s,*t; if (!p || !q) return(0); if (! *q) return(p); for (;*p;p++) { if (*p == *q) { t = p; s = q; for (;*t;s++,t++) { if (*t != *s) break; } if (! *s) return(p); } } return(0); } #endif #ifdef MSDOS /************************************************************* * findit(path,file,dst,cnt) * recursive search for a file. Returns the cnt file match in dst. */ int findit(path,file,dst,cnt) char *path,*file,*dst; int cnt; { #ifdef _WIN32 struct _finddata_t info; long fhandle; #else struct _find_t info; #endif char tmp[200]; *dst = 0; sprintf(tmp,"%s/*.*",path); #ifdef _WIN32 fhandle = _findfirst(tmp,&info); while (fhandle) { if (strequ(info.name,".") || strequ(info.name,"..")) { if (_findnext(fhandle,&info)) break; continue; } strcpy(tmp,info.name); str2lower(tmp); if (strequ(tmp,file)) { sprintf(dst,"%s",path); cnt--; if (cnt <= 0) return(1); } if (info.attrib == _A_SUBDIR) { sprintf(tmp,"%s/%s",path,info.name); if (findit(tmp,file,dst,cnt)) return(1); } if (_findnext(fhandle,&info)) break; } _findclose(fhandle); return(0); #else if (_dos_findfirst(tmp,_A_SUBDIR,&info)) return(0); for (;;) { if (!(strequ(info.name,".") || strequ(info.name,".."))) { strcpy(tmp,info.name); str2lower(tmp); if (strequ(tmp,file)) { sprintf(dst,"%s",path); cnt--; if (cnt <= 0) return(1); } if (info.attrib == _A_SUBDIR) { sprintf(tmp,"%s/%s",path,info.name); if (findit(tmp,file,dst,cnt)) return(1); } } if (_dos_findnext(&info)) return(0); } #endif } str2lower(p) char *p; { for (;*p;p++) if (isupper(*p)) *p = tolower(*p); } #else findit(path,file,dst,cnt) char *path,*file,*dst; int cnt; { DIR *dirp; struct dirent *dp; struct stat st; char tmp[800]; *dst = 0; dirp = opendir(path); if (!dirp) { printf("can't open %s\n",path); return(0); } for (dp = readdir(dirp);dp != NULL; dp = readdir(dirp)) { if (strequ(dp->d_name,".") || strequ(dp->d_name,"..")) continue; if (strequ(dp->d_name,file)) { sprintf(dst,"%s",path); cnt--; if (cnt <= 0) return(1); } sprintf(tmp,"%s/%s",path,dp->d_name); stat(tmp,&st); if (S_ISDIR(st.st_mode)) { if (findit(tmp,file,dst,cnt)) return(1); } } closedir(dirp); return(0); } #endif /************************************************************* * getAlgoToolRev() * 1.4 = 10400 as=1.4 convert exists * 2.0 = 20000 as=2.0 * 2.0b = 20002 as=2.0 atmrt.h exists */ getAlgoToolRev(path) char *path; { int rev; char tmp[100]; #ifdef MSDOS sprintf(tmp,"%s/bin/convert.exe",path); #else sprintf(tmp,"%s/bin/convert",path); #endif if (fileExists(tmp)) rev = 10400; else { /* 2.0 or greater */ sprintf(tmp,"%s/include/lsi/atmrt.h",path); if (fileExists(tmp)) rev = 20002; else rev = 20000; } return(rev); } /************************************************************* * bufprt(p) */ bufprt(p) char *p; { int len; if (!bufptr) bufnl(); len = strlen(p); if ((bufcol+len) > 38) bufcol = bufinl(); strcat(bufptr,p); bufptr += len; bufcol += len; return(len); } /************************************************************* * bufinl() * issue a newline + indent */ bufinl() { int i; bufnl(); for (i=0;i ",def); while (1) { err = 0; gets(buf); printf("\n"); if (*buf == 0) strcpy(buf,def); ac = argvize(av,buf); for (i=0;i "); } if (lststr(cpu,"LR33300")) memTypeCfg(0); else memtype = "NONE"; } /************************************************************* * memTypeCfg(cmd) */ VOID memTypeCfg(cmd) int cmd; { if (cmd) { sprintf(tmp,"LR333xx Memory Type: "); bufprt(tmp); if (memtype) sprintf(tmp,"%s",memtype); else sprintf(tmp,"NONE"); bufprt(tmp); return; } if (strequ(memtype,"LR333_DRAM")) def = "1"; else if (strequ(memtype,"LR333_IDRAM")) def = "2"; else if (strequ(memtype,"LR333_SDRAM")) def = "3"; else if (strequ(memtype,"TURBORKT")) def = "4"; else if (strequ(memtype,"NONE")) def = "5"; if (lststr(cpu,"LR33300")) { def = "1"; printf("The possible memory configurations for the LR333xx are:\n"); printf("\n"); printf("1. Regular DRAM\n"); printf("2. Interleaved DRAM\n"); printf("3. Synchronous DRAM\n"); printf("4. Turbo Rocket - selection via jumper\n"); printf("5. None\n"); printf("\n"); printf("Select one of the above [1-5] (1) > "); while (1) { gets(buf); printf("\n"); if (*buf == 0) strcpy(buf,def); if (strequ(buf,"1")) memtype = "LR333_DRAM"; else if (strequ(buf,"2")) memtype = "LR333_IDRAM"; else if (strequ(buf,"3")) memtype = "LR333_SDRAM"; else if (strequ(buf,"4")) memtype = "TURBORKT"; else if (strequ(buf,"5")) memtype = "NONE"; else { printf("BAD INPUT, reenter your selection > "); continue; } break; } } else printf("memtype only relevent for LR333xx\n"); } /************************************************************* * devCfg(cmd) */ VOID devCfg(cmd) int cmd; { int i; if (cmd) { bufprt("Serial Baudrate: "); bufprt(defbaud); return; } printf("Your current serial Baudrate is: %s\n",defbaud); printf("The possible Baudrates are:\n"); printf("\n"); for (i=0;bauds[i];i++) printf("%s ",bauds[i]); printf("\nSelect one of the above (%s) > ",defbaud); while (1) { gets(buf); printf("\n"); if (*buf == 0) strcpy(buf,defbaud); for (i=0;bauds[i];i++) { if (strequ(buf,bauds[i])) break; } if (bauds[i]) break; printf("%s: bad baudrate. Please reenter your selection.\n",buf); printf("(%s) > ",defbaud); } defbaud = bauds[i]; } /************************************************************* * ramRomCfg(cmd) */ VOID ramRomCfg(cmd) int cmd; { long r; if (cmd) { bufprt("Memory addresses:"); sprintf(tmp,"ROM=%s RAM=%s",ftext,fdata); bufprt(tmp); sprintf(tmp,"Client PC=%s",clientpc); bufprt(tmp); return; } printf("If you have located your ROM and RAM at non-standard\n"); printf("addresses you will need to enter their addresses, otherwise\n"); printf("just press enter. The address if entered must be a virtual\n"); printf("address of the form a0c00000\n"); printf("\n"); while (1) { printf("Enter ROM base address in hex (%s) > ",ftext); Gets(buf); printf("\n"); if (*buf == 0) break; if (sscanf(buf,"%lx",&r) == 1) break; printf("BAD INPUT\n"); } if (*buf) strcpy(ftext,buf); while (1) { printf("Enter RAM base address in hex (%s) > ",fdata); Gets(buf); printf("\n"); if (*buf == 0) break; if (sscanf(buf,"%lx",&r) == 1) break; printf("BAD INPUT\n"); } if (*buf) strcpy(fdata,buf); sscanf(fdata,"%lx",&r); sprintf(clientpc,"%08x",(r&~0xfff)+(128*1024)); printf("Specify the base address to be used when building client programs.\n"); printf("This address must be at least 128K beyond the start of RAM, and\n"); printf("fall on a 64KB boundary.\n"); while (1) { printf("Enter client base address in hex (%s) > ",clientpc); Gets(buf); printf("\n"); if (*buf == 0) break; if (sscanf(buf,"%lx",&r) == 1) break; printf("BAD INPUT\n"); } if (*buf) strcpy(clientpc,buf); } VOID autoMemCfg(cmd) int cmd; { int r; if (cmd) { sprintf(tmp,"Client RAM size: ",cmd); bufprt(tmp); if (memsize) sprintf(tmp,"%dK bytes", memsize/1024); else sprintf(tmp,"AUTO"); bufprt(tmp); return; } printf("Normally PMON figures out how much RAM there is automatically.\n"); printf("However, some boards don't like you to access not existent\n"); printf("memory, in that case using this option to tell PMON how much\n"); printf("RAM you have available to client programs. This is usually the\n"); printf("distance from the client base address to the top of memory.\n"); printf("\n"); while (1) { printf("Enter memory size in Kbytes (AUTO) > "); Gets(buf); printf("\n"); if (*buf == 0) break; if (sscanf(buf,"%d",&r) == 1) break; printf("BAD INPUT\n"); } if (!strequ(buf,"")) memsize = ((long)r)*1024; } /************************************************************* * autoClkCfg(cmd) */ VOID autoClkCfg(cmd) int cmd; { int r; char def[16]; if (cmd) { sprintf(tmp,"CPU clock frequency: "); bufprt(tmp); if (clkfreq) sprintf(tmp,"%d MHz",clkfreq); else sprintf(tmp,"AUTO"); bufprt(tmp); return; } if (clkfreq) sprintf(def,"%d",clkfreq); else strcpy(def,"AUTO"); printf("Normally PMON figures out what the clock frequency is automatically 'a'.\n"); printf("If this feature causes a problem in your system, you can specify\n"); printf("the frequency directly.\n"); printf("\n"); while (1) { printf("Enter CPU clock frequency in MHz [a #] (%s) > ",def); Gets(buf); printf("\n"); r = 0; if (*buf == 0) strcpy(buf,def); if (striequ(buf,"a")) break; if (sscanf(buf,"%d",&r) == 1) break; printf("BAD INPUT\n"); } clkfreq = r; } /************************************************************* * hostDevCfg(cmd) */ VOID hostDevCfg(cmd) int cmd; { if (cmd) { sprintf(tmp,"Host download port: %s",(*dlport)?dlport:"undefined"); bufprt(tmp); return; } if (*dlport) def = dlport; else def = dlport_def; printf("\n"); printf("You need to choose a host I/O port that can be used for\n"); printf("downloading to the target system.\n"); while (1) { printf("Which port do you wish to use? (%s) > ",def); Gets(buf); printf("\n"); if (*buf == 0) strcpy(buf,def); #ifdef MSDOS if (!strncmp(buf,"com",3) && isdigit(buf[3])) break; #else if (!strncmp(buf,"tty",3)) break; #endif printf("%s: bad port name\n",buf); } strcpy(dlport,buf); } /************************************************************* * dbgCfg(cmd) */ VOID dbgCfg(cmd) int cmd; { int i,ac,n; char *av[10],def[8]; if (cmd) { sprintf(tmp,"Source debug protocols: "); bufprt(tmp); if (!srcdebug[0]) { bufprt("NONE"); return; } for (i=0;srcdebug[i];i++) { sprintf(tmp,"%s ",srcdebug[i]); bufprt(tmp); } return; } *def = 0; if (lststr(srcdebug,"GDB_SUPPORT")) strcat(def,"1 "); if (lststr(srcdebug,"CROSSVIEW")) strcat(def,"2 "); if (*def) def[strlen(def)-1] = 0; /* kill trailing space */ lstclr(srcdebug); printf("\n"); printf("What source-level debugger support do you wish to include?\n"); printf("1. GNU gdb MIPS protocol (also used by MIPS' dbx)\n"); printf("2. BSO/Tasking's Crossview\n"); printf("3. None\n"); printf("\n"); printf("Select one or more choices (%s) > ",def); while (1) { Gets(buf); printf("\n"); if (*buf == 0) strcpy(buf,def); ac = argvize(av,buf); for (i=0;i "); break; } } if (i == ac) break; } } /************************************************************* * frecCfg(cmd) */ VOID frecCfg(cmd) int cmd; { if (cmd) { sprintf(tmp,"Fast-record Checksum: %s",(no_chksum)?"NO":"YES"); bufprt(tmp); return; } printf("Do you want to include a checksum in the fast-record format?\n"); printf("Note that records that include checksum data cannot be\n"); printf("downloaded to pre-3.0 versions of PMON.\n"); printf("\n"); while (1) { printf("Include checksum? [y n] (y) > "); Gets(buf); printf("\n"); if (strequ(buf,"") || striequ(buf,"y") || striequ(buf,"n")) break; printf("BAD INPUT\n"); } if (striequ(buf,"n")) no_chksum = 1; } /************************************************************* * recDef(cmd) */ VOID recDef(cmd) int cmd; { char *def; if (cmd) { sprintf(tmp,"Default Records: %s", (strequ(defRecords,"SREC"))?"S-RECORDS":"FAST_RECORDS"); bufprt(tmp); return; } printf("Do you want the pmcc command to default to generating Motorola S-Records\n"); printf("or LSI fast-format records? Note that if you plan to use PMON in its\n"); printf("single-port mode, and download using tip or some similar type of\n"); printf("terminal emulator, you will probably find it better to use S-records.\n"); printf("\n"); if (strequ(defRecords,"SREC")) def = "1"; else if (strequ(defRecords,"FREC")) def = "2"; else printf("install: error 3904\n"); printf("Default to S-records(1) or fast-format records(2)? [1 2] (%s) > ",def); while (1) { Gets(buf); printf("\n"); if (strempty(buf)) strcpy(buf,def); if (strequ(buf,"1")) defRecords = "SREC"; else if (strequ(buf,"2")) defRecords = "FREC"; if (defRecords) break; printf("BAD input, please reenter your selection > "); } } /************************************************************* * timingCfg(cmd) */ VOID timingCfg(cmd) int cmd; { if (cmd) { sprintf(tmp,"Timing: %s",(!lststr(pkgsw,"TIMING"))?"NO":"YES"); bufprt(tmp); return; } if (lststr(pkgsw,"TIMING")) def = "y"; else def = "n"; lstdel(pkgsw,lststr(pkgsw,"TIMING")); printf("Do you want to be able to time the execution of programs?\n"); printf("This feature requires the use of Timer2 in the CPU. Note\n"); printf("that programs that are compiled with this feature switched on,\n"); printf("require that they are invoked with the command \"g -c\" on\n"); printf("pre-3.0 versions of PMON. Also, if you use this feature on the\n"); printf("RacerX board, the beeper will sound unless you disconnect it.\n"); printf("\n"); while (1) { printf("Include timing? [y n] (%s) > ",def); Gets(buf); printf("\n"); if (buf[0] == 0) strcpy(buf,def); if (striequ(buf,"y")) { lstadd(pkgsw,"TIMING"); break; } else if (striequ(buf,"n")) break; printf("BAD INPUT\n"); } } /************************************************************* * etherCfg(cmd) */ VOID etherCfg(cmd) int cmd; { long r; if (cmd) { bufprt("Ethernet Address: "); if (strequ(ethernet,"YES")) { bufinl(); sprintf(tmp,"HWADDR=%s ",etherhwaddr); bufprt(tmp); sprintf(tmp,"IPADDR=%s ",etheripaddr); } else sprintf(tmp,"NO"); bufprt(tmp); return; } ethernet = "NO"; printf("Do you want to include support for download via Ethernet? Note\n"); printf("that this requires an Ethernet controller.\n"); printf("\n"); while (1) { printf("Include Ethernet support [y n] (y) > "); Gets(buf); printf("\n"); if (buf[0] == 0) strcpy(buf,"y"); if (striequ(buf,"y") || striequ(buf,"n")) break; printf("BAD INPUT\n"); } if (striequ(buf,"y")) ethernet = "YES"; strcpy(etherhwaddr,ETHERNET_HW_ADDRESS); if (strequ(ethernet,"YES")) { printf("Select the hardware address for your board.\n"); printf("\n"); while (1) { printf("Hardware address (%s) > ",etherhwaddr); Gets(buf); printf("\n"); if (*buf == 0) break; if (sscanf(buf,"%x:%x:%x:%x:%x:%x",&r,&r,&r,&r,&r,&r) == 6) break; printf("BAD INPUT\n"); } if (*buf) strcpy(etherhwaddr,buf); } strcpy(etheripaddr,ETHERNET_IP_ADDRESS); if (strequ(ethernet,"YES")) { printf("Select the IP address for your board.\n"); printf("\n"); while (1) { printf("IP address (%s) > ",etheripaddr); Gets(buf); printf("\n"); if (*buf == 0) break; if (sscanf(buf,"%d.%d.%d.%d",&r,&r,&r,&r) == 4) break; printf("BAD INPUT\n"); } if (*buf) strcpy(etheripaddr,buf); } } /************************************************************* * dlDevCfg(cmd) */ VOID dlDevCfg(cmd) int cmd; { int r,i; if (cmd) { sprintf(tmp,"Target download port: %s",hostport); bufprt(tmp); return; } printf("PMON normally accepts download records on %s,\n",hostport); printf("and although you can change that at any time using the set\n"); printf("command. It may be more convenient to change the default.\n"); printf("\n"); for (i=0;i<8;i++) printf("%d. tty%d\n",i+1,i); if (strequ(ethernet,"YES")) printf("%d. Ethernet\n",i+1); printf("\n"); printf("Select default hostport [1-n] (%s) > ",hostport); while (1) { Gets(buf); printf("\n"); if (*buf == 0) break; if (sscanf(buf,"%d",&r) != 1) { printf("BAD input, reenter your selection > "); continue; } if (r == (i+1) && strequ(ethernet,"YES")) { strcpy(hostport,"ethernet"); break; } else if (r >= 1 && r <= i) { sprintf(hostport,"tty%d",r-1); break; } printf("BAD input, reenter your selection > "); } } /************************************************************* * protoCfg(cmd) */ VOID protoCfg(cmd) int cmd; { int r; if (cmd) { sprintf(tmp,"Download protocol: "); bufprt(tmp); if (dlproto) sprintf(tmp,"%s",dlproto); else if (dlecho) sprintf(tmp,"echo-%s",dlecho); else sprintf(tmp,"NONE"); bufprt(tmp); return; } dlproto = 0; dlecho = 0; printf("PMON normally uses the %s protocol to provide flow\n",dlproto); printf("control when downloading from a host via a serial port, and\n"); printf("although this can be changed at any time using the set command,\n"); printf("it may be more convenient to change the default.\n"); printf("\n"); printf("1. EtxAck protocol\n"); printf("2. XonXoff protocol\n"); printf("3. Echo\n"); printf("4. Line Feed\n"); printf("5. None\n"); printf("\n"); printf("Select default dlproto [1-n] (1) > "); while (1) { Gets(buf); printf("\n"); if (*buf == 0) break; if (sscanf(buf,"%d",&r) != 1) { printf("BAD input, reenter your selection > "); continue; } if (r == 1) { dlproto = "EtxAck"; break; } else if (r == 2) { dlproto = "XonXoff"; break; } else if (r == 3) { dlecho = "on"; break; } else if (r == 4) { dlecho = "lfeed"; break; } else if (r == 5) break; printf("BAD input, reenter your selection > "); } } /************************************************************* * nvRamChk(cmd) */ VOID nvRamChk(cmd) int cmd; { if (cmd) { sprintf(tmp,"NVRAM check: %s",nvram); bufprt(tmp); return; } if (strequ(nvram,"YES")) def = "y"; else def = "n"; nvram = "NO"; printf("Do you want PMON to check for the existence of NVRAM?\n"); printf("\n"); while (1) { printf("Check for NVRAM? [y n] (%s) > ",def); Gets(buf); printf("\n"); if (buf[0] == 0) strcpy(buf,def); if (striequ(buf,"y") || striequ(buf,"n")) break; printf("BAD INPUT\n"); } if (striequ(buf,"y")) nvram = "YES"; } /************************************************************* * fpCfg(cmd) */ VOID fpCfg(cmd) int cmd; { if (cmd) { sprintf(tmp,"Floating-point support: %s",fpem); bufprt(tmp); return; } if (strequ(fpem,"STD")) def = "1"; else if (strequ(fpem,"OPT")) def = "2"; else if (strequ(fpem,"CP1")) def = "3"; else if (strequ(fpem,"NONE")) def = "4"; else printf("install: error 3181\n"); printf("Floating-point support selection:\n"); printf("\n"); printf("1. Standard floating-point emulation\n"); printf("2. Optimized floating-point emulation\n"); printf("3. No floating-point emulation (fp via Coprocessor 1)\n"); printf("4. No floating-point support\n"); printf("\n"); printf("Select fp support [1-4] (%s) > ",def); while (1) { Gets(buf); printf("\n"); if (strempty(buf)) strcpy(buf,d); if (strequ(buf,"1")) { if (fileExists("fpem")) { fpem = "STD"; break; } printf("Standard fp emulation library not found\n"); } else if (strequ(buf,"2")) { if (fileExists("optfpem")) { fpem = "OPT"; break; } printf("Optimized fp emulation library not found\n"); } else if (strequ(buf,"3")) { fpem = "CP1"; break; } else if (strequ(buf,"4")) { fpem = "NONE"; break; } printf("BAD INPUT, reenter your selection > "); } } /************************************************************* * mdCfg(cmd) */ VOID mdCfg(cmd) int cmd; { if (cmd) { sprintf(tmp,"Multiply/Divide emulation: %s",mdem); bufprt(tmp); return; } if (strequ(mdem,"YES")) def = "2"; else if (strequ(mdem,"NONE")) def = "1"; else printf("install: error 3518\n"); printf("Multiply and divide emulation is required for the LR4002\n"); printf("and the LR4003.\n"); printf("\n"); printf("Multiply/Divide support selection:\n"); printf("\n"); printf("1. No Multiply/Divide emulation\n"); printf("2. Software Multiply/Divide emulation\n"); printf("\n"); printf("Select mdem support [1-2] (%s) > ",def); while (1) { Gets(buf); printf("\n"); if (strempty(buf)) strcpy(buf,def); if (strequ(buf,"1")) { mdem = "NONE"; break; } else if (strequ(buf,"2")) { mdem = "YES"; break; } printf("BAD INPUT, reenter your selection > "); } } /************************************************************* * promptSet(cmd) */ VOID promptSet(cmd) int cmd; { if (cmd) { sprintf(tmp,"Prompt: \"%s\"",(*prompt)?prompt:"PMON> "); bufprt(tmp); return; } printf("Enter the required PMON prompt > "); Gets(prompt); } /************************************************************* * char *strichr(p,c) * inserts c as the first char of the string p */ char *strichr(p,c) char *p; int c; { char *t; if (!p) return(p); for (t=p;*t;t++) ; for (;t >= p;t--) *(t+1) = *t; *p = c; return(p); } /************************************************************* */ char *readFile(dst,fname) char *dst,*fname; { FILE *fp; char *p; int c; *dst = 0; fp = fopen(fname,"r"); if (!fp) return(dst); for (p=dst;;) { c = getc(fp); if (c == EOF) break; if (c == '\n' || c == '\r') continue; if (isspace(c)) c = ' '; *p++ = c; } *p = 0; fclose(fp); return(dst); } /************************************************************* */ char *rstrstr(p,q) char *p,*q; { int qlen,plen; char *r,*s,*t; qlen = strlen(q); plen = strlen(p); if (plen < qlen) return(0); r = &p[plen-1]; for (;r>=p;r--) { if (*r == *q) { t = r; s = q; for (;*t;s++,t++) { if (*t != *s) break; } if (! *s) return(r); } } return(0); }