-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
50 lines (42 loc) · 1.04 KB
/
Makefile
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
# CC auto-detection
# GCC v4.7.x (or later) : `CC = g++'
# GCC v4.5.x or v4.6.x : `CC = gcc'
# skip auto-detection when `CC' is (explicitly) defined in the command line
ifneq ($(origin CC),"command line")
GCCVER = $(shell $(CC) -dumpversion | cut -d. -f-2 | sed 's/\.//')
ifeq ($(GCCVER),47)
CC = g++
endif
ifeq ($(GCCVER),46)
CC = gcc
endif
ifeq ($(GCCVER),45)
CC = gcc
endif
endif
# `CC' version check
GCCVER = $(shell $(CC) -dumpversion | cut -d. -f-2 | sed 's/\.//')
ifneq ($(GCCVER),47)
ifneq ($(GCCVER),46)
ifneq ($(GCCVER),45)
$(error Bad GCC version, please install v4.5.x, v4.6.x, or 4.7.x)
endif
endif
endif
CFLAGS = -DIN_GCC -fPIC -shared -O2 -fvisibility=hidden \
-Wall -Wno-unused-variable \
-I`$(CC) --print-file-name=plugin/include` \
-lbsd -DDEBUG
# do not make changes below this line
SRC = kguard.c
SHARED_OBJ = $(SRC:.c=.so)
# phony targets
.PHONY: all clean
# default target
all: $(SHARED_OBJ)
# build the shared library
$(SHARED_OBJ): $(SRC) $(SRC:.c=.h)
$(CC) $(CFLAGS) $(SRC) -o $@
# clean
clean:
rm -rf $(SHARED_OBJ)