diff options
author | Elliott Hughes <enh@google.com> | 2019-01-29 17:20:00 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2019-01-29 17:20:00 -0800 |
commit | cc165f4be9a6ea8f77ff4533786bcddde1d13fdf (patch) | |
tree | e9b88828241ba7f3d423a3479416c585f35466cf | |
parent | c3c7c1370e9a9969bdcaf2018c5e62096ac15c55 (diff) | |
download | one-true-awk-cc165f4be9a6ea8f77ff4533786bcddde1d13fdf.tar.gz |
maketab: support build systems with read-only source.
If your generated files are considered outputs that live elsewhere, you
need a way to tell maketab where ytab.h actually is.
Specifically, I'm trying to avoid checking in generated files in
Android's AOSP tree's copy of one-true-awk.
-rw-r--r-- | makefile | 2 | ||||
-rw-r--r-- | maketab.c | 8 |
2 files changed, 7 insertions, 3 deletions
@@ -67,7 +67,7 @@ y%.c y%.h: awk.h proto.h awkgram.y ytab.h: ytab.c proctab.c: maketab - ./maketab >proctab.c + ./maketab ytab.h >proctab.c maketab: ytab.h maketab.c $(CC) $(CFLAGS) maketab.c -o maketab @@ -125,8 +125,12 @@ int main(int argc, char *argv[]) for (i = SIZE; --i >= 0; ) names[i] = ""; - if ((fp = fopen("ytab.h", "r")) == NULL) { - fprintf(stderr, "maketab can't open ytab.h!\n"); + if (argc != 2) { + fprintf(stderr, "usage: maketab YTAB_H\n"); + exit(1); + } + if ((fp = fopen(argv[1], "r")) == NULL) { + fprintf(stderr, "maketab can't open %s!\n", argv[1]); exit(1); } printf("static char *printname[%d] = {\n", SIZE); |