summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1993-04-07 20:40:35 +0000
committerRoland McGrath <roland@redhat.com>1993-04-07 20:40:35 +0000
commit5973c4e97ae1df46ebc5f93335252972c684539c (patch)
tree710e088b2e3535df651a0d1cfb2ec4dd5dfc326d /main.c
parent6dbdf2caa8832429b83394d596a2892951d0c48f (diff)
downloadgunmake-5973c4e97ae1df46ebc5f93335252972c684539c.tar.gz
Formerly main.c.~76~
Diffstat (limited to 'main.c')
-rw-r--r--main.c54
1 files changed, 44 insertions, 10 deletions
diff --git a/main.c b/main.c
index 26efb13..c311044 100644
--- a/main.c
+++ b/main.c
@@ -168,11 +168,15 @@ int no_builtin_rules_flag = 0;
int keep_going_flag;
int default_keep_going_flag = 0;
-/* Nonzero means print working directory
- before starting and after finishing make. */
+/* Nonzero means print directory before starting and when done (-w). */
int print_directory_flag = 0;
+/* Nonzero means ignore print_directory_flag and never print the directory.
+ This is necessary because print_directory_flag is set implicitly. */
+
+int inhibit_print_directory_flag = 0;
+
/* Nonzero means print version information. */
int print_version_flag = 0;
@@ -289,6 +293,9 @@ static struct command_switch switches[] =
{ 'w', flag, (char *) &print_directory_flag, 1, 1, 0, 0, 0,
"print-directory", 0,
"Print the current directory" },
+ { -1, flag, (char *) &inhibit_print_directory_flag, 1, 1, 0, 0, 0,
+ "no-print-directory", 0,
+ "Turn off -w, even if it was turned on implicitly" },
{ 'W', string, (char *) &new_files, 0, 0, 0, 0, 0,
"what-if", "FILE",
"Consider FILE to be infinitely new" },
@@ -601,6 +608,10 @@ main (argc, argv, envp)
if (!silent_flag && (directories != 0 || makelevel > 0))
print_directory_flag = 1;
+ /* Let the user disable that with --no-print-directory. */
+ if (inhibit_print_directory_flag)
+ print_directory_flag = 0;
+
/* Construct the list of include directories to search. */
construct_include_path (include_directories == 0 ? (char **) 0
@@ -1279,12 +1290,18 @@ positive integral argument",
}
p = buf;
- sprintf (buf, " -%c%s", cs->c, arg);
- p += strlen (p);
+
+ if (cs->c != -1)
+ {
+ sprintf (buf, " -%c%s", cs->c, arg);
+ p += strlen (p);
+ }
if (cs->long_name != 0)
{
unsigned int i;
- sprintf (p, ", --%s%s", cs->long_name, arg);
+ sprintf (p, "%s--%s%s",
+ cs->c == -1 ? "" : ", ",
+ cs->long_name, arg);
p += strlen (p);
for (i = 0; i < (sizeof (long_option_aliases) /
sizeof (long_option_aliases[0]));
@@ -1409,7 +1426,7 @@ define_makeflags (all, makefile)
struct flag
{
struct flag *next;
- int c;
+ struct command_switch *switch;
char *arg;
unsigned int arglen;
};
@@ -1418,7 +1435,7 @@ define_makeflags (all, makefile)
#define ADD_FLAG(ARG, LEN) \
do { \
struct flag *new = (struct flag *) alloca (sizeof (struct flag)); \
- new->c = cs->c; \
+ new->switch = cs; \
new->arg = (ARG); \
new->arglen = (LEN); \
new->next = flags; \
@@ -1427,6 +1444,9 @@ define_makeflags (all, makefile)
++flagslen; /* Just a single flag letter. */ \
else \
flagslen += 1 + 1 + 1 + 1 + new->arglen; /* " -x foo" */ \
+ if (cs->c == -1) \
+ /* This switch has no single-letter version, so we use the long. */ \
+ flagslen += 2 + strlen (cs->long_name); \
} while (0)
for (cs = switches; cs->c != '\0'; ++cs)
@@ -1522,8 +1542,15 @@ define_makeflags (all, makefile)
*p++ = '-';
do
{
- /* Add the flag letter to the string. */
- *p++ = flags->c;
+ /* Add the flag letter or name to the string. */
+ if (flags->switch->c == -1)
+ {
+ *p++ = '-';
+ strcpy (p, flags->switch->long_name);
+ p += strlen (p);
+ }
+ else
+ *p++ = flags->c;
if (flags->arg != 0)
{
/* A flag that takes an optional argument which in this case
@@ -1533,7 +1560,7 @@ define_makeflags (all, makefile)
if (flags->arglen > 0)
{
/* Add its argument too. */
- *p++ = ' ';
+ *p++ = flags->switch->c == -1 ? '=' : ' ';
bcopy (flags->arg, p, flags->arglen);
p += flags->arglen;
}
@@ -1541,6 +1568,13 @@ define_makeflags (all, makefile)
*p++ = ' ';
*p++ = '-';
}
+ else if (flags->switch->c == -1)
+ {
+ /* Long options must each go in their own word,
+ so we write the following space and dash. */
+ *p++ = ' ';
+ *p++ = '-';
+ }
flags = flags->next;
} while (flags != 0);