Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

gdp / gdp / Makefile @ master

History | View | Annotate | Download (6.64 KB)

1
#
2
#  ----- BEGIN LICENSE BLOCK -----
3
#	GDP: Global Data Plane Support Library
4
#	From the Ubiquitous Swarm Lab, 490 Cory Hall, U.C. Berkeley.
5
#
6
#	Copyright (c) 2015-2019, Regents of the University of California.
7
#	All rights reserved.
8
#
9
#	Permission is hereby granted, without written agreement and without
10
#	license or royalty fees, to use, copy, modify, and distribute this
11
#	software and its documentation for any purpose, provided that the above
12
#	copyright notice and the following two paragraphs appear in all copies
13
#	of this software.
14
#
15
#	IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
16
#	SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST
17
#	PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
18
#	EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
#
20
#	REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
21
#	LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22
#	FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION,
23
#	IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO
24
#	OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
25
#	OR MODIFICATIONS.
26
#  ----- END LICENSE BLOCK -----
27
#
28

    
29
# Version number of library.  All others are derived from here.
30
# NOTE: lang/python/gdp/MISC.py has MAJOR.MINOR hard coded; if you change
31
#       either of them, change `gdp_ver` in that file too.  (This is not
32
#       a feature.)
33
# FIXME: This should be in the top level Makefile, not here.
34
GDP_VERSION_MAJOR=	2
35
GDP_VERSION_MINOR=	3
36
GDP_VERSION_PATCH=	1
37

    
38
# These are generally changed on make command line
39
DESTDIR=
40
LOCALROOT=	/usr
41
LOCAL1=		/usr/local
42
LOCAL2=		/opt/local
43
LOCAL3=		/usr/local/opt/openssl
44

    
45
# These generally do not need to be changed
46
INSTALLROOT=	${DESTDIR}${LOCALROOT}
47
INCDIR=		${INSTALLROOT}/include
48
LIBDIR=		${INSTALLROOT}/lib
49
BINDIR=		${INSTALLROOT}/bin
50
SBINDIR=	${INSTALLROOT}/sbin
51
MANDIR=		${INSTALLROOT}/share/man
52
ALLDIRS=	${BINDIR} \
53
		${SBINDIR} \
54
		${LIBDIR} \
55
		${INCDIR}/gdp \
56
		${MANDIR}/man7 \
57
		${MANDIR}/man8
58
ADM=		../adm
59
LOCALLIBSDIR=	../libs
60
LIBNAME=	libgdp
61

    
62
BINALL=
63

    
64
SBINALL=
65

    
66
MAN1ALL=
67

    
68
MAN3ALL=
69

    
70
MAN5ALL=
71

    
72
MAN7ALL=	gdp.7 \
73

    
74
MAN8ALL=
75

    
76
MANALL=		${MAN1ALL} ${MAN3ALL} ${MAN5ALL} ${MAN7ALL} ${MAN8ALL}
77

    
78
OBJS_ZC = \
79
	gdp_zc_client.o \
80
	gdp_zc_server.o
81

    
82
OBJS_MOST=	\
83
	gdp_api.o \
84
	gdp_buf.o \
85
	gdp_chan.o \
86
	gdp_create.o \
87
	gdp_crypto.o \
88
	gdp_datum.o \
89
	gdp_event.o \
90
	gdp_gob_cache.o \
91
	gdp_gob_mgmt.o \
92
	gdp_gob_ops.o \
93
	gdp_main.o \
94
	gdp_md.o \
95
	gdp_msg.o \
96
	gdp_name.o \
97
	gdp_pdu.o \
98
	gdp_proto.o \
99
	gdp_req.o \
100
	gdp_stat.o \
101
	gdp_subscr.o \
102
	gdp_util.o \
103
	gdp.pb-c.o \
104
	$(OBJS_ZC)
105

    
106
OBJS=	\
107
	${OBJS_MOST} \
108
	gdp_version.o
109

    
110
PUBHFILES=	\
111
	gdp.h \
112
	gdp_buf.h \
113
	gdp_stat.h \
114
	gdp_version.h \
115
	gdp_zc_client.h \
116
	gdp_zc_server.h \
117

    
118
PRIVHFILES=	\
119
	gdp_chan.h \
120
	gdp_event.h \
121
	gdp_hongd.h \
122
	gdp_md.h \
123
	gdp_pdu.h \
124
	gdp_priv.h \
125
	gdp.pb-c.h \
126

    
127
HFILES=		${PUBHFILES} ${PRIVHFILES}
128

    
129
GDPLIBVER=	${GDP_VERSION_MAJOR}.${GDP_VERSION_MINOR}
130
INCALL=		${PUBHFILES}
131
LIBALL=		libgdp.a libgdp.so.${GDPLIBVER}
132
# files that should be removed on "make clean"
133
CLEANALL=	${LIBALL} ${BINALL} ${SBINALL} gdp_version.h
134
# files that should be publicly installed
135
PUBALL=		${SCRIPTS} ${MANALL} ${INCALL} ${LIBALL}
136
# "make all" targets (may be overlap)
137
ALL=		${CLEANALL} ${PUBALL}
138

    
139
SANITIZE=
140
#SANITIZE+=	-fsanitize=address
141
#SANITIZE+=	-fsanitize=thread
142
#SANITIZE+=	-fsanitize=memory
143
#SANITIZE+=	-fsanitize=undefined
144

    
145
INCROOT=	..
146
INCSEARCH=	${INCLOCAL} \
147
		-I${INCROOT} \
148
		`mysql_config --include` \
149
		-I${LOCAL1}/include \
150
		-I${LOCAL2}/include \
151
		-I${LOCAL3}/include
152
LIBROOT=	${INCROOT}
153
LIBEVENT2=	-levent -levent_pthreads
154
LIBCRYPTO=	-lcrypto
155
LIBPROTO_C=	-lprotobuf-c
156
LIBAVAHI=	-lavahi-client -lavahi-common
157
LIBMYSQL=	`mysql_config --libs`
158
LIBADD=		`sh ../adm/add-libs.sh libgdp`
159
INCEP=		-I${INCROOT}
160
LIBEP=		-lep
161
INCS=		${INCSEARCH} ${INCEP} ${INCEVENT2} ${INCAVAHI}
162
LIBSEARCH=	${LIBLOCAL} \
163
		-L${LIBROOT}/ep \
164
		-L${LOCAL1}/lib \
165
		-L${LOCAL2}/lib \
166
		-L${LOCAL3}/lib
167
LDFLAGS+= 	${LIBSEARCH} ${SANITIZE}
168
LDLIBS=		${LIBEP} \
169
		${LIBEVENT2} \
170
		${LIBCRYPTO} \
171
		${LIBPROTO_C} \
172
		${LIBAVAHI} \
173
		${LIBMYSQL} \
174
		${LIBADD}
175
CC=		cc
176
PG=
177
WALL=		-Wall
178
G=		-g
179
O=		-O
180
STD=
181
COPTS=		${PG} ${WALL} $G $O ${STD} ${SANITIZE}
182
CFLAGS+=	${COPTS} ${INCS} -fPIC
183

    
184
LN=		ln
185
MV=		mv
186
CP=		cp
187
RM=		rm
188
MKDIR=		mkdir -p
189
RANLIB=		ranlib
190
PROTOC_C=	protoc-c
191
SHARED=		-shared ${CRYPTOLFLAGS}
192
#SHARED=		-shared ${CRYPTOLFLAGS} -Wl,-soname,$@
193
INSTALLFLAGS=
194
INSTALL=	install ${INSTALLFLAGS}
195

    
196
all: ${ALL}
197

    
198
# Build without avahi, the zero-conf facility that
199
# can be tricky to compile under Mac OS X.
200
all_noavahi:
201
	${MAKE}	STD=-DGDP_OSCF_USE_ZEROCONF=0 LIBAVAHI= OBJS_ZC= all
