summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--codegen.c7
2 files changed, 11 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 79e825b..7f58e16 100644
--- a/Makefile
+++ b/Makefile
@@ -1,17 +1,19 @@
CFLAGS=-std=c11 -g -fno-common -Wall -Wno-switch
-CFLAGS+=-DDIETC_ROOT="\"$(PWD)\""
# CFLAGS=$(CFLAGS) -fsanitize=address
SRCS=$(wildcard *.c)
OBJS=$(addprefix build/,$(SRCS:.c=.o))
dietc: $(OBJS)
- $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
+ $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)
-build/%.o: %.c chibicc.h
+build/%.o: %.c chibicc.h scripts/dietc_helpers.h.bytes
@mkdir -p build
$(CC) $(CFLAGS) -c $(word 1,$^) -o $@
+scripts/%.bytes: scripts/%
+ python3 -c "print(', '.join([hex(ord(c)) for c in open('$^', 'r').read()]))" > $@
+
# Misc.
clean:
diff --git a/codegen.c b/codegen.c
index 0807add..b939531 100644
--- a/codegen.c
+++ b/codegen.c
@@ -912,6 +912,11 @@ static void emit_text(Obj *prog) {
}
}
+static char DIETC_HELPERS_H[] = {
+#include "scripts/dietc_helpers.h.bytes"
+ , 0x00
+};
+
void codegen(Obj *prog, FILE *out) {
TYPE_BUFFER = tmpfile();
MAIN_BUFFER = tmpfile();
@@ -924,7 +929,7 @@ void codegen(Obj *prog, FILE *out) {
emit_text(prog);
pop_buffer(MAIN_BUFFER);
- fprintf(out, "#include \"%s/scripts/dietc_helpers.h\"\n", DIETC_ROOT);
+ fprintf(out, "%s\n", DIETC_HELPERS_H);
flush_buffer(out, TYPE_BUFFER);
flush_buffer(out, MAIN_BUFFER);
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback