Exemple #1
0
void
parse_conf_file(void)
{
	if (!is_nonempty_file(infilename))
		errx(1, "fatal: input file \"%s\" not found", infilename);

	parse_one_file(infilename);
	if (readcache && is_nonempty_file(cachename)) {
		reading_cache = 1;
		parse_one_file(cachename);
	}
}
Exemple #2
0
void 
parse_conf_file(void)
{
	if (!is_nonempty_file(infilename)) {
		fprintf(stderr, "%s: fatal: input file \"%s\" not found.\n",
		    progname, infilename);
		exit(1);
	}
	parse_one_file(infilename);
	if (readcache && is_nonempty_file(cachename)) {
		reading_cache = 1;
		parse_one_file(cachename);
	}
}
Exemple #3
0
/*
 * run the makefile for the program to find which objects are necessary
 */
void
fillin_program(prog_t *p)
{
	char path[MAXPATHLEN];
	char line[MAXLINELEN];
	FILE *f;

	snprintf(line, MAXLINELEN, "filling in parms for %s", p->name);
	status(line);

	if (!p->ident)
		p->ident = genident(p->name);

	/* look for the source directory if one wasn't specified by a special */
	if (!p->srcdir) {
		p->srcdir = dir_search(p->name);
	}

	/* Determine the actual srcdir (maybe symlinked). */
	if (p->srcdir) {
		snprintf(line, MAXLINELEN, "cd %s && echo -n `/bin/pwd`",
		    p->srcdir);
		f = popen(line,"r");
		if (!f)
			errx(1, "Can't execute: %s\n", line);

		path[0] = '\0';
		fgets(path, sizeof path, f);
		if (pclose(f))
			errx(1, "Can't execute: %s\n", line);

		if (!*path)
			errx(1, "Can't perform pwd on: %s\n", p->srcdir);

		p->realsrcdir = strdup(path);
	}

	/* Unless the option to make object files was specified the
	* the objects will be built in the source directory unless
	* an object directory already exists.
	*/
	if (!makeobj && !p->objdir && p->srcdir) {
		char *auto_obj;

		auto_obj = NULL;
		snprintf(line, sizeof line, "%s/%s", objprefix, p->realsrcdir);
		if (is_dir(line) ||
		    ((auto_obj = getenv("MK_AUTO_OBJ")) != NULL &&
		    strcmp(auto_obj, "yes") == 0)) {
			if ((p->objdir = strdup(line)) == NULL)
			out_of_memory();
		} else
			p->objdir = p->realsrcdir;
	}

	/*
	* XXX look for a Makefile.{name} in local directory first.
	* This lets us override the original Makefile.
	*/
	snprintf(path, sizeof(path), "Makefile.%s", p->name);
	if (is_nonempty_file(path)) {
		snprintf(line, MAXLINELEN, "Using %s for %s", path, p->name);
		status(line);
	} else
		if (p->srcdir)
			snprintf(path, sizeof(path), "%s/Makefile", p->srcdir);
	if (!p->objs && p->srcdir && is_nonempty_file(path))
		fillin_program_objs(p, path);

	if (!p->srcdir && !p->objdir && verbose)
		warnx("%s: %s: %s",
		    "warning: could not find source directory",
		    infilename, p->name);
	if (!p->objs && verbose)
		warnx("%s: %s: warning: could not find any .o files",
		    infilename, p->name);

	if ((!p->srcdir || !p->objdir) && !p->objs)
		p->goterror = 1;
}
Exemple #4
0
void 
fillin_program(prog_t * p)
{
	char            path[MAXPATHLEN];
	char           *srcparent;
	strlst_t       *s;
	int             i;

	snprintf(line, sizeof(line), "filling in parms for %s", p->name);
	status(line);

	if (!p->ident)
		p->ident = genident(p->name);
	if (!p->srcdir) {
		srcparent = dir_search(p->name);
		if (srcparent)
			snprintf(path, sizeof(path), "%s/%s", srcparent, p->name);
		if (is_dir(path))
			p->srcdir = strdup(path);
	}
	if (!p->objdir && p->srcdir) {
		snprintf(path, sizeof(path), "%s/%s", p->srcdir, objdir);
		if (is_dir(path))
			p->objdir = strdup(path);
		else {
			snprintf(path, sizeof(path), "%s/obj.%s", p->srcdir, MACHINE);
			if (is_dir(path))
				p->objdir = strdup(path);
			else
				p->objdir = p->srcdir;
		}
	}
	/* We have a sourcedir and no explicit objs, try */
	/* to find makefile and get objs from it. */
	if (p->srcdir && !p->objs) {
		for (i = 0; mf_name[i] != NULL; i++) {
			snprintf(path, sizeof(path), "%s/%s", p->srcdir, mf_name[i]);
			if (is_nonempty_file(path)) {
				p->mf_name = mf_name[i];
				fillin_program_objs(p, path);
				break;
			}
		}
	}
	if (!p->objpaths && p->objdir && p->objs)
		for (s = p->objs; s != NULL; s = s->next) {
			snprintf(line, sizeof(line), "%s/%s", p->objdir, s->str);
			add_string(&p->objpaths, line);
		}

	if (!p->srcdir && verbose)
		fprintf(stderr, "%s: %s: warning: could not find source directory.\n",
		    infilename, p->name);
	if (!p->objs && verbose)
		fprintf(stderr, "%s: %s: warning: could not find any .o files.\n",
		    infilename, p->name);

	if (!p->objpaths) {
		fprintf(stderr,
		    "%s: %s: error: no objpaths specified or calculated.\n",
		    infilename, p->name);
		p->goterror = goterror = 1;
	}
}