/************************************************************* * File: tools/epi.c * Purpose: compiler driver for pmcc command for EPI tools * Author: Phil Bunce (pjb@carmel.com) * Revision History: * 970304 Added -driver and -ice * 970307 Added dList/nList to fix -lmon probs * 970307 Turned off #173 warnings * 970313 mksyms modified to take 2 filenames * 970313 Added -ssyms option (separate symbols) * 970314 Removed $LSIPKG refs in crtn pathnames * 970417 Added check for nfiles==0 * 970902 Removed -ice option */ #include #include #include #include "../include/defines.h" #include "misc.h" #define DYNDEFS /* support dynamic defines */ #define PRAGMAS "-Hpragma='Offwarn(553)' -Hpragma='Offwarn(64)' \ -Hpragma='Offwarn(268)' -Hpragma='Offwarn(289)' -Hpragma='Offwarn(240)' \ -Hpragma='Offwarn(652)' -Hpragma='Offwarn(269)' -Hpragma='Offwarn(173)'" /* set various defaults */ int vflag = 0; int fast = 1; int syms = 1; int ssyms_flag; char *chksum = ""; char *ofile = "a"; char LIBM[100] = "/usr/lib/cmplrs/cc"; char cmdfile[] = "cmdfile"; char cmdchar[] = "@"; int crt0_flag; char tmp[LNMAX],tmp2[LNMAX]; char *ENDIAN,*Gnum,*LSIPMCC; char *COMP_HOST_ROOT; Str flags,cflags,asflags,ldflags,ofiles,llist,ilist,rflags,files,LIBS,ppflags; Str *strlst[] = {&flags,&cflags,&asflags,&ldflags,&ofiles,&llist,&ilist, &ppflags,&rflags,&files,&LIBS,0}; char *LSIPKG; char *LIBC, *crt0; char *initial_lc = "-lc"; char objfile[100]; char tstart[10]; char *dstart; int nfiles; char stoppoint; int SZ; char *HCDIR; char *clientpc; int driver; char *dList[20]; int nList; char *getDef(); /************************************************************* * main(argc,argv) */ main(argc,argv) int argc; char *argv[]; { int i,status,SZ,sz; char *p,*e,h[20],*vtmp,*fmt,*file; FILE *cfp; char tmp2[100]; SZ = 0; if (! (LSIPKG=getenv("LSIPKG"))) { fprintf(stderr,"pmcc: LSIPKG not set\n"); Exit(1); } if (! (HCDIR=getenv("HCDIR"))) { fprintf(stderr,"pmcc: HCDIR not set\n"); Exit(1); } /* for backward compatability we set LSIPMCC */ if (! (LSIPMCC=getenv("LSIPMCC"))) LSIPMCC = ""; #ifdef DYNDEFS sprintf(tmp,"%s/include/defines.h",LSIPKG); readDefs(tmp); if (getDef("SREC")) fast = 0; if (clientpc=getDef("CLIENTPC")) strcpy(tstart,&clientpc[2]); else strcpy(tstart,"80020000"); #else #ifdef SREC fast = 0; #endif #ifdef CLIENTPC sprintf(tstart,"%08lx",CLIENTPC); #else strcpy(tstart,"80020000"); #endif #endif /* Select default Endianess. */ #ifdef LENDEF ENDIAN = "l"; #else ENDIAN = "b"; #endif Gnum = "o"; sprintf(tmp,"-I%s/include",LSIPKG); Strcpy(&ilist,tmp); sprintf(tmp,"-l %s/lib/%%s%%s/libc.a",LSIPKG); Strcpy(&llist,tmp); sprintf(tmp,"-DPMCC -DEPI %s",LSIPMCC); Strcpy(&flags,tmp); Strcpy(&cflags,"-w1"); Strcpy(&asflags,""); getargs(argc,argv); if (strequ(ENDIAN,"l")) addarg(&flags,"-r"); strcpy(objfile,ofile); if (strequ(ofile,"a")) strcpy(objfile,"a.out"); if (stoppoint==0) { addarg(&cflags,"-c"); /* never want the hc driver to call ld */ addarg(&ldflags,"-o"); addarg(&ldflags,objfile); } else if (nfiles == 1) { file = getStrn(&files,0); e = extent(file); getHead(h,file); if (strequ(e,"c")) { addarg(&cflags,"-o"); if (!strequ(ofile,"a")) addarg(&cflags,ofile); else { if (stoppoint == 'c') sprintf(tmp,"%s.o",h); else sprintf(tmp,"%s.s",h); addarg(&cflags,tmp); } } else if (strequ(e,"s")) { addarg(&asflags,"-o"); if (!strequ(ofile,"a")) addarg(&asflags,ofile); else { sprintf(tmp,"%s.o",h); addarg(&asflags,tmp); } } free(file); } sprintf(tmp,llist.str,ENDIAN,Gnum,ENDIAN,Gnum); addarg(&ldflags,tmp); addarg(&flags,ilist.str); if (nfiles == 0) { printf("Fatal error: no files specified.\n"); exit(1); } /* now invoke the compiler */ for (i=0;i 2) { addarg(&flags,argv[i]); } else if (strequ(argv[i],"-float")) { addarg(&flags,argv[i]); addarg(&flags,"-DFLOAT"); SZ = 1; } else if (getStdArgs(argc,argv,&i)) ; else if (argv[i][0] == '-') { fprintf(stderr,"%s: bad arg\n",argv[i]); exit(1); } else { addarg(&files,argv[i]); nfiles++; } } } /************************************************************* * mksyms(ifn,ofn) */ mksyms(ifn,ofn) char *ifn,*ofn; { FILE *ifp,*ofp; char buf[100],*field[10]; int nf,flag,csum,len; if (vflag) fprintf(stderr,"mksyms %s > %s\n",ifn,ofn); flag = 0; ifp = fopen(ifn,"r"); if (ifp == 0) { fprintf(stderr,"Can't open %s\n",ifn); Exit(1); } ofp = fopen(ofn,"w"); if (ofp == 0) { fprintf(stderr,"Can't open %s\n",ofn); Exit(1); } for (;;) { if (!fgets(buf,100,ifp)) break; if (!strncmp(buf,"SYMBOL",6)) { flag = 1; continue; } if (!flag) continue; nf = argvize(field,buf); if (nf < 3 || nf > 4) continue; csum = 0; len = strlen(field[0])+8+2; fprintf(ofp,"S4%02X%s%s,%02x\n",len,field[1],field[0],csum); } fclose(ifp); fclose(ofp); } /************************************************************* * Exit(x) */ Exit(x) int x; { int i; for (i=0;strlst[i];i++) { if (strlst[i]->str) free(strlst[i]->str); } exit(((x)>127)?1:(x)); }