# Makefile for Cordle - C90 Wordle Game # Cross-platform build system for Unix/Linux/macOS and DOS # Compiler and flags CC = gcc CFLAGS = -std=c90 -pedantic -Wpedantic -Wall -Wextra # Platform detection ifdef COMSPEC # DOS/Windows with DJGPP detected PLATFORM = DOS LDFLAGS = -lpdcurses CFLAGS += -D__MSDOS__ TARGET_EXT = .exe else # Unix/Linux/macOS PLATFORM = UNIX LDFLAGS = -lncurses TARGET_EXT = endif # 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$(TARGET_EXT) # 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 - Cross-platform C90 Wordle Game" @echo "================================================" @echo "Detected platform: $(PLATFORM)" @echo "" @echo "Build targets:" @echo " all - Build the game (default)" @echo " clean - Remove build artifacts" @echo " rebuild - Clean and rebuild" @echo " install - Install to $(INSTALL_DIR) (Unix only)" @echo " uninstall - Remove installed files (Unix only)" @echo " help - Show this help message" @echo "" @echo "DOS/DJGPP Requirements:" @echo " - DJGPP compiler (gcc for DOS)" @echo " - PDCurses library" @echo " - GNU Make" @echo "" @echo "Unix/Linux/macOS Requirements:" @echo " - GCC compiler" @echo " - ncurses library" @echo " - GNU Make" .PHONY: all clean install uninstall rebuild wordlists help