aboutsummaryrefslogtreecommitdiff
path: root/config.mk
blob: 5d92114bc6ac5cee9d469443e38850e6b8ca4401 (plain) (blame)
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
# vis version
# we have no tags in git, so just use revision count an hash for now
GITREVCOUNT = "$(shell git rev-list --count master 2>/dev/null)"
GITHASH = "$(shell git log -1 --format="%h" 2>/dev/null)"
ifeq (${GITREVCOUNT},)
	VERSION = devel
else
	VERSION = "0.r${GITREVCOUNT}.g${GITHASH}"
endif

# Customize below to fit your system

PREFIX ?= /usr/local
MANPREFIX = ${PREFIX}/share/man

INCS = -I.
LIBS = -lc -lncursesw

ifeq ($(shell uname),Darwin)
	LIBS = -lc -lncurses
	CFLAGS += -D_DARWIN_C_SOURCE
else ifeq ($(shell uname),OpenBSD)
	LIBS = -lc -lncurses
	CFLAGS += -D_BSD_SOURCE
else ifeq ($(shell uname),FreeBSD)
	CFLAGS += -D_BSD_SOURCE
else ifeq ($(shell uname),NetBSD)
	LIBS = -lc -lcurses
	CFLAGS += -D_BSD_SOURCE
else ifeq ($(shell uname),SunOS)
	INCS += -I/usr/include/ncurses
else ifeq ($(shell uname),AIX)
	CFLAGS += -D_ALL_SOURCE
endif

CFLAGS += -std=c99 -Os ${INCS} -DVERSION=\"${VERSION}\" -DNDEBUG -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700

LDFLAGS += ${LIBS}

DEBUG_CFLAGS = ${CFLAGS} -UNDEBUG -O0 -g -ggdb -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter

CC ?= cc
STRIP ?= strip

# Hardening
ifeq (${CC},gcc)
	CFLAGS += -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2
	LDFLAGS += -z now -z relro -pie
else ifeq (${CC},clang)
	CFLAGS += -fPIE -fstack-protector-all -D_FORTIFY_SOURCE=2
	LDFLAGS += -z now -z relro -pie
endif