From 671e18febd45bba01d3d29db7a544d25d1b36a3b Mon Sep 17 00:00:00 2001 From: venomade Date: Thu, 21 May 2026 16:57:22 +0100 Subject: Initial Commit --- Makefile | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Makefile (limited to 'Makefile') 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) -- cgit 1.4.1-2-gfad0