vis: more comments and cleanups
[vis.git] / config.mk
blob73027bf8256fbb9e09d47eef350ce8b63188156a
1 # optional features
2 HAVE_ACL=0
3 HAVE_SELINUX=0
5 # vis version
6 RELEASE = HEAD
7 # try to get a tag and hash first
8 GITHASH = $(shell git log -1 --format='%h' 2>/dev/null)
9 GITTAG = $(shell git describe --abbrev=0 --tags 2>/dev/null)
10 ifneq ($(GITTAG),)
11 # we have a tag and revcount from there
12 GITREVCOUNT = $(shell git rev-list --count ${GITTAG}.. 2>/dev/null)
13 VERSION = ${GITTAG}.r${GITREVCOUNT}.g${GITHASH}
14 else ifneq ($(GITHASH),)
15 # we have no tags in git, so just use revision count an hash for now
16 GITREVCOUNT = $(shell git rev-list --count HEAD)
17 VERSION = 0.r${GITREVCOUNT}.g${GITHASH}
18 else
19 # this is used when no git is available, e.g. for release tarball
20 VERSION = ${RELEASE}
21 endif
23 # Customize below to fit your system
25 PREFIX ?= /usr/local
26 MANPREFIX = ${PREFIX}/share/man
28 CFLAGS_TERMKEY = $(shell pkg-config --cflags termkey 2> /dev/null || echo "")
29 CFLAGS_CURSES = $(shell pkg-config --cflags ncursesw 2> /dev/null || echo "-I/usr/include/ncursesw")
31 LDFLAGS_TERMKEY = $(shell pkg-config --libs termkey 2> /dev/null || echo "-ltermkey")
32 LDFLAGS_CURSES = $(shell pkg-config --libs ncursesw 2> /dev/null || echo "-lncursesw")
34 LIBS = -lc
35 OS = $(shell uname)
37 ifeq (${OS},Linux)
38 ifeq (${HAVE_SELINUX},1)
39 CFLAGS += -DHAVE_SELINUX
40 LIBS += -lselinux
41 endif
42 ifeq (${HAVE_ACL},1)
43 CFLAGS += -DHAVE_ACL
44 LIBS += -lacl
45 endif
46 else ifeq (${OS},Darwin)
47 CFLAGS += -D_DARWIN_C_SOURCE
48 else ifeq (${OS},OpenBSD)
49 CFLAGS += -D_BSD_SOURCE
50 else ifeq (${OS},FreeBSD)
51 CFLAGS += -D_BSD_SOURCE
52 else ifeq (${OS},NetBSD)
53 CFLAGS += -D_BSD_SOURCE
54 else ifeq (${OS},AIX)
55 CFLAGS += -D_ALL_SOURCE
56 endif
58 CFLAGS_LIBS = $(CFLAGS_TERMKEY) $(CFLAGS_CURSES)
59 LDFLAGS_LIBS = $(LDFLAGS_TERMKEY) $(LDFLAGS_CURSES) $(LIBS)
61 CFLAGS_VIS = $(CFLAGS_LIBS) -std=c99 -Os -DVERSION=\"${VERSION}\" -DNDEBUG -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
62 LDFLAGS_VIS = $(LDFLAGS_LIBS)
64 DEBUG_CFLAGS_VIS = ${CFLAGS_VIS} -UNDEBUG -O0 -g -ggdb -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter
66 CC ?= cc
67 STRIP ?= strip
69 # Hardening
70 ifeq (${CC},gcc)
71 CFLAGS += -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2
72 LDFLAGS += -z now -z relro -pie
73 else ifeq (${CC},clang)
74 CFLAGS += -fPIE -fstack-protector-all -D_FORTIFY_SOURCE=2
75 LDFLAGS += -z now -z relro -pie
76 endif