forked from Nitrokey/nitrokey-hotp-verification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
104 lines (86 loc) · 2.28 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
SRCDIR=src
PKGCONFIG=pkg-config
SRC:= \
$(SRCDIR)/crc32.c \
$(SRCDIR)/device.c \
$(SRCDIR)/operations.c \
$(SRCDIR)/dev_commands.c \
$(SRCDIR)/base32.c \
$(SRCDIR)/random_data.c \
$(SRCDIR)/min.c \
$(SRCDIR)/version.c \
$(SRCDIR)/return_codes.c \
$(SRCDIR)/main.c \
$(SRCDIR)/tlv.c \
$(SRCDIR)/ccid.c \
$(SRCDIR)/utils.c \
$(SRCDIR)/operations_ccid.c
SRC += \
./hidapi/libusb/hid.c
HEADERS := \
$(SRCDIR)/crc32.h \
$(SRCDIR)/structs.h \
$(SRCDIR)/device.h \
$(SRCDIR)/operations.h \
$(SRCDIR)/dev_commands.h \
$(SRCDIR)/base32.h \
$(SRCDIR)/command_id.h \
$(SRCDIR)/random_data.h \
$(SRCDIR)/min.h \
$(SRCDIR)/settings.h \
$(SRCDIR)/version.h \
$(SRCDIR)/return_codes.h \
$(SRCDIR)/ccid.h \
$(SRCDIR)/tlv.h \
$(SRCDIR)/operations_ccid.h
OBJS := ${SRC:.c=.o}
HIDAPI_INC=hidapi
INC:= \
-I$(SRCDIR) \
-I$(HIDAPI_INC) \
-I$(HIDAPI_INC)/hidapi \
LIBUSB_FLAGS=$(shell $(PKGCONFIG) --cflags libusb-1.0)
LIBUSB_LIB=$(shell $(PKGCONFIG) --libs libusb-1.0)
CFLAGS= -Wall -Wextra -fno-guess-branch-probability -Wdate-time -frandom-seed=42 -O2 -gno-record-gcc-switches -DNDEBUG -fdebug-prefix-map=${PWD}=heads -c -std=gnu11 -DNK_REMOVE_PTHREAD $(LIBUSB_FLAGS)
OUTDIR=
OUT=hotp_verification
LDFLAGS=$(LIBUSB_LIB)
all: $(OUT)
ls -lh $^
sha256sum $^
clean:
-rm $(OBJS) $(OUT) $(SRCDIR)/version.c
$(OUT): $(OBJS)
$(CC) $^ $(LDFLAGS) -o $@
%.o: %.c
$(CC) $(CFLAGS) $(INC) -o $@ $<
GITVERSION=$(shell git describe)
$(SRCDIR)/version.c: $(SRCDIR)/version.c.in
sed "s!@GIT_VERSION_PLACEHOLDER@!$(GITVERSION)!g" < $< >$@
.PRECIOUS: %.o
INSTALL=/usr/local/
.PHONY: install
install:
cp -v $(OUT) $(INSTALL)/bin
.PHONY: github_sha
GVER=$(shell git rev-parse HEAD)
libremkey_url := https://github.com/Nitrokey/nitrokey-hotp-verification/archive/$(GVER).tar.gz
github_sha:
wget -c $(libremkey_url)
sha256sum $(GVER).tar.gz
@echo $(GVER)
.PHONY: format
format:
clang-format -i $(shell find src -type f | grep -v base32)
clang-format -i tests/test* ./test_ccid.cpp
CI:
-dnf install -y make gcc gcc-c++ git libusb-devel cmake hidapi-devel meson
git submodule update --init --recursive
@echo "CMake"
mkdir -p ci-build-cmake
cd ci-build-cmake && cmake -DCMAKE_BUILD_TYPE=Release .. && make
@echo "Meson"
meson ci-build-meson && cd ci-build-meson && ninja
@echo "Make"
make
@echo "Finished"