GNUmakefile.in 8.05 KB
Newer Older
Leigh B. Stoller's avatar
Leigh B. Stoller committed
1 2
#
# EMULAB-COPYRIGHT
3
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
4 5
# All rights reserved.
#
6 7
SRCDIR		= @srcdir@
TESTBED_SRCDIR	= @top_srcdir@
8 9
OBJDIR		= @top_builddir@
SUBDIR		= $(subst $(TESTBED_SRCDIR)/,,$(SRCDIR))
10

11 12
DISTFILES	= TODO client.c decls.h event.c event.h log.c log.h \
		  network.c queue.h server.c trace.c trace.h utils.c utils.h
13
EXPANDCOPYRIGHT	= /usr/site/lib/copyright/expand-copyr
14

15 16 17 18
#
# Support encrypted and signed-checksumed images.
# Requires openssl libraries.
#
19
WITH_CRYPTO	= 1
20
WITH_SIGNING	= 1
21

22 23 24 25 26
#
# Support direct sending of IGMP query/report messages.
#
WITH_IGMP	= 1

27
SYSTEM	:= $(shell uname -s)
28 29

# FreeBSD specific goop
30 31
ifeq ($(SYSTEM),FreeBSD)
FBSDREL	:= $(shell uname -r | sed -e 's/\([^-][^-]*\)-.*/\1/')
32 33
FBSDMAJ := $(basename $(FBSDREL))

34
WITH_LTHREADS	= 0
35 36 37 38 39 40

# XXX 5.3 and linuxthreads don't see to get along
# 7.0 and beyond should not need it
ifneq ($(FBSDREL),5.3)
ifneq ($(FBSDMAJ),7)
ifneq ($(FBSDMAJ),8)
41
ifneq ($(FBSDMAJ),9)
42 43 44
WITH_LTHREADS	= 1
endif
endif
45 46
endif
endif
47
endif
48

49
#ifndef WITH_MSERVER_NULL
50
WITH_MSERVER_NULL	= 1
51 52
#endif
#ifndef WITH_MSERVER_EMULAB
53
WITH_MSERVER_EMULAB	= 1
54
#endif
55

56 57
include $(OBJDIR)/Makeconf

58
all:	frisbee frisbeed mfrisbeed frisupload frisuploadd
59

60 61 62
subboss:
	$(MAKE) WITH_MSERVER_EMULAB=0 all

63 64
include $(TESTBED_SRCDIR)/GNUmakerules

65
FRISBEEDIR	= $(TESTBED_IMAGEZIPSRCDIR)
66

67
SHAREDOBJS	= log.o network.o trace.o utils.o
68 69 70

ifeq ($(SYSTEM),Linux)
PTHREADCFLAGS	+= -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_THREAD_SAFE -pthread
71
PTHREADLIBS	+= -lrt
72 73 74
else
ifeq ($(WITH_LTHREADS),1)
PTHREADCFLAGS	= -D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads
75
PTHREADLIBS	= -L/usr/local/lib -llthread -llgcc_r
76
else
77
PTHREADCFLAGS	= -D_THREAD_SAFE -DCONDVARS_WORK
78 79 80
PTHREADLIBS	= -lpthread
endif
endif
81 82

CLIENTFLAGS	= $(CFLAGS)
Ryan Jackson's avatar
Ryan Jackson committed
83 84 85
ifeq ($(SYSTEM),Linux)
CLIENTLIBS	= -lrt -lz $(PTHREADLIBS)
else
86
CLIENTLIBS	= -lz $(PTHREADLIBS)
Ryan Jackson's avatar
Ryan Jackson committed
87
endif
88
CLIENTOBJS	= client.o frisbee.o checksum.o disksize.o $(SHAREDOBJS)
89 90 91 92 93

SERVERFLAGS	= $(CFLAGS)
SERVERLIBS	= $(PTHREADLIBS)
SERVEROBJS	= server.o $(SHAREDOBJS)

