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.22 2006/03/27 17:28:25 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 cvs -d $(CVSROOT) checkout -r $(TAG) -p $(SPEC) >> $@
30 # Parse spec file into Makefile fragment
33 MK := tmp/$(package).mk
35 parseSpec: CFLAGS := -g -Wall
37 parseSpec: LDFLAGS := -lrpm -lrpmbuild
39 $(MK): $(SPECFILE) parseSpec .rpmmacros
41 ./parseSpec $(SPECFILE) > $@
43 # Defines SOURCES, SRPM, RPMS
50 # Get rid of any extensions
52 $(patsubst %.tar.bz2,%, \
53 $(patsubst %.tar.gz,%, \
56 $(patsubst %.tar,%,$(1))))))
58 SOURCEDIRS := $(call stripext,$(SOURCES))
62 cd SOURCES && cvs -d $(CVSROOT) export -r $(TAG) -d $(package) $(MODULE)
64 # Make a hard-linked copy of the exported directory for each Source
65 # defined in the spec file. However, our convention is that there
66 # should be only one Source file and one CVS module per RPM. It's okay
67 # if the CVS module consists of multiple directories, as long as the
68 # spec file knows what's going on.
69 $(SOURCEDIRS): SOURCES/$(package)
72 .SECONDARY: SOURCES/$(package) $(SOURCEDIRS)
75 SOURCES/%.tar.bz2: SOURCES/%
76 tar cpjf $@ -C SOURCES $*
78 SOURCES/%.tar.gz: SOURCES/%
79 tar cpzf $@ -C SOURCES $*
81 SOURCES/%.tgz: SOURCES/%
82 tar cpzf $@ -C SOURCES $*
84 SOURCES/%.zip: SOURCES/%
85 cd SOURCES && zip -r ../$@ $*
87 SOURCES/%.tar: SOURCES/%
88 tar cpf $@ -C SOURCES $*
97 $(RPMS): $(SPECFILE) $(SOURCES) .rpmmacros
99 $(RPMBUILD) $(RPMFLAGS) -bb $<
101 # Make the rest of the RPMS depend on the first one since building one
103 ifneq ($(words $(RPMS)),1)
104 $(wordlist 2,$(words $(RPMS)),$(RPMS)): $(firstword $(RPMS))
108 $(SRPM): $(SPECFILE) $(SOURCES) .rpmmacros
110 rpmbuild $(RPMFLAGS) -bs $<
112 # Base rpmbuild in the current directory
114 echo "%_topdir $(HOME)" > $@
115 echo "%_tmppath $(HOME)/tmp" >> $@
117 # Remove files generated by this package
121 $(patsubst SOURCES/%,BUILD/%,$(SOURCEDIRS)) \
122 $(SOURCES) $(SOURCEDIRS) SOURCES/$(package) \