-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (42 loc) · 2.61 KB
/
Makefile
File metadata and controls
60 lines (42 loc) · 2.61 KB
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
58
59
60
# ─────────────────────────────────────────────────────────────────────
# libdeck39 — Build System
# Produces: static library, shared library, test suite, example binary
# ─────────────────────────────────────────────────────────────────────
CC = gcc
AR = ar
CFLAGS = -Wall -Wextra -Werror -std=c99
LDFLAGS =
# ── Sources ──────────────────────────────────────────────────────────
LIB_SRC = app_build/deck.c
LIB_OBJ = $(LIB_SRC:.c=.o)
# ── Outputs ──────────────────────────────────────────────────────────
STATIC = libdeck39.a
SHARED = libdeck39.so
TEST_BIN = tests/test_deck
EX_BIN = examples/example_usage
# ── Phony targets ────────────────────────────────────────────────────
.PHONY: all lib test example clean
all: lib test example
# ── Library ──────────────────────────────────────────────────────────
lib: $(STATIC) $(SHARED)
$(STATIC): $(LIB_OBJ)
$(AR) rcs $@ $^
$(SHARED): $(LIB_SRC)
$(CC) $(CFLAGS) -fPIC -shared $< -o $@
app_build/%.o: app_build/%.c
$(CC) $(CFLAGS) -c $< -o $@
# ── Test suite ───────────────────────────────────────────────────────
test: $(TEST_BIN)
@echo ""
@./$(TEST_BIN)
$(TEST_BIN): tests/test_deck.c $(STATIC)
$(CC) $(CFLAGS) -Iapp_build $< $(STATIC) -o $@
# ── Example program ─────────────────────────────────────────────────
example: $(EX_BIN)
@echo ""
@./$(EX_BIN)
$(EX_BIN): examples/example_usage.c $(STATIC)
$(CC) $(CFLAGS) -Iapp_build $< $(STATIC) -o $@
# ── Cleanup ──────────────────────────────────────────────────────────
clean:
rm -f $(LIB_OBJ) $(STATIC) $(SHARED) $(TEST_BIN) $(EX_BIN)