* Makefile mostly reverted to rev. 7084 - do not use srpm packages for now
[build.git] / Makefile
index 8f7e977..82d8e0a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -74,7 +74,7 @@
 #     the complete path where this module lies; 
 #     you can specify the trunk or a given tag with this variable
 # 
-# OR if the module is managed under cvs
+# OR if the module is managed under cvs (will be obsoleted)
 # 
 # (*) module-CVSROOT
 # (*) module-TAG
@@ -185,10 +185,7 @@ include $(ALLMKS)
 #all : codebases
 #all : rpms
 #all : srpms
-# mention $(ALL) here rather than rpms 
-# this is because the inter-package dependencies are expressed like
-# util-vserver: util-python
-all: $(ALL)
+all: rpms
 all: srpms
 endif
 endif
@@ -245,8 +242,12 @@ $(foreach package, $(ALL), $(eval $(call package_hasdate,$(package))))
 define target_spec
 $($(1)_specpath):
        mkdir -p SPECS
-       echo "%define pldistro $(PLDISTRO)" > $($(1)_specpath)
+       (echo -n "# Generated by planetlab build from $($(1)-SPEC) on " ; date) > $($(1)_specpath)
+       echo "%define distroname $(DISTRO)" >> $($(1)_specpath)
+       echo "%define distrorelease $(RELEASE)" >> $($(1)_specpath)
+       echo "%define pldistro $(PLDISTRO)" >> $($(1)_specpath)
        $(if $($(1)_hasdate),echo "%define date $(shell date +%Y.%m.%d)" >> $($(1)_specpath),)
+       echo "# included from codebase specfile" >> $($(1)_specpath)
        $(if $($(1)-SPECVARS), \
          $(foreach line,$($(1)-SPECVARS), \
            echo "%define" $(word 1,$(subst =, ,$(line))) "$(word 2,$(subst =, ,$(line)))" >> $($(1)_specpath) ;))
@@ -266,10 +267,18 @@ spec2make: spec2make.c
        $(CC) -g -Wall $< -o $@ -lrpm -lrpmbuild
 
 # Base rpmbuild in the current directory
-export HOME := $(shell pwd)
+# trying a longer topdir 
+# http://forums.fedoraforum.org/showthread.php?t=39625
+# and more specifically post#6
+# hard-wired for now 
+export HOME := /building
 .rpmmacros:
-       echo "%_topdir $(HOME)" > $@
+       rm -f /building ; ln -s /build /building
+       rm -f $@ 
+       echo "%_topdir $(HOME)" >> $@
        echo "%_tmppath $(HOME)/tmp" >> $@
+       echo "%_netsharedpath /proc:/dev/pts" >> $@
+       echo "%_install_langs C:de:en:es:fr" >> $@
 
 ### run spec2make on the spec file and include the result
 # usage: spec2make package
@@ -310,6 +319,13 @@ SOURCES/%.tar.gz: SOURCES/%
 SOURCES/%.tgz: SOURCES/%
        tar chpzf $@ -C SOURCES $*
 
+##
+URLS/%: url=$(subst @colon@,:,$(subst @slash@,/,$(notdir $@)))
+URLS/%: basename=$(notdir $(url))
+URLS/%: 
+       echo curl $(url) -o SOURCES/$(basename)
+       touch $@
+
 ### the directory SOURCES/<package>-<version> is made 
 # with a copy -rl from CODEBASES/<package>
 # the former is $(package-SOURCE) and the latter is $(package-CODEBASE)
@@ -360,8 +376,7 @@ CODEBASES/%:
 
 ### rpmbuild invokation
 ALLRPMS:=$(foreach package,$(ALL),$($(package)-RPM))
-# same as above, mention $(ALL) and not $(ALLRPMS)
-rpms: $(ALL)
+rpms: $(ALLRPMS)
        @echo $(words $(ALLRPMS)) binary rpms OK
 .PHONY: rpms
 
@@ -386,15 +401,26 @@ srpms: $(ALLSRPMS)
        @echo $(words $(ALLSRPMS)) source rpms OK
 .PHONY: srpms
 
-# usage: build_source_rpm package
+# usage: target_source_rpm package
+# select upon the package name, whether it contains srpm or not
 define target_source_rpm 
-$($(1)-SRPM): $($(1)_specpath) $($(1)-TARBALL) .rpmmacros
+ifeq "$(subst srpm,,$(1))" "$(1)"
+$($(1)-SRPM): $($(1)_specpath) .rpmmacros $($(1)-TARBALL) 
        mkdir -p BUILD SRPMS tmp
        @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) " ; date)
        $(if $($(1)-RPMBUILD),\
          $($(1)-RPMBUILD) $($(1)-RPMFLAGS) -bs $($(1)_specpath),
          $(RPMBUILD) $($(1)-RPMFLAGS) -bs $($(1)_specpath))    
        @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
+else
+$($(1)-SRPM): $($(1)_specpath) .rpmmacros $($(1)-CODEBASE)
+       mkdir -p BUILD SRPMS tmp
+       @(echo -n "XXXXXXXXXXXXXXX -- BEG SRPM $(1) (using make srpm) " ; date)
+       make -C $($(1)-CODEBASE) srpm && \
+           rm -f SRPMS/$(notdir $($(1)-SRPM)) && \
+           ln $($(1)-CODEBASE)/$(notdir $($(1)-SRPM)) SRPMS/$(notdir $($(1)-SRPM)) 
+       @(echo -n "XXXXXXXXXXXXXXX -- END SRPM $(1) " ; date)
+endif
 endef
 
 $(foreach package,$(ALL),$(eval $(call target_source_rpm,$(package))))