⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mkmakefile.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 3 页
字号:
			do_cfiles(ofp);		else if (eq(line, "%SFILES\n"))			do_sfiles(ofp);		else if (eq(line, "%EMRULES\n"))			do_emrules(ofp);		else if (eq(line, "%RULES\n"))			do_rules(ofp);		else if (eq(line, "%LOAD\n"))			do_load(ofp);		else if(eq(line,"%MACROS\n"))			do_macros(ofp);		else			fprintf(stderr,			    "Unknown %% construct in generic makefile: %s",			    line);	}	(void) fclose(ifp);	(void) fclose(ofp);}/* * get next word from stream and error out if EOF */char *next_word(fp, fname)FILE *fp;char *fname;{	register char *wd;	if ((wd = get_word(fp)) == (char *) EOF) {		printf("%s: Unexpected end of file\n", fname);		exit(1);	}	return(wd);}/* * Read in information about existing file systems. */read_filesystems(){	FILE *fp;	char fsname[32], *wd, *name;	struct file_sys *fs;	fp = fopen("filesystems", "r");	if (fp == NULL) {		perror("filesystems");		exit(1);	}	/* process each line */	while ((wd = get_word(fp)) != (char *)EOF) {		if (wd == NULL)			continue;		/* record each file system name */		name = ns(wd);		fs = (struct file_sys *)malloc(sizeof (struct file_sys));		fs->fs_name = name;		fs->fs_next = file_sys;		file_sys = fs;	}	(void) fclose(fp);}/* * Read in the information about files used in making the system. * Store it in the ftab linked list. */read_files(){	FILE *fp;	register struct file_list *tp;	register struct device *dp, *dp2;	int sysfile, required, doopts, override, skipopts, negate;	int noneed, nexneed, failing;	char fname[32], *wd, *module;	/*	 * filename	[ standard | optional ] [ config-dependent ]	 *	[ dev* [ or dev* ] | profiling-routine ] [ device-driver] 	 *	[Binary | Notbinary] [ Unsupported ] 	 */	ftab = NULL;	required = 1;	override = 0;	/* loop for all file lists we have to process */	for (sysfile = 0, dp2 = dtab; sysfile < 4; sysfile++) {		if (dp2 && sysfile == 2)			sysfile -= 1;		/* select appropriate file */		switch (sysfile) {			case 0:				strcpy(fname, "files");				break;			case 1:				for (; dp2; dp2 = dp2->d_next) {					if (dp2->d_type == PSEUDO_DEVICE							&& dp2->d_unit != -1)						break;				}				if (!dp2)					continue;				(void) sprintf(fname, "files.%s", dp2->d_name);				dp2 = dp2->d_next;				required = 0;				override = 1;				break;			case 2:				(void) sprintf(fname, "files.%s", machinename);				required = 1;				override = 0;				break;			case 3:				(void) sprintf(fname, "files.%s",						raise(ident));				required = 0;				override = 1;				break;		}		fp = fopen(fname, "r");		if (fp == NULL) {			if (required == 0) {				continue;			} else {				perror(fname);				exit(1);			}		}		/* process each line */		while ((wd = get_word(fp)) != (char *)EOF) {			if (wd == NULL) {				continue;			}			/* record and check module name */			module = ns(wd);			if (fl_lookup(module)) {				printf("%s: Duplicate file %s.\n", fname,					module);				exit(1);			}			if (override != 0) {				if ((tp = fltail_lookup(module)) != NULL) {					printf("%s: Local file %s overrides %s.\n",						fname, module, tp->f_fn);				} else				     tp = new_fent(); 			} else {				tp = new_fent();			}			tp->f_fn = module;			tp->f_type = 0;			tp->f_flags = 0;			for (nexneed = 0; nexneed < NNEEDS; nexneed++) {				tp->f_needs[nexneed] = NULL;			}			nexneed = -1;			/* process optional or standard specification */			wd = get_word(fp);			if (eq(wd, "optional")) {				doopts = 1;			} else if (eq(wd, "standard")) {				doopts = 0;			} else {				printf("%s: %s must be optional or standard\n",					fname, module);			}			wd = next_word(fp, fname);			/* process config-dependent specification */			if (eq(wd, "config-dependent")) {				tp->f_flags |= CONFIGDEP;				wd = next_word(fp, fname);			}			/* process optional specifications */			failing = 0;			if (doopts == 1) {				noneed = 0;				skipopts = 0;				negate = 0;				while (wd != NULL) {					if (eq(wd, "device-driver")						|| eq(wd, "profiling-routine")						|| eq(wd, "Binary")						|| eq(wd, "Unsupported")						|| eq(wd, "Notbinary")) {						break;					}					/* if this is or, dependency is met */					if (eq(wd, "or")) {						if (negate) {							printf("%s: %s has unspecified negate\n",								fname, module);							exit(1);						}						if (failing == 0) {							skipopts = 1;						} else {							skipopts = 0;							failing = 0;						}						wd = next_word(fp, fname);						continue;					}					/* if this is not, next dependency					   is negated */					if (eq(wd, "not")) {						negate = 1;						wd = next_word(fp, fname);						continue;					}					/* if dependent on cpu, do					   not build header file */					if (eq(wd, "cpu")) {						noneed = 1;						wd = next_word(fp, fname);						continue;					}					/* if dependent on bus recognize					   keyword, does nothing now */					if (eq(wd, "bus")) {						wd = next_word(fp, fname);						continue;					}					/* process normal dependency */					if (nexneed < 0) {						nexneed = 0;					}					if (noneed == 0) {						if (nexneed >= NNEEDS) {							printf("%s: %s has too many dependencies",								fname, module);							exit(1);						}						tp->f_needs[nexneed++] =							ns(wd);					}					noneed = 0;					/* if dependency met, wait for field					   terminator */					if (skipopts != 0) {						wd = next_word(fp, fname);						continue;					}					/* see if dependency is satisfied */					dp = dtab;					while (dp != NULL && !eq(wd, dp->d_name)) {						dp = dp->d_next;					}					if ((dp == NULL && negate == 0) ||						(dp != NULL && negate != 0)) {						/* flush rest of this line						   or until we find an "or" */						failing = 1;						skipopts = 1;					}					wd = next_word(fp, fname);					negate = 0;				}				/* finished with dependencies, error if none				   or hanging not */				if (negate) {					printf("%s: %s has unspecified negate\n",						fname, module);					exit(1);				}				if (nexneed < 0					&& !eq(wd, "profiling-routine")) {					printf("%s: what is %s optional on?\n",						fname, module);					exit(1);				}			}			/* is this module to be included? */			if (failing != 0) {				tp->f_flags |= INVISIBLE;			}			/* handle profiling or device driver spec */			if (eq(wd, "profiling-routine")) {				tp->f_type = PROFILING;				if (profiling == 0) {					tp->f_flags |= INVISIBLE;				}				wd = next_word(fp, fname);			} else if (eq(wd, "device-driver")) {				tp->f_type = DRIVER;				wd = next_word(fp, fname);			} else {				tp->f_type = NORMAL;			}			/* handle binary or not binary spec */			if (eq(wd, "Binary")) {				if (!source) {					tp->f_flags |= OBJS_ONLY;				}				wd = next_word(fp, fname);			} else if (eq(wd, "Notbinary")) {				if (source) {					tp->f_flags |= NOTBINARY;				}				wd = next_word(fp, fname);			}			/* handle unsupported spec */			if (eq(wd, "Unsupported")) {				if (!source) {					tp->f_flags |= UNSUPPORTED;				}				wd = next_word(fp, fname);			}			/* if anything left, its a syntax error */			if (wd != NULL) {				printf("%s: syntax error describing %s found %s type %d flags 0x%x\n",					fname, module, wd, tp->f_type,					tp->f_flags);				exit(1);			}		}	}}/* * This routine handles the MicroVAX emulation code object modules. These  * routines must be processed in a particular order. This is necessary so * that the space they occupy can be mapped as user read. */do_emulo(fp)	FILE *fp;{	static char *objects[]={ 	" vaxarith.o  vaxcvtpl.o vaxeditpc.o vaxhandlr.o \\\n",	"	vaxashp.o vaxcvtlp.o vaxdeciml.o vaxemulat.o vaxstring.o \\\n",	"	vaxconvrt.o ",	0 };	char **cptr;	if ( emulation_instr || emulation_float )		fprintf(fp, "EMULO=\tvaxbegin.o ");	else		return;	if ( emulation_instr ) {		for( cptr = objects ; *cptr ; cptr++ )			fputs(*cptr, fp);	}	if ( emulation_float )		fprintf(fp, "vaxfloat.o ");	fprintf(fp,"vaxexception.o vaxend.o\n");}do_objs(fp)	FILE *fp;{	register struct file_list *tp, *fl;	register int lpos, len;	register char *cp, och, *sp;	char swapname[32];	fprintf(fp, "OBJS=\t");	lpos = 8;	for (tp = ftab; tp != 0; tp = tp->f_next) {		if ((tp->f_flags & INVISIBLE) != 0)			continue;		if ((tp->f_flags & NOTBINARY) && source)		/* do not load object in the BINARY directory */			continue;		sp = tail(tp->f_fn);		for (fl = conf_list; fl; fl = fl->f_next) {			if (fl->f_type != SWAPSPEC)				continue;			if (eq(fl->f_fn, "generic") || eq(fl->f_fn, "boot"))				sprintf(swapname, "swap.c", fl->f_fn);			else				sprintf(swapname, "swap%s.c", fl->f_fn);			if (eq(sp, swapname))				goto cont;		}		cp = sp + (len = strlen(sp)) - 1;		och = *cp;		*cp = 'o';		if (len + lpos > 72) {			lpos = 8;			fprintf(fp, "\\\n\t");		}		fprintf(fp, "%s ", sp);		if (tp->f_flags & UNSUPPORTED)			printf("Warning this device is not supported by DIGITAL %s\n",sp);		lpos += len + 1;		*cp = och;cont:		;	}	if (lpos != 8)		putc('\n', fp);}/* *	This routine outputs the emulation source file names */do_emuls(fp)	FILE *fp;{	static char *sources[]={	"../machine/emul/vaxarith.s ../machine/emul/vaxashp.s \\\n",	"	../machine/emul/vaxconvrt.s ../machine/emul/vaxcvtlp.s\\\n",	"	../machine/emul/vaxcvtpl.s ../machine/emul/vaxdeciml.s\\\n",	"	../machine/emul/vaxeditpc.s ../machine/emul/vaxemulat.s \\\n",	"	../machine/emul/vaxhandlr.s ../machine/emul/vaxstring.s \\\n",	0};	char **cptr;	if( !source ) 		return;	if (emulation_instr || emulation_float)		fprintf(fp,"EMULS=\t../machine/emul/vaxbegin.s ");	else		return;	if (emulation_instr) {		for( cptr=sources ; *cptr ; cptr++ )			fputs(*cptr, fp);	}	fprintf(fp,"\t");	if (emulation_float)		fprintf(fp,"../machine/emul/vaxfloat.s ");	fprintf(fp,"../machine/emul/vaxexception.s ../machine/emul/vaxend.s\n");}#define MAXFILES	150	/* maximum number of files in CFILES */do_cfiles(fp)	FILE *fp;{	register struct file_list *tp;	register int lpos, len, count;	int	cfiles;	char buf[1024];	char cstr[20];	bzero(buf,1024);	strcpy(buf,"\nALLCFILES=\t${CFILES}");	fprintf(fp, "CFILES=\t");	lpos = 8;	count = 0;	cfiles = 1;	for (tp = ftab; tp != 0; tp = tp->f_next) {		if ((tp->f_flags & INVISIBLE) != 0)			continue;		if (tp->f_flags & OBJS_ONLY)			continue;		if ((tp->f_flags & NOTBINARY) && source)		/* do not compile in the BINARY directory */			continue;		if (tp->f_fn[strlen(tp->f_fn)-1] != 'c')			continue;		if ((len = 3 + strlen(tp->f_fn)) + lpos > 72) {			lpos = 8;			fprintf(fp, "\\\n\t");		}		fprintf(fp, "../../%s ", tp->f_fn);		lpos += len + 1;		if (++count == MAXFILES) {			fprintf(fp, "\n\n");			sprintf(cstr,"CFILES%d",cfiles);			fprintf(fp,"%s=", cstr);			lpos = 8;			count = 0;			strcat(buf," ${");			strcat(buf,cstr);			strcat(buf,"}");			cfiles++;		}	}	if (source)		fprintf(fp, "\\\n\t../machine/genassym.c");	if (lpos != 8)		putc('\n', fp);	strcat(buf,"\n");	fprintf(fp,buf);}do_sfiles(fp)	FILE *fp;{	register struct file_list *tp;	register int lpos, len;	fprintf(fp, "SFILES=");	lpos = 8;	for (tp = ftab; tp != 0; tp = tp->f_next) {		if ((tp->f_flags & INVISIBLE) != 0)			continue;		if (tp->f_flags & OBJS_ONLY)			continue;		if((tp->f_flags & NOTBINARY) && source)			continue;		if (tp->f_fn[strlen(tp->f_fn)-1] != 's')			continue;		if ((len = 3 + strlen(tp->f_fn)) + lpos > 72) {			lpos = 8;			fprintf(fp, "\\\n\t");		}		fprintf(fp, "../../%s ", tp->f_fn);		lpos += len + 1;	}	if (lpos != 8)		putc('\n', fp);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -