Skip to content
Snippets Groups Projects
GNUmakefile.in 14.6 KiB
Newer Older
# Copyright (c) 2000-2021 University of Utah and the Flux Group.
# 
# {{{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/>.
# 
# }}}
SRCDIR		= @srcdir@
OBJDIR		= .
SUBDIR		= 
TESTBED_SRCDIR  = @top_srcdir@
DISTCLEAN_FILES = @DISTCLEAN_FILES@ 
PELABSUPPORT	= @PELABSUPPORT@
PGENISUPPORT    = @PROTOGENI_SUPPORT@
MOBILESUPPORT   = @MOBILESUPPORT@
SYSTEM	       := $(shell uname -s)

#
# Ordering here matters!
# Things with no dependencies go first: 
# Things that may have dependencies go next:
#   @optional_subdirs@ (has event)
# Then things that only depend on stuff we've done:
#   pxe tbsetup tmcd utils backend www tip vis
# Then things that depend on stuff we just did:
#
ifeq ($(STANDALONE_CLEARINGHOUSE),0)
SUBDIRS = \
	clientside/lib \
	db assign www @optional_subdirs@ clientside ipod security sensors \
Mike Hibler's avatar
Mike Hibler committed
	pxe tbsetup account tmcd utils wbstore backend ipod vis \
	sensors os xmlrpc autofs install/newnode_sshkeys \
	tools/svn collab/exp-vis node_usage install
SUBDIRS += tools/whol
SUBDIRS += protogeni apt powder
else
SUBDIRS = db tbsetup account protogeni
endif
all:		all-subdirs just-builddirs 
#
# 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

ifeq ($(STANDALONE_CLEARINGHOUSE),0)
	@echo "Choose either boss-install, ops-install or fs-install"
	@echo "Choose opsfs-install instead of ops-install for a combined ops/fs machine"
	@echo "Choose tipserv-install for dedicated tip server machines."
# For installation on boss node
		install-subdirs install-mkdirs \
		install-setbuildinfo
# Same target, with the checks omitted
boss-install-force:	install-subdirs install-mkdirs install-setbuildinfo
# Skip only the schema checks, but do the other checks.
boss-install-noschemacheck: install-updatecheck \
		install-sitevarscheck install-dbfillcheck \
		install-genischemacheck install-subdirs install-mkdirs \
		install-setbuildinfo

# Skip the update check. 
boss-install-noupdatecheck: install-schemacheck \
		install-sitevarscheck install-dbfillcheck \
		install-genischemacheck install-subdirs install-mkdirs \
		install-setbuildinfo

# Only the checks:
		install-schemacheck \
		install-sitevarscheck \
		install-dbfillcheck install-genischemacheck
	@echo "Installation checks completed!"

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

	@$(MAKE) -C ipod post-install
	@$(MAKE) -C vis post-install
	@$(MAKE) -C www post-install
	@$(MAKE) -C event post-install
endif
ifeq ($(MOBILESUPPORT),1)
	@$(MAKE) -C mobile
	@$(MAKE) -C tools post-install
	@$(MAKE) -C collab post-install
ifeq ($(NODE_USAGE_SUPPORT),1)
	@$(MAKE) -C node_usage post-install
endif
# For installation on the 'ops' or 'users' node (okay, plastic)
	-mkdir -p $(INSTALL_TOPDIR)/log
	-mkdir -p $(INSTALL_TOPDIR)/log/mysql
	-chmod 770 $(INSTALL_TOPDIR)/log/mysql
	-chown mysql $(INSTALL_TOPDIR)/log/mysql
	-chgrp mysql $(INSTALL_TOPDIR)/log/mysql
	-mkdir -p $(INSTALL_TOPDIR)/log/logfiles
	-chmod 777 $(INSTALL_TOPDIR)/log/logfiles
	@$(MAKE) -C rc.d control-install
	@$(MAKE) -C tbsetup control-install
	@$(MAKE) -C security control-install
	@$(MAKE) -C utils control-install
	@$(MAKE) -C clientside control-install
	@$(MAKE) -C event control-install
Leigh B. Stoller's avatar
Leigh B. Stoller committed
	@$(MAKE) -C account control-install
ifeq ($(PELABSUPPORT),1)
	@$(MAKE) -C pelab control-install
endif
	@$(MAKE) -C tbsetup fs-install
	@$(MAKE) -C clientside fs-install
Timothy Stack's avatar
 
