final changes to gets things to build on FC6
[build.git] / Rules.mk
index d02aa7f..473a4e1 100644 (file)
--- a/Rules.mk
+++ b/Rules.mk
@@ -4,7 +4,7 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2003-2006 The Trustees of Princeton University
 #
-# $Id: Rules.mk,v 1.22 2006/03/27 17:28:25 mlhuang Exp $
+# $Id: Rules.mk,v 1.34 2007/07/19 20:39:33 mef Exp $
 #
 
 # Base rpmbuild in the current directory
@@ -23,8 +23,14 @@ $(SPECFILE):
 ifeq ($(TAG),HEAD)
         # Define date for untagged builds
        echo "%define date $(shell date +%Y.%m.%d)" >> $@
+else
+        # Define cvstag for tagged builds
+       echo "%define cvstag $(TAG)" >> $@
 endif
-       cvs -d $(CVSROOT) checkout -r $(TAG) -p $(SPEC) >> $@
+       $(if $($(package)-SVNPATH),\
+  svn cat $($(package)-SVNPATH)/$(SPEC) >> $@,\
+  cvs -d $(CVSROOT) checkout -r $(TAG) -p $(SPEC) >> $@)
+
 
 #
 # Parse spec file into Makefile fragment
@@ -32,13 +38,13 @@ endif
 
 MK := tmp/$(package).mk
 
-parseSpec: CFLAGS := -g -Wall
+parseSpec: CFLAGS := -g -Wall -D_GNU_SOURCE
 
 parseSpec: LDFLAGS := -lrpm -lrpmbuild
 
 $(MK): $(SPECFILE) parseSpec .rpmmacros
        mkdir -p tmp
-       ./parseSpec $(SPECFILE) > $@
+       ./parseSpec $(RPMFLAGS) $(SPECFILE) > $@
 
 # Defines SOURCES, SRPM, RPMS
 include $(MK)
@@ -57,9 +63,29 @@ $(patsubst %.tar,%,$(1))))))
 
 SOURCEDIRS := $(call stripext,$(SOURCES))
 
+# Thierry - Jan 29 2007
+# Allow different modules to have  different CVSROOT
+# and/or to be extracted from their SVNPATH
+#
+# is there a single module ? to mimick cvs export -d behaviour
+MULTI_MODULE := $(word 2,$(MODULE))
+ifeq "$(MULTI_MODULE)" ""
+# single module: do as before
 SOURCES/$(package):
        mkdir -p SOURCES
-       cd SOURCES && cvs -d $(CVSROOT) export -r $(TAG) -d $(package) $(MODULE)
+       $(if $($(package)-SVNPATH),\
+  cd SOURCES && svn export $($(package)-SVNPATH) $(package),\
+  cd SOURCES && cvs -d $(CVSROOT) export -r $(TAG) -d $(package) $(MODULE))
+else
+# multiple modules : iterate 
+SOURCES/$(package):
+       mkdir -p SOURCES/$(package) && cd SOURCES/$(package) && (\
+       $(foreach module,$(MODULE),\
+        $(if $($(module)-SVNPATH), \
+  svn export $($(module)-SVNPATH) $(module);, \
+  cvs -d $(if $($(module)-CVSROOT),$($(module)-CVSROOT),$(CVSROOT)) export -r $(TAG)  $(module);\
+         )))
+endif
 
 # Make a hard-linked copy of the exported directory for each Source
 # defined in the spec file. However, our convention is that there
@@ -94,7 +120,7 @@ SOURCES/%.tar: SOURCES/%
 all: $(RPMS) $(SRPM)
 
 # Build RPMS
-$(RPMS): $(SPECFILE) $(SOURCES) .rpmmacros
+$(RPMS): $(SPECFILE) $(SOURCES) .rpmbuild.sh
        mkdir -p BUILD RPMS
        $(RPMBUILD) $(RPMFLAGS) -bb $<
 
@@ -105,15 +131,21 @@ $(wordlist 2,$(words $(RPMS)),$(RPMS)): $(firstword $(RPMS))
 endif
 
 # Build SRPM
-$(SRPM): $(SPECFILE) $(SOURCES) .rpmmacros
+$(SRPM): $(SPECFILE) $(SOURCES) .rpmbuild.sh
        mkdir -p SRPMS
-       rpmbuild $(RPMFLAGS) -bs $<
+       $(RPMBUILD) $(RPMFLAGS) -bs $<
 
 # Base rpmbuild in the current directory
 .rpmmacros:
        echo "%_topdir $(HOME)" > $@
        echo "%_tmppath $(HOME)/tmp" >> $@
 
+.rpmbuild.sh:
+       echo "# GENERATED BY Rules.mk" > $@
+       echo "export HOME=$(HOME)" >> $@
+       echo "# There must be a more clever way to pass all args to rpmbuild!" >> $@
+       echo 'rpmbuild $$1 $$2 $$3 $$4 $$5 $$6' >> $@
+
 # Remove files generated by this package
 clean:
        rm -rf \
@@ -123,3 +155,13 @@ clean:
        $(MK) $(SPECFILE)
 
 .PHONY: all clean
+
+#################### convenience, for debugging only
+# make +foo : prints the value of $(foo)
+# make ++foo : idem but verbose, i.e. foo=$(foo)
+++%: varname=$(subst +,,$@)
+++%:
+       @echo $(varname)=$($(varname))
++%: varname=$(subst +,,$@)
++%:
+       @echo $($(varname))