-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
63 lines (46 loc) · 1009 Bytes
/
Makefile
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
61
62
63
# Compiler and linker
CC=gcc
LD=gcc
# Directories
INCLDIR=include
SRCDIR=src
BUILDDIR=build
# Binary
BIN=ow18b
# Source files
SRC=$(wildcard $(SRCDIR)/*.c)
# Compiler
CFLAGS=-c -std=gnu99 -march=native \
-I$(INCLDIR) \
-Wall -Wextra -Wvla -Wmissing-prototypes
# Linker
LDLIBS=-lbluetooth
# Debug
DBGDIR=$(BUILDDIR)/debug
DBGOBJ=$(SRC:$(SRCDIR)/%.c=$(DBGDIR)/%.o)
DBGCFLAGS=-g -O0 -DDEBUG_BUILD
DBGBIN=$(DBGDIR)/$(BIN)
# Release
RELDIR=$(BUILDDIR)/release
RELOBJ=$(SRC:$(SRCDIR)/%.c=$(RELDIR)/%.o)
RELCFLAGS=-O3
RELBIN=$(RELDIR)/$(BIN)
.PHONY: all clean prep debug release
all: release
clean:
rm -rf $(BUILDDIR)
mkdir -p $(DBGDIR) $(RELDIR)
prep:
mkdir -p $(DBGDIR) $(RELDIR)
# Debug
$(DBGDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) $(DBGCFLAGS) -o $@ $<
$(DBGBIN): $(DBGOBJ)
$(LD) -o $@ $^ $(LDLIBS)
debug: prep $(DBGBIN)
# Release
$(RELDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) $(RELCFLAGS) -o $@ $<
$(RELBIN): $(RELOBJ)
$(LD) -o $@ $^ $(LDLIBS)
release: prep $(RELBIN)