Timothy Stack committed
	@$(MAKE) -C sensors fs-install

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

	-mkdir -p $(INSTALL_TOPDIR)/locks
	-mkdir -p $(INSTALL_TOPDIR)/log
	-mkdir -p $(INSTALL_TOPDIR)/log/mysql
	-mkdir -p $(INSTALL_TOPDIR)/etc
	-mkdir -p $(INSTALL_TOPDIR)/www
	-mkdir -p $(INSTALL_TOPDIR)/suidbin
	-mkdir -p $(INSTALL_TOPDIR)/ssl
	-chmod 770 $(INSTALL_TOPDIR)/ssl
ifeq ($(STANDALONE_CLEARINGHOUSE),0)
	-mkdir -p $(INSTALL_TOPDIR)/opsdir
	-mkdir -p $(INSTALL_TOPDIR)/log/exports
	-mkdir -p $(INSTALL_TOPDIR)/lists
	-mkdir -p $(INSTALL_TOPDIR)/backup
	-mkdir -p $(INSTALL_TOPDIR)/expwork
	-mkdir -p $(INSTALL_TOPDIR)/batch
	-chmod 777 $(INSTALL_TOPDIR)/batch
	-mkdir -p $(INSTALL_TOPDIR)/expinfo
	-chmod 777 $(INSTALL_TOPDIR)/expinfo
	-mkdir -p $(INSTALL_TOPDIR)/exparchive
	-chmod 777 $(INSTALL_TOPDIR)/exparchive
	-mkdir -p $(INSTALL_TOPDIR)/exparchive/Archive
	-chmod 777 $(INSTALL_TOPDIR)/exparchive/Archive
	-mkdir -p $(INSTALL_TOPDIR)/images
	-chmod 775 $(INSTALL_TOPDIR)/images
	-ln -sf /usr/testbed/bin/nse $(INSTALL_TOPDIR)/bin
just-builddirs:
	@$(MAKE) -C rc.d all
	@$(MAKE) -C apache all

tipserv-install:
	-mkdir -p $(INSTALL_TOPDIR)/log/tiplogs
	-mkdir -p $(INSTALL_TOPDIR)/etc
	@$(MAKE) -C clientside/tip tipserv-install
	@$(MAKE) -C clientside/os/capture tipserv-install
client-mkdirs:
	-mkdir -p $(DESTDIR)$(CLIENT_BINDIR)
	-mkdir -p $(DESTDIR)$(CLIENT_MANDIR)
Leigh B Stoller's avatar
Leigh B Stoller committed
	@$(MAKE) -C clientside client
	@$(MAKE) -C os client

client-install: client client-mkdirs
Leigh B Stoller's avatar
Leigh B Stoller committed
	@$(MAKE) -C clientside client-install
subboss: 
	@$(MAKE) -C clientside subboss
	@$(MAKE) -C tbsetup subboss
	@$(MAKE) -C db subboss
	@$(MAKE) -C os subboss
	@$(MAKE) -C utils subboss

subboss-install: subboss
	@$(MAKE) -C clientside subboss-install
	@$(MAKE) -C tbsetup subboss-install
	@$(MAKE) -C os subboss-install
	@$(MAKE) -C utils subboss-install
	@$(MAKE) -C db subboss-install
	@$(MAKE) -C rc.d subboss-install
	@$(MAKE) -C dhcpd subboss-install
	# 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
TARBALLDESTDIR = /var/tmp/emulab-client

client-tarball:
	@$(MAKE) -C clientside client-tarball
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
	mkdir -p rpmbuild/SOURCES rpmbuild/SRPMS
	$(CP) emulab-client-src.tar.gz rpmbuild/SOURCES
	$(RPM) -v -bs --nodeps --define='_topdir $(TOPDIR)/rpmbuild' \
		clientside/shadow.spec

destdircheck:
	@if [ -z "$(DESTDIR)" ]; then \
	    echo "You must define DESTDIR for this target!"; \
	    false; \
	fi
	@if [ "$(DESTDIR)" = "/" ]; then \
	    echo "DESTDIR is '/', really really bad idea!"; \
	    false; \
mfsoscheck:
	@if [ `uname -s` != "FreeBSD" ]; then \
Mike Hibler's avatar
Mike Hibler committed
	    echo "Must build CDROM/MFS files on a FreeBSD system!"; \
Leigh B Stoller's avatar
Leigh B Stoller committed
	@$(MAKE) -C clientside mfs
Mike Hibler's avatar
Mike Hibler committed
mfs-nostatic: mfsoscheck
Leigh B Stoller's avatar
Leigh B Stoller committed
	@NOSTATIC=1 $(MAKE) -C clientside mfs
