forked from couriersud/msigd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
147 lines (114 loc) · 3.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
SRC = src
OBJ = src
OBJS=
ifndef TARGETOS
TARGETOS=linux
endif
SOURCES = $(SRC)/msigd.cpp
TARGETS = msigd
CXX = g++
CXXFLAGS = -O2 -g -Wall -Wextra -Wno-format-security -std=c++14 $(CXXEXTRAFLAGS)
#CC = clang++
#CFLAGS = -O2 -g -Wall -Wextra -std=c++14 -Weverything -Wno-c++98-compat -Wno-weak-vtables
LD = $(CXX)
#-------------------------------------------------
# No more configuration
#-------------------------------------------------
ifndef USE_HIDAPI
USE_HIDAPI=1
endif
CXXDEFS=-DUSE_HID=$(USE_HIDAPI)
ifeq ($(TARGETOS),windows)
LIBS = -lusb
ifeq ($(USE_HIDAPI),1)
LIBS += -lhidapi
endif
CXXEXTRAFLAGS += -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501 -DWIN32_LEAN_AND_MEAN
LDEXTRAFLAGS += -Wl,--subsystem,console municode
DOXYGEN=doxygen.exe
else
ifeq ($(TARGETOS),osx)
LIBS = -lusb
ifeq ($(USE_HIDAPI),1)
LIBS += -lhidapi
endif
else
ifeq ($(TARGETOS),arch)
LIBS = -lusb-1.0
ifeq ($(USE_HIDAPI),1)
LIBS += -lhidapi-hidraw
endif
else
LIBS = -lusb
ifeq ($(USE_HIDAPI),1)
LIBS += -lhidapi-hidraw
endif
endif
endif
endif
MAKEFILE_TARGETS_WITHOUT_INCLUDE := clean doc clang mingw nvcc
#-------------------------------------------------
# all
#-------------------------------------------------
all: depend $(TARGETS)
#-------------------------------------------------
# clean
#-------------------------------------------------
clean:
$(RM) -rf $(OBJS) $(TARGETS) $(OBJ)/msigd.o .depend doxy/*
#-------------------------------------------------
# msigd
#-------------------------------------------------
msigd: $(OBJ)/msigd.o $(OBJS)
@echo Linking $@...
$(LD) -o $@ $(LDFLAGS) $^ $(LIBS)
#-------------------------------------------------
# documentation
#-------------------------------------------------
doc:
help2man --include=msigd.help2man --no-info ./msigd > man/msigd.1
groff -mandoc -Thtml man/msigd.1 > html/msigd.html
echo -n '```sh\n./msigd --help\n```\n\n```\n' > md/msigd_help.md
./msigd --help >> md/msigd_help.md
echo '```' >> md/msigd_help.md
#-------------------------------------------------
# depends
#-------------------------------------------------
.depend: $(SOURCES)
@echo creating .depend
@rm -f ./.depend
@for i in $(SOURCES); do \
$(CXX) $(CXXFLAGS) -MM $$i -MT `echo $$i | sed -e 's+$(SRC)+$(OBJ)+' -e 's+.cpp+.o+' ` >> ./.depend; \
done
depend: .depend
# Include only if the goal needs it
ifeq ($(filter $(MAKECMDGOALS),$(MAKEFILE_TARGETS_WITHOUT_INCLUDE)),)
-include .depend
endif
#-------------------------------------------------
# generic rules
#-------------------------------------------------
$(OBJ)/%.o: $(SRC)/%.cpp
@echo Compiling $<...
@$(CXX) $(CXXDEFS) $(CXXFLAGS) -c $< -o $@
$(OBJ)/%.pp: $(SRC)/%.cpp
@echo Compiling $<...
@$(CXX) $(CXXDEFS) $(CXXFLAGS) -E $< -o $@
$(OBJ)/%.s: $(SRC)/%.cpp
@echo Compiling $<...
@$(CXX) $(CXXDEFS) $(CXXFLAGS) -S $< -o $@
$(OBJ)/%.a:
@echo Archiving $@...
$(RM) $@
$(AR) $(ARFLAGS) $@ $^
$(OBJ)/%.json: $(SRC)/%.cpp
@echo Building compile database entry for $< ...
@echo { \"directory\": \".\", >> $(TIDY_DB)
@echo \"command\": \"$(CC) $(CXXDEFS) $(CXXFLAGS) -c $< -o dummy.o\", >> $(TIDY_DB)
@echo \"file\": \"$(CURDIR)/$<\" } >> $(TIDY_DB)
@echo "," >> $(TIDY_DB)
compile_commands_prefix:
@echo "[" > $(TIDY_DB)
compile_commands_postfix:
@echo "]" >> $(TIDY_DB)