-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
156 lines (127 loc) · 4.46 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
147
148
149
150
151
152
153
154
155
156
# Makefile for AI registry tools:
# - regserver (registry server)
# - regclient (registry client)
# Variables
# =========
NAME_SERVER = regserver
NAME_CLIENT = regclient
NAME_INITD = regserver
NAME_SYSTEMD = regserver.service
PATH_ROOT = .
PATH_SOURCE = ./source
PATH_INCLUDE = ./include
INSTALL_PATH = /ocadrone/apps/registry
INSTALL_INITD = /etc/init.d
INSTALL_SYSTEMD = /usr/lib/systemd/system
# Sources
# =======
SRC_SERVER = $(PATH_SOURCE)/main_server.cpp \
$(PATH_SOURCE)/server.cpp
SRC_CLIENT = $(PATH_SOURCE)/main_client.cpp
SRC_INITD = $(PATH_SOURCE)/regserver.initd
SRC_SYSTEMD = $(PATH_SOURCE)/regserver.systemd
# Compilation options
# ===================
CC = g++
CFLAGS = -W -Wall -ansi -pedantic -O3 -std=c++11 -Wl,-rpath /usr/local/lib/
CLIBS = -lKNM -lAIRegistry -lpthread
# Rules configuration
# ===================
.PHONY: help clean \
build build-server build-client \
install install-server install-client \
install-initd install-systemd \
remove remove-server remove-client
.SILENT: help clean \
build build-server build-client \
install install-server install-client \
install-initd install-systemd \
remove remove-server remove-client
# Basic Rules
# ===========
$(NAME): help
help:
@echo "Registry tools' Makefile help"
@echo "============================="
@echo "[*] Compilation"
@echo " Type 'make build' to build the tools."
@echo " To build only server: 'make build-server'"
@echo " To build only client: 'make build-client'"
@echo ""
@echo "[*] Installation"
@echo " Type 'make install' (as root)."
@echo " To install initd script: make install-initd"
@echo " To install systemd script: make install-systemd"
@echo ""
@echo "[*] Removing"
@echo " Type 'make remove'."
@echo ""
@echo "Note: Two libraries are needed:"
@echo "'libKNM' and 'libAIRegistry'."
# Compilation rules
# =================
build:
make --no-print-directory build-server
make --no-print-directory build-client
build-server:
@echo "--------------------------------------------"
@echo "Building server"
@echo "Compiler : $(CC)"
@echo "Compiler flags : $(CFLAGS)"
@echo "Libraries : $(CLIBS)"
@echo "--------------------------------------------"
$(CC) $(CFLAGS) $(CLIBS) $(SRC_SERVER) -I $(PATH_INCLUDE) -o $(NAME_SERVER)
build-client:
@echo "--------------------------------------------"
@echo "Building client"
@echo "Compiler : $(CC)"
@echo "Compiler flags : $(CFLAGS)"
@echo "Libraries : $(CLIBS)"
@echo "--------------------------------------------"
$(CC) $(CFLAGS) $(CLIBS) $(SRC_CLIENT) -I $(PATH_INCLUDE) -o $(NAME_CLIENT)
# Installation rules
# ==================
install:
if [ ! -d $(INSTALL_PATH) ]; then mkdir -p $(INSTALL_PATH); fi
make --no-print-directory install-server
make --no-print-directory install-client
install-server:
@echo "---"
@echo "Installing registry server 'regserver'"
@echo "Installation directory: $(INSTALL_PATH)"
cp $(NAME_SERVER) $(INSTALL_PATH)
@echo "Done."
install-client:
@echo "---"
@echo "Installing registry client 'regclient'"
@echo "Installation directory: $(INSTALL_PATH)"
cp $(NAME_CLIENT) $(INSTALL_PATH)
@echo "Done."
install-initd:
@echo "---"
@echo "Installing registry server init.d script"
if [ -e $(SRC_INITD) ]; then cp $(SRC_INITD) $(INSTALL_INITD)/$(NAME_INITD); fi
@echo "Done."
install-systemd:
@echo "---"
@echo "Installing registry server systemd script"
if [ -e $(SRC_SYSTEMD) ]; then cp $(SRC_SYSTEMD) $(INSTALL_SYSTEMD)/$(NAME_SYSTEMD); fi
@echo "Done."
# Removing & cleaning rules
# =========================
remove:
make --no-print-directory remove-server
make --no-print-directory remove-client
remove-server:
@echo "Removing server"
if [ -e $(INSTALL_PATH)/$(NAME_SERVER) ]; then rm $(INSTALL_PATH)/$(NAME_SERVER); fi
if [ -e $(INSTALL_INITD)/$(NAME_INITD) ]; then rm $(INSTALL_INITD)/$(NAME_INITD); fi
if [ -e $(INSTALL_SYSTEMD)/$(NAME_SYSTEMD) ]; then rm $(INSTALL_SYSTEMD)/$(NAME_SYSTEMD); fi
@echo "Done."
remove-client:
@echo "Removing client"
if [ -e $(INSTALL_PATH)/$(NAME_CLIENT) ]; then rm $(INSTALL_PATH)/$(NAME_CLIENT); fi
@echo "Done."
clean:
if [ -e $(NAME_SERVER) ]; then rm $(NAME_SERVER); fi
if [ -e $(NAME_CLIENT) ]; then rm $(NAME_CLIENT); fi