diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e2efd9d --- /dev/null +++ b/Makefile @@ -0,0 +1,43 @@ +TARGET := bot + +# Directories +SRC_DIR := src +INC_DIR := include +WREN_DIR := lib/wren + +# --- Compiler / Flags --- +CC := gcc +CFLAGS := -I$(INC_DIR) -I$(WREN_DIR) -Wall -Wextra -O2 +LDFLAGS := -L$(WREN_DIR) -Wl,-rpath,$(WREN_DIR) -lwren -ldiscord -lcurl -lpthread + +# --- Automatic Source & Object Discovery --- +SRC := $(shell find $(SRC_DIR) -type f -name '*.c') +OBJ := $(SRC:.c=.o) + +# --- Default Target --- +all: $(TARGET) + +# Link all objects into final binary +$(TARGET): $(OBJ) + @echo "๐Ÿ”— Linking $(TARGET)" + $(CC) $(OBJ) -o $@ $(LDFLAGS) + +# Compile each C source file into an object +%.o: %.c + @echo "๐Ÿงฑ Compiling $<" + $(CC) $(CFLAGS) -c $< -o $@ + +# --- Utility Targets --- +run: all + ./$(TARGET) + +clean: + @echo "๐Ÿงน Cleaning build files" + rm -f $(OBJ) $(TARGET) + +# --- Optional Debug Build --- +debug: CFLAGS += -g -DDEBUG +debug: clean all + +.PHONY: all clean run debug +