-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
41 lines (33 loc) · 988 Bytes
/
Copy pathMakefile
File metadata and controls
41 lines (33 loc) · 988 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
CC = gcc
CFLAGS = -std=c99 -Wall -Wextra -g -Og -pedantic -fsanitize=undefined
RELEASE_FLAGS = -std=c99 -Wall -Wextra -O2 -DNDEBUG=1
LFLAGS = -I.
TEST_DIR = tests
TARGETS = $(TEST_DIR)/test_range.exe \
$(TEST_DIR)/test_stack.exe \
$(TEST_DIR)/test_queue.exe \
$(TEST_DIR)/test_slist.exe \
$(TEST_DIR)/test_objpool.exe
HEADERS = range.h stack.h queue.h objpool.h slist.h
OBJECTS = $(TARGETS:.exe=.o)
# Default target (debug build)
all: $(TARGETS)
# Build the executable (debug)
%.exe : %.o
$(CC) $(CFLAGS) -o $@ $<
# Compile source files to object files
%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) -c -o $@ $< $(LFLAGS)
# Build optimized release version
release: clean-objects
$(MAKE) $(TARGETS) CFLAGS="$(RELEASE_FLAGS)"
# Clean build artifacts
clean:
rm -f $(TARGETS) $(OBJECTS)
# Clean only object files
clean-objects:
rm -f $(OBJECTS)
# Rebuild everything
rebuild: clean all
# Mark targets as phony (not file names)
.PHONY: all clean clean-objects rebuild release