📄 mkmakefile.c
字号:
char *tail(fn) char *fn;{ register char *cp; cp = rindex(fn, '/'); if (cp == 0) return (fn); return (cp+1);}/* * Output the emulation code rules. This is really a hack but considering * the fact that the code and rules are not optional for microvax and that * the rules are special and do not fit with the general case we do it this * way. */do_emrules( fp ) FILE *fp;{ char **cptr; /* * This is the list of files that make up the emulation code. * Some of the code is dependant on the placement and order * of the first three names. */ static char *emuls[]={ "vaxbegin", "vaxend", "vaxfloat", "vaxarith", "vaxcvtpl", "vaxeditpc","vaxhandlr", "vaxashp", "vaxcvtlp", "vaxdeciml", "vaxemulat", "vaxstring", "vaxconvrt", "vaxexception",0 }; cptr = emuls; if( !source ){ for( ; *cptr ; cptr++ ){ fprintf(fp, "%s.o: ../BINARY/%s.o\n", *cptr, *cptr); fprintf(fp, "\t@${LN} -s ../BINARY/%s.o %s.o\n\n", *cptr, *cptr); } } else { /* * do begin and end */ fprintf(fp, "%s.o: ../machine/emul/%s.s\n\t${CC} -c ../machine/emul/%s.s\n\n", *cptr, *cptr, *cptr); cptr++; fprintf(fp, "%s.o: ../machine/emul/%s.s\n\t${CC} -c ../machine/emul/%s.s\n\n", *cptr, *cptr, *cptr); cptr++; /* * do float */ fprintf(fp, "%s.o: ../machine/emul/%s.s ../machine/emul/%s.awk\n", *cptr, *cptr, *cptr); fprintf(fp, "\t${AWK} -f ../machine/emul/%s.awk ../machine/emul/%s.s | \\\n\t\t${CPP} -I. | ${AS} -o %s.o -\n", *cptr, *cptr, *cptr); cptr++; /* * Do the rest */ for( ; *cptr ; cptr++ ) { fprintf(fp, "%s.o: ../machine/emul/%s.s\n", *cptr, *cptr); fprintf(fp, "\t${CPP} -I. "); fprintf(fp, "../machine/emul/%s.s | ${AS} -o %s.o -\n\n", *cptr, *cptr); } }}/* * Create the makerules for each file * which is part of the system. * Devices are processed with the special c2 option -i * which avoids any problem areas with i/o addressing * (e.g. for the VAX); assembler files are processed by as. */do_rules(f) FILE *f;{ register char *cp, *np, och, *tp; register struct file_list *ftp; char *extras; if(machine == MACHINE_VAX) { if(source){ fprintf(f,"locore_bin.o: assym.s ${AHEADS} ../machine/rpb.s"); fprintf(f,"\t../machine/scb.s ../machine/lock.s ../machine/locore.s \\\n"); fprintf(f,"\t../machine/mtpr.h ../machine/trap.h ../machine/psl.h \\\n"); fprintf(f,"\t../machine/pte.h ../machine/cpu.h mba.h\n"); fprintf(f,"\t${CAT} assym.s ../machine/locore.s > locore.c\n"); fprintf(f,"\t${CC} -E -I. -DLOCORE ${COPTS} locore.c > locore.i\n"); fprintf(f,"\t${AS} -o locore_bin.o ${AHEADS} locore.i\n"); fprintf(f,"\t${RM} locore.i locore.c\n\n"); fprintf(f,"scb.o: assym.s ../machine/rpb.s ../machine/scb.s ../machine/lock.s\n"); fprintf(f,"\t${CAT} assym.s ../machine/rpb.s ../machine/scb.s ../machine/lock.s > scb.c\n"); fprintf(f,"\t${CC} -E -I. -DLOCORE ${COPTS} scb.c > scb.i\n"); fprintf(f,"\t${AS} -o scb.o ${AHEADS} scb.i\n"); fprintf(f,"\t${RM} scb.i scb.c\n\n"); fprintf(f,"spt.o: assym.s ../machine/spt.s\n"); fprintf(f,"\t${CAT} assym.s ../machine/spt.s > spt.c\n"); fprintf(f,"\t${CC} -E -I. -DLOCORE ${COPTS} ${PARAM} spt.c | \\\n\t\t$(MAKESPT) > spt.i\n"); fprintf(f,"\t${AS} -o spt.o ${AHEADS} spt.i\n"); fprintf(f,"\t${RM} spt.i spt.c\n\n"); fprintf(f,"genassym: genassym.o\n"); fprintf(f,"\t${CC} -o genassym ${CFLAGS} ${PARAM} genassym.o\n\n"); fprintf(f,"genassym.o: ../machine/genassym.c\n"); fprintf(f,"\t${CC} -c ${CFLAGS} ${PARAM} ../machine/genassym.c\n\n"); fprintf(f,"assym.s: ../../h/param.h ../machine/pte.h ../../h/buf.h ../../h/vmparam.h \\\n"); fprintf(f,"\t../../h/vmmeter.h ../../h/dir.h ../../h/cmap.h ../../h/map.h ../../io/uba/ubavar.h \\\n"); fprintf(f,"\t../../h/proc.h makefile genassym\n"); fprintf(f,"\t./genassym %d %d %d >assym.s\n\n", maxusers, physmem, bufcache); /*RR - needed -DKERNEL*/ /*RR - IDENT changed to CFLAGS*/ fprintf(f,"${INLINE}: ../machine/inline/inline.h \\\n"); fprintf(f,"\t../machine/inline/langpats.c ../machine/inline/libcpats.c \\\n"); fprintf(f,"\t../machine/inline/machdep.c ../machine/inline/machpats.c \\\n"); fprintf(f,"\t../machine/inline/main.c\n"); fprintf(f,"\tcd ../machine/inline; ${MAKE}\n\n"); } else { fprintf(f,"scb.o: assym.s ../machine/rpb.s ../machine/scb.s ../machine/lock.s\n"); fprintf(f,"\t${CAT} assym.s ../machine/rpb.s ../machine/scb.s ../machine/lock.s > scb.c\n"); fprintf(f,"\t${CC} -E -I. -DLOCORE ${COPTS} scb.c > scb.i\n"); fprintf(f,"\t${AS} -o scb.o ${AHEADS} scb.i\n"); fprintf(f,"\t${RM} scb.i scb.c\n\n"); fprintf(f,"spt.o: assym.s ../machine/spt.s\n"); fprintf(f,"\t${CAT} assym.s ../machine/spt.s > spt.c\n"); fprintf(f,"\t${CC} -E -I. -DLOCORE ${COPTS} ${PARAM} spt.c | $(MAKESPT) > spt.i\n"); fprintf(f,"\t${AS} -o spt.o ${AHEADS} spt.i\n"); fprintf(f,"\t${RM} spt.i spt.c\n\n"); fprintf(f,"locore_bin.o:\n"); fprintf(f,"\t@${LN} -s ../BINARY/locore_bin.o locore_bin.o\n\n"); fprintf(f,"assym.s: makefile\n\t../BINARY/genassym %d %d %d > assym.s\n\n", maxusers, physmem, bufcache); } } /* End of MACHINE_VAX */ for (ftp = ftab; ftp != 0; ftp = ftp->f_next) { if ((ftp->f_flags & INVISIBLE) != 0) continue; if ((ftp->f_flags & NOTBINARY) && source) continue; cp = (np = ftp->f_fn) + strlen(ftp->f_fn) - 1; och = *cp; *cp = '\0'; if (ftp->f_flags & OBJS_ONLY) { fprintf(f,"%so: ../BINARY/%so\n\t@${LN} -s ../BINARY/%so %so\n\n" ,tail(np),tail(np),tail(np),tail(np)); continue; } fprintf(f, "%so: ../../%s%c\n", tail(np), np, och); tp = tail(np); if (och == 's') { switch (machine) { case MACHINE_MIPS: fprintf(f, "\t${CC} ${CCASFLAGS} -o %so ../../%ss\n\n", tp, np); break; case MACHINE_VAX: default: fprintf(f, "\t${AS} -o %so ../../%ss\n\n", tp, np); break; } continue; } if (ftp->f_flags & CONFIGDEP) extras = "${PARAM} "; else extras = ""; switch (ftp->f_type) { case NORMAL: switch (machine) { case MACHINE_VAX: fprintf(f, "\t${CC} -I. -c -S ${COPTS} ${PARAM} %s../../%sc\n", extras, np); fprintf(f, "\t${C2} %ss | ${INLINE} |", tp); fprintf(f, " ${AS} -o %so\n", tp); fprintf(f, "\t${RM} -f %ss\n\n", tp); break; case MACHINE_MIPS: fprintf(f, "\t${CC} ${CCNFLAGS} %s../../%sc\n\n", extras, np); break; case MACHINE_SUN: fprintf(f, "\t${CC} -I. -c -O ${COPTS} %s../%sc\n\n", extras, np); break; } break; case DRIVER: switch (machine) { case MACHINE_VAX: fprintf(f, "\t${CC} -I. -c -S ${COPTS} ${PARAM} %s../../%sc\n", extras, np); fprintf(f,"\t${C2} -i %ss | ${INLINE} |", tp); fprintf(f, " ${AS} -o %so\n", tp); fprintf(f, "\t${RM} -f %ss\n\n", tp); break; case MACHINE_MIPS: fprintf(f, "\t${CC} ${CCDFLAGS} %s../../%sc\n\n", extras, np); break; case MACHINE_SUN: fprintf(f, "\t${CC} -I. -c -O ${COPTS} %s../%sc\n\n", extras, np); } break; case PROFILING: if (!profiling) continue; if (COPTS == 0) { fprintf(stderr, "config: COPTS undefined in generic makefile"); COPTS = ""; } switch (machine) { case MACHINE_VAX: fprintf(f, "\t${CC} -I. -c -S ${PARAM} %s %s../../%sc\n", COPTS, extras, np); fprintf(f, "\t${EX} - %ss < ${GPROF.EX}\n", tp); fprintf(f, "\t${INLINE} %ss | ${AS} -o %so\n", tp, tp); fprintf(f, "\t${RM} -f %ss\n\n", tp); break; case MACHINE_MIPS: if(!profiling) continue; fprintf(f, "\t${RM} -f %so\n", tp); fprintf(f, "\t${CC} ${CCPFLAGS} %s../../%sc\n\n", extras, np); break; case MACHINE_SUN: fprintf(stderr, "config: don't know how to profile kernel on sun\n"); break; } break; default: printf("Don't know rules for %s\n", np); break; } *cp = och;}}/* * Create the load strings */do_load(f) register FILE *f;{ register struct file_list *fl; int first = 1; struct file_list *do_systemspec(); fl = conf_list; while (fl) { if (fl->f_type != SYSTEMSPEC) { fl = fl->f_next; continue; } fl = do_systemspec(f, fl, first); if (first) first = 0; } fprintf(f, "all:"); for (fl = conf_list; fl != 0; fl = fl->f_next) if (fl->f_type == SYSTEMSPEC) fprintf(f, " %s", fl->f_needs[0]); fprintf(f, "\n");}do_macros(f) register FILE *f;{ register struct opt *op; for (op = mkopt; op; op = op->op_next) fprintf(f, "%s=%s\n", op->op_name, op->op_value);}struct file_list *do_systemspec(f, fl, first) FILE *f; register struct file_list *fl; int first;{ int swaptype; char *depends; if(machine == MACHINE_MIPS) if (fl == NULL) return(fl); if ( emulation_instr || emulation_float ) depends = "${OBJS} ${EMULO}"; else depends = "${OBJS}"; fprintf(f, "%s: makefile", fl->f_needs[0]); if (machine == MACHINE_VAX) { if (source) { fprintf(f, " "); fprintf(f, "${INLINE}"); } fprintf(f, " spt.o scb.o locore_bin.o ubglue.o \\\n"); fprintf(f, "\t%s param.o", depends); if (source) fprintf(f, " ioconf.o swap.o"); else fprintf(f, " ioconf.o swapgen%s.o", fl->f_needs[0]); } if(machine == MACHINE_MIPS) fprintf(f, " ${LOBJS} ${OBJS} "); switch (machine) { case MACHINE_MIPS: if (!source) { if (!eq(fl->f_fn, "generic") && !eq(fl->f_fn, "boot")) fprintf(f, " swap%s.o", fl->f_fn); /*RR*/ else fprintf(f, " swapgeneric.o"); /*RSP*/ } break; case MACHINE_VAX: default: if (!eq(fl->f_fn, "generic") && !eq(fl->f_fn, "boot")) fprintf(f, " swap%s.o", fl->f_fn); /*RR*/ break; } if (dontload) { /* * Don't load if the BINARY option has been specified */ switch (machine) { case MACHINE_VAX: if(kdebug) fprintf(f,"\n\t(cd ../machine/kdb; make)\n"); break; default: break; } fprintf(f, "\n"); /*RR*/ fprintf(f, "\t@${ECHO} Binary build done\n\n"); } else { /* we are loading */ /* first define a load tag on the end of vmunix */ /* and define that symbol as the actual load commands */ /* now we can say "make vmunix" to get the old style loads */ /* with all the dependancy checking */ /* or we can say "make load" and we execute the load commands */ if (strcmp(fl->f_needs[0],"vmunix")==0) { /*for vmunix we allow "make load" or "make loadvmunix"*/ fprintf(f, " load%s\n\nload load%s:\n", fl->f_needs[0], fl->f_needs[0]); /*RR*/ } else { fprintf(f, " load%s\n\nload%s:\n", fl->f_needs[0], fl->f_needs[0]); /*RR*/ } fprintf(f, "\t${RM} -f %s\n", fl->f_needs[0]); fprintf(f, "\t${SH} ${CONF}/newvers.sh\n");/*RR*/ switch (machine) { case MACHINE_VAX: fprintf(f, "\t${CC} $(CFLAGS) -c vers.c\n"); break; case MACHINE_MIPS: fprintf(f, "\t${CC} $(CCNFLAGS) -c vers.c\n"); break; default: break; } fprintf(f, "\t@${ECHO} loading %s\n", fl->f_needs[0]); switch (machine) { case MACHINE_VAX: /* -B flag for page alignment of spt in BSS. */ fprintf(f,"\t@${LD} -n -o %s -e start -x -T 80000000 -B ", fl->f_needs[0]); /* spt.o MUST be first module for load!!! */ fprintf(f, "spt.o scb.o \\\n\t\t"); fprintf(f, "locore_bin.o ubglue.o "); fprintf(f, "%s \\\n\t\t",depends); fprintf(f, "ioconf.o param.o swap.o "); if (kdebug) fprintf(f,"../machine/kdb/kdb.o -lc "); break; case MACHINE_MIPS: fprintf(f, "\t@${LD} ${LDFLAGS} -o %s ${LOBJS} ${OBJS} ", fl->f_needs[0]); break; case MACHINE_SUN: fprintf(f, "\t@${LD} -o %s -e start -x -T 4000 ", fl->f_needs[0]); break; } fprintf(f, "vers.o ", fl->f_fn); switch (machine) { case MACHINE_MIPS: if (!source) { if (!eq(fl->f_fn, "generic") && !eq(fl->f_fn, "boot")) fprintf(f, "swap%s.o\n", fl->f_fn); else fprintf(f, " swapgeneric.o\n"); /*RSP*/ } break; case MACHINE_VAX: if (!eq(fl->f_fn, "generic") && !eq(fl->f_fn, "boot")) fprintf(f, "swap%s.o\n", fl->f_fn); else fprintf(f, "\n"); break; } fprintf(f, "\t@echo rearranging symbols\n"); fprintf(f, "\t@-${SYMORDER} ../machine/symbols.sort %s\n", fl->f_needs[0]); fprintf(f, "\t@${SIZE} %s\n", fl->f_needs[0]); if (machine == MACHINE_VAX) { if (kdebug){ fprintf(f, "\t(cd ../machine/kdb; make kdbload)\n"); fprintf(f, "\t../machine/kdb/kdbload %s \n",fl->f_needs[0]); fprintf(f, "\t@${SIZE} %s\n", fl->f_needs[0]); } } fprintf(f, "\t@${CHMOD} 755 %s\n\n", fl->f_needs[0]); } swaptype = 0; if (eq(fl->f_fn, "generic")) swaptype = 1; else if (eq(fl->f_fn, "boot")) swaptype = 2; if (!source) { switch (machine) { case MACHINE_VAX: fprintf(f, "swapgen%s.o:\n", fl->f_needs[0]); fprintf(f, "\t${CC} -I. -c -S ${COPTS} -DSWAPTYPE=%d ../machine/swap.c\n", swaptype); fprintf(f, "\t${C2} swap.s | ${INLINE}"); fprintf(f, " | ${AS} -o swap.o\n"); fprintf(f, "\t${RM} -f swap.s\n\n"); break; case MACHINE_MIPS: if (swaptype) { fprintf(f, "swapgeneric.o:\n"); fprintf(f, "\t${RM} -f swapgeneric.o\n"); fprintf(f, "\t${CC} ${CCSFLAGS} -DSWAPTYPE=%d ../machine/swapgeneric.c\n", swaptype); fprintf(f, "\n"); } break; } } do_swapspec(f, fl->f_fn); for (fl = fl->f_next; fl && fl->f_type == SWAPSPEC; fl = fl->f_next) ; return (fl);}do_swapspec(f, name) FILE *f; register char *name;{ if ((eq(name, "generic") || eq(name, "boot")) && source) { switch (machine) { case MACHINE_VAX: fprintf(f, "swap.o: ../machine/swap.c\n"); fprintf(f, "\t${CC} -I. -c -S ${COPTS} "); fprintf(f, "../machine/swap.c\n"); fprintf(f, "\t${C2} swap.s | ${INLINE}"); fprintf(f, " | ${AS} -o swap.o\n"); fprintf(f, "\t${RM} -f swap.s\n\n"); break; case MACHINE_MIPS: break; case MACHINE_SUN: fprintf(f, "\t${CC} -I. -c -O ${COPTS} "); fprintf(f, "../%s/swap.c\n\n", machinename); break; } } else if (!eq(name, "generic") && !eq(name, "boot")) { switch (machine) { case MACHINE_VAX: fprintf(f, "swap%s.o: swap%s.c\n", name, name); fprintf(f, "\t${CC} -I. -c -O ${COPTS} swap%s.c\n\n", name); break; case MACHINE_MIPS: fprintf(f, "swap%s.o: swap%s.c\n", name, name); fprintf(f, "\t${RM} -f swap%s.o\n", name); fprintf(f, "\t${CC} ${CCSFLAGS} swap%s.c\n\n", name); break; } }}char *raise(str) register char *str;{ register char *cp = str; while (*str) { if (islower(*str)) *str = toupper(*str); str++; } return (cp);}isconfigured(device) register char *device;{ register struct device *dp; for (dp = dtab; dp != 0; dp = dp->d_next) if (dp->d_unit != -1 && eq(dp->d_name, device)) return(1); return(0);}#ifdef mipseq(a,b)register char *a,*b;{ if (a && b) { /* survive those null pointers...rr */ return(!strcmp(a,b)); } return(0);}#endif mips
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -