version 1.248, 2016/06/07 03:04:45 |
version 1.248.2.1, 2017/01/07 08:56:58 |
Line 680 Main_ParseArgLine(const char *line) |
|
Line 680 Main_ParseArgLine(const char *line) |
|
} |
} |
|
|
Boolean |
Boolean |
Main_SetObjdir(const char *path) |
Main_SetObjdir(const char *fmt, ...) |
{ |
{ |
struct stat sb; |
struct stat sb; |
char *p = NULL; |
char *p, *path; |
char buf[MAXPATHLEN + 1]; |
char buf[MAXPATHLEN + 1], pbuf[MAXPATHLEN + 1]; |
Boolean rc = FALSE; |
Boolean rc = FALSE; |
|
va_list ap; |
|
|
|
va_start(ap, fmt); |
|
vsnprintf(path = pbuf, MAXPATHLEN, fmt, ap); |
|
va_end(ap); |
|
|
/* expand variable substitutions */ |
/* expand variable substitutions */ |
if (strchr(path, '$') != 0) { |
if (strchr(path, '$') != 0) { |
snprintf(buf, MAXPATHLEN, "%s", path); |
snprintf(buf, MAXPATHLEN, "%s", path); |
path = p = Var_Subst(NULL, buf, VAR_GLOBAL, VARF_WANTRES); |
path = p = Var_Subst(NULL, buf, VAR_GLOBAL, VARF_WANTRES); |
} |
} else |
|
p = NULL; |
|
|
if (path[0] != '/') { |
if (path[0] != '/') { |
snprintf(buf, MAXPATHLEN, "%s/%s", curdir, path); |
snprintf(buf, MAXPATHLEN, "%s/%s", curdir, path); |
Line 718 Main_SetObjdir(const char *path) |
|
Line 724 Main_SetObjdir(const char *path) |
|
return rc; |
return rc; |
} |
} |
|
|
|
static Boolean |
|
Main_SetVarObjdir(const char *var, const char *suffix) |
|
{ |
|
char *p1, *path; |
|
if ((path = Var_Value(var, VAR_CMD, &p1)) == NULL) |
|
return FALSE; |
|
|
|
(void)Main_SetObjdir("%s%s", path, suffix); |
|
free(p1); |
|
return TRUE; |
|
} |
|
|
/*- |
/*- |
* ReadAllMakefiles -- |
* ReadAllMakefiles -- |
* wrapper around ReadMakefile() to read all. |
* wrapper around ReadMakefile() to read all. |
Line 1093 main(int argc, char **argv) |
|
Line 1111 main(int argc, char **argv) |
|
* MAKEOBJDIR is set in the environment, try only that value |
* MAKEOBJDIR is set in the environment, try only that value |
* and fall back to .CURDIR if it does not exist. |
* and fall back to .CURDIR if it does not exist. |
* |
* |
* Otherwise, try _PATH_OBJDIR.MACHINE, _PATH_OBJDIR, and |
* Otherwise, try _PATH_OBJDIR.MACHINE-MACHINE_ARCH, _PATH_OBJDIR.MACHINE, |
* finally _PATH_OBJDIRPREFIX`pwd`, in that order. If none |
* and * finally _PATH_OBJDIRPREFIX`pwd`, in that order. If none |
* of these paths exist, just use .CURDIR. |
* of these paths exist, just use .CURDIR. |
*/ |
*/ |
Dir_Init(curdir); |
Dir_Init(curdir); |
(void)Main_SetObjdir(curdir); |
(void)Main_SetObjdir("%s", curdir); |
|
|
if ((path = Var_Value("MAKEOBJDIRPREFIX", VAR_CMD, &p1)) != NULL) { |
if (!Main_SetVarObjdir("MAKEOBJDIRPREFIX", curdir) && |
(void)snprintf(mdpath, MAXPATHLEN, "%s%s", path, curdir); |
!Main_SetVarObjdir("MAKEOBJDIR", "") && |
(void)Main_SetObjdir(mdpath); |
!Main_SetObjdir("%s.%s-%s", _PATH_OBJDIR, machine, machine_arch) && |
free(p1); |
!Main_SetObjdir("%s.%s", _PATH_OBJDIR, machine) && |
} else if ((path = Var_Value("MAKEOBJDIR", VAR_CMD, &p1)) != NULL) { |
!Main_SetObjdir("%s", _PATH_OBJDIR)) |
(void)Main_SetObjdir(path); |
(void)Main_SetObjdir("%s%s", _PATH_OBJDIRPREFIX, curdir); |
free(p1); |
|
} else { |
|
(void)snprintf(mdpath, MAXPATHLEN, "%s.%s", _PATH_OBJDIR, machine); |
|
if (!Main_SetObjdir(mdpath) && !Main_SetObjdir(_PATH_OBJDIR)) { |
|
(void)snprintf(mdpath, MAXPATHLEN, "%s%s", |
|
_PATH_OBJDIRPREFIX, curdir); |
|
(void)Main_SetObjdir(mdpath); |
|
} |
|
} |
|
|
|
/* |
/* |
* Initialize archive, target and suffix modules in preparation for |
* Initialize archive, target and suffix modules in preparation for |