-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (69 loc) · 1.5 KB
/
Copy pathMakefile
File metadata and controls
83 lines (69 loc) · 1.5 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#
# Compiler flags
#
CC ?= gcc
CFLAGS += -Wall -pedantic -MMD
LDFLAGS += -lm
BUILD ?= debug
ifdef RELEASE
ifeq ($(RELEASE),1)
BUILD = release
endif
endif
ifdef STATIC
CFLAGS += -static
endif
#
# Debug build settings
#
ifeq ($(BUILD),debug)
CFLAGS += -g -fno-omit-frame-pointer
ifeq ($(ASAN),1)
CFLAGS += -fsanitize=address
endif
endif
#
# Release build settings
#
ifeq ($(BUILD),release)
CFLAGS += -O2 -s
endif
#
# Sources, Objects, and Dependencies
#
SRCS := $(wildcard src/*.c)
OBJS := $(SRCS:src/%.c=obj/%.o)
DEPS := $(OBJS:obj/%.o=obj/%.d)
#
# Targets
#
bin/scwrapper: $(OBJS)
@mkdir -p bin
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $@
obj/%.o: src/%.c
@mkdir -p obj
$(CC) $(CFLAGS) -c $< -o $@
.PHONY: clean
clean:
rm -rf bin obj scwrapper.mister.tar.gz
#
# Docker Toolchains
#
.PHONY: toolchain-x86_64
toolchain-x86_64:
docker build -f toolchains/Dockerfile.x86_64 -t $@ toolchains
.PHONY: toolchain-arm7vl
toolchain-arm7vl:
docker build -f toolchains/Dockerfile.armv7l -t $@ toolchains
#
# Static Release Builds
#
UID := $(shell id -u)
GID := $(shell id -g)
.PHONY: scwrapper.x86_64
scwrapper.x86_64: toolchain-x86_64
docker run -it -v "${PWD}:/project" --user "$(UID):$(GID)" --rm toolchain-x86_64 bash -c 'cd /project && make STATIC=1 RELEASE=1'
.PHONY: scwrapper.arm7vl
scwrapper.arm7vl: toolchain-arm7vl
docker run -it -v "${PWD}:/project" --user "$(UID):$(GID)" --rm toolchain-arm7vl bash -c 'cd /project && make STATIC=1 RELEASE=1'
-include $(DEPS)