# SOURCES contains the list of all files to be compiled, even dynamic ones that # were generated during the configure run (like optnik.pc.in -> optnik.pc.) If # the generated files should be removed on distclean, one can put them in the # GENERATED_SOURCES variable instead. # # PUBLIC VARIABLES: # # build_sources - full set of source files to compile # # .xaml files processed with xamlg generate .xaml.g.cs source files. To both # automatically process the XAML and include the generate file in the compiled # sources just add the .xaml.g.cs file to GENERATED_SOURCES. build_sources = $(SOURCES) $(GENERATED_SOURCES) build_xamlg_files = $(filter %.xaml.g.cs,$(build_sources)) # RESOURCES holds the list of all resources (resx and not). Resources can be # specified using the FILENAME,ID trick to include filename with the given ID. # Always specify the "soruce" name (e.g., use .resx and not .resources) and let # the rules to their magic (.resx, .txt and .text files are compiled using # resgen while other extensions are embedded as-is.) # # PUBLIC VARIABLES: # # build_resources - automatically generated (and not) resources to depend on # build_resources_embed - command-line ready compiler '-resource' arguments # a couple of useful variables to represent reserved chars at__=@ comma__=, # $(call resource-file,resource) define resource-file $(firstword $(subst $(comma__), ,$1)) endef # $(call check-resources,extension,resource-variable) define check-resources $(if $(filter %.$1,$(call resource-file,$($2))),$($2),) endef # First separate the list of resources in resgen-izable ones and others. build_resx_list = $(foreach r,$(RESOURCES),$(call check-resources,resx,r)) build_text_list = $(foreach r,$(RESOURCES),$(call check-resources,text,r)) build_txt_list = $(foreach r,$(RESOURCES),$(call check-resources,txt,r)) build_resgen_list = $(build_resx_list) $(build_text_list) $(build_txt_list) build_others_list = $(filter-out $(build_resgen_list),$(RESOURCES)) # Build a list of files for the Makefile DIST list. build_resx_files = $(foreach r,$(build_resx_list),$(call resource-file,$(r))) build_text_files = $(foreach r,$(build_text_list),$(call resource-file,$(r))) build_txt_files = $(foreach r,$(build_txt_list),$(call resource-file,$(r))) build_resgen_files = $(foreach r,$(build_resgen_list),$(call resource-file,$(r))) build_others_files = $(foreach r,$(build_others_list),$(call resource-file,$(r))) # Build a list of compiled resources, to be used as dependencies. build_resx_resources = $(build_resx_files:.resx=.resources) build_text_resources = $(build_text_files:.resx=.resources) build_txt_resources = $(build_text_files:.resx=.resources) build_resgen_resources = $(build_resx_resources) $(build_text_resources) $(build_txt_resources) build_others_resources = $(build_others_files) # Build a list of resources ready for the compiler command lines. build_resx_resources_embed = $(foreach res,$(subst .resx,.resources,$(build_resx_list)),-resource:$(res)) build_text_resources_embed = $(foreach res,$(subst .text,.resources,$(build_text_list)),-resource:$(res)) build_txt_resources_embed = $(foreach res,$(subst .txt,.resources,$(build_txt_list)),-resource:$(res)) build_resgen_resources_embed = $(build_resx_resources_embed) $(build_text_resources_embed) $(build_txt_resources_embed) build_others_resources_embed = $(foreach res,$(build_others_files),-resource:$(res)) build_resources = $(build_resgen_resources) $(build_others_resources) build_resources_embed = $(build_resgen_resources_embed) $(build_others_resources_embed) # REFERENCES, DLL_REFERENCES and PROJECT_REFERENCES respectively hold the name # of GAC assemblies, the filename of DLLs and the filename of related project # assemblies. Note that DLLs and project assemblies are installed to the # destination package library directory but are not copied in-tree by default. # If you want to run from the source tree without installing, see the various # emit- macros below. # # PUBLIC VARIABLES: # # build_references_ref - command-line ready compiler '-r' arguments build_references_ref = $(foreach r,$(REFERENCES),$(if $(filter -pkg:%,$(r)),$(r),$(if $(filter -r:%,$(r)),$(r),-r:$(r)))) build_references_ref += $(foreach ref,$(DLL_REFERENCES),-r:$(ref)) build_references_ref += $(foreach ref,$(PROJECT_REFERENCES),-r:$(ref)) # Project DLLs and stand-alone DLLs should be copied to the destination # build directory to make sure chanins of dependencies still find everything # and build correctly. build_dependencies_dlls = $(foreach r,$(DLL_REFERENCES),$(BUILD_DIR)/$(notdir $r)) build_dependencies_dlls += $(foreach r,$(PROJECT_REFERENCES),$(BUILD_DIR)/$(notdir $r)) # $(eval $(call emit-deploy-script,scriptfile)) define emit-deploy-script $1: $1.in sed -e "s,$(at__)prefix$(at__),$(prefix)," \ -e "s,$(at__)PACKAGE$(at__),$(PACKAGE)," \ -e "s,$(at__)VERSION$(at__),$(VERSION)," \ < $1.in > $1 mkdir -p $(BUILD_DIR) $(INSTALL_SCRIPT) $1 $(BUILD_DIR)/$1 endef # $(eval $(call emit-deploy-pkgconfig,pkgconfigfile)) define emit-deploy-pkgconfig $1: $1.in sed -e "s,$(at__)prefix$(at__),$(prefix)," \ -e "s,$(at__)PACKAGE$(at__),$(PACKAGE)," \ -e "s,$(at__)VERSION$(at__),$(VERSION)," \ < $1.in > $1 mkdir -p $(BUILD_DIR) $(INSTALL_DATA) $1 $(BUILD_DIR)/$1 endef # $(call emit-dependency-dll,dll) define emit-dependency-dll $(BUILD_DIR)/$(notdir $1): $1 $(INSTALL_DATA) $1 $(BUILD_DIR)/$(notdir $1) @test -f $1.mdb && $(INSTALL_DATA) $1.mdb $(BUILD_DIR)/$(notdir $1).mdb || true endef ## END OF PUBLIC VARIABLES AND MACROS ## # Extra files to be included in the distribution. EXTRA_DIST = $(build_sources) $(build_resgen_files) $(build_others_files) $(EXTRAS) $(DATA_FILES) # Files to be cleaned (compiled assembly, wrapper scripts, generated resources) CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(BINARIES) $(build_resgen_resources) # Remove everything that was generated. DISTCLEANFILES = $(GENERATED_SOURCES) $(LINUX_PKGCONFIG) $(BUILD_DIR)/* # Where to install assemblies, scripts and generated .pc files. pkglib_DATA = $(ASSEMBLY) $(build_dependencies_dlls) bin_SCRIPTS = $(BINARIES) linuxpkgconfigdir = $(prefix)/lib/pkgconfig linuxpkgconfig_DATA = $(LINUX_PKGCONFIG)