GNUmakefile.in 14.9 KB
Newer Older
1
#
2
# Copyright (c) 2000-2017 University of Utah and the Flux Group.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file 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 Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
22
#
23 24
# Testbed Makefile
#
25 26 27 28 29
SRCDIR		= @srcdir@
OBJDIR		= .
SUBDIR		= 
TESTBED_SRCDIR  = @top_srcdir@
DISTCLEAN_FILES = @DISTCLEAN_FILES@ 
30
EVENTSYS	= @EVENTSYS@
31
PELABSUPPORT	= @PELABSUPPORT@
32
PGENISUPPORT    = @PROTOGENI_SUPPORT@
33
ISMAINSITE	= @TBMAINSITE@
34
SPEWFROMOPS	= @SPEWFROMOPS@
35
MOBILESUPPORT   = @MOBILESUPPORT@
36 37
SYSTEM	       := $(shell uname -s)

38 39
include Makeconf

40 41 42
#
# Ordering here matters!
# Things with no dependencies go first: 
43
#   assign db lib www
44 45
# Things that may have dependencies go next:
#   @optional_subdirs@ (has event)
46
#   ipod os security sensors 
47
# Then things that only depend on stuff we've done:
48
#   pxe tbsetup tmcd utils backend www tip vis
49 50
# Then things that depend on stuff we just did:
#
51
ifeq ($(STANDALONE_CLEARINGHOUSE),0)
52 53 54
SUBDIRS = \
	clientside/lib \
	db assign www @optional_subdirs@ clientside ipod security sensors \
55
	pxe tbsetup account tmcd utils backend tip ipod vis \
56
	sensors os xmlrpc autofs install/newnode_sshkeys \
57
	tools/svn collab/exp-vis node_usage install
58
ifeq ($(ISMAINSITE),1)
59
SUBDIRS += tools/rmanage tools/whol
60
endif
61
ifeq ($(PGENISUPPORT),1)
62
SUBDIRS += protogeni apt
63
endif
64 65 66
else
SUBDIRS = db tbsetup account protogeni
endif
67

68
all:		all-subdirs just-builddirs 
69

70 71 72 73 74 75 76
#
# We used to statically link our event agents.  We no longer do this, but
# if you want "old style" agents, use this target.
#
all-static:
	@LDSTATIC=-static $(MAKE) all

77
ifeq ($(STANDALONE_CLEARINGHOUSE),0)
78
install:	
79 80
	@echo "Choose either boss-install, ops-install or fs-install"
	@echo "Choose opsfs-install instead of ops-install for a combined ops/fs machine"
81
	@echo "Choose tipserv-install for dedicated tip server machines."
82 83 84
else
install: clrhouse-install
endif
85 86

#
87
# For installation on boss node
88
# 
89
boss-install:	install-checks \
90
		install-subdirs install-mkdirs \
91
		install-setbuildinfo
92
	@echo "Boss node installed!"
93

94
# Same target, with the checks omitted
95
boss-install-force:	install-subdirs install-mkdirs install-setbuildinfo
96
	@echo "Boss node installed!"
97

98
# Skip only the schema checks, but do the other checks.
99
boss-install-noschemacheck: install-updatecheck \
100 101 102 103 104
		install-sitevarscheck install-dbfillcheck \
		install-genischemacheck install-subdirs install-mkdirs \
		install-setbuildinfo

# Skip the update check. 
105
boss-install-noupdatecheck: install-schemacheck \
106
		install-sitevarscheck install-dbfillcheck \
107 108 109
		install-genischemacheck install-subdirs install-mkdirs \
		install-setbuildinfo

110
# Only the checks:
111
install-checks: \
112
		install-updatecheck \
113 114 115 116 117
		install-schemacheck \
		install-sitevarscheck \
		install-dbfillcheck install-genischemacheck
	@echo "Installation checks completed!"

118 119 120
clrhouse-install:	install-subdirs install-mkdirs
	@echo "CleaingHouse code installed!"

121
post-install:
122
	@$(MAKE) -C db post-install
123
	@$(MAKE) -C ipod post-install
124
	@$(MAKE) -C tbsetup post-install
