-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
77 lines (59 loc) · 2.41 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
70
71
72
73
74
75
76
77
# Compile Noise Source as user space application
CC ?= $(CROSS_COMPILE)gcc
STRIP ?= $(CROSS_COMPILE)strip
CFLAGS ?=-Wextra -Wall -pedantic -fwrapv --param ssp-buffer-size=4 -fvisibility=hidden -fPIE -Wcast-align -Wmissing-field-initializers -Wshadow -Wswitch-enum -O0
LDFLAGS ?=-Wl,-z,relro,-z,now -pie
GCCVERSIONFORMAT := $(shell echo `$(CC) -dumpversion | sed 's/\./\n/g' | wc -l`)
ifeq "$(GCCVERSIONFORMAT)" "3"
GCC_GTEQ_490 := $(shell expr `$(CC) -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/'` \>= 40900)
else
GCC_GTEQ_490 := $(shell expr `$(CC) -dumpfullversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/'` \>= 40900)
endif
ifeq "$(GCC_GTEQ_490)" "1"
CFLAGS += -fstack-protector-strong
else
CFLAGS += -fstack-protector-all
endif
# Change as necessary
DESTDIR :=
INSTALL ?= install
PREFIX := /usr/local
UNITDIR ?= $(shell pkg-config --variable=systemdsystemunitdir systemd 2>/dev/null || echo /usr/lib/systemd/system)
NAME := jitterentropy-rngd
C_SRCS := $(sort $(wildcard lib/*.c))
C_SRCS += jitterentropy-rngd.c
C_OBJS := ${C_SRCS:.c=.o}
OBJS := $(C_OBJS)
INCLUDE_DIRS := . lib/
LIBRARY_DIRS :=
LIBRARIES := rt pthread
CFLAGS += $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir))
LDFLAGS += $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir))
LDFLAGS += $(foreach library,$(LIBRARIES),-l$(library))
analyze_srcs = $(filter %.c, $(sort $(C_SRCS)))
analyze_plists = $(analyze_srcs:%.c=%.plist)
.PHONY: all scan clean distclean
all: $(NAME)
$(NAME): $(OBJS)
# scan-build --use-analyzer=/usr/bin/clang $(CC) $(OBJS) -o $(NAME) $(LDFLAGS)
$(CC) $(OBJS) -o $(NAME) $(LDFLAGS)
$(analyze_plists): %.plist: %.c
@echo " CCSA " $@
clang --analyze $(CFLAGS) $< -o $@
scan: $(analyze_plists)
cppcheck:
cppcheck --force -q --enable=performance --enable=warning --enable=portability *.h *.c
strip: $(NAME)
$(STRIP) --strip-unneeded $(NAME)
install: strip
$(INSTALL) -D -m 0755 $(NAME) $(DESTDIR)$(PREFIX)/sbin/$(NAME)
$(INSTALL) -D -m 0644 $(NAME).1 $(DESTDIR)$(PREFIX)/share/man/man1/$(NAME).1
gzip -9 $(DESTDIR)$(PREFIX)/share/man/man1/$(NAME).1
sed "s|@PATH@|$(PREFIX)/sbin|" jitterentropy.service.in > jitterentropy.service
$(INSTALL) -D -m 0644 jitterentropy.service $(DESTDIR)$(UNITDIR)/jitterentropy.service
clean:
@- $(RM) $(NAME)
@- $(RM) $(OBJS)
@- $(RM) jitterentropy.service
@- $(RM) $(analyze_plists)
distclean: clean