main.c (246223) | main.c (249033) |
---|---|
1/* $NetBSD: main.c,v 1.205 2013/01/26 15:53:00 christos Exp $ */ | 1/* $NetBSD: main.c,v 1.210 2013/03/23 05:31:29 sjg Exp $ */ |
2 3/* 4 * Copyright (c) 1988, 1989, 1990, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Adam de Boor. 9 * --- 54 unchanged lines hidden (view full) --- 64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 68 * SUCH DAMAGE. 69 */ 70 71#ifndef MAKE_NATIVE | 2 3/* 4 * Copyright (c) 1988, 1989, 1990, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Adam de Boor. 9 * --- 54 unchanged lines hidden (view full) --- 64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 68 * SUCH DAMAGE. 69 */ 70 71#ifndef MAKE_NATIVE |
72static char rcsid[] = "$NetBSD: main.c,v 1.205 2013/01/26 15:53:00 christos Exp $"; | 72static char rcsid[] = "$NetBSD: main.c,v 1.210 2013/03/23 05:31:29 sjg Exp $"; |
73#else 74#include <sys/cdefs.h> 75#ifndef lint 76__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ 77 The Regents of the University of California. All rights reserved."); 78#endif /* not lint */ 79 80#ifndef lint 81#if 0 82static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; 83#else | 73#else 74#include <sys/cdefs.h> 75#ifndef lint 76__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ 77 The Regents of the University of California. All rights reserved."); 78#endif /* not lint */ 79 80#ifndef lint 81#if 0 82static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; 83#else |
84__RCSID("$NetBSD: main.c,v 1.205 2013/01/26 15:53:00 christos Exp $"); | 84__RCSID("$NetBSD: main.c,v 1.210 2013/03/23 05:31:29 sjg Exp $"); |
85#endif 86#endif /* not lint */ 87#endif 88 89/*- 90 * main.c -- 91 * The main file for this entire program. Exit routines etc 92 * reside here. --- 21 unchanged lines hidden (view full) --- 114 */ 115 116#include <sys/types.h> 117#include <sys/time.h> 118#include <sys/param.h> 119#include <sys/resource.h> 120#include <signal.h> 121#include <sys/stat.h> | 85#endif 86#endif /* not lint */ 87#endif 88 89/*- 90 * main.c -- 91 * The main file for this entire program. Exit routines etc 92 * reside here. --- 21 unchanged lines hidden (view full) --- 114 */ 115 116#include <sys/types.h> 117#include <sys/time.h> 118#include <sys/param.h> 119#include <sys/resource.h> 120#include <signal.h> 121#include <sys/stat.h> |
122#ifdef MAKE_NATIVE | |
123#include <sys/utsname.h> | 122#include <sys/utsname.h> |
124#endif | |
125#include "wait.h" 126 127#include <errno.h> 128#include <fcntl.h> 129#include <stdarg.h> 130#include <stdio.h> 131#include <stdlib.h> 132#include <time.h> --- 630 unchanged lines hidden (view full) --- 763 764 if (mode && *mode) { 765 if (strstr(mode, "compat")) { 766 compatMake = TRUE; 767 forceJobs = FALSE; 768 } 769#if USE_META 770 if (strstr(mode, "meta")) | 123#include "wait.h" 124 125#include <errno.h> 126#include <fcntl.h> 127#include <stdarg.h> 128#include <stdio.h> 129#include <stdlib.h> 130#include <time.h> --- 630 unchanged lines hidden (view full) --- 761 762 if (mode && *mode) { 763 if (strstr(mode, "compat")) { 764 compatMake = TRUE; 765 forceJobs = FALSE; 766 } 767#if USE_META 768 if (strstr(mode, "meta")) |
771 meta_init(mode); | 769 meta_mode_init(mode); |
772#endif 773 } 774 if (mp) 775 free(mp); 776} 777 778/*- 779 * main -- --- 28 unchanged lines hidden (view full) --- 808 const char *machine_arch = getenv("MACHINE_ARCH"); 809 char *syspath = getenv("MAKESYSPATH"); 810 Lst sysMkPath; /* Path of sys.mk */ 811 char *cp = NULL, *start; 812 /* avoid faults on read-only strings */ 813 static char defsyspath[] = _PATH_DEFSYSPATH; 814 char found_path[MAXPATHLEN + 1]; /* for searching for sys.mk */ 815 struct timeval rightnow; /* to initialize random seed */ | 770#endif 771 } 772 if (mp) 773 free(mp); 774} 775 776/*- 777 * main -- --- 28 unchanged lines hidden (view full) --- 806 const char *machine_arch = getenv("MACHINE_ARCH"); 807 char *syspath = getenv("MAKESYSPATH"); 808 Lst sysMkPath; /* Path of sys.mk */ 809 char *cp = NULL, *start; 810 /* avoid faults on read-only strings */ 811 static char defsyspath[] = _PATH_DEFSYSPATH; 812 char found_path[MAXPATHLEN + 1]; /* for searching for sys.mk */ 813 struct timeval rightnow; /* to initialize random seed */ |
816#ifdef MAKE_NATIVE | |
817 struct utsname utsname; | 814 struct utsname utsname; |
818#endif | |
819 820 /* default to writing debug to stderr */ 821 debug_file = stderr; 822 823#ifdef SIGINFO 824 (void)bmake_signal(SIGINFO, siginfo); 825#endif 826 /* 827 * Set the seed to produce a different random sequence 828 * on each program execution. 829 */ 830 gettimeofday(&rightnow, NULL); 831 srandom(rightnow.tv_sec + rightnow.tv_usec); 832 833 if ((progname = strrchr(argv[0], '/')) != NULL) 834 progname++; 835 else 836 progname = argv[0]; | 815 816 /* default to writing debug to stderr */ 817 debug_file = stderr; 818 819#ifdef SIGINFO 820 (void)bmake_signal(SIGINFO, siginfo); 821#endif 822 /* 823 * Set the seed to produce a different random sequence 824 * on each program execution. 825 */ 826 gettimeofday(&rightnow, NULL); 827 srandom(rightnow.tv_sec + rightnow.tv_usec); 828 829 if ((progname = strrchr(argv[0], '/')) != NULL) 830 progname++; 831 else 832 progname = argv[0]; |
837#ifdef RLIMIT_NOFILE | 833#if defined(MAKE_NATIVE) || (defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)) |
838 /* 839 * get rid of resource limit on file descriptors 840 */ 841 { 842 struct rlimit rl; 843 if (getrlimit(RLIMIT_NOFILE, &rl) != -1 && 844 rl.rlim_cur != rl.rlim_max) { 845 rl.rlim_cur = rl.rlim_max; 846 (void)setrlimit(RLIMIT_NOFILE, &rl); 847 } 848 } 849#endif 850 | 834 /* 835 * get rid of resource limit on file descriptors 836 */ 837 { 838 struct rlimit rl; 839 if (getrlimit(RLIMIT_NOFILE, &rl) != -1 && 840 rl.rlim_cur != rl.rlim_max) { 841 rl.rlim_cur = rl.rlim_max; 842 (void)setrlimit(RLIMIT_NOFILE, &rl); 843 } 844 } 845#endif 846 |
847 if (uname(&utsname) == -1) { 848 (void)fprintf(stderr, "%s: uname failed (%s).\n", progname, 849 strerror(errno)); 850 exit(2); 851 } 852 |
|
851 /* 852 * Get the name of this type of MACHINE from utsname 853 * so we can share an executable for similar machines. 854 * (i.e. m68k: amiga hp300, mac68k, sun3, ...) 855 * 856 * Note that both MACHINE and MACHINE_ARCH are decided at 857 * run-time. 858 */ 859 if (!machine) { 860#ifdef MAKE_NATIVE | 853 /* 854 * Get the name of this type of MACHINE from utsname 855 * so we can share an executable for similar machines. 856 * (i.e. m68k: amiga hp300, mac68k, sun3, ...) 857 * 858 * Note that both MACHINE and MACHINE_ARCH are decided at 859 * run-time. 860 */ 861 if (!machine) { 862#ifdef MAKE_NATIVE |
861 if (uname(&utsname) == -1) { 862 (void)fprintf(stderr, "%s: uname failed (%s).\n", progname, 863 strerror(errno)); 864 exit(2); 865 } | |
866 machine = utsname.machine; 867#else 868#ifdef MAKE_MACHINE 869 machine = MAKE_MACHINE; 870#else 871 machine = "unknown"; 872#endif 873#endif --- 13 unchanged lines hidden (view full) --- 887 888 myPid = getpid(); /* remember this for vFork() */ 889 890 /* 891 * Just in case MAKEOBJDIR wants us to do something tricky. 892 */ 893 Var_Init(); /* Initialize the lists of variables for 894 * parsing arguments */ | 863 machine = utsname.machine; 864#else 865#ifdef MAKE_MACHINE 866 machine = MAKE_MACHINE; 867#else 868 machine = "unknown"; 869#endif 870#endif --- 13 unchanged lines hidden (view full) --- 884 885 myPid = getpid(); /* remember this for vFork() */ 886 887 /* 888 * Just in case MAKEOBJDIR wants us to do something tricky. 889 */ 890 Var_Init(); /* Initialize the lists of variables for 891 * parsing arguments */ |
892 Var_Set(".MAKE.OS", utsname.sysname, VAR_GLOBAL, 0); |
|
895 Var_Set("MACHINE", machine, VAR_GLOBAL, 0); 896 Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL, 0); 897#ifdef MAKE_VERSION 898 Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL, 0); 899#endif 900 Var_Set(".newline", "\n", VAR_GLOBAL, 0); /* handy for :@ loops */ 901 /* 902 * This is the traditional preference for makefiles. --- 79 unchanged lines hidden (view full) --- 982 Var_Set(MAKE_LEVEL, ep, VAR_GLOBAL, 0); 983 snprintf(tmp, sizeof(tmp), "%u", myPid); 984 Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0); 985 snprintf(tmp, sizeof(tmp), "%u", getppid()); 986 Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL, 0); 987 } 988 Job_SetPrefix(); 989 | 893 Var_Set("MACHINE", machine, VAR_GLOBAL, 0); 894 Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL, 0); 895#ifdef MAKE_VERSION 896 Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL, 0); 897#endif 898 Var_Set(".newline", "\n", VAR_GLOBAL, 0); /* handy for :@ loops */ 899 /* 900 * This is the traditional preference for makefiles. --- 79 unchanged lines hidden (view full) --- 980 Var_Set(MAKE_LEVEL, ep, VAR_GLOBAL, 0); 981 snprintf(tmp, sizeof(tmp), "%u", myPid); 982 Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0); 983 snprintf(tmp, sizeof(tmp), "%u", getppid()); 984 Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL, 0); 985 } 986 Job_SetPrefix(); 987 |
988#ifdef USE_META 989 meta_init(); 990#endif |
|
990 /* 991 * First snag any flags out of the MAKE environment variable. 992 * (Note this is *not* MAKEFLAGS since /bin/make uses that and it's 993 * in a different format). 994 */ 995#ifdef POSIX 996 Main_ParseArgLine(getenv("MAKEFLAGS")); 997#else --- 694 unchanged lines hidden (view full) --- 1692void 1693Finish(int errors) 1694 /* number of errors encountered in Make_Make */ 1695{ 1696 Fatal("%d error%s", errors, errors == 1 ? "" : "s"); 1697} 1698 1699/* | 991 /* 992 * First snag any flags out of the MAKE environment variable. 993 * (Note this is *not* MAKEFLAGS since /bin/make uses that and it's 994 * in a different format). 995 */ 996#ifdef POSIX 997 Main_ParseArgLine(getenv("MAKEFLAGS")); 998#else --- 694 unchanged lines hidden (view full) --- 1693void 1694Finish(int errors) 1695 /* number of errors encountered in Make_Make */ 1696{ 1697 Fatal("%d error%s", errors, errors == 1 ? "" : "s"); 1698} 1699 1700/* |
1700 * enunlink -- | 1701 * eunlink -- |
1701 * Remove a file carefully, avoiding directories. 1702 */ 1703int 1704eunlink(const char *file) 1705{ 1706 struct stat st; 1707 1708 if (lstat(file, &st) == -1) --- 225 unchanged lines hidden --- | 1702 * Remove a file carefully, avoiding directories. 1703 */ 1704int 1705eunlink(const char *file) 1706{ 1707 struct stat st; 1708 1709 if (lstat(file, &st) == -1) --- 225 unchanged lines hidden --- |