#
# PlanetLab RPM generation
#
-# Copyright (c) 2003 The Trustees of Princeton University (Trustees).
-# All Rights Reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-#
-# * Neither the name of the copyright holder nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TRUSTEES OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# Mark Huang <mlhuang@cs.princeton.edu>
+# Copyright (C) 2003-2005 The Trustees of Princeton University
#
-# $Id$
+# $Id: Makefile,v 1.63 2005/04/11 14:46:16 mlhuang Exp $
#
# Base cvsps and rpmbuild in the current directory
MK := SPECS/$(patsubst %.spec,%.mk,$(notdir $(SPEC)))
$(MK): SPECS/$(notdir $(SPEC)).in
- # Substitute '$' for '%' and '%define name value' or 'name: value' for 'name := value'
+ # Substitute '$' for '%' and 'name := value' for '%define name value' or 'name: value'
sed -n \
-e 's/%{/$${/g' \
- -e 's/^%define[ ]*\([^ ]*\)[ ]*\([^ ]*\)/\1 := \2/p' \
+ -e 's/%\([[:alnum:]]\+\)/$${\1}/g' \
+ -e 's/^$${define}[ ]*\([^ ]*\)[ ]*\([^ ]*\)/\1 := \2/p' \
-e 's/^\([^ ]*\):[ ]*\([^ ]*\)/\1 := \2/p' \
$< > $@
ifneq ($(INITIAL),$(TAG))
# Get list of PatchSets
- cvsps --root $(CVSROOT) -r $(INITIAL) $(if $(TAG:HEAD=),-r $(TAG)) $(MODULE) | \
+ cvsps --cvs-direct --root $(CVSROOT) -r $(INITIAL) $(if $(TAG:HEAD=),-r $(TAG)) $(MODULE) | \
sed -ne 's|^PatchSet[ ]*\([0-9]*\)|PATCHES += \1|p' >> $@
+ifeq ($(shell echo $(MAKE_VERSION) | awk '{ print ($$1 < 3.80) }'),1)
+ # make-3.80 can use $(eval) instead (see below)
+ cvsps --cvs-direct --root $(CVSROOT) -r $(INITIAL) $(if $(TAG:HEAD=),-r $(TAG)) $(MODULE) | \
+ sh Patchrules >> $@
+endif
endif
SPECS/$(notdir $(SPEC)).in:
# Generate tarball
#
+# Get rid of URL
+Source0 := $(notdir $(if $(Source),$(Source),$(Source0)))
+
# Add tarball to the list of sources
SOURCES += SOURCES/$(Source0)
# Get rid of .tar.bz2 or .tar.gz or .tgz
-Base0 := $(basename $(basename $(Source0)))
+Base0 := $(Source0:.tgz=)
+Base0 := $(Base0:.bz2=)
+Base0 := $(Base0:.gz=)
+Base0 := $(Base0:.tar=)
# Export module
SOURCES/$(Base0):
# In case the spec file did not explicitly list the PatchSet
ifeq ($$(origin Patch$(1)),undefined)
-Patch$(1) := $(1).patch.bz2
+Patch$(1) := $$(package)-$(1).patch.bz2
endif
+# Get rid of URL
+Patch$(1) := $$(notdir $$(Patch$(1)))
+
# Add patch to the list of sources
SOURCES += SOURCES/$$(Patch$(1))
# Generate uncompressed patch
SOURCES/$$(patsubst %.gz,%,$$(patsubst %.bz2,%,$$(Patch$(1)))):
mkdir -p SOURCES
- cvsps --root $(CVSROOT) -g -s $(1) $(MODULE) > $$@
+ cvsps --cvs-direct --root $$(CVSROOT) -g -s $(1) $$(MODULE) > $$@
endef
%.gz: %
gzip -c $< > $@
-# Generate rules to generate patches
+# Generate rules to generate patches (make-3.80 and above expands this)
$(foreach n,$(PATCHES),$(eval $(call PATCH_template,$(n))))
#
# Build
#
-NVR := $(shell rpmquery $(RPMFLAGS) $(if $(DATE),--define "date $(DATE)") --specfile SPECS/$(notdir $(SPEC)).in | head -1)
-ARCH := $(shell rpm $(RPMFLAGS) --showrc | sed -ne 's/^build arch[ ]*:[ ]*\(.*\)/\1/p')
+ifeq ($(TAG),HEAD)
+RPMFLAGS += --define "date $(DATE)"
+endif
+NVR := $(shell rpmquery $(RPMFLAGS) --specfile SPECS/$(notdir $(SPEC)).in 2>/dev/null | head -1)
+ARCH := $(shell rpmquery $(RPMFLAGS) --queryformat '%{ARCH}\n' --specfile SPECS/$(notdir $(SPEC)).in 2>/dev/null | head -1)
all: RPMS/$(ARCH)/$(NVR).$(ARCH).rpm SRPMS/$(NVR).src.rpm
.rpmmacros:
echo "%_topdir $(HOME)" > $@
-.PHONY: all
+# Remove files generated by this package
+clean:
+ rm -rf \
+ BUILD/$(Base0) \
+ RPMS/$(ARCH)/$(NVR).$(ARCH).rpm \
+ SOURCES/$(Base0)* SOURCES/$(package)* \
+ SPECS/$(notdir $(SPEC)).in SPECS/$(notdir $(SPEC)) $(MK) \
+ SRPMS/$(NVR).src.rpm \
+ .cvsps/$(subst /,#,$(CVSROOT)/$(MODULE))
+
+.PHONY: all clean