diff options
author | harti <harti@FreeBSD.org> | 2005-05-12 14:35:01 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2005-05-12 14:35:01 +0000 |
commit | 00f50de80b1cf3480968e312fb7c6a2de7e02434 (patch) | |
tree | 69906fd177e8695f5b9f11b64d746e2d7dca4593 /usr.bin/make/main.c | |
parent | ce844954aeb4f5280f8e31cdc04dfc235228e13c (diff) | |
download | FreeBSD-src-00f50de80b1cf3480968e312fb7c6a2de7e02434.zip FreeBSD-src-00f50de80b1cf3480968e312fb7c6a2de7e02434.tar.gz |
Reshuffle functions to get rid of prototypes.
Submitted by: Max Okumoto <okumoto@ucsd.edu> (7.235)
Diffstat (limited to 'usr.bin/make/main.c')
-rw-r--r-- | usr.bin/make/main.c | 210 |
1 files changed, 102 insertions, 108 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index ea4253b..cb04589 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -140,13 +140,25 @@ Lst envFirstVars = Lst_Initializer(envFirstVars); Boolean jobsRunning; /* TRUE if the jobs might be running */ char *chdir_verify_path(const char *, char *); -static int ReadMakefile(const char *); -static void usage(void); static char *curdir; /* startup directory */ static char *objdir; /* where we chdir'ed to */ /** + * Exit with usage message. + */ +static void +usage(void) +{ + fprintf(stderr, + "usage: make [-BPSXeiknqrstv] [-C directory] [-D variable]\n" + "\t[-d flags] [-E variable] [-f makefile] [-I directory]\n" + "\t[-j max_jobs] [-m directory] [-V variable]\n" + "\t[variable=value] [target ...]\n"); + exit(2); +} + +/** * MFLAGS_append * Append a flag with an optional argument to MAKEFLAGS and MFLAGS */ @@ -223,6 +235,94 @@ Main_ParseWarn(const char *arg, int iscmd) } /** + * Open and parse the given makefile. + * + * Results: + * TRUE if ok. FALSE if couldn't open file. + */ +static Boolean +ReadMakefile(const char p[]) +{ + char *fname; /* makefile to read */ + FILE *stream; + char *name, path[MAXPATHLEN]; + char *MAKEFILE; + int setMAKEFILE; + + /* XXX - remove this once constification is done */ + fname = estrdup(p); + + if (!strcmp(fname, "-")) { + Parse_File("(stdin)", stdin); + Var_Set("MAKEFILE", "", VAR_GLOBAL); + } else { + setMAKEFILE = strcmp(fname, ".depend"); + + /* if we've chdir'd, rebuild the path name */ + if (curdir != objdir && *fname != '/') { + snprintf(path, MAXPATHLEN, "%s/%s", curdir, fname); + /* + * XXX The realpath stuff breaks relative includes + * XXX in some cases. The problem likely is in + * XXX parse.c where it does special things in + * XXX ParseDoInclude if the file is relateive + * XXX or absolute and not a system file. There + * XXX it assumes that if the current file that's + * XXX being included is absolute, that any files + * XXX that it includes shouldn't do the -I path + * XXX stuff, which is inconsistant with historical + * XXX behavior. However, I can't pentrate the mists + * XXX further, so I'm putting this workaround in + * XXX here until such time as the underlying bug + * XXX can be fixed. + */ +#if THIS_BREAKS_THINGS + if (realpath(path, path) != NULL && + (stream = fopen(path, "r")) != NULL) { + MAKEFILE = fname; + fname = path; + goto found; + } + } else if (realpath(fname, path) != NULL) { + MAKEFILE = fname; + fname = path; + if ((stream = fopen(fname, "r")) != NULL) + goto found; + } +#else + if ((stream = fopen(path, "r")) != NULL) { + MAKEFILE = fname; + fname = path; + goto found; + } + } else { + MAKEFILE = fname; + if ((stream = fopen(fname, "r")) != NULL) + goto found; + } +#endif + /* look in -I and system include directories. */ + name = Path_FindFile(fname, &parseIncPath); + if (!name) + name = Path_FindFile(fname, &sysIncPath); + if (!name || !(stream = fopen(name, "r"))) + return (FALSE); + MAKEFILE = fname = name; + /* + * set the MAKEFILE variable desired by System V fans -- the + * placement of the setting here means it gets set to the last + * makefile specified, as it is set by SysV make. + */ +found: + if (setMAKEFILE) + Var_Set("MAKEFILE", MAKEFILE, VAR_GLOBAL); + Parse_File(fname, stream); + fclose(stream); + } + return (TRUE); +} + +/** * MainParseArgs * Parse a given argument vector. Called from main() and from * Main_ParseArgLine() when the .MAKEFLAGS target is used. @@ -1005,109 +1105,3 @@ main(int argc, char **argv) return (0); } -/** - * ReadMakefile - * Open and parse the given makefile. - * - * Results: - * TRUE if ok. FALSE if couldn't open file. - * - * Side Effects: - * lots - */ -static Boolean -ReadMakefile(const char *p) -{ - char *fname; /* makefile to read */ - FILE *stream; - char *name, path[MAXPATHLEN]; - char *MAKEFILE; - int setMAKEFILE; - - /* XXX - remove this once constification is done */ - fname = estrdup(p); - - if (!strcmp(fname, "-")) { - Parse_File("(stdin)", stdin); - Var_Set("MAKEFILE", "", VAR_GLOBAL); - } else { - setMAKEFILE = strcmp(fname, ".depend"); - - /* if we've chdir'd, rebuild the path name */ - if (curdir != objdir && *fname != '/') { - snprintf(path, MAXPATHLEN, "%s/%s", curdir, fname); - /* - * XXX The realpath stuff breaks relative includes - * XXX in some cases. The problem likely is in - * XXX parse.c where it does special things in - * XXX ParseDoInclude if the file is relateive - * XXX or absolute and not a system file. There - * XXX it assumes that if the current file that's - * XXX being included is absolute, that any files - * XXX that it includes shouldn't do the -I path - * XXX stuff, which is inconsistant with historical - * XXX behavior. However, I can't pentrate the mists - * XXX further, so I'm putting this workaround in - * XXX here until such time as the underlying bug - * XXX can be fixed. - */ -#if THIS_BREAKS_THINGS - if (realpath(path, path) != NULL && - (stream = fopen(path, "r")) != NULL) { - MAKEFILE = fname; - fname = path; - goto found; - } - } else if (realpath(fname, path) != NULL) { - MAKEFILE = fname; - fname = path; - if ((stream = fopen(fname, "r")) != NULL) - goto found; - } -#else - if ((stream = fopen(path, "r")) != NULL) { - MAKEFILE = fname; - fname = path; - goto found; - } - } else { - MAKEFILE = fname; - if ((stream = fopen(fname, "r")) != NULL) - goto found; - } -#endif - /* look in -I and system include directories. */ - name = Path_FindFile(fname, &parseIncPath); - if (!name) - name = Path_FindFile(fname, &sysIncPath); - if (!name || !(stream = fopen(name, "r"))) - return (FALSE); - MAKEFILE = fname = name; - /* - * set the MAKEFILE variable desired by System V fans -- the - * placement of the setting here means it gets set to the last - * makefile specified, as it is set by SysV make. - */ -found: - if (setMAKEFILE) - Var_Set("MAKEFILE", MAKEFILE, VAR_GLOBAL); - Parse_File(fname, stream); - fclose(stream); - } - return (TRUE); -} - -/* - * usage -- - * exit with usage message - */ -static void -usage(void) -{ - fprintf(stderr, "%s\n%s\n%s\n%s\n", -"usage: make [-ABPSXeiknqrstv] [-C directory] [-D variable] [-d flags]", -" [-E variable] [-f makefile] [-I directory] [-j max_jobs]", -" [-m directory] [-V variable] [variable=value] [-x warn_flag]", -" [target ...]"); - exit(2); -} |