-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
38 lines (28 loc) · 724 Bytes
/
Makefile
File metadata and controls
38 lines (28 loc) · 724 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
36
37
38
CC = clang
CFLAGS = -Wall -Wextra -pedantic -std=gnu99
DFLAGS = -DDEBUG -O0 -g
RFLAGS = -D_FORTIFY_SOURCE=2 -O2
BUILDDIR = bin
SRCDIR = src
EXECUTABLE = serialjs
TARGET = $(BUILDDIR)/$(EXECUTABLE)
PREFIX := /usr/local
SOURCES = $(shell find $(SRCDIR) -name *.c)
HEADERS = $(shell find $(SRCDIR) -name *.h)
OBJECTS = $(SOURCES:%=$(BUILDDIR)/%.o)
debug: CFLAGS += $(DFLAGS)
debug: $(TARGET)
release: CFLAGS += $(RFLAGS)
release: $(TARGET)
strip $^
$(BUILDDIR)/%.c.o: %.c $(HEADERS)
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -o $@ -c $<
$(TARGET): $(OBJECTS)
$(CC) -o $@ $^
install:
install -Dm755 $(TARGET) '$(PREFIX)/bin/$(EXECUTABLE)'
uninstall:
rm '$(PREFIX)/bin/$(EXECUTABLE)'
clean:
rm -fv $(TARGET) $(OBJECTS)