-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
35 lines (27 loc) · 777 Bytes
/
Copy pathMakefile
File metadata and controls
35 lines (27 loc) · 777 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
# Compiler settings
CC = gcc
CFLAGS = -Wall -Wextra -g
# Project files
TARGET = todomanager
SRCS = main.c tasks.c
OBJS = $(SRCS:.c=.o)
HEADERS = tasks.h
# Default target when you just type 'make'
all: $(TARGET)
# Link the object files to create the executable
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $(TARGET) $(OBJS)
# Compile C source files into object files
%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) -c $< -o $@
# Clean up build files (object files and executable)
clean:
rm -f $(OBJS) $(TARGET)
# Build and run the program in one command
run: $(TARGET)
./$(TARGET)
# Check for memory leaks using Valgrind
valgrind: $(TARGET)
valgrind --leak-check=full --track-origins=yes ./$(TARGET)
# Phony targets to prevent conflicts with file names
.PHONY: all clean run valgrind