94 95 96 97 98 99 100 101
#
# Master server configuration
#
# Default master server config
MSERVERFLAGS	= -DUSE_NULL_CONFIG $(CFLAGS) -I$(OBJDIR)
MSERVEROBJS	= mserver.o $(SHAREDOBJS) config.o config_null.o
MSERVERLIBS	= 

102 103
# Master server based image uploader client
UPLOADFLAGS	= $(CFLAGS)
104 105 106
ifeq ($(SYSTEM),Linux)
UPLOADLIBS	= -lrt
else
107
UPLOADLIBS	=
108
endif
109 110 111 112 113 114 115
UPLOADOBJS	= upload.o uploadio.o log.o network.o utils.o

# Master server based image uploader server
UPLOADDFLAGS	= $(CFLAGS)
UPLOADDLIBS	=
UPLOADDOBJS	= frisuploader.o uploadio.o log.o

116 117
ifeq ($(WITH_MSERVER_EMULAB),1)
# Emulab master server config
118 119
MYSQLCFLAGS	= -I/usr/local/include
MYSQLLIBS	= -L/usr/local/lib/mysql -lmysqlclient
120 121
MSERVERFLAGS	+= -DUSE_EMULAB_CONFIG -DUSE_LOCALHOST_PROXY $(MYSQLCFLAGS) \
		   -I$(TESTBED_LIBSRCDIR)/libtb
122
MSERVEROBJS	+= config_emulab.o
123
MSERVERLIBS	+= $(TESTBED_LIBOBJDIR)/libtb/libtb.a $(MYSQLLIBS)
124
endif
125 126

CFLAGS		= -O2 -g -Wall -fno-builtin-log $(LDSTATIC) $(PTHREADCFLAGS) -DSTATS -DMASTER_SERVER
Mike Hibler's avatar
Mike Hibler committed
127
LDFLAGS		= $(LDSTATIC)
128

129 130 131 132
IUZFLAGS	= -DFRISBEE
IUZLIBS		= 

ifeq ($(WITH_CRYPTO),1)
133 134 135 136
IUZFLAGS	+= -DWITH_CRYPTO
ifeq ($(WITH_SIGNING),1)
IUZFLAGS	+= -DSIGN_CHECKSUM
endif
137 138
IUZLIBS		+= -lcrypto
endif
139

140 141 142 143 144 145 146 147
#
# Define this to use select to implement packet-receive-with-timeout
# rather than using the SO_RCVTIMEO socket option.
#
ifeq ($(SYSTEM),CYGWIN_NT-5.1)
CFLAGS		+= -DNO_SOCKET_TIMO
endif

Mike Hibler's avatar
Mike Hibler committed
148 149 150 151 152 153 154
#
# Define this to break chunks into 8192 byte rather than 1024 byte blocks
#
ifeq ($(WITH_JUMBO),1)
CFLAGS		+= -DJUMBO
endif

155 156 157 158 159 160 161
#
# Send direct IGMP packets
#
ifeq ($(WITH_IGMP),1)
CFLAGS		+= -DWITH_IGMP
endif

Mike Hibler's avatar
Mike Hibler committed
162 163 164 165 166 167 168 169 170 171 172
#
# Define this to run the client and server on the same physical machine
# over the loopback interface.  You will also have to setup an alias on
# the loopback interface so that client and server can use different IPs:
#
#   ifconfig lo0 alias 127.0.0.2 netmask 255.255.255.255
#
# and just use unicast and not multi/broadcast.
#
#CFLAGS		+= -DSAME_HOST_HACK

173 174 175 176 177
#
# Define this if your implementation of cond_vars works well
# ("works well" in this case means doesn't hang forever or burn up
# the CPU while in condwait).
#
Mike Hibler's avatar
Mike Hibler committed
178 179
#CFLAGS		+= -DCONDVARS_WORK

