[csw-devel] SF.net SVN: gar:[2998] csw/mgar/gar/v2-dynamiclicense/gar.pkg.mk

dmichelsen at users.sourceforge.net dmichelsen at users.sourceforge.net
Thu Feb 5 23:23:23 CET 2009


Revision: 2998
          http://gar.svn.sourceforge.net/gar/?rev=2998&view=rev
Author:   dmichelsen
Date:     2009-02-05 22:23:23 +0000 (Thu, 05 Feb 2009)

Log Message:
-----------
mGAR v2 dynamiclicense: First commit

Modified Paths:
--------------
    csw/mgar/gar/v2-dynamiclicense/gar.pkg.mk

Modified: csw/mgar/gar/v2-dynamiclicense/gar.pkg.mk
===================================================================
--- csw/mgar/gar/v2-dynamiclicense/gar.pkg.mk	2009-02-05 19:44:31 UTC (rev 2997)
+++ csw/mgar/gar/v2-dynamiclicense/gar.pkg.mk	2009-02-05 22:23:23 UTC (rev 2998)
@@ -21,7 +21,12 @@
 
 PKGINFO ?= /usr/bin/pkginfo
 
-SPKG_SPECS     ?= $(basename $(filter %.gspec,$(DISTFILES)))
+# You can use either PACKAGES with dynamic gspec-files or explicitly add gspec-files to DISTFILES.
+# Do "PACKAGES = " when you build a package whose GARNAME is not the package name.
+# The whole processing is done from SPKG_SPECS, which includes all packages to be build.
+# DO NOT USE $(PACKAGES) IN RULES!
+PACKAGES ?= CSW$(GARNAME)
+SPKG_SPECS     ?= $(sort $(basename $(filter %.gspec,$(DISTFILES))) $(PACKAGES))
 _PKG_SPECS      = $(filter-out $(NOPACKAGE),$(SPKG_SPECS))
 
 # Set this to your svn binary
@@ -201,6 +206,44 @@
 		)) >$@)
 
 
+$(foreach SPEC,$(_PKG_SPECS),$(eval CATALOGNAME_$(SPEC) ?= $(patsubst CSW%,%,$(SPEC))))
+
+# This rule dynamically generates gspec-files
+.PRECIOUS: $(WORKDIR)/%.gspec
+$(WORKDIR)/%.gspec: ARCHALL_$* ?= $(ARCHALL)
+$(WORKDIR)/%.gspec:
+	$(_DBG)(echo "%var            bitname $(CATALOGNAME_$*)"; \
+	echo "%var            pkgname $*"; \
+	$(if $(ARCHALL_$*),echo "%var            arch all";) \
+	echo "%include        url file://%{PKGLIB}/csw_dyndepend.gspec") >$@
+
+# This rule dynamically generates copyright files
+.PRECIOUS: $(WORKDIR)/copyright $(WORKDIR)/%.copyright
+# LICENSE may be a path starting with $(WORKROOTDIR) or a filename inside $(WORKSRC)
+LICENSE ?= COPYING
+_DEFAULT_LICENSE = $(firstword $(wildcard \
+			$(LICENSE) \
+			$(foreach D,$(foreach M,global $(MODULATIONS),build-$M), \
+				$(WORKROOTDIR)/$D/$(DISTNAME)/$(LICENSE) \
+			) \
+		))
+
+$(foreach SPEC,$(_PKG_SPECS),$(eval LICENSE_$(SPEC) ?= copyright))
+
+$(WORKDIR)/%.copyright: | $(WORKDIR)/copyright
+	$(_DBG)cp $(WORKDIR)/copyright $@
+
+merge-license:
+	$(_DBG)$(foreach SPEC,$(_PKG_SPECS),\
+		if [ -f $(WORKDIR)/$(LICENSE_$(SPEC)) ]; then \
+			LICENSEDIR=$(docdir)/$(CATALOGNAME_$(SPEC)); \
+			mkdir -p $(PKGROOT)$(LICENSEDIR) && \
+			cp $(WORKDIR)/$(LICENSE_$(SPEC)) $(PKGROOT)$(LICENSEDIR)/license; \
+			(echo "This software is copyrighted. Please see the full license at"; \
+			echo "  $(LICENSEDIR)/license") > $(PKGROOT)$(LICENSEDIR)/license; \
+		fi; \
+	)
+
 # package - Use the mkpackage utility to create Solaris packages
 #
 
@@ -225,7 +268,7 @@
 package: extract merge $(SPKG_DESTDIRS) pre-package $(PACKAGE_TARGETS) post-package
 	$(DONADA)
 
-package-%: $(WORKDIR)/%.prototype-$(GARCH) $(WORKDIR)/%.depend
+package-%: $(WORKDIR)/%.gspec $(WORKDIR)/%.copyright $(WORKDIR)/%.prototype-$(GARCH) $(WORKDIR)/%.depend
 	@echo " ==> Processing $*.gspec"
 	$(_DBG)( $(call _PKG_ENV,$*) mkpackage --spec $(WORKDIR)/$*.gspec \
 						 --spooldir $(SPKG_SPOOLDIR) \
@@ -267,6 +310,7 @@
 	@rm -rf $(foreach T,extract checksum package pkgcheck,$(COOKIEDIR)/*$(T)-$**)
 	@rm -rf $(COOKIEDIR)/pre-package $(COOKIEDIR)/post-package
 	@rm -rf $(WORKDIR)/$*.* $(WORKDIR)/prototype
+	@rm -f $(WORKDIR)/copyright $(WORKDIR)/*.copyright
 
 repackage: pkgreset package
 
@@ -287,11 +331,11 @@
 #
 
 define _pkglist_pkgname
-$(shell perl -F'\s+' -ane 'print "$$F[2]" if( $$F[0] eq "%var" && $$F[1] eq "pkgname")' files/$(1).gspec)
+$(if $(filter $(1),$(PACKAGES)),$(filter $(1),$(PACKAGES)),$(shell perl -F'\s+' -ane 'print "$$F[2]" if( $$F[0] eq "%var" && $$F[1] eq "pkgname")' files/$(1).gspec))
 endef
 
 define _pkglist_catalogname
-$(shell perl -F'\s+' -ane 'print "$$F[2]" if( $$F[0] eq "%var" && $$F[1] eq "bitname")' files/$(1).gspec)
+$(if $(filter $(1),$(PACKAGES)),$(call catalogname,$(1)),$(shell perl -F'\s+' -ane 'print "$$F[2]" if( $$F[0] eq "%var" && $$F[1] eq "bitname")' files/$(1).gspec))
 endef
 
 define _pkglist_one


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list