diff options
author | Roland McGrath <roland@redhat.com> | 1994-07-25 23:33:26 +0000 |
---|---|---|
committer | Roland McGrath <roland@redhat.com> | 1994-07-25 23:33:26 +0000 |
commit | 021ea7e61c9e70ec8041a03cc32f6064272ae77e (patch) | |
tree | b87dea47613f8cb87ba99fc643d9db469f945d82 /main.c | |
parent | f663464925a9a79bf0ec5e91ebf2e4cfd056b9eb (diff) | |
download | make-021ea7e61c9e70ec8041a03cc32f6064272ae77e.tar.gz |
(directory_before_chdir): New variable, moved out of main (was local).
(main) [__MSDOS__]: Look for \ or : to delimit last component of PROGRAM.
Don't frob ARGV[0] before setting MAKE_COMMAND variable.
(die): Change back to `directory_before_chdir' before dying.
Part of MSDOS/GO32 port from DJ Delorie <dj@ctron.com>.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -312,6 +312,10 @@ struct stringlist *other_args = 0; char *program; +/* Our current directory before processing any -C options. */ + +char *directory_before_chdir; + /* Our current directory after processing all -C options. */ char *starting_directory; @@ -394,7 +398,6 @@ main (argc, argv, envp) register struct dep *lastgoal; struct dep *read_makefiles; PATH_VAR (current_directory); - char *directory_before_chdir; default_goal_file = 0; reading_filename = 0; @@ -464,6 +467,12 @@ main (argc, argv, envp) else { program = rindex (argv[0], '/'); +#ifdef __MSDOS__ + if (program == 0) + program = rindex (argv[0], '\\'); + if (program == 0) + program = rindex (argv[0], ':'); +#endif if (program == 0) program = argv[0]; else @@ -601,6 +610,7 @@ main (argc, argv, envp) } free (cmd_defs); +#ifndef __MSDOS__ /* Set the "MAKE_COMMAND" variable to the name we were invoked with. (If it is a relative pathname with a slash, prepend our directory name so the result will run the same program regardless of the current dir. @@ -610,6 +620,7 @@ main (argc, argv, envp) if (current_directory[0] != '\0' && argv[0] != 0 && argv[0][0] != '/' && index (argv[0], '/') != 0) argv[0] = concat (current_directory, "/", argv[0]); +#endif (void) define_variable ("MAKE_COMMAND", 12, argv[0], o_default, 0); @@ -1755,6 +1766,13 @@ die (status) dying = 1; + /* Try to move back to the original directory. This is essential on + MS-DOS (where there is really only one process), and on Unix it + puts core files in the original directory instead of the -C + directory. */ + if (directory_before_chdir != 0) + chdir (directory_before_chdir); + if (print_version_flag) print_version (); |