202

    
203
${LIBNAME}.a: ${OBJS}
204
	${AR} -r $@ ${OBJS}
205
	${RANLIB} $@
206
	${RM} -f ${LOCALLIBSDIR}/$@
207
	${CP} $@ ${LOCALLIBSDIR}
208

    
209
${LIBNAME}.so.${GDPLIBVER}: ${OBJS}
210
	${CC} ${SHARED} -o $@ ${LDFLAGS} ${OBJS} ${LDLIBS}
211
	${RM} -f ${LOCALLIBSDIR}/$@
212
	${CP} $@ ${LOCALLIBSDIR}
213
	sh ${LOCALLIBSDIR}/makelinks.sh gdp ${GDP_VERSION_MAJOR} ${GDP_VERSION_MINOR} ${LOCALLIBSDIR}
214

    
215
${OBJS}: ${HFILES}
216

    
217

    
218
gdp.pb-c.c gdp.pb-c.h: gdp.proto
219
	${PROTOC_C} --c_out=. gdp.proto
220

    
221
gdp_version.o: gdp_version.c ${OBJS_MOST} Makefile gdp_version.h
222
	${CC} ${CFLAGS} \
223
		-D_VERSION_INFO_="\"`sh ../adm/get-version-info.sh`\"" \
224
		-c gdp_version.c
225

    
226
gdp_version.h ../adm/gdp-version.sh: gdp_version.template gdp_version.sh Makefile
227
	sh gdp_version.sh ${GDP_VERSION_MAJOR} ${GDP_VERSION_MINOR} ${GDP_VERSION_PATCH}
228

    
229
#../git-version.txt:
230
#	../adm/get-version-info.sh > /dev/null
231

    
232
#
233
#  Administrative stuff
234
#
235

    
236
# cleanup
237
clean:
238
	-rm -f ${CLEANALL} *.o *.core
239

    
240
# system installation
241
install-lib: ${LIBDIR} ${LIBALL}
242
	test -z "${LIBALL}"  || ${CP} ${LIBALL}  ${LIBDIR}
243
	sh ${LOCALLIBSDIR}/makelinks.sh gdp ${GDP_VERSION_MAJOR} ${GDP_VERSION_MINOR} ${LIBDIR}
244

    
245
install-include: ${INCDIR}/gdp ${INCALL}
246
	test -z "${INCALL}"  || ${CP} ${INCALL}  ${INCDIR}/gdp
247

    
248
install-bin: ${BINDIR} ${SBINDIR}
249
	test -z "${BINALL}"  || ${INSTALL} ${BINALL}  ${BINDIR}
250
	test -z "${SBINALL}" || ${INSTALL} ${SBINALL} ${SBINDIR}
251

    
252
install-man: ${MANDIR} ${MANALL}
253
	test -z "${MAN1ALL}" || ${CP} ${MAN1ALL} ${MANDIR}/man1
254
	test -z "${MAN3ALL}" || ${CP} ${MAN3ALL} ${MANDIR}/man3
255
	test -z "${MAN7ALL}" || ${CP} ${MAN7ALL} ${MANDIR}/man7
256
	test -z "${MAN8ALL}" || ${CP} ${MAN8ALL} ${MANDIR}/man8
257

    
258
install:	install-include install-lib install-bin install-man
259

    
260
${ALLDIRS}:
261
	${MKDIR} $@
262

    
263
# local installation (into source tree, needed for Java & Debian package build)
264
# XXX Why is this needed?  It's done when the libraries are built.
265
install-local:	${LOCALLIBSDIR} ${LIBALL}
266
	${CP} ${LIBALL} ${LOCALLIBSDIR}
267
	sh ${LOCALLIBSDIR}/makelinks.sh gdp ${GDP_VERSION_MAJOR} ${GDP_VERSION_MINOR} ${LOCALLIBSDIR}
268

    
269
UPDATE_LICENSE=	${ADM}/update-license.sh
270

    
271
update-license:
272
	${UPDATE_LICENSE} Makefile *.[ch]
273

    
274
FORCE: