diff options
| author | venomade <venomade@venomade.com> | 2026-05-21 16:57:22 +0100 |
|---|---|---|
| committer | venomade <venomade@venomade.com> | 2026-05-21 16:57:22 +0100 |
| commit | 671e18febd45bba01d3d29db7a544d25d1b36a3b (patch) | |
| tree | 61bb6654df52df2f2c3d77c9169ea4e0b84177f3 /Makefile | |
Initial Commit main
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ad57dfc --- /dev/null +++ b/Makefile @@ -0,0 +1,42 @@ +CC := clang +LUAC := luac + +CFLAGS := -Wall -Wextra -O2 -std=c11 -MMD -MP +CPPFLAGS := -I/opt/homebrew/include + +LDFLAGS := -L/opt/homebrew/lib +LDLIBS := /opt/homebrew/lib/liblua.a -lncurses -lm + +TARGET := lume +SRC := main.c lua_bytecode.c +OBJ := $(SRC:.c=.o) +DEP := $(OBJ:.o=.d) + +.PHONY: all clean run + +all: $(TARGET) + +lua_bytecode.c: main.lua + @echo "Compiling Lua to bytecode..." + $(LUAC) -o main.luac main.lua + @echo "Generating C array..." + #@echo 'const char lua_bytecode[] = {' > lua_bytecode.c + #@od -An -tx1 -v main.luac | sed 's/ *\([0-9a-f][0-9a-f]\)/0x\1,/g' | sed 's/,$$//' >> lua_bytecode.c + @xxd -i main.luac > lua_bytecode.c + #@echo '};' >> lua_bytecode.c + #@echo 'const unsigned int lua_bytecode_len = sizeof(lua_bytecode);' >> lua_bytecode.c + @rm -f main.luac + +$(TARGET): $(OBJ) + $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS) + +%.o: %.c + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ + +-include $(DEP) + +clean: + rm -f $(OBJ) $(TARGET) $(DEP) lua_bytecode.c main.luac + +run: $(TARGET) + ./$(TARGET) |
