diff options
author | Abdoulaye Walsimou Gaye <awg@embtoolkit.org> | 2011-09-02 18:45:47 +0200 |
---|---|---|
committer | Abdoulaye Walsimou Gaye <awg@embtoolkit.org> | 2011-09-02 18:45:47 +0200 |
commit | 88c76868dc7b83ad3c122af08350f9cd65ef3433 (patch) | |
tree | c291845deda1c47a725edf14dd9f5a332a580a15 /mk/macros.mk | |
parent | f069ca57359213adc645f92178ccfe0c240c85aa (diff) | |
download | embtoolkit-88c76868dc7b83ad3c122af08350f9cd65ef3433.tar.gz embtoolkit-88c76868dc7b83ad3c122af08350f9cd65ef3433.tar.bz2 embtoolkit-88c76868dc7b83ad3c122af08350f9cd65ef3433.tar.xz |
Build system: move generic macros for packages management in a dedicated file
Signed-off-by: Abdoulaye Walsimou Gaye <awg@embtoolkit.org>
Diffstat (limited to 'mk/macros.mk')
-rw-r--r-- | mk/macros.mk | 514 |
1 files changed, 3 insertions, 511 deletions
diff --git a/mk/macros.mk b/mk/macros.mk index 89eeb7e..0339119 100644 --- a/mk/macros.mk +++ b/mk/macros.mk @@ -58,21 +58,6 @@ endef # __embtk_mk_strcmp=$(shell [ $(strip $(1)) = $(strip $(2)) ] && echo y) -# -# wget wrapper -# usage: $(call embtk_wget,$(OUTPUT_FILE),$(SITE),$(FOREIGN_FILE)) -# -__wget_outfile = $(patsubst %/,%,$(DOWNLOAD_DIR))/$(strip $(1)) -__wget_remotesite = $(patsubst %/,%,$(strip $(2))) -__wget_foreignfiles = $(strip $(3)) -__wget_opts = --tries=5 --timeout=10 --waitretry=5 -define embtk_wget - wget $(__wget_opts) -O $(__wget_outfile) \ - $(__wget_remotesite)/$(__wget_foreignfiles) || \ - wget $(__wget_opts) --no-passive-ftp -O $(__wget_outfile) \ - $(__wget_remotesite)/$(__wget_foreignfiles) -endef - #Decompress message #usage $(call EMBTK_DECOMPRESS_MSG,$(NAME_PACKAGE)) define EMBTK_DECOMPRESS_MSG @@ -126,7 +111,7 @@ define embtk_pinfo $(call embtk_echo_blue,"################################################################################") endef -#Successful build of EmbToolkit message +# Successful build of EmbToolkit message successful_build: $(call embtk_echo_blue," --------------------- ") $(call embtk_echo_blue,"| Toolchain build log |") @@ -156,498 +141,5 @@ endif @echo $(call embtk_echo_blue,"################################################################################") -# -# embtk_pkgconfig_getlibs: -# A macro to get pkg-config libs entry for a target package -# Usage: $(call embtk_pkgconfig_getlibs,pkgname) -# -define embtk_pkgconfig_getlibs - $(shell \ - PKG_CONFIG_PATH=$(EMBTK_PKG_CONFIG_PATH) \ - PKG_CONFIG_LIBDIR="$(EMBTK_PKG_CONFIG_LIBDIR)" \ - $(PKGCONFIG_BIN) $(strip $(1)) --libs) -endef - -# -# embtk_pkgconfig_getcflags: -# A macro to get pkg-config cflags entry for a target package -# Usage: $(call embtk_pkgconfig_getcflags,pkgname) -# -define embtk_pkgconfig_getcflags - $(shell \ - PKG_CONFIG_PATH=$(EMBTK_PKG_CONFIG_PATH) \ - PKG_CONFIG_LIBDIR="$(EMBTK_PKG_CONFIG_LIBDIR)" \ - $(PKGCONFIG_BIN) $(strip $(1)) --cflags) -endef - -#Macro to adapt libtool files (*.la) for cross compiling -__ltlibdirold=libdir='\/usr\/$(LIBDIR)' -__ltlibdirnew=libdir='$(SYSROOT)\/usr\/$(LIBDIR)' -define __embtk_fix_libtool_files - @LIBTOOLS_LA_FILES=`find $(SYSROOT)/usr/$(LIBDIR) -name *.la`; \ - for i in $$LIBTOOLS_LA_FILES; do \ - sed -i "s;$(__ltlibdirold);$(__ltlibdirnew);" $$i; \ - done -endef -libtool_files_adapt: - $(Q)$(call __embtk_fix_libtool_files) - -#Macro to adapt pkg-config files for cross compiling -define __embtk_fix_pkgconfig_files - PKGCONFIG_FILES=`find $(SYSROOT)/usr/$(LIBDIR)/pkgconfig -name *.pc`; \ - for i in $$PKGCONFIG_FILES; do \ - sed -e 's;prefix=.*;prefix=$(SYSROOT)/usr;' \ - -e 's;includedir=$${prefix}/include;includedir=$(SYSROOT)/usr/include;' \ - -e 's;libdir=.*;libdir=$(SYSROOT)/usr/$(LIBDIR);' < $$i > $$i.new; \ - mv $$i.new $$i; \ - done -endef -pkgconfig_files_adapt: - $(Q)$(call __embtk_fix_pkgconfig_files) - -#A macro to remove rpath in packages that use libtool -rpath -define __embtk_kill_lt_rpath - cd $(strip $(1)); \ - LOCAL_LT_FILES=`find -type f -name libtool`; \ - for i in $$LOCAL_LT_FILES; \ - do \ - sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' $$i; \ - sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' $$i; \ - done -endef - -# -# Get passed package variables prefix and set some helpers macros. -# -PKGV = $(strip $(shell echo $(1) | tr a-z A-Z)) -pkgv = $(strip $(shell echo $(1) | tr A-Z a-z)) -__embtk_pkg_name = $(strip $($(PKGV)_NAME)) -__embtk_pkg_version = $(strip $($(PKGV)_VERSION)) -__embtk_pkg_site = $(strip $($(PKGV)_SITE)) -__embtk_patch_site = ftp://ftp.embtoolkit.org/embtoolkit.org -__embtk_pkg_patch_site = $(strip $(if $($(PKGV)_PATCH_SITE), \ - $($(PKGV)_PATCH_SITE), \ - $(__embtk_patch_site)/$(__embtk_pkg_name)/$(__embtk_pkg_version))) -__embtk_pkg_patch_f = $(strip $(DOWNLOAD_DIR))/$(__embtk_pkg_name)-$(__embtk_pkg_version).patch -__embtk_pkg_mirror1 = $(strip $($(PKGV)_MIRROR1)) -__embtk_pkg_mirror2 = $(strip $($(PKGV)_MIRROR2)) -__embtk_pkg_mirror3 = $(strip $($(PKGV)_MIRROR3)) -__embtk_pkg_package = $(strip $($(PKGV)_PACKAGE)) -__embtk_pkg_package_f = $(strip $(DOWNLOAD_DIR))/$(__embtk_pkg_package) -__embtk_pkg_srcdir = $(patsubst %/,%,$(strip $($(PKGV)_SRC_DIR))) -__embtk_pkg_builddir = $(patsubst %/,%,$(strip $($(PKGV)_BUILD_DIR))) - -__embtk_pkg_etc = $(strip $($(PKGV)_ETC)) -__embtk_pkg_bins = $(strip $($(PKGV)_BINS)) -__embtk_pkg_sbins = $(strip $($(PKGV)_SBINS)) -__embtk_pkg_includes = $(strip $($(PKGV)_INCLUDES)) -__embtk_pkg_libs = $(strip $($(PKGV)_LIBS)) -__embtk_pkg_libexecs = $(strip $($(PKGV)_LIBEXECS)) -__embtk_pkg_pkgconfigs = $(strip $($(PKGV)_PKGCONFIGS)) - -__embtk_pkg_configureenv = $(strip $($(PKGV)_CONFIGURE_ENV)) -__embtk_pkg_setrpath = $(strip $($(PKGV)_SET_RPATH)) -__embtk_pkg_configureopts = $(strip $($(PKGV)_CONFIGURE_OPTS)) -__embtk_pkg_sysrootsuffix = $(strip $($(PKGV)_SYSROOT_SUFFIX)) -__embtk_pkg_prefix = $(strip $($(PKGV)_PREFIX)) -__embtk_pkg_destdir = $(strip $($(PKGV)_DESTDIR)) -__embtk_pkg_nodestdir = $(strip $($(PKGV)_NODESTDIR)) -__embtk_pkg_deps = $(strip $($(PKGV)_DEPS)) - -__embtk_pkg_makedirs = $(strip $($(PKGV)_MAKE_DIRS)) -__embtk_pkg_makeenv = $(strip $($(PKGV)_MAKE_ENV)) -__embtk_pkg_makeopts = $(strip $($(PKGV)_MAKE_OPTS)) - -# -# A macro to get packages version from .config file. -# usage: $(call embtk_get_pkgversion,PACKAGE) -# -embtk_get_pkgversion = $(subst ",,$(strip $(CONFIG_EMBTK_$(PKGV)_VERSION_STRING))) - - -# -# A macro to test if a package is already decompressed. -# It returns y if decompressed and nothing if not. -# -__embtk_pkg_decompressed-y = $(shell test -e $(__embtk_pkg_srcdir)/.decompressed && echo y) - -# -# A macro to test if a package is already patched. -# It returns y if patched and nothing if not. -# -__embtk_pkg_patched-y = $(shell test -e $(__embtk_pkg_srcdir)/.patched && echo y) - -# -# A macro to test if a package is already configured using autotools configure -# script. It returns y if configured and nothing if not. -# -__embtk_pkg_configured-y = $(shell test -e $(__embtk_pkg_builddir)/.configured && echo y) - -# -# A macro to test if a package is already installed. -# It returns y if installed and nothing if not. -# -__installed_f=$(__embtk_pkg_builddir)/.installed -__pkgkconfig_f=$(__embtk_pkg_builddir)/.embtk.$(__embtk_pkg_name).kconfig -__pkgkconfig_f_old=$(__embtk_pkg_builddir)/.embtk.$(__embtk_pkg_name).kconfig.old -__embtk_pkg_installed-y = $(shell \ - if [ -e $(__installed_f) ] && [ -e $(__pkgkconfig_f) ]; then \ - cp $(__pkgkconfig_f) $(__pkgkconfig_f_old); \ - grep 'CONFIG_EMBTK_.*$(PKGV)_.*' $(EMBTK_DOTCONFIG) \ - > $(__pkgkconfig_f); \ - cmp -s $(__pkgkconfig_f) $(__pkgkconfig_f_old); \ - if [ "x$$?" = "x0" ]; then \ - echo y; \ - fi; \ - else \ - mkdir -p $(__embtk_pkg_builddir); \ - grep 'CONFIG_EMBTK_.*$(PKGV)_.*' $(EMBTK_DOTCONFIG) \ - > $(__pkgkconfig_f); \ - fi;) - -# -# A macro which runs configure script (conpatible with autotools configure) -# for a package and sets environment variables correctly. -# Usage: -# $(call embtk_configure_pkg,PACKAGE) -# -define __embtk_configure_autoreconfpkg -if [ "x$(CONFIG_EMBTK_$(PKGV)_NEED_AUTORECONF)" = "xy" ]; then \ - test -e $(__embtk_pkg_srcdir)/configure.ac || \ - test -e $(__embtk_pkg_srcdir)/configure.in || exit 1; \ - cd $(__embtk_pkg_srcdir); \ - $(AUTORECONF) --install -f; \ -fi -endef -define __embtk_print_configure_opts - $(call embtk_echo_blue,"Configure options:") - for i in `echo $(1) | tr " " "\n"`; \ - do echo -e $(__embtk_color_blue)$$i$(__embtk_no_color); done -endef -define embtk_configure_pkg - $(call embtk_pinfo,"Configure $(__embtk_pkg_package)...") - $(call __embtk_configure_autoreconfpkg,$(1)) - $(Q)test -e $(__embtk_pkg_srcdir)/configure || exit 1 - $(call __embtk_print_configure_opts,"$(__embtk_pkg_configureopts)") - $(Q)cd $(__embtk_pkg_builddir); \ - CC=$(TARGETCC_CACHED) \ - CXX=$(TARGETCXX_CACHED) \ - AR=$(TARGETAR) \ - RANLIB=$(TARGETRANLIB) \ - AS=$(CROSS_COMPILE)as \ - LD=$(TARGETLD) \ - NM=$(TARGETNM) \ - STRIP=$(TARGETSTRIP) \ - OBJDUMP=$(TARGETOBJDUMP) \ - OBJCOPY=$(TARGETOBJCOPY) \ - CFLAGS="$(TARGET_CFLAGS)" \ - CXXFLAGS="$(TARGET_CFLAGS)" \ - LDFLAGS="-L$(SYSROOT)/$(LIBDIR) -L$(SYSROOT)/usr/$(LIBDIR)" \ - CPPFLAGS="-I$(SYSROOT)/usr/include" \ - PKG_CONFIG="$(PKGCONFIG_BIN)" \ - PKG_CONFIG_PATH="$(EMBTK_PKG_CONFIG_PATH)" \ - PKG_CONFIG_LIBDIR="$(EMBTK_PKG_CONFIG_LIBDIR)" \ - ac_cv_func_malloc_0_nonnull=yes \ - ac_cv_func_realloc_0_nonnull=yes \ - $(__embtk_pkg_configureenv) \ - $(CONFIG_SHELL) $(__embtk_pkg_srcdir)/configure \ - --build=$(HOST_BUILD) --host=$(STRICT_GNU_TARGET) \ - --target=$(STRICT_GNU_TARGET) --libdir=/usr/$(LIBDIR) \ - --prefix=/usr --sysconfdir=/etc --disable-rpath \ - $(__embtk_pkg_configureopts) - $(Q)touch $(__embtk_pkg_builddir)/.configured - $(Q)$(call __embtk_kill_lt_rpath,$(__embtk_pkg_builddir)) -endef - -# -# A macro which runs configure script (conpatible with autotools configure) -# for a package for host development machine and sets environment variables -# correctly. -# Usage: -# $(call embtk_configure_hostpkg,PACKAGE) -# -__embtk_hostpkg_rpathldflags="-Wl,-rpath,$(HOSTTOOLS)/usr/lib" -__embtk_hostpkg_rpath=$(strip $(if $(__embtk_pkg_setrpath), \ - $(__embtk_hostpkg_rpathldflags))) -define embtk_configure_hostpkg - $(call embtk_pinfo,"Configure $(__embtk_pkg_package) for host...") - $(call __embtk_configure_autoreconfpkg,$(1)) - $(Q)test -e $(__embtk_pkg_srcdir)/configure || exit 1 - $(call __embtk_print_configure_opts,"$(__embtk_pkg_configureopts)") - $(Q)cd $(__embtk_pkg_builddir); \ - CPPFLAGS="-I$(HOSTTOOLS)/usr/include" \ - LDFLAGS="-L$(HOSTTOOLS)/usr/lib $(__embtk_hostpkg_rpath)" \ - PKG_CONFIG="$(PKGCONFIG_BIN)" \ - PKG_CONFIG_PATH="$(EMBTK_HOST_PKG_CONFIG_PATH)" \ - $(if $(call __embtk_mk_strcmp,$(PKGV),CCACHE),,CC=$(HOSTCC_CACHED)) \ - $(if $(call __embtk_mk_strcmp,$(PKGV),CCACHE),,CXX=$(HOSTCXX_CACHED)) \ - $(__embtk_pkg_configureenv) \ - $(CONFIG_SHELL) $(__embtk_pkg_srcdir)/configure \ - --build=$(HOST_BUILD) --host=$(HOST_ARCH) \ - --prefix=$(strip $(if $(__embtk_pkg_prefix), \ - $(__embtk_pkg_prefix),$(HOSTTOOLS)/usr)) \ - $(__embtk_pkg_configureopts) - $(Q)touch $(__embtk_pkg_builddir)/.configured -endef - -# -# Various helpers macros for different steps while installing packages. -# -__embtk_multi_make = $(foreach builddir,$(__embtk_pkg_makedirs), \ - $(__embtk_pkg_makeenv) \ - $(MAKE) -C $(__embtk_pkg_builddir)/$(builddir) \ - $(__embtk_pkg_makeopts) $(J);) - -__embtk_single_make = $(__embtk_pkg_makeenv) $(MAKE) -C $(__embtk_pkg_builddir) \ - $(__embtk_pkg_makeopts) $(J) - -__embtk_multi_make_install = $(foreach builddir,$(__embtk_pkg_makedirs), \ - $(__embtk_pkg_makeenv) $(MAKE) -C $(__embtk_pkg_builddir)/$(builddir) \ - $(if $(__embtk_pkg_nodestdir),, \ - DESTDIR=$(SYSROOT)$(if $(__embtk_pkg_sysrootsuffix),/$(__embtk_pkg_sysrootsuffix))) \ - $(__embtk_pkg_makeopts) install;) - -__embtk_single_make_install = $(__embtk_pkg_makeenv) \ - $(MAKE) -C $(__embtk_pkg_builddir) \ - $(if $(__embtk_pkg_nodestdir),, \ - DESTDIR=$(SYSROOT)$(if $(__embtk_pkg_sysrootsuffix),/$(__embtk_pkg_sysrootsuffix))) \ - $(__embtk_pkg_makeopts) install - -__embtk_multi_make_hostinstall = $(foreach builddir,$(__embtk_pkg_makedirs), \ - $(__embtk_pkg_makeenv) \ - $(MAKE) -C $(__embtk_pkg_builddir)/$(builddir) \ - $(if $(__embtk_pkg_destdir),DESTDIR=$(__embtk_pkg_destdir)) \ - $(__embtk_pkg_makeopts) install;) - -__embtk_single_make_hostinstall = $(__embtk_pkg_makeenv) \ - $(MAKE) -C $(__embtk_pkg_builddir) \ - $(if $(__embtk_pkg_destdir),DESTDIR=$(__embtk_pkg_destdir)) \ - $(__embtk_pkg_makeopts) install - -__embtk_autotoolspkg-y=$(2) -define __embtk_install_pkg_make - $(call embtk_pinfo,"Compiling and installing $(__embtk_pkg_name)-$(__embtk_pkg_version) in your root filesystem...") - $(Q)$(if $(strip $(__embtk_pkg_deps)),$(MAKE) $(__embtk_pkg_deps)) - $(Q)$(call embtk_download_pkg,$(1)) - $(Q)$(call embtk_decompress_pkg,$(1)) - $(Q)$(if $(embtk_beforeinstall_$(pkgv)),$(embtk_beforeinstall_$(pkgv))) - $(Q)$(if $(__embtk_autotoolspkg-y),$(call embtk_configure_pkg,$(1))) - $(Q)$(if $(__embtk_pkg_makedirs), \ - $(__embtk_multi_make), \ - $(__embtk_single_make)) - $(Q)$(if $(__embtk_pkg_makedirs), \ - $(__embtk_multi_make_install), \ - $(__embtk_single_make_install)) - $(Q)$(if $(__embtk_autotoolspkg-y),$(call __embtk_fix_libtool_files)) - $(Q)$(if $(__embtk_autotoolspkg-y),$(call __embtk_fix_pkgconfig_files)) - $(Q)touch $(__embtk_pkg_builddir)/.installed -endef -define __embtk_install_hostpkg_make - $(call embtk_pinfo,"Compiling and installing $(__embtk_pkg_name)-$(__embtk_pkg_version) for host...") - $(Q)$(if $(strip $(__embtk_pkg_deps)),$(MAKE) $(__embtk_pkg_deps)) - $(Q)$(call embtk_download_pkg,$(1)) - $(Q)$(call embtk_decompress_pkg,$(1)) - $(if $(embtk_beforeinstall_$(pkgv)),$(embtk_beforeinstall_$(pkgv))) - $(Q)$(if $(__embtk_autotoolspkg-y),$(call embtk_configure_hostpkg,$(1))) - $(Q)$(if $(__embtk_pkg_makedirs), \ - $(__embtk_multi_make), \ - $(__embtk_single_make)) - $(Q)$(if $(__embtk_pkg_makedirs), \ - $(__embtk_multi_make_hostinstall), \ - $(__embtk_single_make_hostinstall)) - $(Q)touch $(__embtk_pkg_builddir)/.installed -endef - -# -# A macro to exit with error when needed package variables not define. -# Usage: -# $(call __embtk_install_paramsfailure,pkgname) -# -define __embtk_install_paramsfailure - $(call embtk_perror,"!Not all needed variables defined for $(1)!") - exit 1 -endef - -__embtk_xinstall_xpkg_allvarset-y = $(and $(__embtk_pkg_name), \ - $(__embtk_pkg_version), \ - $(__embtk_pkg_site)) - -# -# A macro to install automatically a package, using autotools scripts, intended -# to run on the target -# Usage: -# $(call embtk_install_pkg,package) -# -define embtk_install_pkg - $(if $(__embtk_xinstall_xpkg_allvarset-y), - $(if $(__embtk_pkg_installed-y),true, - $(call __embtk_install_pkg_make,$(1),autotools)) - $(if $(embtk_postinstall_$(pkgv)),$(embtk_postinstall_$(pkgv))), - $(call __embtk_install_paramsfailure,$(1))) -endef - -# -# A macro to install automatically a package, using simple Makefile and an -# install target, intented to run on the target. -# Usage: -# $(call embtk_makeinstall_pkg,package) -# -define embtk_makeinstall_pkg - $(if $(__embtk_xinstall_xpkg_allvarset-y), - $(if $(__embtk_pkg_installed-y),true, - $(call __embtk_install_pkg_make,$(1))) - $(if $(embtk_postinstall_$(pkgv)),$(embtk_postinstall_$(pkgv))), - $(call __embtk_install_paramsfailure,$(1))) -endef - -# -# A macro to install automatically a package, using autotools scripts, intended -# to run on the host development machine. -# Usage: -# $(call embtk_install_hostpkg,package) -# -define embtk_install_hostpkg - $(if $(__embtk_xinstall_xpkg_allvarset-y), - $(if $(__embtk_pkg_installed-y),true, - $(call __embtk_install_hostpkg_make,$(1),autotools)) - $(if $(embtk_postinstall_$(pkgv)),$(embtk_postinstall_$(pkgv))), - $(call __embtk_install_paramsfailure,$(1))) -endef - -# -# A macro to install automatically a package, using simple Makefile and an -# install target, intended to run on the host development machine. -# Usage: -# $(call embtk_makeinstall_hostpkg,package) -# -define embtk_makeinstall_hostpkg - $(if $(__embtk_xinstall_xpkg_allvarset-y), - $(if $(__embtk_pkg_installed-y),true, - $(call __embtk_install_hostpkg_make,$(1))) - $(if $(embtk_postinstall_$(pkgv)),$(embtk_postinstall_$(pkgv))), - $(call __embtk_install_paramsfailure,$(1))) -endef - -# -# A macro which downloads a package. -# Usage: -# $(call embtk_download_pkg,PACKAGE) -# -define __embtk_download_pkg_patches -if [ "x$(CONFIG_EMBTK_$(PKGV)_NEED_PATCH)" = "xy" ]; then \ - test -e $(__embtk_pkg_patch_f) || \ - $(call embtk_wget, \ - $(__embtk_pkg_name)-$(__embtk_pkg_version).patch, \ - $(__embtk_pkg_patch_site), \ - $(__embtk_pkg_name)-$(__embtk_pkg_version)-*.patch); \ -fi -endef -define __embtk_download_pkg_from_mirror -if [ "x$($(PKGV)_SITE_MIRROR$(2))" = "x" ]; then \ - false; \ -else \ - $(call embtk_wget, \ - $(__embtk_pkg_package), \ - $($(PKGV)_SITE_MIRROR$(2)), \ - $(__embtk_pkg_package)); \ -fi -endef - -define __embtk_download_pkg_exitfailure - (echo -e "\E[1;31m!Error on $(notdir $(1)) download!\E[0m";rm -rf $(1); \ - exit 1) -endef - -define embtk_download_pkg - $(call embtk_pinfo,"Download $(__embtk_pkg_package) if needed...") - $(Q)test -e $(__embtk_pkg_package_f) || \ - $(call embtk_wget, \ - $(__embtk_pkg_package), \ - $(__embtk_pkg_site), \ - $(__embtk_pkg_package)) || \ - $(call __embtk_download_pkg_from_mirror,$(1),1) || \ - $(call __embtk_download_pkg_from_mirror,$(1),2) || \ - $(call __embtk_download_pkg_from_mirror,$(1),3) || \ - $(call __embtk_download_pkg_exitfailure,$(__embtk_pkg_package_f)) - $(call __embtk_download_pkg_patches,$(1)) || \ - $(call __embtk_download_pkg_exitfailure,$(__embtk_pkg_patch_f)) -endef - -# -# A macro to decompress packages tarball intended to run on target. -# Usage: -# $(call embtk_decompress_pkg,pkgname) -# -define embtk_decompress_pkg - $(call embtk_pinfo,"Decrompressing $(__embtk_pkg_package) ...") - $(Q)if [ "x$(CONFIG_EMBTK_$(PKGV)_PKG_IS_TARGZ)" = "xy" ] && \ - [ ! -e $(__embtk_pkg_srcdir)/.decompressed ]; then \ - tar -C $(dir $(__embtk_pkg_srcdir)) -xzf \ - $(__embtk_pkg_package_f) && \ - mkdir -p $(__embtk_pkg_builddir) && \ - touch $(__embtk_pkg_srcdir)/.decompressed; \ - elif [ "x$(CONFIG_EMBTK_$(PKGV)_PKG_IS_TARBZ2)" = "xy" ] && \ - [ ! -e $(__embtk_pkg_srcdir)/.decompressed ]; then \ - tar -C $(dir $(__embtk_pkg_srcdir)) -xjf \ - $(__embtk_pkg_package_f) && \ - mkdir -p $(__embtk_pkg_builddir) && \ - touch $(__embtk_pkg_srcdir)/.decompressed; \ - elif [ "x$(CONFIG_EMBTK_$(PKGV)_PKG_IS_TARBZ2)" = "x" ] && \ - [ "x$(CONFIG_EMBTK_$(PKGV)_PKG_IS_TARGZ)" = "x" ] && \ - [ ! -e $(__embtk_pkg_srcdir)/.decompressed ]; then \ - echo -e "\E[1;31m!Unknown package compression type!\E[0m"; \ - exit 1; \ - fi - $(Q)if [ "x$(CONFIG_EMBTK_$(PKGV)_NEED_PATCH)" = "xy" ] && \ - [ ! -e $(__embtk_pkg_srcdir)/.patched ]; then \ - cd $(__embtk_pkg_srcdir); \ - patch -p1 < \ - $(__embtk_pkg_patch_f) && touch $(__embtk_pkg_srcdir)/.patched; \ - fi - $(Q)mkdir -p $(__embtk_pkg_builddir) -endef - -# -# A macro to clean installed packages from sysroot. -# Usage: -# $(call embtk_cleanup_pkg,PACKAGE) -# -define embtk_cleanup_pkg - $(call embtk_pinfo,"Cleanup $(__embtk_pkg_name)...") - $(Q)-if [ "x$(__embtk_pkg_etc)" != "x" ] && [ -e $(SYSROOT)/etc ]; \ - then \ - cd $(SYSROOT)/etc; rm -rf $(__embtk_pkg_etc); \ - fi - $(Q)-if [ "x$(__embtk_pkg_bins)" != "x" ] && [ -e $(SYSROOT)/usr/bin ]; \ - then \ - cd $(SYSROOT)/usr/bin; rm -rf $(__embtk_pkg_bins); \ - fi - $(Q)-if [ "x$(__embtk_pkg_sbins)" != "x" ] && \ - [ -e $(SYSROOT)/usr/sbin ]; \ - then \ - cd $(SYSROOT)/usr/sbin; rm -rf $(__embtk_pkg_sbins); \ - fi - $(Q)-if [ "x$(__embtk_pkg_includes)" != "x" ] && \ - [ -e $(SYSROOT)/usr/include ]; \ - then \ - cd $(SYSROOT)/usr/include; rm -rf $(__embtk_pkg_includes); \ - fi - $(Q)-if [ "x$(__embtk_pkg_libs)" != "x" ] && \ - [ -e $(SYSROOT)/usr/$(LIBDIR) ]; \ - then \ - cd $(SYSROOT)/usr/$(LIBDIR); rm -rf $(__embtk_pkg_libs); \ - fi - $(Q)-if [ "x$(__embtk_pkg_libexecs)" != "x" ] && \ - [ -e $(SYSROOT)/usr/$(LIBDIR)/libexec ]; \ - then \ - cd $(SYSROOT)/usr/$(LIBDIR)/libexec; \ - rm -rf $(__embtk_pkg_libexecs); \ - fi - $(Q)-if [ "x$(__embtk_pkg_pkgconfigs)" != "x" ] && \ - [ -e $(SYSROOT)/usr/$(LIBDIR)/pkgconfig ]; \ - then \ - cd $(SYSROOT)/usr/$(LIBDIR)/pkgconfig; \ - rm -rf $(__embtk_pkg_pkgconfigs); \ - fi - $(Q)-rm -rf $(__embtk_pkg_builddir)* -endef +# Packages management macros +include $(EMBTK_ROOT)/mk/macros.packages.mk |