70 lines
1.6 KiB
Makefile
70 lines
1.6 KiB
Makefile
|
|
# Makefile for Cordle - C90 Wordle Game
|
||
|
|
|
||
|
|
# Compiler and flags
|
||
|
|
CC = gcc
|
||
|
|
CFLAGS = -std=c90 -pedantic -Wpedantic -Wall -Wextra
|
||
|
|
LDFLAGS = -lncurses
|
||
|
|
|
||
|
|
# Directories
|
||
|
|
SRC_DIR = src
|
||
|
|
INCLUDE_DIR = include
|
||
|
|
BUILD_DIR = build
|
||
|
|
INSTALL_DIR = /usr/local
|
||
|
|
|
||
|
|
# Source files
|
||
|
|
SRCS = $(SRC_DIR)/main.c $(SRC_DIR)/game.c $(SRC_DIR)/ui.c $(SRC_DIR)/words.c
|
||
|
|
OBJS = $(SRCS:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o)
|
||
|
|
|
||
|
|
# Target executable
|
||
|
|
TARGET = $(BUILD_DIR)/cordle
|
||
|
|
|
||
|
|
# Default target
|
||
|
|
all: $(TARGET) wordlists
|
||
|
|
|
||
|
|
# Create build directory
|
||
|
|
$(BUILD_DIR):
|
||
|
|
mkdir -p $(BUILD_DIR)
|
||
|
|
|
||
|
|
# Compile source files to object files
|
||
|
|
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR)
|
||
|
|
$(CC) $(CFLAGS) -I$(INCLUDE_DIR) -c $< -o $@
|
||
|
|
|
||
|
|
# Link object files to create executable
|
||
|
|
$(TARGET): $(OBJS)
|
||
|
|
$(CC) $(OBJS) $(LDFLAGS) -o $(TARGET)
|
||
|
|
|
||
|
|
# Copy wordlists to build directory
|
||
|
|
wordlists: $(TARGET)
|
||
|
|
cp -R wordlists $(BUILD_DIR)/
|
||
|
|
|
||
|
|
# Clean build artifacts
|
||
|
|
clean:
|
||
|
|
rm -rf $(BUILD_DIR)
|
||
|
|
|
||
|
|
# Install the game
|
||
|
|
install: all
|
||
|
|
install -d $(INSTALL_DIR)/bin
|
||
|
|
install -m 755 $(TARGET) $(INSTALL_DIR)/bin/cordle
|
||
|
|
install -d $(INSTALL_DIR)/share/cordle
|
||
|
|
cp -R wordlists $(INSTALL_DIR)/share/cordle/
|
||
|
|
|
||
|
|
# Uninstall the game
|
||
|
|
uninstall:
|
||
|
|
rm -f $(INSTALL_DIR)/bin/cordle
|
||
|
|
rm -rf $(INSTALL_DIR)/share/cordle
|
||
|
|
|
||
|
|
# Rebuild everything
|
||
|
|
rebuild: clean all
|
||
|
|
|
||
|
|
# Help target
|
||
|
|
help:
|
||
|
|
@echo "Cordle Makefile targets:"
|
||
|
|
@echo " all - Build the game (default)"
|
||
|
|
@echo " clean - Remove build artifacts"
|
||
|
|
@echo " rebuild - Clean and rebuild"
|
||
|
|
@echo " install - Install to $(INSTALL_DIR)"
|
||
|
|
@echo " uninstall - Remove installed files"
|
||
|
|
@echo " help - Show this help message"
|
||
|
|
|
||
|
|
.PHONY: all clean install uninstall rebuild wordlists help
|