-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (43 loc) · 1.65 KB
/
Copy pathMakefile
File metadata and controls
57 lines (43 loc) · 1.65 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
# vTree Makefile
# Builds for the host by default; cross-compile by setting CC and SYSROOT.
#
# Usage:
# make — debug build (sanitizers, symbols)
# make release — optimised release build
# make clean — remove build artefacts
#
# Cross-compile example (muOS / ARM):
# make CC=arm-linux-gnueabihf-gcc release
CC ?= gcc
TARGET := vtree
SRCS := main.c config.c fileop.c viewer.c hexview.c imgview.c keyboard.c snake.c lang.c ui_audio.c
OBJS := $(SRCS:.c=.o)
SDL2_CFLAGS :=
SDL2_LIBS := -lSDL2
CFLAGS_COMMON := -Wall -Wextra -std=c99 $(SDL2_CFLAGS) \
-DSDL_MAIN_HANDLED \
-D_POSIX_C_SOURCE=200809L \
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
# _FILE_OFFSET_BITS=64 makes off_t/stat/fseeko/ftello 64-bit on 32-bit targets
# (armhf): required for >2 GB files and so copy_file_range's loff_t* offsets
# match off_t. No-op on 64-bit. _LARGEFILE_SOURCE exposes fseeko/ftello.
LIBS := $(SDL2_LIBS) -lSDL2_ttf -lSDL2_image -lm -lpthread
# Debug (default)
CFLAGS := $(CFLAGS_COMMON) -g -O0 -fsanitize=address,undefined
LDFLAGS := -fsanitize=address,undefined
# Release — with runtime hardening (FORTIFY needs -O1+; stack canaries).
CFLAGS_REL := $(CFLAGS_COMMON) -O2 -DNDEBUG \
-D_FORTIFY_SOURCE=2 -fstack-protector-strong
LDFLAGS_REL :=
LIBS := $(SDL2_LIBS) -lSDL2_ttf -lSDL2_image -lm
.PHONY: all release clean
all: $(TARGET)
release: CFLAGS = $(CFLAGS_REL)
release: LDFLAGS = $(LDFLAGS_REL)
release: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
%.o: %.c vtree.h
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -f $(OBJS) $(TARGET)