GNUmakerules 4.53 KB
Newer Older
1
#
2
# EMULAB-COPYRIGHT
3
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
4
# All rights reserved.
5 6 7 8 9 10 11 12 13

# 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.
# 
14 15 16
$(INSTALL_BINDIR)/%: %
	@echo "Installing $<"
	-mkdir -p $(INSTALL_BINDIR)
17
	$(INSTALL_PROGRAM) $< $@
18

19 20 21 22 23
$(INSTALL_SBINDIR)/%: %
	@echo "Installing $<"
	-mkdir -p $(INSTALL_SBINDIR)
	$(INSTALL_PROGRAM) $< $@

24
$(INSTALL_LIBDIR)/%: %
25
	@echo "Installing $<"
26
	-mkdir -p $(INSTALL_LIBDIR)
27
	$(INSTALL_PROGRAM) $< $@
28

29
$(INSTALL_LIBEXECDIR)/%: %
30
	@echo "Installing $<"
31
	-mkdir -p $(INSTALL_LIBEXECDIR)
32
	$(INSTALL_PROGRAM) $< $@
33

34 35 36 37 38
$(INSTALL_ETCDIR)/%: %
	@echo "Installing $<"
	-mkdir -p $(INSTALL_ETCDIR)
	$(INSTALL_DATA) $< $@

39
$(addprefix $(INSTALL_SBINDIR)/, $(SETUID_SBIN_PROGS)): $(INSTALL_SBINDIR)/%: %
40 41 42 43
	echo "Installing (setuid) $<"
	-mkdir -p $(INSTALL_SBINDIR)
	$(SUDO) $(INSTALL) -o root -m 4755 $< $@

44
$(addprefix $(INSTALL_BINDIR)/, $(SETUID_BIN_PROGS)): $(INSTALL_BINDIR)/%: %
45 46 47 48
	echo "Installing (setuid) $<"
	-mkdir -p $(INSTALL_BINDIR)
	$(SUDO) $(INSTALL) -o root -m 4755 $< $@

49
$(addprefix $(INSTALL_LIBEXECDIR)/, $(SETUID_LIBX_PROGS)): $(INSTALL_LIBEXECDIR)/%: %
50 51 52 53
	echo "Installing (setuid) $<"
	-mkdir -p $(INSTALL_LIBEXECDIR)
	$(SUDO) $(INSTALL) -o root -m 4755 $< $@

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
$(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 $@

72 73 74 75 76 77 78
# 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 $@

79 80 81
$(INSTALL_SUIDDIR)/%: %
	echo "Installing (real script) $<"
	-mkdir -p $(INSTALL_SUIDDIR)
82
	$(SUDO) $(INSTALL_PROGRAM) $< $@	
83

84 85
CFLAGS += $(LOCALCFLAGS)

86 87
clean:

88 89 90 91
# This is to avoid warnings about duplicate targets. 
distclean: default-clean

default-clean:
92 93 94 95 96 97 98 99
	rm -f GNUmakefile

#
# 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.
#
Leigh Stoller's avatar
Leigh Stoller committed
100 101 102 103
vpath %.in  $(SRCDIR) $(MOSTLY_SRCDIRS)
vpath %.c   $(SRCDIR) $(MOSTLY_SRCDIRS)
vpath %.cc  $(SRCDIR) $(MOSTLY_SRCDIRS)
vpath %     $(SRCDIR) $(MOSTLY_SRCDIRS)
104 105 106 107 108 109 110

#
# Define rules which we blew away with .SUFFIXES
# 
%.o: %.c
	$(CC) -c -o $@ $(CFLAGS) $<

111 112 113
%.o: %.cc
	$(CXX) -c -o $@ $(CXXFLAGS) $<

Timothy Stack's avatar
Timothy Stack committed
114 115 116
%.o: %.C
	$(CXX) -c -o $@ $(CXXFLAGS) $<

117 118 119 120 121 122
%_xdr.h: %.x
	rpcgen -h $< > $@

%_xdr.c: %.x %_xdr.h
	rpcgen -c $< > $@

123
%: %-debug
124
	$(STRIP) -o $@$(EXE) $<$(EXE)
125

Timothy Stack's avatar
Timothy Stack committed
126 127 128
%-version.c:
	echo >$@ "char build_info[] = \"Built on `date` by `id -nu`@`hostname | sed 's/\..*//'`:`pwd`\";"

129 130 131
#
# Rules to regen configure written files.
#
132
%: %.in $(OBJDIR)/config.status
133
	@echo "Regenerating $@"
134
	cd $(OBJDIR) && CONFIG_FILES=$(SUBDIR)/$@ ./config.status
135 136 137 138 139

ifeq ($(TESTS),)
.PHONY: check
else
check: $(TESTS)
140
	@export SRCDIR=${SRCDIR}; for tst in $^; do \
141 142 143 144 145
		if test `basename $$tst .sh` != `basename $$tst`; then \
			tst="sh $$tst"; \
		fi; \
		if $$tst; then \
			echo "PASS: $$tst"; \
Timothy Stack's avatar
Timothy Stack committed
146 147 148
		else \
			echo "FAIL: $$tst"; \
			exit 1; \
149 150 151
		fi \
	done
endif
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173

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