-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (44 loc) · 985 Bytes
/
Makefile
File metadata and controls
57 lines (44 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Compiler and flags
CC = gcc
EXTRA_CFLAGS ?=
CFLAGS ?= -Wall -Wextra -std=c99 -pedantic -O3 -flto $(EXTRA_CFLAGS)
LDFLAGS ?=
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) $(LDFLAGS) $(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