version 1.11, 1997/01/27 05:24:09 |
version 1.12, 1997/04/01 07:28:13 |
|
|
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
/* $NetBSD: main.c,v 1.31 1996/11/06 17:59:12 christos Exp $ */ |
/* $NetBSD: main.c,v 1.34 1997/03/24 20:56:36 gwr Exp $ */ |
|
|
/* |
/* |
* Copyright (c) 1988, 1989, 1990, 1993 |
* Copyright (c) 1988, 1989, 1990, 1993 |
|
|
#include <sys/resource.h> |
#include <sys/resource.h> |
#include <sys/signal.h> |
#include <sys/signal.h> |
#include <sys/stat.h> |
#include <sys/stat.h> |
#ifndef MACHINE |
#ifndef MAKE_BOOTSTRAP |
#include <sys/utsname.h> |
#include <sys/utsname.h> |
#endif |
#endif |
#include <sys/wait.h> |
#include <sys/wait.h> |
#include <errno.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <stdio.h> |
#include <stdio.h> |
#if __STDC__ |
#include <stdlib.h> |
|
#ifdef __STDC__ |
#include <stdarg.h> |
#include <stdarg.h> |
#else |
#else |
#include <varargs.h> |
#include <varargs.h> |
|
|
char obpath[MAXPATHLEN + 1]; |
char obpath[MAXPATHLEN + 1]; |
char cdpath[MAXPATHLEN + 1]; |
char cdpath[MAXPATHLEN + 1]; |
char *machine = getenv("MACHINE"); |
char *machine = getenv("MACHINE"); |
|
char *machine_arch = getenv("MACHINE_ARCH"); |
Lst sysMkPath; /* Path of sys.mk */ |
Lst sysMkPath; /* Path of sys.mk */ |
char *cp = NULL, *start; |
char *cp = NULL, *start; |
/* avoid faults on read-only strings */ |
/* avoid faults on read-only strings */ |
|
|
* so we can share an executable for similar machines. |
* so we can share an executable for similar machines. |
* (i.e. m68k: amiga hp300, mac68k, sun3, ...) |
* (i.e. m68k: amiga hp300, mac68k, sun3, ...) |
* |
* |
* Note that both MACHINE and MACHINE_ARCH can be overridden |
* Note that both MACHINE and MACHINE_ARCH are decided at |
* by environment variables. MACHINE through the getenv() |
* run-time. |
* above and MACHINE_ARCH, below. |
|
*/ |
*/ |
if (!machine) { |
if (!machine) { |
#ifndef MACHINE |
#ifndef MAKE_BOOTSTRAP |
struct utsname utsname; |
struct utsname utsname; |
|
|
if (uname(&utsname) == -1) { |
if (uname(&utsname) == -1) { |
|
|
#endif |
#endif |
} |
} |
|
|
|
if (!machine_arch) { |
|
#ifndef MACHINE_ARCH |
|
machine_arch = "unknown"; /* XXX: no uname -p yet */ |
|
#else |
|
machine_arch = MACHINE_ARCH; |
|
#endif |
|
} |
|
|
/* |
/* |
* If the MAKEOBJDIR (or by default, the _PATH_OBJDIR) directory |
* If the MAKEOBJDIR (or by default, the _PATH_OBJDIR) directory |
* exists, change into it and build there. (If a .${MACHINE} suffix |
* exists, change into it and build there. (If a .${MACHINE} suffix |
|
|
Var_Set(MAKEFLAGS, "", VAR_GLOBAL); |
Var_Set(MAKEFLAGS, "", VAR_GLOBAL); |
Var_Set("MFLAGS", "", VAR_GLOBAL); |
Var_Set("MFLAGS", "", VAR_GLOBAL); |
Var_Set("MACHINE", machine, VAR_GLOBAL); |
Var_Set("MACHINE", machine, VAR_GLOBAL); |
#ifdef MACHINE_ARCH |
Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL); |
if (NULL == getenv("MACHINE_ARCH")) { |
|
Var_Set("MACHINE_ARCH", MACHINE_ARCH, VAR_GLOBAL); |
|
} |
|
#endif |
|
|
|
/* |
/* |
* First snag any flags out of the MAKE environment variable. |
* First snag any flags out of the MAKE environment variable. |
|
|
*/ |
*/ |
/* VARARGS */ |
/* VARARGS */ |
void |
void |
#if __STDC__ |
#ifdef __STDC__ |
Error(char *fmt, ...) |
Error(char *fmt, ...) |
#else |
#else |
Error(va_alist) |
Error(va_alist) |
|
|
#endif |
#endif |
{ |
{ |
va_list ap; |
va_list ap; |
#if __STDC__ |
#ifdef __STDC__ |
va_start(ap, fmt); |
va_start(ap, fmt); |
#else |
#else |
char *fmt; |
char *fmt; |
|
|
*/ |
*/ |
/* VARARGS */ |
/* VARARGS */ |
void |
void |
#if __STDC__ |
#ifdef __STDC__ |
Fatal(char *fmt, ...) |
Fatal(char *fmt, ...) |
#else |
#else |
Fatal(va_alist) |
Fatal(va_alist) |
|
|
#endif |
#endif |
{ |
{ |
va_list ap; |
va_list ap; |
#if __STDC__ |
#ifdef __STDC__ |
va_start(ap, fmt); |
va_start(ap, fmt); |
#else |
#else |
char *fmt; |
char *fmt; |
|
|
*/ |
*/ |
/* VARARGS */ |
/* VARARGS */ |
void |
void |
#if __STDC__ |
#ifdef __STDC__ |
Punt(char *fmt, ...) |
Punt(char *fmt, ...) |
#else |
#else |
Punt(va_alist) |
Punt(va_alist) |
|
|
#endif |
#endif |
{ |
{ |
va_list ap; |
va_list ap; |
#if __STDC__ |
#ifdef __STDC__ |
va_start(ap, fmt); |
va_start(ap, fmt); |
#else |
#else |
char *fmt; |
char *fmt; |