125
	@$(MAKE) -C account post-install
126
	@$(MAKE) -C security post-install
127 128
	@$(MAKE) -C vis post-install
	@$(MAKE) -C www post-install
129
ifeq ($(EVENTSYS),1)
130
	@$(MAKE) -C event post-install
131 132 133
endif
ifeq ($(MOBILESUPPORT),1)
	@$(MAKE) -C mobile
134
endif
135
	@$(MAKE) -C tools post-install
136
	@$(MAKE) -C collab post-install
137
	@$(MAKE) -C utils post-install
138 139 140
ifeq ($(NODE_USAGE_SUPPORT),1)
	@$(MAKE) -C node_usage post-install
endif
141

142
#
143
# For installation on the 'ops' or 'users' node (okay, plastic)
144
# 
145
ops-install:
146 147 148
	-mkdir -p $(INSTALL_TOPDIR)/log
	-mkdir -p $(INSTALL_TOPDIR)/log/mysql
	-chmod 770 $(INSTALL_TOPDIR)/log/mysql
149 150
	-chown mysql $(INSTALL_TOPDIR)/log/mysql
	-chgrp mysql $(INSTALL_TOPDIR)/log/mysql
151 152
	-mkdir -p $(INSTALL_TOPDIR)/log/logfiles
	-chmod 777 $(INSTALL_TOPDIR)/log/logfiles
153
	@$(MAKE) -C rc.d control-install
154 155
	@$(MAKE) -C tbsetup control-install
	@$(MAKE) -C security control-install
156 157
	@$(MAKE) -C tip control-install
	@$(MAKE) -C db control-install
158
	@$(MAKE) -C utils control-install
159
	@$(MAKE) -C clientside control-install
160
ifeq ($(EVENTSYS),1)
161
	@$(MAKE) -C event control-install
162
endif
163
	@$(MAKE) -C xmlrpc control-install
Leigh Stoller's avatar
Leigh Stoller committed
164
	@$(MAKE) -C account control-install
165 166 167
ifeq ($(PELABSUPPORT),1)
	@$(MAKE) -C pelab control-install
endif
168

169
fs-install:
170
	@$(MAKE) -C rc.d fs-install
171
	@$(MAKE) -C tbsetup fs-install
172
	@$(MAKE) -C clientside fs-install
173
	@$(MAKE) -C sensors fs-install
174 175 176 177

opsfs-install: ops-install fs-install
	@echo "Combined ops/fs install done."

178
install-mkdirs:
179
	-mkdir -p $(INSTALL_TOPDIR)/db
180 181
	-mkdir -p $(INSTALL_TOPDIR)/locks
	-mkdir -p $(INSTALL_TOPDIR)/log
182
	-mkdir -p $(INSTALL_TOPDIR)/log/mysql
183 184
	-mkdir -p $(INSTALL_TOPDIR)/etc
	-mkdir -p $(INSTALL_TOPDIR)/www
185
	-mkdir -p $(INSTALL_TOPDIR)/suidbin
186 187 188 189
	-mkdir -p $(INSTALL_TOPDIR)/ssl
	-chmod 770 $(INSTALL_TOPDIR)/ssl
ifeq ($(STANDALONE_CLEARINGHOUSE),0)
	-mkdir -p $(INSTALL_TOPDIR)/opsdir
190
	-mkdir -p $(INSTALL_TOPDIR)/log/exports
191
	-mkdir -p $(INSTALL_TOPDIR)/lists
192
	-mkdir -p $(INSTALL_TOPDIR)/backup
193
	-mkdir -p $(INSTALL_TOPDIR)/expwork
194 195
	-mkdir -p $(INSTALL_TOPDIR)/batch
	-chmod 777 $(INSTALL_TOPDIR)/batch
196 197
	-mkdir -p $(INSTALL_TOPDIR)/expinfo
	-chmod 777 $(INSTALL_TOPDIR)/expinfo
198 199
	-mkdir -p $(INSTALL_TOPDIR)/exparchive
	-chmod 777 $(INSTALL_TOPDIR)/exparchive
