cordle/Makefile

121 lines
3.1 KiB
Makefile
Raw Normal View History

# Makefile for Cordle - C90 Wordle Game
2026-01-26 14:29:55 +00:00
# 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
2026-01-26 14:29:55 +00:00
# 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
2026-01-26 14:29:55 +00:00
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
2026-01-27 19:28:14 +00:00
# Rebuild everything
rebuild: clean all
# Help target
help:
2026-01-26 14:29:55 +00:00
@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"
2026-01-26 14:29:55 +00:00
@echo " install - Install to $(INSTALL_DIR) (Unix only)"
@echo " uninstall - Remove installed files (Unix only)"
@echo " help - Show this help message"
2026-01-26 14:29:55 +00:00
@echo ""
2026-01-27 19:50:10 +00:00
@echo "DOS Requirements:"
@echo " - Borland Turbo C++ 3.x (includes MAKE)"
2026-01-26 14:29:55 +00:00
@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