aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/build.c b/build.c
index 600ac92..085722d 100644
--- a/build.c
+++ b/build.c
@@ -1,5 +1,6 @@
#include <ctype.h>
#include <err.h>
+#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -124,8 +125,11 @@ main(int argc, char *argv[])
dd("%s: target '%s'\n", argv[i], tgt);
if (stat(argv[i], &sb))
err(1, argv[i]);
- if (stat(tgt, &ssb))
+ if (stat(tgt, &ssb)) {
+ if (errno == ENOENT)
+ goto build;
err(1, tgt);
+ }
if (sb.st_mtime > ssb.st_mtime) {
d("%s: %s is modified, building\n",
argv[i], argv[i]);
@@ -141,8 +145,13 @@ main(int argc, char *argv[])
dd("%s: depend '%s'\n",
argv[i], d);
- if (stat(d, &sb))
- err(1, d);
+ if (stat(d, &sb)) {
+ if (errno != ENOENT)
+ err(1, d);
+ fprintf(stderr, "%s: dependency %s does not "
+ "exist\n", argv[0], d);
+ continue;
+ }
free(d);
if (sb.st_mtime > ssb.st_mtime) {
d("%s: %s is modified, building\n",