aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/build.c b/build.c
index 6817b62..8b4e060 100644
--- a/build.c
+++ b/build.c
@@ -32,7 +32,7 @@ main(int argc, char *argv[])
{
char *b, buf[MAXBUF], *cmd[MAXCMDS], *d, *dep, *name, *tgt;
FILE *fp;
- int c, dflag, i, icmd, j;
+ int c, dflag, fflag, i, icmd, j;
struct stat sb, ssb;
/* allocate memory */
@@ -49,12 +49,15 @@ main(int argc, char *argv[])
/* process arguments */
name = argv[0];
- dflag = 0;
- while ((c = getopt(argc, argv, "d")) != -1)
+ dflag = fflag = 0;
+ while ((c = getopt(argc, argv, "df")) != -1)
switch (c) {
case 'd':
dflag++;
break;
+ case 'f':
+ fflag = 1;
+ break;
default:
fprintf(stderr, USAGE);
return 1;
@@ -112,7 +115,7 @@ main(int argc, char *argv[])
continue;
}
- if (!*tgt)
+ if (fflag || !*tgt)
goto build;
/* compare source > target */
@@ -155,7 +158,7 @@ build:
/* run commands */
buf[0] = 0;
for (j = 0; j < icmd; j++) {
- fprintf(stderr, "$ %s\n", cmd[j]);
+ fprintf(stderr, "%s: $ %s\n", argv[i], cmd[j]);
strncat(buf, cmd[j], MAXBUF-1);
strncat(buf, "\n", MAXBUF-1);
}