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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
#!/usr/bin/make -f
-include Makefile.cfg
# ---
# Informations principales concernant le projet.
# ---
# Nom et description.
NAME := weshd
DESC := Démon et utilitaires de gestion de serveurs WES.
# Informations concernant le mainteneur.
MAINTAINER_NAME := Thomas Touhey
MAINTAINER_MAIL := thomas@touhey.fr
MAINTAINER := $(MAINTAINER_NAME) <$(MAINTAINER_MAIL)>
# Version du projet.
MAJOR := 0
MINOR := 1
INDEV := y
VERSION := $(MAJOR).$(MINOR)$(if $(INDEV),-indev)
# Noms des composants.
DAEMON := weshd
LIB := wesh
LIBW := wes
CLIENT := weshclient
# ---
# Utilitaires.
# ---
CC := clang
LD := clang
CWARN := -Weverything -Wno-disabled-macro-expansion \
-Wno-switch-enum -Wno-missing-field-initializers -Wno-format-nonliteral \
-Wno-reserved-id-macro -Wno-padded -Wno-covered-switch-default
CDEFS := -D WESHD_VERSION="\"$(VERSION)\"" -D WESHD_MAINT="\"$(MAINTAINER)\""
CFLAGS := -pedantic$(if $(DEBUG_SYMS), -g) $(CWARN) $(CDEFS)
CXXWARN := $(CWARN) -Wno-c++98-compat -Wno-c++98-compat-pedantic \
-Wno-vla -Wno-vla-extension -Wno-weak-vtables -Wno-covered-switch-default \
$(CDEFS)
CXX := clang++
LDXX := clang++
CXXFLAGS := $(CXXWARN)
RM := rm -f
CP := cp
MV := mv
LN := ln -sf
MD := mkdir -p
INST := install
RPCGEN := rpcgen
# ---
# Dépendances.
# ---
# libcurl, pour accéder au serveur en HTTP et FTP.
DEP_libcurl_CFLAGS := $(shell pkg-config libcurl --cflags)
DEP_libcurl_LIBS := $(shell pkg-config libcurl --libs)
# SunRPC, pour l'IPC entre la bibliothèque client et le démon.
DEP_rpc_CFLAGS := $(shell pkg-config libtirpc --cflags)
DEP_rpc_LIBS := $(shell pkg-config libtirpc --libs)
# libwes, soit la bibliothèque d'interaction avec le WES.
DEP_lw_CFLAGS := -I libwes/
DEP_lw_LIBS := -L build -l$(LIBW)
# libwesh, soit la bibliothèque client.
DEP_lib_CXXFLAGS := -I include/
DEP_lib_LIBS := -L build -l$(LIB)
# boost tel qu'utilisé par le client.
DEP_boost_CXXFLAGS :=
DEP_boost_LIBS := -lboost_program_options
# ---
# Informations concernant les fichiers générés par SunRPC.
# ---
# Fichiers et dossiers concernés.
S_FROM := ./weshd.x
S_OBJDIR := ./build/rpc
S_NAME := $(patsubst %.x,%,$(notdir $(S_FROM)))
# Options.
S_CFLAGS := $(DEP_rpc_CFLAGS)
# ---
# Informations concernant la bibliothèque d'interaction avec les WES.
# ---
# Dossiers la concernant.
W_DEST := ./build/lib$(LIBW).so
W_SRCDIR := ./libwes/src
W_INCDIR := ./libwes/include
W_OBJDIR := ./build/libw
# Recherche de ses sources.
W_SRC := \
$(patsubst $(W_SRCDIR)/%,%,$(wildcard $(W_SRCDIR)/*.c \
$(W_SRCDIR)/**/*.c))
W_OBJ := $(W_SRC:%=$(W_OBJDIR)/%.o)
W_INCp := $(patsubst $(W_INCDIR)/%,%,$(wildcard \
$(W_INCDIR)/*.hpp $(W_INCDIR)/**/*.hpp))
W_INC := $(W_INCp:%=$(W_INCDIR)/%) \
$(wildcard $(W_SRCDIR)/*.h $(W_SRCDIR)/**/*.h)
# Dépendances et options.
W_DEPS := libcurl
W_CFLAGS := $(CFLAGS) $(foreach x,$(W_DEPS),$(DEP_$(x)_CFLAGS)) \
-fPIC -I $(W_INCDIR) \
-D DELETE_SCRIPTS="$(if $(DELETE_SCRIPTS),$(DELETE_SCRIPTS),1)" \
-D CURLHTTPVERBOSE="$(if $(CURL_HTTP_VERBOSE),$(CURL_HTTP_VERBOSE),0)L" \
-D CURLFTPVERBOSE="$(if $(CURL_FTP_VERBOSE),$(CURL_FTP_VERBOSE),0)L"
W_LIBS := $(foreach x,$(W_DEPS),$(DEP_$(x)_LIBS))
W_LDFLAGS := $(W_LIBS) -shared -Wl,-z,relro -Wl,-z,combreloc -Wl,-z,defs \
-Wl,-soname,lib$(LIBW).so.$(MAJOR)
# ---
# Informations concernant le démon.
# ---
# Dépendances et options.
D_DEPS := rpc libw
D_CFLAGS := $(CFLAGS) $(foreach x,$(D_DEPS),$(DEP_$(x)_CFLAGS)) \
-I $(S_OBJDIR) -D NOLOGO=$(NO_LOGO) -D DEFAULT_LOGLEVEL=WL$(LOG_LEVEL)
D_LIBS := $(foreach x,$(D_DEPS),$(DEP_$(x)_LIBS))
# Dossiers le concernant.
D_DEST := ./build/$(DAEMON)
D_SRCDIR := ./daemon
D_OBJDIR := ./build/daemon
# Recherche de ses sources.
D_SRC := \
$(patsubst $(D_SRCDIR)/%,%,$(wildcard $(D_SRCDIR)/*.c $(D_SRCDIR)/**/*.c))
D_OBJ := $(D_SRC:%=$(D_OBJDIR)/%.o) \
$(S_OBJDIR)/$(S_NAME)_xdr.c.o $(S_OBJDIR)/$(S_NAME)_svc.c.o
D_INC := $(wildcard $(D_SRCDIR)/*.h $(D_SRCDIR)/**/*.h) \
$(S_OBJDIR)/$(S_NAME).h
# ---
# Informations concernant la bibliothèque client.
# ---
# Dossiers la concernant.
L_DEST := ./build/lib$(LIB).so
L_SRCDIR := ./libwesh/src
L_INCDIR := ./libwesh/include
L_OBJDIR := ./build/lib
# Recherche de ses sources.
L_SRC := \
$(patsubst $(L_SRCDIR)/%,%,$(wildcard $(L_SRCDIR)/*.cpp \
$(L_SRCDIR)/**/*.cpp))
L_OBJ := $(L_SRC:%=$(L_OBJDIR)/%.o) \
$(S_OBJDIR)/$(S_NAME)_xdr.c.o $(S_OBJDIR)/$(S_NAME)_clnt.c.o
L_INCp := $(patsubst $(L_INCDIR)/%,%,$(wildcard \
$(L_INCDIR)/*.hpp $(L_INCDIR)/**/*.hpp))
L_INC := $(L_INCp:%=$(L_INCDIR)/%) $(S_OBJDIR)/$(S_NAME).h \
$(wildcard $(L_SRCDIR)/*.hpp $(L_SRCDIR)/**/*.hpp)
# Dépendances et options.
L_DEPS := rpc
L_CXXFLAGS := $(CXXFLAGS) $(foreach x,$(L_DEPS),$(DEP_$(x)_CFLAGS)) \
-I $(S_OBJDIR) -fPIC -I $(L_INCDIR)
L_LIBS := $(foreach x,$(L_DEPS),$(DEP_$(x)_LIBS))
L_LDFLAGS := $(L_LIBS) -shared -Wl,-z,relro -Wl,-z,combreloc -Wl,-z,defs \
-Wl,-soname,lib$(LIB).so.$(MAJOR)
# ---
# Informations concernant le client de base.
# ---
# Dossiers le concernant.
C_DEST := ./build/$(CLIENT)
C_SRCDIR := ./client
C_OBJDIR := ./build/client
# Recherche de ses sources.
C_SRC := \
$(patsubst $(C_SRCDIR)/%,%,$(wildcard $(C_SRCDIR)/*.cpp))
C_OBJ := $(C_SRC:%=$(C_OBJDIR)/%.o) \
$(S_OBJDIR)/$(S_NAME)_xdr.c.o $(S_OBJDIR)/$(S_NAME)_clnt.c.o
C_INC := $(wildcard $(C_SRCDIR)/*.hpp) $(wildcard $(L_INCDIR)/*.hpp) \
$(S_OBJDIR)/$(S_NAME).h
# Dépendances et options.
C_DEPS := lib boost
C_CXXFLAGS := $(CXXFLAGS) $(foreach x,$(C_DEPS),$(DEP_$(x)_CXXFLAGS))
C_LIBS := $(foreach x,$(C_DEPS),$(DEP_$(x)_LIBS))
C_LDFLAGS := $(C_LIBS)
# ---
# Vérification du DESTDIR (comme préfixe aux racines d'installation).
# ---
OINCDIR := $(IINCDIR)
OLIBDIR := $(ILIBDIR)
define add-dest-dir
$1 = $(DESTDIR)$($1)
endef
$(if $(DESTDIR),$(foreach idir,IBINDIR IPKGDIR ILIBDIR IINCDIR,\
$(eval $(call add-dest-dir,$(idir)))))
# End of file.
|