aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-07-09 15:40:24 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-07-09 15:41:52 +0200
commit72c344521267378fd82e675a7c2f40a9ae25287e (patch)
tree5e4463fcdea1de383ee0cfef0d4d0dd389b2bef6
parent3019c48804fb43f97d5c8e8ee15b5ae13ab1c4a9 (diff)
downloadbuild-72c344521267378fd82e675a7c2f40a9ae25287e.tar.gz
Handle non-existent target, dependencies
-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",