build_sources = $(FILES) $(GENERATED_FILES)
build_sources_embed = $(build_sources:%='$(srcdir)/%')
build_references_ref = $(foreach ref, $(REFERENCES), $(if $(filter -pkg:%, $(ref)), $(ref), $(if $(filter -r:%, $(ref)), $(ref), -r:$(ref))))
build_references_ref += $(foreach ref, $(DLL_REFERENCES), -r:$(ref))
build_references_ref += $(foreach ref, $(PROJECT_REFERENCES), -r:$(ref))

EXTRA_DIST += $(build_sources) $(ASSEMBLY_WRAPPER_IN) $(EXTRAS) $(DATA_FILES) 
CLEANFILES += $(ASSEMBLY) $(ASSEMBLY).mdb $(BINARIES)
DISTCLEANFILES = $(GENERATED_FILES) $(pc_files) $(BUILD_DIR)/*

pkglib_SCRIPTS = $(ASSEMBLY)
bin_SCRIPTS = $(BINARIES)

programfilesdir = @libdir@/@PACKAGE@
programfiles_DATA = $(PROGRAMFILES)
linuxpkgconfigdir = @libdir@/pkgconfig
linuxpkgconfig_DATA = $(LINUX_PKGCONFIG)

# $(call emit-deploy-target,deploy-variable-name)
define emit-deploy-target
$($1): $($1_SOURCE)
	mkdir -p $$(dir $($1))
	cp '$$<' '$$@'
endef

# $(call emit-deploy-wrapper,wrapper-variable-name,wrapper-sourcefile,x)
# assumes that for a wrapper foo.pc its source template is foo.pc.in
# if $3 is non-empty then wrapper is marked exec
define emit-deploy-wrapper
$($1): $2 
	mkdir -p '$$(@D)'
	cp '$$<' '$$@'
	$(if $3,chmod +x '$$@')
endef

