# # Copyright (c) 2000-2012, 2016 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 . # # }}} # Get rid of a bunch of nasty built-in implicit rules, # to avoid bogus circular dependencies and make things go faster. # Use the `-r' command line option to make to get even better performance. .SUFFIXES: # # Various install targets. # $(INSTALL_BINDIR)/%: % @echo "Installing $<" -mkdir -p $(INSTALL_BINDIR) $(INSTALL_PROGRAM) $< $@ $(INSTALL_SBINDIR)/%: % @echo "Installing $<" -mkdir -p $(INSTALL_SBINDIR) $(INSTALL_PROGRAM) $< $@ $(INSTALL_LIBDIR)/%: % @echo "Installing $<" -mkdir -p $(INSTALL_LIBDIR) $(INSTALL_PROGRAM) $< $@ $(INSTALL_LIBEXECDIR)/%: % @echo "Installing $<" -mkdir -p $(INSTALL_LIBEXECDIR) $(INSTALL_PROGRAM) $< $@ $(INSTALL_ETCDIR)/%: % @echo "Installing $<" -mkdir -p $(INSTALL_ETCDIR) $(INSTALL_DATA) $< $@ $(addprefix $(INSTALL_SBINDIR)/, $(SETUID_SBIN_PROGS)): $(INSTALL_SBINDIR)/%: % echo "Installing (setuid) $<" -mkdir -p $(INSTALL_SBINDIR) $(SUDO) $(INSTALL) -o root -m 4755 $< $@ $(addprefix $(INSTALL_BINDIR)/, $(SETUID_BIN_PROGS)): $(INSTALL_BINDIR)/%: % echo "Installing (setuid) $<" -mkdir -p $(INSTALL_BINDIR) $(SUDO) $(INSTALL) -o root -m 4755 $< $@ $(addprefix $(INSTALL_LIBEXECDIR)/, $(SETUID_LIBX_PROGS)): $(INSTALL_LIBEXECDIR)/%: % echo "Installing (setuid) $<" -mkdir -p $(INSTALL_LIBEXECDIR) $(SUDO) $(INSTALL) -o root -m 4755 $< $@ $(addprefix $(INSTALL_SBINDIR)/, $(SETUID_SBIN_SCRIPTS)): $(INSTALL_SBINDIR)/%: % $(INSTALL_SUIDDIR)/% echo "Installing (link to wrapper) $<" -mkdir -p $(INSTALL_SBINDIR) -rm -f $@ ln -s $(INSTALL_LIBEXECDIR)/runsuid $@ $(addprefix $(INSTALL_BINDIR)/, $(SETUID_BIN_SCRIPTS)): $(INSTALL_BINDIR)/%: % $(INSTALL_SUIDDIR)/% echo "Installing (link to wrapper) $<" -mkdir -p $(INSTALL_BINDIR) -rm -f $@ ln -s $(INSTALL_LIBEXECDIR)/runsuid $@ $(addprefix $(INSTALL_LIBEXECDIR)/, $(SETUID_LIBX_SCRIPTS)): $(INSTALL_LIBEXECDIR)/%: % $(INSTALL_SUIDDIR)/% echo "Installing (link to wrapper) $<" -mkdir -p $(INSTALL_LIBEXECDIR) -rm -f $@ ln -s $(INSTALL_LIBEXECDIR)/runsuid $@ # Special libexec rule for scripts invoked by suexec (cannot be a symlink) $(addprefix $(INSTALL_LIBEXECDIR)/, $(SETUID_SUEXEC_SCRIPTS)): $(INSTALL_LIBEXECDIR)/%: % $(INSTALL_SUIDDIR)/% echo "Installing (hard link to wrapper) $<" -mkdir -p $(INSTALL_LIBEXECDIR) -rm -f $@ ln $(INSTALL_LIBEXECDIR)/runsuid $@ $(INSTALL_SUIDDIR)/%: % echo "Installing (real script) $<" -mkdir -p $(INSTALL_SUIDDIR) $(SUDO) $(INSTALL_PROGRAM) $< $@ CFLAGS += $(LOCALCFLAGS) clean: # This is to avoid warnings about duplicate targets. distclean: default-clean default-clean: rm -f GNUmakefile # This is to avoid warnings about duplicate targets. default-install-notusing: ifeq ($(ISMAINSITE),1) ifeq ($(TBROOT),/usr/testbed) (cd $(SRCDIR) ; \ git status --porcelain -s -b | head -1 | grep -q -s current) else /usr/bin/true endif else /usr/bin/true endif #install: default-install # # Where to find source files. # Using specific patterns instead of the catch-all VPATH variable # avoids hitting miscellaneous wrong targets in other directories # when configuring in the source directory. # vpath %.in $(SRCDIR) $(MOSTLY_SRCDIRS) vpath %.c $(SRCDIR) $(MOSTLY_SRCDIRS) vpath %.cc $(SRCDIR) $(MOSTLY_SRCDIRS) vpath % $(SRCDIR) $(MOSTLY_SRCDIRS) # # Define rules which we blew away with .SUFFIXES # %.o: %.c $(CC) -c -o $@ $(CFLAGS) $< %.o: %.cc $(CXX) -c -o $@ $(CXXFLAGS) $< %.o: %.C $(CXX) -c -o $@ $(CXXFLAGS) $< %_xdr.h: %.x rpcgen -h $< > $@ %_xdr.c: %.x %_xdr.h rpcgen -c $< > $@ %: %-debug $(STRIP) -o $@$(EXE) $<$(EXE) %-version.c: echo >$@ "char build_info[] = \"Built on `date` by `id -nu`@`hostname | sed 's/\..*//'`:`pwd`\";" # # Rules to regen configure written files. # %: %.in $(OBJDIR)/config.status @echo "Regenerating $@" cd $(OBJDIR) && CONFIG_FILES=$(SUBDIR)/$@ ./config.status ifeq ($(TESTS),) .PHONY: check else check: $(TESTS) @export SRCDIR=${SRCDIR}; for tst in $^; do \ if test `basename $$tst .sh` != `basename $$tst`; then \ tst="sh $$tst"; \ fi; \ if $$tst; then \ echo "PASS: $$tst"; \ else \ echo "FAIL: $$tst"; \ exit 1; \ fi \ done endif ifeq ($(MERGE_BUILD),1) .PRECIOUS: ${SRCDIR}/* # # I really want to say something like: # ${TESTBED_SRCDIR}/.merged: $(wildcard ${OBJDIR}/${MERGE_BUILD_SANDBOX}/${SUBDIR}/*) # but that causes problems if one the prereq. has a rule for it (such # as when both GNUmakefile and GNUmakefile.in exist in the source tree), # thus I do the equivalent manually # newest=$(shell ls -rtd "${OBJDIR}/${MERGE_BUILD_SANDBOX}/${SUBDIR}/"* "${TESTBED_SRCDIR}/.merged" | tail -n 1) ifneq ($(newest),${TESTBED_SRCDIR}/.merged) ${TESTBED_SRCDIR}/.merged: cd ${TESTBED_SRCDIR} && utils/merge-build sync .PHONY: ${TESTBED_SRCDIR}/.merged else ${TESTBED_SRCDIR}/.merged: endif ${SRCDIR}/*: ${TESTBED_SRCDIR}/.merged endif