mirror of
https://github.com/Soccera1/agg.git
synced 2025-09-21 14:17:03 +02:00
Add makefile
This commit is contained in:
parent
2ef7de5617
commit
3717c5f020
1 changed files with 55 additions and 0 deletions
55
Makefile
Normal file
55
Makefile
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
# Compiler and flags
|
||||||
|
CC = gcc
|
||||||
|
CFLAGS = -Wall -Wextra -std=c99 -O3 -flto
|
||||||
|
DEBUG_FLAGS = -g -DDEBUG
|
||||||
|
|
||||||
|
# Directories
|
||||||
|
SRCDIR = src
|
||||||
|
OBJDIR = obj
|
||||||
|
BINDIR = bin
|
||||||
|
|
||||||
|
# Source files
|
||||||
|
SOURCES = $(SRCDIR)/agg.c
|
||||||
|
OBJECTS = $(OBJDIR)/agg.o
|
||||||
|
TARGET = $(BINDIR)/agg
|
||||||
|
|
||||||
|
# Default target
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
# Create directories if they don't exist
|
||||||
|
$(OBJDIR):
|
||||||
|
mkdir -p $(OBJDIR)
|
||||||
|
|
||||||
|
$(BINDIR):
|
||||||
|
mkdir -p $(BINDIR)
|
||||||
|
|
||||||
|
# Compile object files
|
||||||
|
$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
# Link executable
|
||||||
|
$(TARGET): $(OBJECTS) | $(BINDIR)
|
||||||
|
$(CC) $(OBJECTS) -o $@
|
||||||
|
|
||||||
|
# Debug build
|
||||||
|
debug: CFLAGS += $(DEBUG_FLAGS)
|
||||||
|
debug: $(TARGET)
|
||||||
|
|
||||||
|
# Clean build artifacts
|
||||||
|
clean:
|
||||||
|
rm -rf $(OBJDIR) $(BINDIR)
|
||||||
|
|
||||||
|
# Run the program
|
||||||
|
run: $(TARGET)
|
||||||
|
./$(TARGET)
|
||||||
|
|
||||||
|
# Install (copy to /usr/local/bin)
|
||||||
|
install: $(TARGET)
|
||||||
|
cp $(TARGET) /usr/local/bin/
|
||||||
|
|
||||||
|
# Uninstall
|
||||||
|
uninstall:
|
||||||
|
rm -f /usr/local/bin/agg
|
||||||
|
|
||||||
|
# Phony targets
|
||||||
|
.PHONY: all debug clean run install uninstall
|
Loading…
Add table
Reference in a new issue