aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-08-26 14:38:19 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-08-26 14:38:19 +0200
commitae283997b95c18181091e530ba554624cd93a0e2 (patch)
tree75cd3b0c1f8673421a4768cbd4122b62e31551e8
parentf02e82378b210c0ed4670a683a4e4bc2bbc259c9 (diff)
Add 'dist' subsystem for preparing distributions
-rw-r--r--build/dist.make6
-rw-r--r--build/dist/functions.make71
2 files changed, 77 insertions, 0 deletions
diff --git a/build/dist.make b/build/dist.make
new file mode 100644
index 0000000..eb9748e
--- /dev/null
+++ b/build/dist.make
@@ -0,0 +1,6 @@
+# file : build/dist.make
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+$(call include-once,$(bld_root)/dist/functions.make,$(out_base))
diff --git a/build/dist/functions.make b/build/dist/functions.make
new file mode 100644
index 0000000..fcebe67
--- /dev/null
+++ b/build/dist/functions.make
@@ -0,0 +1,71 @@
+# file : build/dist/functions.make
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+dist_cmd := $(bld_root)/install/install
+
+dist_dir := $(dist_cmd) -d -m 755
+dist_data := $(dist_cmd) -p -m 644
+dist_exec := $(dist_cmd) -p -m 755
+
+$(out_root)/%: dist_dir := $(dist_dir)
+$(out_root)/%: dist_data := $(dist_data)
+$(out_root)/%: dist_exec := $(dist_exec)
+
+# Arguments:
+#
+# $1 - files
+# $2 - optional destination directory. If not specified,
+# $(dist_prefix)/<path> is used where path is computed as
+# difference between src_base and src_root.
+#
+$(out_base)/%: dist-data = \
+$(call dist-data-body,$1,$(if $2,$2,$(dist_prefix)$(subst \
+$(src_root),,$(src_base))))
+
+$(out_base)/%: dist-exec = \
+$(call dist-exec-body,$1,$(if $2,$2,$(dist_prefix)$(subst \
+$(src_root),,$(src_base))))
+
+# Arguments:
+#
+# $1 - directory
+# $2 - optional find predicates
+# $3 - optional destination directory. If not specified,
+# $(dist_prefix)/<path> is used where path is computed as
+# difference between src_base and src_root.
+#
+$(out_base)/%: dist-dir = \
+$(call dist-dir-body,$1,$2,$(if $3,$3,$(dist_prefix)$(subst \
+$(src_root),,$(src_base))))
+
+
+$(out_base)/%: dist-data-body = \
+$(call message,,$(dist_dir) $2)\
+$(foreach d,$(sort $(dir $(addprefix $2/,$1))),$(literal_newline)\
+$(literal_tab)$(call message,,$(dist_dir) $d))\
+$(foreach f,$1,$(literal_newline)\
+$(literal_tab)$(call message,dist $2/$f,$(dist_data) $(src_base)/$f $2/$f))
+
+$(out_base)/%: dist-exec-body = \
+$(call message,,$(dist_dir) $2)\
+$(foreach d,$(sort $(dir $(addprefix $2/,$1))),$(literal_newline)\
+$(literal_tab)$(call message,,$(dist_dir) $d))\
+$(foreach f,$1,$(literal_newline)\
+$(literal_tab)$(call message,dist $2/$f,$(dist_exec) $(src_base)/$f $2/$f))
+
+$(out_base)/%: dist-dir-body = \
+$(call message,dist $3/$1,find -L $(src_base)/$1 $2 -type f -print \
+| xargs -n 1 $(bld_root)/run-if-arg dirname \
+| sort -u \
+| sed -e 's%$(src_base)/$1\(.*\)%$3/$1\1%' \
+| xargs -n 1 $(bld_root)/run-if-arg "$(dist_dir)")$(literal_newline)\
+$(literal_tab)$(call message,,\
+find -L $(src_base)/$1 $2 -type f ! -perm -100 -print \
+| sed -e 's%$(src_base)/$1\(.*\)%$(src_base)/$1\1 $3/$1\1%' \
+| xargs -n 2 $(bld_root)/run-if-arg "$(dist_data)")$(literal_newline)\
+$(literal_tab)$(call message,,\
+find -L $(src_base)/$1 $2 -type f -perm -100 -print \
+| sed -e 's%$(src_base)/$1\(.*\)%$(src_base)/$1\1 $3/$1\1%' \
+| xargs -n 2 $(bld_root)/run-if-arg "$(dist_exec)")