200 201
	-mkdir -p $(INSTALL_TOPDIR)/exparchive/Archive
	-chmod 777 $(INSTALL_TOPDIR)/exparchive/Archive
202 203
	-mkdir -p $(INSTALL_TOPDIR)/images
	-chmod 775 $(INSTALL_TOPDIR)/images
204
	-ln -sf /usr/testbed/bin/nse $(INSTALL_TOPDIR)/bin
205
endif
206

207 208 209 210
just-builddirs:
	@$(MAKE) -C rc.d all
	@$(MAKE) -C apache all

211 212
tipserv-install:
	-mkdir -p $(INSTALL_TOPDIR)/log/tiplogs
213
	-mkdir -p $(INSTALL_TOPDIR)/etc
214
	@$(MAKE) -C tip tipserv-install
215
	@$(MAKE) -C clientside/os/capture tipserv-install
216 217
	@$(MAKE) -C tbsetup tipserv-install

218 219
client-mkdirs:
	-mkdir -p $(DESTDIR)$(CLIENT_BINDIR)
220
	-mkdir -p $(DESTDIR)$(CLIENT_MANDIR)
221 222

client:
Leigh Stoller's avatar
Leigh Stoller committed
223
	@$(MAKE) -C clientside client
224
	@$(MAKE) -C os client
225
ifneq ($(SYSTEM),CYGWIN_NT-5.1)
226
	@$(MAKE) -C tip client
227
endif
228 229

client-install: client client-mkdirs
Leigh Stoller's avatar
Leigh Stoller committed
230
	@$(MAKE) -C clientside client-install
231
	@$(MAKE) -C os client-install
232
ifneq ($(SYSTEM),CYGWIN_NT-5.1)
233
	@$(MAKE) -C tip client-install
234
endif
235

236 237
subboss: 
	@$(MAKE) -C clientside subboss
238 239
	@$(MAKE) -C tbsetup subboss
	@$(MAKE) -C db subboss
240
	@$(MAKE) -C os subboss
241 242 243
ifneq ($(SYSTEM),CYGWIN_NT-5.1)
	@$(MAKE) -C tip client
endif
244 245
	@$(MAKE) -C utils subboss

246
subboss-install: subboss
247
	@$(MAKE) -C clientside subboss-install
248
	@$(MAKE) -C tbsetup subboss-install
249
	@$(MAKE) -C os subboss-install
250 251 252
ifneq ($(SYSTEM),CYGWIN_NT-5.1)
	@$(MAKE) -C tip client-install
endif
253
	@$(MAKE) -C utils subboss-install
254 255
	@$(MAKE) -C db subboss-install
	@$(MAKE) -C rc.d subboss-install
256
	@$(MAKE) -C dhcpd subboss-install
257 258 259
	# Hack: this should probably be done by a subboss-install
	# script, but there isn't a huge need for that yet
	@rm -f $(INSTALL_RCDIR)/isc-dhcpd
260

261 262 263
TARBALLDESTDIR = /var/tmp/emulab-client

client-tarball:
264
	@$(MAKE) -C clientside client-tarball
265

266 267 268 269 270 271 272
client-src-tarball:
	@rm -f emulab-client-src.tar.gz
	tar clzf emulab-client-src.tar.gz -C clientside

# This is not finished yet.
client-shadow-rpm:
	-$(RM) -rf rpmbuild
273
	mkdir -p rpmbuild/SOURCES rpmbuild/SRPMS
274 275 276 277
	$(CP) emulab-client-src.tar.gz rpmbuild/SOURCES
	$(RPM) -v -bs --nodeps --define='_topdir $(TOPDIR)/rpmbuild' \
		clientside/shadow.spec

278 279 280 281
destdircheck:
	@if [ -z "$(DESTDIR)" ]; then \
	    echo "You must define DESTDIR for this target!"; \
	    false; \
282 283 284 285
	fi
	@if [ "$(DESTDIR)" = "/" ]; then \
	    echo "DESTDIR is '/', really really bad idea!"; \
	    false; \
286 287
	fi

288 289
mfsoscheck:
	@if [ `uname -s` != "FreeBSD" ]; then \
