-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
92 lines (73 loc) · 2.65 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
# Copyright (c) 2022 by Thomas A. Early N7TAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# locations for the executibles and other files are set here
# NOTE: IF YOU CHANGE THESE, YOU WILL NEED TO UPDATE THE service.* FILES AND
# if you change these locations, make sure the sgs.service file is updated!
# you will also break hard coded paths in the dashboard file, index.php.
EXE = mrefd
include $(EXE).mk
ifeq ($(USESYMLINK), true)
CPORLN = ln -s
else
CPORLN = cp -f
endif
CFLAGS += -c -W -std=c++17 -MMD -c
LDFLAGS=-pthread
ifeq ($(DEBUG), true)
CFLAGS += -ggdb3
endif
ifeq ($(DHT), true)
LDFLAGS += -lopendht -lcurl
else
CFLAGS += -DNO_DHT
endif
ifeq ($(DAEMON), true)
CFLAGS += -DRUN_AS_DAEMON
endif
ifeq ("$(OS)","Windows_NT")
CFLAGS += -D_GNU_SOURCE
endif
SRCS = base.cpp bwset.cpp callsign.cpp client.cpp clients.cpp configure.cpp crc.cpp gatekeeper.cpp ifile.cpp ifileitem.cpp ip.cpp packet.cpp packetstream.cpp peer.cpp peers.cpp protocol.cpp reflector.cpp udpsocket.cpp user.cpp users.cpp version.cpp main.cpp
OBJS = $(SRCS:.cpp=.o)
DEPS = $(SRCS:.cpp=.d)
all : $(EXE) test-all
test-all : test-all.o crc.o callsign.o
$(CXX) $^ -o $@
$(EXE) : $(OBJS)
$(CXX) $^ -o $@ $(LDFLAGS)
%.o : %.cpp
$(CXX) $(CFLAGS) $< -o $@
clean :
$(RM) *.o *.d $(EXE) test-all
-include $(DEPS)
install : $(EXE).blacklist $(EXE).whitelist $(EXE).interlink $(EXE).cfg
$(CPORLN) $(shell pwd)/$(EXE).blacklist $(CFGDIR)/$(EXE).blacklist
$(CPORLN) $(shell pwd)/$(EXE).whitelist $(CFGDIR)/$(EXE).whitelist
$(CPORLN) $(shell pwd)/$(EXE).interlink $(CFGDIR)/$(EXE).interlink
$(CPORLN) $(shell pwd)/$(EXE).cfg $(CFGDIR)/$(EXE).cfg
sed -e "s#XXX#$(CFGDIR)#" -e "s#YYY#$(EXE)#" systemd/mrefd.service > /etc/systemd/system/$(EXE).service
cp -f $(EXE) $(BINDIR)
systemctl enable $(EXE).service
systemctl daemon-reload
systemctl start $(EXE)
uninstall :
rm -f $(CFGDIR)/$(EXE).blacklist
rm -f $(CFGDIR)/$(EXE).whitelist
rm -f $(CFGDIR)/$(EXE).interlink
rm -f $(CFGDIR)/$(EXE).cfg
systemctl stop $(EXE).service
systemctl disable $(EXE).service
rm -f /etc/systemd/system/$(EXE).service
systemctl daemon-reload