180
# Define this to a non-zero value to enable recording of trace data
Mike Hibler's avatar
Mike Hibler committed
181
#CFLAGS		+= -DNEVENTS=500000
182 183 184 185 186

# Turn on client event handling
#CFLAGS		+= -DDOEVENTS
#CLIENTOBJS	+= event.o $(OBJDIR)/event/lib/event.o $(OBJDIR)/event/lib/util.o
#CLIENTLIBS	+= `elvin-config --libs vin4c`
187
#EVENTFLAGS	= $(CFLAGS) `elvin-config --cflags vin4c` -I$(TESTBED_SRCDIR)
188

Mike Hibler's avatar
Mike Hibler committed
189
frisbee-debug: $(CLIENTOBJS)
190
	$(CC) $(LDFLAGS) $(CLIENTFLAGS) $(CLIENTOBJS) $(CLIENTLIBS) $(IUZLIBS) -o $@
Mike Hibler's avatar
Mike Hibler committed
191 192
#	cp frisbee frisbee.debug
#	strip frisbee
193

Mike Hibler's avatar
Mike Hibler committed
194 195 196 197
frisbeed-debug: $(SERVEROBJS)
	$(CC) $(LDFLAGS) $(SERVERFLAGS) $(SERVEROBJS) $(SERVERLIBS) -o $@
#	cp frisbeed frisbeed.debug
#	strip frisbeed
198

199 200 201 202 203 204 205 206 207 208
frisupload-debug: $(UPLOADOBJS)
	$(CC) $(LDFLAGS) $(UPLOADFLAGS) $(UPLOADOBJS) $(UPLOADLIBS) -o $@
#	cp frisupload frisupload.debug
#	strip frisupload

frisuploadd-debug: $(UPLOADDOBJS)
	$(CC) $(LDFLAGS) $(UPLOADDFLAGS) $(UPLOADDOBJS) $(UPLOADDLIBS) -o $@
#	cp frisuploadd frisuploadd.debug
#	strip frisuploadd

209 210
mfrisbeed-debug: $(MSERVEROBJS)
	$(CC) $(LDFLAGS) $(MSERVERFLAGS) $(MSERVEROBJS) $(MSERVERLIBS) -o $@
211

212 213 214 215 216 217
frisuploader.o: $(SRCDIR)/frisuploader.c decls.h uploadio.h
	$(CC) -c $(UPLOADDFLAGS) $(SRCDIR)/frisuploader.c
upload.o: $(SRCDIR)/upload.c decls.h utils.h uploadio.h
	$(CC) -c $(UPLOADFLAGS) $(SRCDIR)/upload.c
uploadio.o: $(SRCDIR)/uploadio.c decls.h utils.h uploadio.h
	$(CC) -c $(UPLOADFLAGS) $(SRCDIR)/uploadio.c
218 219
mserver.o: $(SRCDIR)/mserver.c decls.h configdefs.h utils.h
	$(CC) -c $(MSERVERFLAGS) $(SRCDIR)/mserver.c
220 221 222 223
config.o: $(SRCDIR)/config.c configdefs.h log.h
	$(CC) -c $(MSERVERFLAGS) $(SRCDIR)/config.c
config_emulab.o: $(SRCDIR)/config_emulab.c configdefs.h log.h
	$(CC) -c $(MSERVERFLAGS) $(SRCDIR)/config_emulab.c
224 225
config_null.o: $(SRCDIR)/config_null.c configdefs.h log.h
	$(CC) -c $(MSERVERFLAGS) $(SRCDIR)/config_null.c
226

227 228 229
log.o:		$(SRCDIR)/log.c decls.h log.h
	$(CC) $(CFLAGS) -DLOG_TESTBED=$(LOG_TESTBED) -c $(SRCDIR)/log.c

230 231 232
event.o:	$(SRCDIR)/event.c decls.h log.h event.h
	$(CC) $(EVENTFLAGS) -c $(SRCDIR)/event.c

