forked from smuellerDD/libkcapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (52 loc) · 1.94 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#
# Copyright (C) 2014, Stephan Mueller <[email protected]>
#
CC=gcc
CFLAGS +=-Wextra -Wall -pedantic -fPIC -O2
#Hardening
CFLAGS +=-D_FORTIFY_SOURCE=2 -fstack-protector-strong -fwrapv --param ssp-buffer-size=4
LDFLAGS +=-Wl,-z,relro,-z,now
# Change as necessary
PREFIX := /usr/local
# library target directory (either lib or lib64)
LIBDIR := lib
NAME := kcapi
LIBMAJOR=$(shell cat kcapi-kernel-if.c | grep define | grep MAJVERSION | awk '{print $$3}')
LIBMINOR=$(shell cat kcapi-kernel-if.c | grep define | grep MINVERSION | awk '{print $$3}')
LIBPATCH=$(shell cat kcapi-kernel-if.c | grep define | grep PATCHLEVEL | awk '{print $$3}')
LIBVERSION := $(LIBMAJOR).$(LIBMINOR).$(LIBPATCH)
C_SRCS := $(wildcard *.c)
C_OBJS := ${C_SRCS:.c=.o}
OBJS := $(C_OBJS)
INCLUDE_DIRS :=
LIBRARY_DIRS :=
LIBRARIES :=
CFLAGS += $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir))
LDFLAGS += $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir))
LDFLAGS += $(foreach library,$(LIBRARIES),-l$(library))
.PHONY: all scan install clean distclean man maninstall pdf ps html
all: $(NAME)
$(NAME): $(OBJS)
$(CC) -shared -Wl,-soname,lib$(NAME).so.$(LIBMAJOR) -o lib$(NAME).so.$(LIBVERSION) $(OBJS) $(LDFLAGS)
scan: $(OBJS)
scan-build --use-analyzer=/usr/bin/clang $(CC) -shared -Wl,-soname,lib$(NAME).so.$(LIBMAJOR) -o lib$(NAME).so.$(LIBVERSION) $(OBJS) $(LDFLAGS)
install:
install -m 0755 -s lib$(NAME).so.$(LIBVERSION) $(PREFIX)/$(LIBDIR)/
$(RM) $(PREFIX)/$(LIBDIR)/lib$(NAME).so.$(LIBMAJOR)
ln -s lib$(NAME).so.$(LIBVERSION) $(PREFIX)/$(LIBDIR)/lib$(NAME).so.$(LIBMAJOR)
install -m 0644 kcapi.h $(PREFIX)/include
man:
LIBVERSION=$(LIBVERSION) doc/gendocs.sh man
maninstall:
install -m 0644 doc/man/* $(PREFIX)/share/man/man3
html:
LIBVERSION=$(LIBVERSION) doc/gendocs.sh html
pdf:
LIBVERSION=$(LIBVERSION) doc/gendocs.sh pdf
ps:
LIBVERSION=$(LIBVERSION) doc/gendocs.sh ps
clean:
@- $(RM) $(OBJS)
@- $(RM) lib$(NAME).so.$(LIBVERSION)
@- doc/gendocs.sh clean
distclean: clean