Mike Hibler's avatar
Mike Hibler committed
290
	    echo "Must build CDROM/MFS files on a FreeBSD system!"; \
291 292 293 294
	    false; \
	fi

mfs: mfsoscheck
Leigh Stoller's avatar
Leigh Stoller committed
295
	@$(MAKE) -C clientside mfs
296

Mike Hibler's avatar
Mike Hibler committed
297
mfs-nostatic: mfsoscheck
Leigh Stoller's avatar
Leigh Stoller committed
298
	@NOSTATIC=1 $(MAKE) -C clientside mfs
Mike Hibler's avatar
Mike Hibler committed
299

300
mfs-install: destdircheck mfs client-mkdirs
Leigh Stoller's avatar
Leigh Stoller committed
301
	@$(MAKE) -C clientside mfs-install
302

Mike Hibler's avatar
Mike Hibler committed
303
mfs-nostatic-install: destdircheck mfs-nostatic client-mkdirs
Leigh Stoller's avatar
Leigh Stoller committed
304
	@$(MAKE) -C clientside mfs-install
Mike Hibler's avatar
Mike Hibler committed
305

306
frisbee-mfs: mfsoscheck
Leigh Stoller's avatar
Leigh Stoller committed
307
	@$(MAKE) -C clientside frisbee-mfs
308

Mike Hibler's avatar
Mike Hibler committed
309
frisbee-mfs-nostatic: mfsoscheck
Leigh Stoller's avatar
Leigh Stoller committed
310
	@NOSTATIC=1 $(MAKE) -C clientside frisbee-mfs
Mike Hibler's avatar
Mike Hibler committed
311

312
frisbee-mfs-install: destdircheck frisbee-mfs
Leigh Stoller's avatar
Leigh Stoller committed
313
	@$(MAKE) -C clientside frisbee-mfs-install
314

Mike Hibler's avatar
Mike Hibler committed
315
frisbee-mfs-nostatic-install: destdircheck frisbee-mfs-nostatic
Leigh Stoller's avatar
Leigh Stoller committed
316
	@$(MAKE) -C clientside frisbee-mfs-install
Mike Hibler's avatar
Mike Hibler committed
317

318 319 320 321 322 323 324 325 326 327 328 329
newnode-mfs: mfsoscheck
	@$(MAKE) -C clientside newnode-mfs

newnode-mfs-nostatic: mfsoscheck
	@NOSTATIC=1 $(MAKE) -C clientside newnode-mfs

newnode-mfs-install: destdircheck newnode-mfs client-mkdirs
	@$(MAKE) -C clientside newnode-mfs-install

newnode-mfs-nostatic-install: destdircheck newnode-mfs-nostatic client-mkdirs
	@$(MAKE) -C clientside newnode-mfs-install

Mike Hibler's avatar
Mike Hibler committed
330 331 332 333 334
cdboot: mfsoscheck client
	@echo "CD/Dongle files built"

cdboot-install: destdircheck cdboot
	@$(MAKE) -C cdrom client-install
Leigh Stoller's avatar
Leigh Stoller committed
335
	@$(MAKE) -C clientside/tmcc/freebsd6 cdboot-install
Mike Hibler's avatar
Mike Hibler committed
336

337 338 339 340
flashboot: mfsoscheck client
	@echo "Flash dongle files built"

flashboot-install: destdircheck flashboot
Leigh Stoller's avatar
Leigh Stoller committed
341
	@$(MAKE) -C clientside/tmcc/freebsd6 cdboot-install
342 343
	@$(MAKE) -C os frisbee-mfs-install
	@$(MAKE) -C flash client-install
Leigh Stoller's avatar
Leigh Stoller committed
344
	@$(MAKE) -C clientside frisbee-mfs-install
345

346 347 348 349
#
# A check to see if this is a 'real' install. Kinda hacky, but as far as I can
# tell, you can't put ifeq()'s inside of targets
#
350 351 352 353 354
ifeq ($(TBROOT),/usr/testbed)
UPDATETESTBED= @cd $(OBJDIR)/install && perl update-testbed
else
UPDATETESTBED= @echo "Skipping update check, since prefix isn't /usr/testbed"
endif
355 356 357 358 359 360 361
ifeq ($(ISMAINSITE),1)
update-testbed: update-testbed-nostop
else
update-testbed:	update-testbed-install
endif

