1 contributor
27 lines598 bytes
Newer
Older
-
+
commited
{line.log.rev}
on
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
8 months ago
5
EXAMPLES_SRC = $(wildcard examples/*.c)
6
EXAMPLES_OBJ = $(EXAMPLES_SRC:.c=.o)
7
EXAMPLES = $(patsubst examples/%.c, %, $(wildcard examples/*.c))
8
LIB_SRC = $(wildcard coroutine/*.c)
9
LIB_OBJ = $(LIB_SRC:.c=.o)
10
OBJ = $(EXAMPLES_OBJ) $(LIB_OBJ)
8 months ago
10
11
DEP = $(OBJ:.o=.d)
12
8 months ago
13
all: $(EXAMPLES)
8 months ago
10
14
8 months ago
15
%: examples/%.o $(LIB_OBJ)
8 months ago
10
16
$(CC) $(CFLAGS) -o $@ $^
17
18
%.o: %.c
19
$(CC) $(CFLAGS) -I include -c $< -o $@
20
21
-include $(DEP)
22
23
clean:
8 months ago
24
rm -f $(OBJ) $(DEP) $(EXAMPLES)
8 months ago
10
25
26
.PHONY: all clean
27