commit - 03656db54f9d24e0e5c6344b159da1eb3d78932f
commit + 56b8970e016ef878addb3a2bb6b965bab0618dd4
blob - c61a0ebec9766c51e3d0c5f54733206a010e1c36
blob + fae3ab7b588ebd6ec2fca7724642b14d063bbc34
--- make/make.c
+++ make/make.c
usage ()
{
- fprintf (stderr, "usage: %s [-pv] [target...]\n", m_make.value);
+ fprintf (stderr, "usage: %s [-pv] [-C dir] [target...]\n", m_make.value);
return 1;
}
struct scope *sc;
struct path *path;
struct macro *m;
- char *s;
+ char *s, *cd = NULL;
int i, option, pr = 0, n = 0;
m_dmake.value = m_make.value = argv[0];
str_reset ();
- while ((option = getopt (argc, argv, "pv")) != -1) {
- str_push (' ');
- str_push ('-');
- str_push (option);
+ while ((option = getopt (argc, argv, "pvC:")) != -1) {
switch (option) {
case 'p':
+ str_push_str (" -p");
pr = 1;
break;
case 'v':
+ str_push_str (" -v");
verbose = 1;
break;
+ case 'C':
+ cd = optarg;
+ break;
case '?':
return usage ();
default:
}
}
+ if (cd != NULL && chdir (cd) != 0)
+ err (1, "chdir()");
+
argv += optind;
argc -= optind;