update-testbed-install:
362 363 364
	@echo "Updating the testbed ..."
	$(UPDATETESTBED) -i -s

365 366 367 368 369 370 371 372
update-testbed-noinstall:
	@echo "Updating the testbed ..."
	$(UPDATETESTBED)

update-testbed-nostop:
	@echo "Updating the testbed ..."
	$(UPDATETESTBED) -i

373 374 375 376 377 378 379 380 381 382 383 384 385
update-testbed-force:
	@echo "Updating the testbed in force mode ..."
	$(UPDATETESTBED) -f

ifeq ($(TBROOT),/usr/testbed)
UPDATECHECK= @cd $(OBJDIR)/install && perl update-testbed -v
else
UPDATECHECK= @echo "Skipping update checks, since prefix isn't /usr/testbed"
endif
install-updatecheck:
	@echo "Checking to see if updates need to be run"
	$(UPDATECHECK)

386
ifeq ($(TBROOT),/usr/testbed)
387
SCHEMACHECK= cd $(OBJDIR)/db && perl schemacheck
388 389 390 391 392 393 394
else
SCHEMACHECK= @echo "Skipping schema check, since prefix isn't /usr/testbed"
endif
install-schemacheck:
	@echo "Checking DB schema..."
	$(SCHEMACHECK)

395 396 397 398 399 400 401 402 403
ifeq ($(TBROOT),/usr/testbed)
SITEVARSCHECK= cd $(OBJDIR)/db && perl sitevarscheck
else
SITEVARSCHECK= @echo "Skipping sitevars check, since prefix isn't /usr/testbed"
endif
install-sitevarscheck:
	@echo "Checking Site variables..."
	$(SITEVARSCHECK)

404 405 406 407 408 409 410 411 412
ifeq ($(TBROOT),/usr/testbed)
DBFILLCHECK= cd $(OBJDIR)/db && perl dbfillcheck
else
DBFILLCHECK= @echo "Skipping DB fill check, since prefix isn't /usr/testbed"
endif
install-dbfillcheck:
	@echo "Checking Initial DB Fill ..."
	$(DBFILLCHECK)

413 414 415 416 417 418 419 420 421
ifeq ($(TBROOT),/usr/testbed)
SETBUILDINFO= cd $(OBJDIR)/utils && perl setbuildinfo
else
SETBUILDINFO= @echo "Skipping setbuildinfo, since prefix isn't /usr/testbed"
endif
install-setbuildinfo:
	@echo "Setting the Build and Version info"
	$(SETBUILDINFO)

422
install-genischemacheck:
423
ifeq ($(PGENISUPPORT),1)
424
	@$(MAKE) -C protogeni install-genischemacheck
425
endif
Leigh Stoller's avatar
Leigh Stoller committed
426
	@echo "Done"
427

428 429 430 431 432
BRANCHCHECK=
BRANCHECHO= @echo "Skipping branch check since not the Mothership"
ifeq ($(ISMAINSITE),1)
ifeq ($(TBROOT),/usr/testbed)
BRANCHCHECK= cd $(SRCDIR) && \
433
		git status --porcelain -s -b | head -1 | grep -q -s current
434 435 436 437 438 439 440
BRANCHECHO= @echo "Checking to make sure you are on the mothership branch"
endif
endif
install-branchcheck:
	$(BRANCHECHO)
	$(BRANCHCHECK)

441 442 443
# We use separate src and obj trees in Emulab, so the traditional distclean to
# clean "made" files from a mingled source-and-obj tree is unnecessary.
# However, this may be useful if you mistakenly configure and make a src tree.
444 445
clean:		clean-subdirs
distclean:	distclean-subdirs
Mike Hibler's avatar
Mike Hibler committed
446
	rm -f Makeconf GNUmakefile config.h config.status config.cache config.log
447
	rm -f $(DISTCLEAN_FILES)
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462

