8 months ago |
10 |
1 |
# Basic Makefile for a C program with multiple source files and header dependencies | ||
2 |
|||||
3 |
CC = gcc | ||||
4 |
CFLAGS = -Wall -Wextra -g -O0 -MMD -MP -std=c17 | ||||
5 |
SRC = $(wildcard coroutine/*.c) $(wildcard examples/*.c) | ||||
6 |
OBJ = $(SRC:.c=.o) | ||||
7 |
DEP = $(OBJ:.o=.d) | ||||
8 |
TARGET = main | ||||
9 |
|||||
10 |
all: $(TARGET) | ||||
11 |
|||||
12 |
$(TARGET): $(OBJ) | ||||
13 |
$(CC) $(CFLAGS) -o $@ $^ | ||||
14 |
|||||
15 |
%.o: %.c | ||||
16 |
$(CC) $(CFLAGS) -I include -c $< -o $@ | ||||
17 |
|||||
18 |
-include $(DEP) | ||||
19 |
|||||
20 |
clean: | ||||
21 |
rm -f $(OBJ) $(DEP) $(TARGET) | ||||
22 |
|||||
23 |
.PHONY: all clean | ||||
24 |