# Compiler
CC = x86_64-w64-mingw32-gcc
CFLAGS = -Wall -w -s -IInclude
LFLAGS = -liphlpapi -lnetapi32 -lwininet -lws2_32 -lwinhttp
DFLAGS = -D_DEBUG

# Directories
SRC_FILES := *.c
BUILD_DIR = build

# Ensure build directory exists
$(shell mkdir -p $(BUILD_DIR))

# Build Targets
all: exe dll

exe: $(BUILD_DIR)/cazalla.exe

dll: $(BUILD_DIR)/cazalla.dll

debug: debug_exe debug_dll

debug_exe: $(BUILD_DIR)/cazalla-debug.exe

debug_dll: $(BUILD_DIR)/cazalla-debug.dll

# Executable Target
$(BUILD_DIR)/cazalla.exe: $(SRC_FILES)
	$(CC) $^ -o $@ $(CFLAGS) -D_EXE $(LFLAGS)

$(BUILD_DIR)/cazalla-debug.exe: $(SRC_FILES)
	$(CC) $^ -o $@ $(CFLAGS) -D_EXE $(LFLAGS) $(DFLAGS)

# DLL Target
$(BUILD_DIR)/cazalla.dll: $(SRC_FILES)
	$(CC) $^ -o $@ -shared -D_DLL $(CFLAGS) $(LFLAGS)

$(BUILD_DIR)/cazalla-debug.dll: $(SRC_FILES)
	$(CC) $^ -o $@ -shared -D_DLL $(CFLAGS) $(LFLAGS) $(DFLAGS)

# Clean up
clean:
	rm -rf $(BUILD_DIR)
