/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1984-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* make file read routines
*/
#include "make.h"
/*
* read the base and global rules
*/
static void
readrules(void)
{
register char* s;
register List_t* p;
/*
* read the base rules
*/
else if (*s)
{
}
/*
* read the explicit global makefiles
*
* NOTE: internal.tmplist is used to handle the effects
* of load() on internal list pointers
*/
{
}
}
/*
* read a file given an open file pointer
*/
static void
{
register char* s;
register char* t;
int n;
int needrules;
int preprocess;
int splice;
char* name;
char* b;
char* e;
char* objfile;
Rule_t* x;
objfile = 0;
{
/*
* set up the related file names
*/
sfstrclose(fp);
objfile = objectfile();
}
/*
* load if object file
*/
{
readrules();
{
return;
}
}
/*
* check object corresponding to file
*/
{
if (!objfile)
{
}
sfstrclose(fp);
if (!x || !x->time)
/* ignore */;
else if (x == r)
{
if (needrules)
{
if (needrules)
{
{
{
error(state.exec || state.mam.out ? -1 : 1, "%s: base rules changed to %s", sfstrbase(internal.tmp), sfstrbase(internal.wrk));
needrules = 1;
}
}
{
needrules = 0;
readrules();
}
}
{
if (n > 0)
{
return;
}
}
}
error(1, "%s: reading%s", r->name, state.forceread ? " -- should be compiled before local makefiles" : null);
else if (state.writeobject)
}
}
/*
* at this point we have to read it
* if its the first makefile then the
* base rules must be determined and loaded
* along with the global rules before the parse
*/
{
/*
* first check for and apply makefile converter
*/
s = 0;
{
char* u;
char* v;
e++;
else
e = r->name;
b = tokopen(t, 1);
{
u = tokopen(t, 0);
tokclose(u);
if (!(s = tokread(b)))
{
break;
}
if (v)
{
break;
}
s = 0;
}
tokclose(b);
}
if (s)
{
free(t);
preprocess = -1;
}
if (needrules)
{
{
int c;
int d;
int old;
if (n > 0)
{
if (n > MAXNAME)
n = MAXNAME;
else
n--;
}
/*
* quick makefile type check while
* checking for base rules
*/
old = 0;
splice = 0;
b = s;
c = *(s + n);
*(s + n) = 0;
for (;;)
{
if (e = strchr(s, '\n'))
*e = 0;
else if (c != '\n')
break;
if (splice)
/* skip */;
else if (*s == SALT)
{
while (isspace(*++s));
for (t = s; isalnum(*t); t++);
d = *t;
*t = 0;
{
if (*t = d)
t++;
while (*t == ' ' || *t == '\t')
t++;
break;
}
else if (!strmatch(s, "assert|comment|define|elif|else|endif|endmac|error|ident|if|ifdef|ifndef|include|line|macdef|pragma|unassert|undef|warning"))
old = 1;
else if (!preprocess)
preprocess = 1;
*t = d;
}
else if (*s == '<' && *(s + 1) == '<')
{
old = preprocess = 0;
break;
}
else
{
while (isspace(*s))
s++;
{
for (s += 5; *s == ' ' || *s == '\t'; s++);
old = 0;
break;
}
{
old = 0;
break;
}
else
{
d = ':';
while (*s)
{
break;
else if (*s == d)
{
if (*++s == d)
s++;
else if (isalnum(*s))
{
while (isalnum(*s))
s++;
if (*s == d)
break;
}
d = 0;
}
while (*s && *s != d && !isspace(*s))
s++;
while (isspace(*s))
s++;
}
if (*s)
{
old = 0;
break;
}
}
}
if (!(s = e))
break;
*s++ = '\n';
}
if (e)
*e = '\n';
*(b + n) = c;
if (old)
punt(1);
}
readrules();
}
}
/*
* check for obsolete makefile preprocessor
*/
if (preprocess > 0)
{
s = "$(MAKEPP) $(MAKEPPFLAGS) $(>)";
}
/*
* parse the file
*/
{
}
}
/*
* read a makefile
*/
int
{
register Rule_t* r;
{
}
{
if (rfp = filter ? fapply(internal.internal, null, file, filter, CO_ALWAYS|CO_LOCAL|CO_URGENT) : rsfopen(file))
{
{
}
else
{
oldname(r);
}
{
}
return(1);
}
{
r->property |= P_dontcare;
return(0);
}
}
if (!(type & COMP_DONTCARE))
error((type & COMP_INCLUDE) ? 2 : 3, "%s: cannot read%s", file, (type & COMP_INCLUDE) ? " include file" : (type & COMP_GLOBAL) ? " global rules" : (type & COMP_BASE) ? " base rules" : null);
return(0);
}