233 234
$(FRISBEEDIR)/imageunzip.c: $(FRISBEEDIR)/imagehdr.h $(FRISBEEDIR)/queue.h $(FRISBEEDIR)/checksum.h
$(FRISBEEDIR)/checksum.c: $(FRISBEEDIR)/imagehdr.h $(FRISBEEDIR)/checksum.h
235

236
disksize.o:	$(FRISBEEDIR)/disksize.c
237 238 239 240
	$(CC) -c $(CFLAGS) $(IUZFLAGS) -I$(FRISBEEDIR) -o disksize.o $<

checksum.o:	$(FRISBEEDIR)/checksum.c
	$(CC) -c $(CFLAGS) $(IUZFLAGS) -I$(FRISBEEDIR) -o checksum.o $<
241

242
frisbee.o:	$(FRISBEEDIR)/imageunzip.c
243
	$(CC) -c $(CFLAGS) $(IUZFLAGS) -I$(FRISBEEDIR) -o frisbee.o $<
244

Mike Hibler's avatar
Mike Hibler committed
245 246
client.o:	decls.h log.h utils.h trace.h
server.o:	decls.h log.h utils.h trace.h
247
log.o:		decls.h log.h
Mike Hibler's avatar
Mike Hibler committed
248
network.o:	decls.h utils.h
249
trace.o:	decls.h trace.h log.h
250

251
install:	$(INSTALL_SBINDIR)/mfrisbeed $(INSTALL_SBINDIR)/frisbeed $(INSTALL_SBINDIR)/frisbee $(INSTALL_SBINDIR)/frisuploadd
252

253 254 255
subboss-install: subboss
	$(MAKE) WITH_MSERVER_EMULAB=0 install

256
client: frisbee frisupload
257 258

client-install: client
259
	$(INSTALL_PROGRAM) frisbee $(DESTDIR)$(CLIENT_BINDIR)
260
	$(INSTALL_PROGRAM) frisupload $(DESTDIR)$(CLIENT_BINDIR)
261

262
clean:
263
	/bin/rm -f *.o *.a frisbee frisbeed mfrisbeed *.debug
Mike Hibler's avatar
Mike Hibler committed
264 265
	/bin/rm -f frisbee.tar frisbee.tar.gz
	/bin/rm -rf frisbee-dist
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282

frisbee.tar.gz: frisbee.tar
	gzip -c frisbee.tar > frisbee.tar.gz

frisbee.tar: frisbee-dist
	tar cf frisbee.tar frisbee-dist
	rm -rf frisbee-dist

frisbee-dist: Makefile.sa Makefile-linux.sa README.sa $(DISTFILES)
	rm -rf frisbee-dist
	mkdir frisbee-dist frisbee-dist/frisbee frisbee-dist/doc
	(cd $(SRCDIR); \
		tar cf - Makefile.sa Makefile-linux.sa README.sa $(DISTFILES))|\
			(cd frisbee-dist/frisbee; tar xf -)
	mv frisbee-dist/frisbee/Makefile.sa frisbee-dist/frisbee/Makefile
	mv frisbee-dist/frisbee/Makefile-linux.sa frisbee-dist/frisbee/Makefile-linux
	mv frisbee-dist/frisbee/README.sa frisbee-dist/README
283
	cp $(TESTBED_SRCDIR)/GPL-COPYING frisbee-dist/COPYING
284
	cp $(TESTBED_SRCDIR)/doc/papers/frisbee-usenix03.pdf frisbee-dist/doc
285
	(cd frisbee-dist/frisbee; \
Mike Hibler's avatar
Mike Hibler committed
286
		$(EXPANDCOPYRIGHT) Makefile Makefile-linux $(DISTFILES))
287 288 289
	(cd ../imagezip; $(MAKE) imagezip.tar)
	(cd frisbee-dist; tar xf -; mv imagezip-dist imagezip) \
		< ../imagezip/imagezip.tar