catching up
[build.git] / Makefile
index fd7f8d9..4dd947a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -94,7 +94,8 @@ PLANETLAB_RELEASE = 4.2
 #
 # Default values
 #
-HOSTARCH := $(shell uname -i)
+# minimal compat with macos, just so this does not complain 
+HOSTARCH := $(shell uname -i 2> /dev/null || uname -m 2> /dev/null)
 DISTRO := $(shell ./getdistro.sh)
 RELEASE := $(shell ./getrelease.sh)
 DISTRONAME := $(shell ./getdistroname.sh)
@@ -229,21 +230,26 @@ endef
 
 $(foreach package, $(ALL), $(eval $(call package_hasdate,$(package))))
 
+### the common header for generated specfiles
+# useful when trying new specfiles manually
+header.spec:
+       (echo -n "# Generated by planetlab build from $($(1)-SPEC) on " ; date) > $@
+       echo "%define distro $(DISTRO)" >> $@
+       echo "%define distrorelease $(RELEASE)" >> $@
+       echo "%define distroname $(DISTRONAME)" >> $@
+       echo "%define pldistro $(PLDISTRO)" >> $@
+       echo "%define plrelease $(PLANETLAB_RELEASE)" >> $@
+
 ### extract spec file from scm
 define target_spec
-$($(1).specpath):
+$($(1).specpath): header.spec
        mkdir -p SPECS
-       (echo -n "# Generated by planetlab build from $($(1)-SPEC) on " ; date) > $($(1).specpath)
-       echo "%define distro $(DISTRO)" >> $($(1).specpath)
-       echo "%define distrorelease $(RELEASE)" >> $($(1).specpath)
-       echo "%define distroname $(DISTRONAME)" >> $($(1).specpath)
-       echo "%define pldistro $(PLDISTRO)" >> $($(1).specpath)
-       echo "%define plrelease $(PLANETLAB_RELEASE)" >> $($(1).specpath)
+       cat header.spec > $($(1).specpath)
        $(if $($(1).has-date),echo "%define date $(shell date +%Y.%m.%d)" >> $($(1).specpath),)
        $(if $($(1)-SPECVARS), \
          $(foreach line,$($(1)-SPECVARS), \
            echo "%define" $(word 1,$(subst =, ,$(line))) "$(word 2,$(subst =, ,$(line)))" >> $($(1).specpath) ;))
-       echo "# included from codebase specfile" >> $($(1).specpath)
+       echo "# included from $($(1)-SPEC)" >> $($(1).specpath)
        $(if $($($(1).module)-SVNPATH),\
           svn cat $($($(1).module)-SVNPATH)/$($(1)-SPEC) >> $($(1).specpath) || rm $($(1).specpath),\
           cvs -d $($($(1).module)-CVSROOT) checkout \
@@ -558,7 +564,7 @@ clean-help:
 
 ### brute force clean
 distclean1:
-       rm -rf pldistro.mk .rpmmacros spec2make SPECS MAKE 
+       rm -rf pldistro.mk .rpmmacros spec2make header.spec SPECS MAKE 
 distclean2:
        rm -rf CODEBASES SOURCES BUILD RPMS SRPMS tmp
 distclean: distclean1 distclean2
@@ -637,6 +643,39 @@ endif
 # only if present
 -include $(PLDISTROINSTALL)
 
+#################### package info
+PKGKEYS := tarballs source codebase srpm rpms rpmnames rpm-release rpm-name rpm-version rpm-subversion
+%-pkginfo: package=$(subst -pkginfo,,$@)
+%-pkginfo: 
+       @$(foreach key,$(PKGKEYS),echo "$(package).$(key)=$($(package).$(key))";)
+## rpm info
+RPMKEYS := rpm-path package
+%-rpminfo: rpm=$(subst -rpminfo,,$@)
+%-rpminfo: 
+       @$(foreach key,$(RPMKEYS),echo "$(rpm).$(key)=$($(rpm).$(key))";)
+
+#################### various lists - designed to run with stage1=true
+packages:
+       @$(foreach package,$(ALL), echo package=$(package) ref_module=$($(package).module) modules=$($(package)-MODULES); )
+
+modules:
+       @$(foreach module,$(ALL-MODULES), echo module=$(module) svnpath=$($(module)-SVNPATH); )
+
+branches:
+       @$(foreach module,$(ALL-MODULES), \
+         $(if $($(module)-SVNBRANCH),echo module=$(module) branch=$($(module)-SVNBRANCH);))
+
+module-tools:
+       @$(foreach module,$(ALL-MODULES), \
+        $(if $($(module)-SVNPATH), \
+         $(if $($(module)-SVNBRANCH), \
+            echo $(module):$($(module)-SVNBRANCH); , \
+            echo $(module); )))
+
+info: packages modules branches 
+
+.PHONY: info packages modules branches module-tools
+
 ####################
 help:
        @echo "********** Run make in two stages:"
@@ -702,6 +741,8 @@ help:
        @echo "  Displays know attributes of a package"
        @echo "make kernel-devel-rpminfo"
        @echo "  Displays know attributes of an rpm"
+       @echo "make stage1=true PLDISTROTAGS=planetlab-tags-4.2.mk packages modules branches module-tools"
+       @echo "  Lists mentioned items - module-tools is used in modules.update"
        @echo ""
        @echo "********** Known pakages are"
        @echo "$(ALL)"
@@ -715,13 +756,3 @@ help:
 +%: varname=$(subst +,,$@)
 +%:
        @echo "$($(varname))"
-## package info
-PKGKEYS := tarballs source codebase srpm rpms rpmnames rpm-release rpm-name rpm-version rpm-subversion
-%-pkginfo: package=$(subst -pkginfo,,$@)
-%-pkginfo: 
-       @$(foreach key,$(PKGKEYS),echo "$(package).$(key)=$($(package).$(key))";)
-## rpm info
-RPMKEYS := rpm-path package
-%-rpminfo: rpm=$(subst -rpminfo,,$@)
-%-rpminfo: 
-       @$(foreach key,$(RPMKEYS),echo "$(rpm).$(key)=$($(rpm).$(key))";)