# 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 -Wstrict-prototypes -Wold-style-definition # 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) words # 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 words: $(TARGET) cp -R WORDS $(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 words $(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 Requirements:" @echo " - Borland Turbo C++ 3.x (includes MAKE)" @echo " - PDCurses library" @echo "" @echo "Unix/Linux/macOS Requirements:" @echo " - GCC compiler" @echo " - ncurses library" @echo " - GNU Make" .PHONY: all clean install uninstall rebuild wordlists help # Static analysis targets analyze: cppcheck # Relaxed splint (too noisy with +standard) splint: @echo "Running splint with relaxed checks..." @splint -weak +posixlib -I./include src/*.c 2>&1 | grep -v "Definition of" || true # Strict splint (very verbose, use with caution) splint-strict: splint +standard -I./include src/*.c cppcheck: @echo "Running cppcheck..." @cppcheck --std=c90 --enable=warning,style,performance,portability \ --suppress=missingIncludeSystem --quiet -I./include src/ strict-compile: gcc -std=c90 -pedantic -Wpedantic -Wall -Wextra \ -Wstrict-prototypes -Wold-style-definition \ -Wmissing-prototypes -Wdeclaration-after-statement \ -Iinclude -c src/*.c