main.c (138510) | main.c (138512) |
---|---|
1/* 2 * Copyright (c) 1988, 1989, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (c) 1989 by Berkeley Softworks 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Adam de Boor. --- 32 unchanged lines hidden (view full) --- 41#ifndef lint 42#if 0 43static char copyright[] = 44"@(#) Copyright (c) 1988, 1989, 1990, 1993\n\ 45 The Regents of the University of California. All rights reserved.\n"; 46#endif 47#endif /* not lint */ 48#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1988, 1989, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (c) 1989 by Berkeley Softworks 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Adam de Boor. --- 32 unchanged lines hidden (view full) --- 41#ifndef lint 42#if 0 43static char copyright[] = 44"@(#) Copyright (c) 1988, 1989, 1990, 1993\n\ 45 The Regents of the University of California. All rights reserved.\n"; 46#endif 47#endif /* not lint */ 48#include <sys/cdefs.h> |
49__FBSDID("$FreeBSD: head/usr.bin/make/main.c 138510 2004-12-07 10:14:16Z harti $"); | 49__FBSDID("$FreeBSD: head/usr.bin/make/main.c 138512 2004-12-07 13:49:13Z harti $"); |
50 51/*- 52 * main.c -- 53 * The main file for this entire program. Exit routines etc 54 * reside here. 55 * 56 * Utility functions defined in this file: 57 * Main_ParseArgLine Takes a line of arguments, breaks them and --- 30 unchanged lines hidden (view full) --- 88#include "pathnames.h" 89 90#define WANT_ENV_MKLVL 1 91#define MKLVL_MAXVAL 500 92#define MKLVL_ENVVAR "__MKLVL__" 93 94#define MAKEFLAGS ".MAKEFLAGS" 95 | 50 51/*- 52 * main.c -- 53 * The main file for this entire program. Exit routines etc 54 * reside here. 55 * 56 * Utility functions defined in this file: 57 * Main_ParseArgLine Takes a line of arguments, breaks them and --- 30 unchanged lines hidden (view full) --- 88#include "pathnames.h" 89 90#define WANT_ENV_MKLVL 1 91#define MKLVL_MAXVAL 500 92#define MKLVL_ENVVAR "__MKLVL__" 93 94#define MAKEFLAGS ".MAKEFLAGS" 95 |
96Lst create; /* Targets to be made */ | 96Lst *create; /* Targets to be made */ |
97time_t now; /* Time at start of make */ 98GNode *DEFAULT; /* .DEFAULT node */ 99Boolean allPrecious; /* .PRECIOUS given on line by itself */ 100 101static Boolean noBuiltins; /* -r flag */ | 97time_t now; /* Time at start of make */ 98GNode *DEFAULT; /* .DEFAULT node */ 99Boolean allPrecious; /* .PRECIOUS given on line by itself */ 100 101static Boolean noBuiltins; /* -r flag */ |
102static Lst makefiles; /* ordered list of makefiles to read */ | 102static Lst *makefiles; /* ordered list of makefiles to read */ |
103static Boolean expandVars; /* fully expand printed variables */ | 103static Boolean expandVars; /* fully expand printed variables */ |
104static Lst variables; /* list of variables to print */ | 104static Lst *variables; /* list of variables to print */ |
105int maxJobs; /* -j argument */ 106static Boolean forceJobs; /* -j argument given */ 107Boolean compatMake; /* -B argument */ 108Boolean debug; /* -d flag */ 109Boolean noExecute; /* -n flag */ 110Boolean keepgoing; /* -k flag */ 111Boolean queryFlag; /* -q flag */ 112Boolean touchFlag; /* -t flag */ 113Boolean usePipes; /* !-P flag */ 114Boolean ignoreErrors; /* -i flag */ 115Boolean beSilent; /* -s flag */ 116Boolean beVerbose; /* -v flag */ 117Boolean oldVars; /* variable substitution style */ 118Boolean checkEnvFirst; /* -e flag */ | 105int maxJobs; /* -j argument */ 106static Boolean forceJobs; /* -j argument given */ 107Boolean compatMake; /* -B argument */ 108Boolean debug; /* -d flag */ 109Boolean noExecute; /* -n flag */ 110Boolean keepgoing; /* -k flag */ 111Boolean queryFlag; /* -q flag */ 112Boolean touchFlag; /* -t flag */ 113Boolean usePipes; /* !-P flag */ 114Boolean ignoreErrors; /* -i flag */ 115Boolean beSilent; /* -s flag */ 116Boolean beVerbose; /* -v flag */ 117Boolean oldVars; /* variable substitution style */ 118Boolean checkEnvFirst; /* -e flag */ |
119Lst envFirstVars; /* (-E) vars to override from env */ | 119Lst *envFirstVars; /* (-E) vars to override from env */ |
120Boolean jobsRunning; /* TRUE if the jobs might be running */ 121 122static void MainParseArgs(int, char **); 123char * chdir_verify_path(char *, char *); 124static int ReadMakefile(void *, void *); 125static void usage(void); 126 127static char *curdir; /* startup directory */ --- 317 unchanged lines hidden (view full) --- 445 * 0. 446 * 447 * Side Effects: 448 * The program exits when done. Targets are created. etc. etc. etc. 449 */ 450int 451main(int argc, char **argv) 452{ | 120Boolean jobsRunning; /* TRUE if the jobs might be running */ 121 122static void MainParseArgs(int, char **); 123char * chdir_verify_path(char *, char *); 124static int ReadMakefile(void *, void *); 125static void usage(void); 126 127static char *curdir; /* startup directory */ --- 317 unchanged lines hidden (view full) --- 445 * 0. 446 * 447 * Side Effects: 448 * The program exits when done. Targets are created. etc. etc. etc. 449 */ 450int 451main(int argc, char **argv) 452{ |
453 Lst targs; /* target nodes to create -- passed to Make_Init */ | 453 Lst *targs; /* target nodes to create -- passed to Make_Init */ |
454 Boolean outOfDate = TRUE; /* FALSE if all targets up to date */ 455 struct stat sa; 456 char *p, *p1, *path, *pathp; 457 char mdpath[MAXPATHLEN]; 458 char obpath[MAXPATHLEN]; 459 char cdpath[MAXPATHLEN]; 460 char *machine = getenv("MACHINE"); 461 char *machine_arch = getenv("MACHINE_ARCH"); 462 char *machine_cpu = getenv("MACHINE_CPU"); | 454 Boolean outOfDate = TRUE; /* FALSE if all targets up to date */ 455 struct stat sa; 456 char *p, *p1, *path, *pathp; 457 char mdpath[MAXPATHLEN]; 458 char obpath[MAXPATHLEN]; 459 char cdpath[MAXPATHLEN]; 460 char *machine = getenv("MACHINE"); 461 char *machine_arch = getenv("MACHINE_ARCH"); 462 char *machine_cpu = getenv("MACHINE_CPU"); |
463 Lst sysMkPath; /* Path of sys.mk */ | 463 Lst *sysMkPath; /* Path of sys.mk */ |
464 char *cp = NULL, *start; 465 /* avoid faults on read-only strings */ 466 static char syspath[] = _PATH_DEFSYSPATH; 467 468 { 469 /* 470 * Catch SIGCHLD so that we get kicked out of select() when we 471 * need to look at a child. This is only known to matter for the --- 232 unchanged lines hidden (view full) --- 704 time(&now); 705 706 /* 707 * Set up the .TARGETS variable to contain the list of targets to be 708 * created. If none specified, make the variable empty -- the parser 709 * will fill the thing in with the default or .MAIN target. 710 */ 711 if (!Lst_IsEmpty(create)) { | 464 char *cp = NULL, *start; 465 /* avoid faults on read-only strings */ 466 static char syspath[] = _PATH_DEFSYSPATH; 467 468 { 469 /* 470 * Catch SIGCHLD so that we get kicked out of select() when we 471 * need to look at a child. This is only known to matter for the --- 232 unchanged lines hidden (view full) --- 704 time(&now); 705 706 /* 707 * Set up the .TARGETS variable to contain the list of targets to be 708 * created. If none specified, make the variable empty -- the parser 709 * will fill the thing in with the default or .MAIN target. 710 */ 711 if (!Lst_IsEmpty(create)) { |
712 LstNode ln; | 712 LstNode *ln; |
713 714 for (ln = Lst_First(create); ln != NULL; ln = Lst_Succ(ln)) { 715 char *name = Lst_Datum(ln); 716 717 Var_Append(".TARGETS", name, VAR_GLOBAL); 718 } 719 } else 720 Var_Set(".TARGETS", "", VAR_GLOBAL); --- 18 unchanged lines hidden (view full) --- 739 } 740 741 /* 742 * Read in the built-in rules first, followed by the specified 743 * makefile, if it was (makefile != (char *) NULL), or the default 744 * Makefile and makefile, in that order, if it wasn't. 745 */ 746 if (!noBuiltins) { | 713 714 for (ln = Lst_First(create); ln != NULL; ln = Lst_Succ(ln)) { 715 char *name = Lst_Datum(ln); 716 717 Var_Append(".TARGETS", name, VAR_GLOBAL); 718 } 719 } else 720 Var_Set(".TARGETS", "", VAR_GLOBAL); --- 18 unchanged lines hidden (view full) --- 739 } 740 741 /* 742 * Read in the built-in rules first, followed by the specified 743 * makefile, if it was (makefile != (char *) NULL), or the default 744 * Makefile and makefile, in that order, if it wasn't. 745 */ 746 if (!noBuiltins) { |
747 LstNode ln; | 747 LstNode *ln; |
748 749 sysMkPath = Lst_Init(); 750 Dir_Expand(_PATH_DEFSYSMK, sysIncPath, sysMkPath); 751 if (Lst_IsEmpty(sysMkPath)) 752 Fatal("make: no system rules (%s).", _PATH_DEFSYSMK); 753 ln = Lst_Find(sysMkPath, NULL, ReadMakefile); 754 if (ln != NULL) 755 Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); 756 } 757 758 if (!Lst_IsEmpty(makefiles)) { | 748 749 sysMkPath = Lst_Init(); 750 Dir_Expand(_PATH_DEFSYSMK, sysIncPath, sysMkPath); 751 if (Lst_IsEmpty(sysMkPath)) 752 Fatal("make: no system rules (%s).", _PATH_DEFSYSMK); 753 ln = Lst_Find(sysMkPath, NULL, ReadMakefile); 754 if (ln != NULL) 755 Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); 756 } 757 758 if (!Lst_IsEmpty(makefiles)) { |
759 LstNode ln; | 759 LstNode *ln; |
760 761 ln = Lst_Find(makefiles, NULL, ReadMakefile); 762 if (ln != NULL) 763 Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); 764 } else if (!ReadMakefile("BSDmakefile", NULL)) 765 if (!ReadMakefile("makefile", NULL)) 766 ReadMakefile("Makefile", NULL); 767 --- 43 unchanged lines hidden (view full) --- 811 Suff_DoPaths(); 812 813 /* print the initial graph, if the user requested it */ 814 if (DEBUG(GRAPH1)) 815 Targ_PrintGraph(1); 816 817 /* print the values of any variables requested by the user */ 818 if (!Lst_IsEmpty(variables)) { | 760 761 ln = Lst_Find(makefiles, NULL, ReadMakefile); 762 if (ln != NULL) 763 Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); 764 } else if (!ReadMakefile("BSDmakefile", NULL)) 765 if (!ReadMakefile("makefile", NULL)) 766 ReadMakefile("Makefile", NULL); 767 --- 43 unchanged lines hidden (view full) --- 811 Suff_DoPaths(); 812 813 /* print the initial graph, if the user requested it */ 814 if (DEBUG(GRAPH1)) 815 Targ_PrintGraph(1); 816 817 /* print the values of any variables requested by the user */ 818 if (!Lst_IsEmpty(variables)) { |
819 LstNode ln; | 819 LstNode *ln; |
820 821 for (ln = Lst_First(variables); ln != NULL; 822 ln = Lst_Succ(ln)) { 823 char *value; 824 if (expandVars) { 825 p1 = emalloc(strlen(Lst_Datum(ln)) + 1 + 3); 826 /* This sprintf is safe, because of the malloc above */ 827 sprintf(p1, "${%s}", (char *)Lst_Datum(ln)); --- 306 unchanged lines hidden --- | 820 821 for (ln = Lst_First(variables); ln != NULL; 822 ln = Lst_Succ(ln)) { 823 char *value; 824 if (expandVars) { 825 p1 = emalloc(strlen(Lst_Datum(ln)) + 1 + 3); 826 /* This sprintf is safe, because of the malloc above */ 827 sprintf(p1, "${%s}", (char *)Lst_Datum(ln)); --- 306 unchanged lines hidden --- |