2 # PlanetLab RPM generation
4 # Mark Huang <mlhuang@cs.princeton.edu>
5 # Copyright (C) 2003-2006 The Trustees of Princeton University
7 # $Id: Rules.mk,v 1.27 2007/01/29 19:18:45 thierry Exp $
10 # Base rpmbuild in the current directory
11 export HOME := $(shell pwd)
12 export CVSROOT CVS_RSH
18 SPECFILE := SPECS/$(notdir $(SPEC))
22 echo "%define pldistro $(PLDISTRO)" > $@
24 # Define date for untagged builds
25 echo "%define date $(shell date +%Y.%m.%d)" >> $@
27 # Define cvstag for tagged builds
28 echo "%define cvstag $(TAG)" >> $@
30 cvs -d $(CVSROOT) checkout -r $(TAG) -p $(SPEC) >> $@
33 # Parse spec file into Makefile fragment
36 MK := tmp/$(package).mk
38 parseSpec: CFLAGS := -g -Wall
40 parseSpec: LDFLAGS := -lrpm -lrpmbuild
42 $(MK): $(SPECFILE) parseSpec .rpmmacros
44 ./parseSpec $(RPMFLAGS) $(SPECFILE) > $@
46 # Defines SOURCES, SRPM, RPMS
53 # Get rid of any extensions
55 $(patsubst %.tar.bz2,%, \
56 $(patsubst %.tar.gz,%, \
59 $(patsubst %.tar,%,$(1))))))
61 SOURCEDIRS := $(call stripext,$(SOURCES))
63 # Thierry - Jan 29 2007
64 # Allow different modules to have different CVSROOT's
66 # is there a single module ? to mimick cvs export -d behaviour
67 MULTI_MODULE := $(word 2,$(MODULE))
68 ifeq "$(MULTI_MODULE)" ""
69 # single module: do as before
72 cd SOURCES && cvs -d $(CVSROOT) export -r $(TAG) -d $(package) $(MODULE)
74 # multiple modules : iterate
76 mkdir -p SOURCES/$(package) && cd SOURCES/$(package) && (\
77 $(foreach module,$(MODULE),\
78 cvs -d $(if $($(module)-CVSROOT),$($(module)-CVSROOT),$(CVSROOT)) export -r $(TAG) $(module);\
82 # Make a hard-linked copy of the exported directory for each Source
83 # defined in the spec file. However, our convention is that there
84 # should be only one Source file and one CVS module per RPM. It's okay
85 # if the CVS module consists of multiple directories, as long as the
86 # spec file knows what's going on.
87 $(SOURCEDIRS): SOURCES/$(package)
90 .SECONDARY: SOURCES/$(package) $(SOURCEDIRS)
93 SOURCES/%.tar.bz2: SOURCES/%
94 tar cpjf $@ -C SOURCES $*
96 SOURCES/%.tar.gz: SOURCES/%
97 tar cpzf $@ -C SOURCES $*
99 SOURCES/%.tgz: SOURCES/%
100 tar cpzf $@ -C SOURCES $*
102 SOURCES/%.zip: SOURCES/%
103 cd SOURCES && zip -r ../$@ $*
105 SOURCES/%.tar: SOURCES/%
106 tar cpf $@ -C SOURCES $*
115 $(RPMS): $(SPECFILE) $(SOURCES)
117 $(RPMBUILD) $(RPMFLAGS) -bb $<
119 # Make the rest of the RPMS depend on the first one since building one
121 ifneq ($(words $(RPMS)),1)
122 $(wordlist 2,$(words $(RPMS)),$(RPMS)): $(firstword $(RPMS))
126 $(SRPM): $(SPECFILE) $(SOURCES)
128 rpmbuild $(RPMFLAGS) -bs $<
130 # Base rpmbuild in the current directory
132 echo "%_topdir $(HOME)" > $@
133 echo "%_tmppath $(HOME)/tmp" >> $@
135 # Remove files generated by this package
139 $(patsubst SOURCES/%,BUILD/%,$(SOURCEDIRS)) \
140 $(SOURCES) $(SOURCEDIRS) SOURCES/$(package) \
145 #################### convenience, for debugging only
146 # make +foo : prints the value of $(foo)
147 # make ++foo : idem but verbose, i.e. foo=$(foo)
148 ++%: varname=$(subst +,,$@)
150 @echo $(varname)=$($(varname))
151 +%: varname=$(subst +,,$@)