Mike Hibler's avatar
Mike Hibler committed

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

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

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

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
cdboot: mfsoscheck client
	@echo "CD/Dongle files built"

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

flashboot: mfsoscheck client
	@echo "Flash dongle files built"

flashboot-install: destdircheck flashboot
Leigh B Stoller's avatar
Leigh B Stoller committed
	@$(MAKE) -C clientside/tmcc/freebsd6 cdboot-install
	@$(MAKE) -C os frisbee-mfs-install
	@$(MAKE) -C flash client-install
Leigh B Stoller's avatar
Leigh B Stoller committed
	@$(MAKE) -C clientside frisbee-mfs-install
#
# 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
#
ifeq ($(TBROOT),/usr/testbed)
UPDATETESTBED= @cd $(OBJDIR)/install && perl update-testbed
else
UPDATETESTBED= @echo "Skipping update check, since prefix isn't /usr/testbed"
endif
ifeq ($(ISMAINSITE),1)
update-testbed: update-testbed-nostop
else
update-testbed:	update-testbed-install
endif

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

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

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

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)

SCHEMACHECK= cd $(OBJDIR)/db && perl schemacheck
else
SCHEMACHECK= @echo "Skipping schema check, since prefix isn't /usr/testbed"
endif
install-schemacheck:
	@echo "Checking DB schema..."
	$(SCHEMACHECK)

Chad Barb's avatar
 
Chad Barb committed
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)

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)

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)

install-genischemacheck:
	@$(MAKE) -C protogeni install-genischemacheck
Leigh B. Stoller's avatar
Leigh B. Stoller committed
	@echo "Done"
BRANCHCHECK=
BRANCHECHO= @echo "Skipping branch check since not the Mothership"
ifeq ($(ISMAINSITE),1)
ifeq ($(TBROOT),/usr/testbed)
BRANCHCHECK= cd $(SRCDIR) && \
		git status --porcelain -s -b | head -1 | grep -q -s current
BRANCHECHO= @echo "Checking to make sure you are on the mothership branch"
endif
endif
install-branchcheck:
	$(BRANCHECHO)
	$(BRANCHCHECK)

# 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.
clean:		clean-subdirs
distclean:	distclean-subdirs
Mike Hibler's avatar
Mike Hibler committed
	rm -f Makeconf GNUmakefile config.h config.status config.cache config.log

#
# 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

update-rcd:
	@$(MAKE) -C rc.d all
	@$(MAKE) -C rc.d install

#
# 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:
	find $SRCDIR -name '*.in' -a -not -name configure.in | \
	    sed -e "s;$SRCDIR;$OBJDIR;" -e 's;[.]in$;;' | xargs rm -f
#
# 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:
	mkdir -p $(INSTALL_TOPDIR)/etc
	cp -f $(SRCDIR)/clientside/tmcc/freebsd/mkextrafs.pl $(INSTALL_TOPDIR)/etc/
	cp -f $(SRCDIR)/clientside/tmcc/common/config/rc.mkelab $(INSTALL_TOPDIR)/etc/
elabinelab-nogit: elabinelab-scripts
	-mkdir -p /share/emulab
	rm -f /share/emulab/emulab-src.tar.gz
	tar czf /share/emulab/emulab-src.tar.gz -C $(SRCDIR) --exclude=.git .

elabinelab-git: elabinelab-scripts
	-mkdir -p /share/emulab
	rm -f /share/emulab/emulab-src.tar.gz
	(cd $(SRCDIR); \
	 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
elabinelab-nogit: elabinelab-scripts
	-mkdir -p $(INSTALL_TOPDIR)/src
	rm -f $(INSTALL_TOPDIR)/src/emulab-src.tar.gz
	tar czf $(INSTALL_TOPDIR)/src/emulab-src.tar.gz -C $(SRCDIR) --exclude=.git .
elabinelab-git: elabinelab-scripts
	-mkdir -p $(INSTALL_TOPDIR)/src
	rm -f $(INSTALL_TOPDIR)/src/emulab-src.tar.gz
	(cd $(SRCDIR); \
	 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
# How to recursively descend into subdirectories to make general
# targets such as `all'.
%.MAKE:
	@$(MAKE) -C $(dir $@) $(basename $(notdir $@))
%-subdirs: $(addsuffix /%.MAKE,$(SUBDIRS)) ;
# By default, make any target by descending into subdirectories.
%: %-subdirs ;
.PHONY: post-install install-mkdirs clrhouse-install install \
	boss-install-noupdatecheck boss-install-noschemacheck \
	boss-install-force update-testbed update-testbed-install \
	update-testbed-noinstall update-testbed-nostop

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