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.32 2007/03/02 20:53:00 faiyaza 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 $(if $($(package)-SVNPATH),\
31 svn cat $($(package)-SVNPATH)/$(SPEC) >> $@,\
32 cvs -d $(CVSROOT) checkout -r $(TAG) -p $(SPEC) >> $@)
36 # Parse spec file into Makefile fragment
39 MK := tmp/$(package).mk
41 parseSpec: CFLAGS := -g -Wall
43 parseSpec: LDFLAGS := -lrpm -lrpmbuild
45 $(MK): $(SPECFILE) parseSpec .rpmmacros
47 ./parseSpec $(RPMFLAGS) $(SPECFILE) > $@
49 # Defines SOURCES, SRPM, RPMS
56 # Get rid of any extensions
58 $(patsubst %.tar.bz2,%, \
59 $(patsubst %.tar.gz,%, \
62 $(patsubst %.tar,%,$(1))))))
64 SOURCEDIRS := $(call stripext,$(SOURCES))
66 # Thierry - Jan 29 2007
67 # Allow different modules to have different CVSROOT
68 # and/or to be extracted from their SVNPATH
70 # is there a single module ? to mimick cvs export -d behaviour
71 MULTI_MODULE := $(word 2,$(MODULE))
72 ifeq "$(MULTI_MODULE)" ""
73 # single module: do as before
76 $(if $($(package)-SVNPATH),\
77 cd SOURCES && svn export $($(package)-SVNPATH) $(package),\
78 cd SOURCES && cvs -d $(CVSROOT) export -r $(TAG) -d $(package) $(MODULE))
80 # multiple modules : iterate
82 mkdir -p SOURCES/$(package) && cd SOURCES/$(package) && (\
83 $(foreach module,$(MODULE),\
84 $(if $($(module)-SVNPATH), \
85 svn export $($(module)-SVNPATH) $(module);, \
86 cvs -d $(if $($(module)-CVSROOT),$($(module)-CVSROOT),$(CVSROOT)) export -r $(TAG) $(module);\
90 # Make a hard-linked copy of the exported directory for each Source
91 # defined in the spec file. However, our convention is that there
92 # should be only one Source file and one CVS module per RPM. It's okay
93 # if the CVS module consists of multiple directories, as long as the
94 # spec file knows what's going on.
95 $(SOURCEDIRS): SOURCES/$(package)
98 .SECONDARY: SOURCES/$(package) $(SOURCEDIRS)
101 SOURCES/%.tar.bz2: SOURCES/%
102 tar cpjf $@ -C SOURCES $*
104 SOURCES/%.tar.gz: SOURCES/%
105 tar cpzf $@ -C SOURCES $*
107 SOURCES/%.tgz: SOURCES/%
108 tar cpzf $@ -C SOURCES $*
110 SOURCES/%.zip: SOURCES/%
111 cd SOURCES && zip -r ../$@ $*
113 SOURCES/%.tar: SOURCES/%
114 tar cpf $@ -C SOURCES $*
123 $(RPMS): $(SPECFILE) $(SOURCES)
125 $(RPMBUILD) $(RPMFLAGS) -bb $<
127 # Make the rest of the RPMS depend on the first one since building one
129 ifneq ($(words $(RPMS)),1)
130 $(wordlist 2,$(words $(RPMS)),$(RPMS)): $(firstword $(RPMS))
134 $(SRPM): $(SPECFILE) $(SOURCES)
136 rpmbuild $(RPMFLAGS) -bs $<
138 # Base rpmbuild in the current directory
140 echo "%_topdir $(HOME)" > $@
141 echo "%_tmppath $(HOME)/tmp" >> $@
143 # Remove files generated by this package
147 $(patsubst SOURCES/%,BUILD/%,$(SOURCEDIRS)) \
148 $(SOURCES) $(SOURCEDIRS) SOURCES/$(package) \
153 #################### convenience, for debugging only
154 # make +foo : prints the value of $(foo)
155 # make ++foo : idem but verbose, i.e. foo=$(foo)
156 ++%: varname=$(subst +,,$@)
158 @echo $(varname)=$($(varname))
159 +%: varname=$(subst +,,$@)