-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
executable file
·64 lines (50 loc) · 1.48 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
#!/usr/bin/env make
SRC_DIR := .
KEY_DIR := Keys
OBJ_DIR := obj
CXXFLAGS := -std=c++11 -MMD -MP -Wall -Wfatal-errors -Wextra -fPIE
LDFLAGS := -fPIE
ifdef CROSS_COMPILE
$(info Doing a cross-compilation)
STATIC := -static
CXX := $(CROSS_COMPILE)g++
CC := $(CROSS_COMPILE)gcc
LDFLAGS += -L /opt/lib
CROSS_CFLAGS := -I /opt/include
CXXFLAGS += $(CROSS_CFLAGS)
export CROSS_CFLAGS
export CXX
export CC
export STATIC
endif
override LDFLAGS += -lmbedcrypto
MODULES := $(wildcard $(SRC_DIR)/*.cpp)
OBJECTS := $(MODULES:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.o)
U2FDevice: $(OBJECTS) libuECC.a libcppb64.a
$(CXX) -o $@ $^ $(LDFLAGS) $(STATIC)
install: U2FDevice
install -m775 -t /usr/bin U2FDevice
install -m775 -t /etc/systemd/system Services/U2FDevice.service
install -d /usr/share/U2FDevice/
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR) $(SRC_DIR)/Certificates.hpp
$(CXX) $(STATIC) $(CXXFLAGS) -c -o $@ $<
$(OBJ_DIR):
mkdir $(OBJ_DIR)
-include $(OBJECTS:.o=.d)
clean:
rm -f $(OBJ_DIR)/*
rm -f U2FDevice libuECC.a libcppb64.a
$(MAKE) -C micro-ecc clean
$(MAKE) -C cpp-base64 clean
clean-certificates:
rm -f $(KEY_DIR)/*
rm -f Certificates.cpp Certificates.hpp
$(SRC_DIR)/Certificates.hpp: $(SRC_DIR)/Certificates.hpp.template
$(error "Please run the GenCertificates.sh script to generate certificate before building\n")
.PHONY: clean clean-certificates install
libuECC.a:
$(MAKE) -C micro-ecc
cp micro-ecc/libuECC.a libuECC.a
libcppb64.a:
$(MAKE) -C cpp-base64
cp cpp-base64/libcppb64.a libcppb64.a