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.23 2006/03/28 22:05:24 mlhuang 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 $(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))
65 cd SOURCES && cvs -d $(CVSROOT) export -r $(TAG) -d $(package) $(MODULE)
67 # Make a hard-linked copy of the exported directory for each Source
68 # defined in the spec file. However, our convention is that there
69 # should be only one Source file and one CVS module per RPM. It's okay
70 # if the CVS module consists of multiple directories, as long as the
71 # spec file knows what's going on.
72 $(SOURCEDIRS): SOURCES/$(package)
75 .SECONDARY: SOURCES/$(package) $(SOURCEDIRS)
78 SOURCES/%.tar.bz2: SOURCES/%
79 tar cpjf $@ -C SOURCES $*
81 SOURCES/%.tar.gz: SOURCES/%
82 tar cpzf $@ -C SOURCES $*
84 SOURCES/%.tgz: SOURCES/%
85 tar cpzf $@ -C SOURCES $*
87 SOURCES/%.zip: SOURCES/%
88 cd SOURCES && zip -r ../$@ $*
90 SOURCES/%.tar: SOURCES/%
91 tar cpf $@ -C SOURCES $*
100 $(RPMS): $(SPECFILE) $(SOURCES) .rpmmacros
102 $(RPMBUILD) $(RPMFLAGS) -bb $<
104 # Make the rest of the RPMS depend on the first one since building one
106 ifneq ($(words $(RPMS)),1)
107 $(wordlist 2,$(words $(RPMS)),$(RPMS)): $(firstword $(RPMS))
111 $(SRPM): $(SPECFILE) $(SOURCES) .rpmmacros
113 rpmbuild $(RPMFLAGS) -bs $<
115 # Base rpmbuild in the current directory
117 echo "%_topdir $(HOME)" > $@
118 echo "%_tmppath $(HOME)/tmp" >> $@
120 # Remove files generated by this package
124 $(patsubst SOURCES/%,BUILD/%,$(SOURCEDIRS)) \
125 $(SOURCES) $(SOURCEDIRS) SOURCES/$(package) \