#
# Be careful, do not run these unless you are updating your installation
# with a new IP subnet or domain name. 
#
boss-updateip-clean:	clean
	@$(MAKE) -C rc.d clean
	@$(MAKE) -C apache clean
	@$(MAKE) -C named clean
	@$(MAKE) -C dhcpd clean

ops-updateip-clean:	clean
	@$(MAKE) -C rc.d clean
	@$(MAKE) -C apache clean

463 464 465 466
update-rcd:
	@$(MAKE) -C rc.d all
	@$(MAKE) -C rc.d install

467 468 469 470
#
# Here's a different approch to recover from just configure problems.  It cleans
# all files from an obj tree that have a corresponding .in file in the src tree.
undo-configure:
471
	find $SRCDIR -name '*.in' -a -not -name configure.in | \
472
	    sed -e "s;$SRCDIR;$OBJDIR;" -e 's;[.]in$;;' | xargs rm -f
473

474 475 476 477 478 479
#
# XXX a "temporary" hack for scripts that were evolving fast.
# We didn't want to have to remake the client image whenever we changed these.
# They are copied over to the embryonic boss and ops during setup.
#
elabinelab-scripts:
480
	mkdir -p $(INSTALL_TOPDIR)/etc
481 482
	cp -f $(SRCDIR)/clientside/tmcc/freebsd/mkextrafs.pl $(INSTALL_TOPDIR)/etc/
	cp -f $(SRCDIR)/clientside/tmcc/common/config/rc.mkelab $(INSTALL_TOPDIR)/etc/
483

484
ifeq ($(SPEWFROMOPS),1)
485
elabinelab-nogit: elabinelab-scripts
486 487 488 489
	-mkdir -p /share/emulab
	rm -f /share/emulab/emulab-src.tar.gz
	tar czf /share/emulab/emulab-src.tar.gz -C $(SRCDIR) --exclude=.git .

490
elabinelab-git: elabinelab-scripts
491 492
	-mkdir -p /share/emulab
	rm -f /share/emulab/emulab-src.tar.gz
493
	(cd $(SRCDIR); \
494 495 496 497
	 git archive HEAD > /share/emulab/emulab-src.tar)
	tar rf /share/emulab/emulab-src.tar -C $(SRCDIR) \
	 --exclude=.git protogeni/rspec-geni
	gzip /share/emulab/emulab-src.tar
498
else
499
elabinelab-nogit: elabinelab-scripts
500 501
	-mkdir -p $(INSTALL_TOPDIR)/src
	rm -f $(INSTALL_TOPDIR)/src/emulab-src.tar.gz
502
	tar czf $(INSTALL_TOPDIR)/src/emulab-src.tar.gz -C $(SRCDIR) --exclude=.git .
503

504
elabinelab-git: elabinelab-scripts
505 506
	-mkdir -p $(INSTALL_TOPDIR)/src
	rm -f $(INSTALL_TOPDIR)/src/emulab-src.tar.gz
507
	(cd $(SRCDIR); \
508 509 510 511
	 git archive HEAD > $(INSTALL_TOPDIR)/src/emulab-src.tar)
	tar rf $(INSTALL_TOPDIR)/src/emulab-src.tar -C $(SRCDIR) \
	 --exclude=.git protogeni/rspec-geni
	gzip $(INSTALL_TOPDIR)/src/emulab-src.tar
512
endif
513

514 515 516 517 518
# How to recursively descend into subdirectories to make general
# targets such as `all'.
%.MAKE:
	@$(MAKE) -C $(dir $@) $(basename $(notdir $@))
%-subdirs: $(addsuffix /%.MAKE,$(SUBDIRS)) ;
519

520 521
# By default, make any target by descending into subdirectories.
%: %-subdirs ;
522

523 524
.PHONY: post-install install-mkdirs clrhouse-install install \
	boss-install-noupdatecheck boss-install-noschemacheck \
525 526
	boss-install-force update-testbed update-testbed-install \
	update-testbed-noinstall update-testbed-nostop
527 528 529

# Get rid of a bunch of nasty built-in implicit rules.
.SUFFIXES: