-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (36 loc) · 1.25 KB
/
Copy pathMakefile
File metadata and controls
54 lines (36 loc) · 1.25 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
# make CC=aarch64-linux-gcc TARGET=../frontend/bin/muterm
CC ?= gcc
TARGET := muterm
SRCDIR := .
BUILDDIR := build
DEBUG ?= 0
OPT_LEVEL ?= 2
CFLAGS ?= -pipe -Wall -Wextra -std=c11
LDLIBS ?= -lSDL2 -lSDL2_ttf -lSDL2_image
CFLAGS += -O$(OPT_LEVEL) -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE \
-ffunction-sections -fdata-sections -flto=auto \
-fno-plt -fstack-protector-strong -fstack-clash-protection \
-D_FORTIFY_SOURCE=3 -fPIE -fno-ident \
$(if $(filter 1,$(DEBUG)),-g)
LDFLAGS += -flto=auto -Wl,--gc-sections -pie -Wl,-z,relro,-z,now \
$(if $(filter 1,$(DEBUG)),,-s)
MAIN_SRC := $(wildcard $(SRCDIR)/*.c)
LANG_SRC := $(wildcard $(SRCDIR)/lang/*.c)
OBJS := $(MAIN_SRC:$(SRCDIR)/%.c=$(BUILDDIR)/%.o) \
$(LANG_SRC:$(SRCDIR)/%.c=$(BUILDDIR)/%.o)
DEPS := $(OBJS:.o=.d)
.PHONY: all clean
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
$(BUILDDIR):
mkdir -p $(BUILDDIR)
$(BUILDDIR)/lang:
mkdir -p $(BUILDDIR)/lang
$(BUILDDIR)/%.o: $(SRCDIR)/%.c | $(BUILDDIR)
$(CC) $(CFLAGS) -MMD -MP -c -o $@ $<
$(BUILDDIR)/lang/%.o: $(SRCDIR)/lang/%.c | $(BUILDDIR)/lang
$(CC) $(CFLAGS) -MMD -MP -c -o $@ $<
-include $(DEPS)
clean:
rm -rf $(BUILDDIR) $(TARGET)