vis: more cleanups
[vis.git] / config.mk
blob193881a73a736f70a895f7b1a4bb20fb36721afd
1 # vis version
2 VERSION = 0.1
4 # optional features
5 CONFIG_LUA=1
6 CONFIG_ACL=0
7 CONFIG_SELINUX=0
9 # Customize below to fit your system
11 PREFIX ?= /usr/local
12 MANPREFIX = ${PREFIX}/share/man
13 SHAREPREFIX = ${PREFIX}/share/vis
15 LIBS = -lc
17 CFLAGS_TERMKEY = $(shell pkg-config --cflags termkey 2> /dev/null || echo "")
18 LDFLAGS_TERMKEY = $(shell pkg-config --libs termkey 2> /dev/null || echo "-ltermkey")
20 CFLAGS_CURSES = $(shell pkg-config --cflags ncursesw 2> /dev/null || echo "-I/usr/include/ncursesw")
21 LDFLAGS_CURSES = $(shell pkg-config --libs ncursesw 2> /dev/null || echo "-lncursesw")
23 ifeq (${CONFIG_LUA},1)
24 CFLAGS_LUA = $(shell pkg-config --cflags lua5.2 2> /dev/null || echo "-I/usr/include/lua5.2")
25 LDFLAGS_LUA = $(shell pkg-config --libs lua5.2 2> /dev/null || echo "-llua -lm")
26 endif
28 CFLAGS += -DCONFIG_LUA=${CONFIG_LUA}
29 CFLAGS += -DCONFIG_SELINUX=${CONFIG_SELINUX}
30 CFLAGS += -DCONFIG_ACL=${CONFIG_ACL}
32 ifeq (${CONFIG_ACL},1)
33 LIBS += -lacl
34 endif
36 OS = $(shell uname)
38 ifeq (${OS},Linux)
39 ifeq (${CONFIG_SELINUX},1)
40 LIBS += -lselinux
41 endif
42 else ifeq (${OS},Darwin)
43 CFLAGS += -D_DARWIN_C_SOURCE
44 else ifeq (${OS},OpenBSD)
45 CFLAGS += -D_BSD_SOURCE
46 else ifeq (${OS},FreeBSD)
47 CFLAGS += -D_BSD_SOURCE
48 else ifeq (${OS},NetBSD)
49 CFLAGS += -D_BSD_SOURCE
50 else ifeq (${OS},AIX)
51 CFLAGS += -D_ALL_SOURCE
52 endif
54 CFLAGS_LIBS = $(CFLAGS_LUA) $(CFLAGS_TERMKEY) $(CFLAGS_CURSES)
55 LDFLAGS_LIBS = $(LDFLAGS_LUA) $(LDFLAGS_TERMKEY) $(LDFLAGS_CURSES) $(LIBS)
57 CFLAGS_VIS = $(CFLAGS_LIBS) -std=c99 -Os -DVERSION=\"${VERSION}\" -DNDEBUG -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 -DLUA_COMPAT_ALL
58 LDFLAGS_VIS = $(LDFLAGS_LIBS)
60 DEBUG_CFLAGS_VIS = ${CFLAGS_VIS} -UNDEBUG -O0 -g -ggdb -Wall -Wextra -pedantic -Wno-missing-field-initializers -Wno-unused-parameter
62 CC ?= cc
63 STRIP ?= strip
65 # Hardening
66 ifeq (${CC},gcc)
67 CFLAGS += -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2
68 LDFLAGS += -z now -z relro -pie
69 else ifeq (${CC},clang)
70 CFLAGS += -fPIE -fstack-protector-all -D_FORTIFY_SOURCE=2
71 LDFLAGS += -z now -z relro -pie
72 endif