From patchwork Tue Oct 28 13:33:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Oudinet X-Patchwork-Id: 404249 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id 53D2314007F for ; Wed, 29 Oct 2014 00:35:08 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 8BE01915A5; Tue, 28 Oct 2014 13:35:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xmGhLKSXKjCm; Tue, 28 Oct 2014 13:35:05 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id C320E916D6; Tue, 28 Oct 2014 13:35:05 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id CC7461C1E77 for ; Tue, 28 Oct 2014 13:34:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id CA1ABA1B8A for ; Tue, 28 Oct 2014 13:34:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id icpx9dG4nTQ5 for ; Tue, 28 Oct 2014 13:34:48 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com [74.125.82.42]) by fraxinus.osuosl.org (Postfix) with ESMTPS id CE5B5A1B63 for ; Tue, 28 Oct 2014 13:34:47 +0000 (UTC) Received: by mail-wg0-f42.google.com with SMTP id k14so865012wgh.1 for ; Tue, 28 Oct 2014 06:34:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wl9h8IfxYcZpHdZ+3MXF/yxPA1VeT0j/zy4FWemNAog=; b=0/bCRVge4gN450SXThF5JypJHMwFtk38ytkkUt8sM1x5LX8vYS5i1+mcEc/AMrlOW9 wJDCSoFxfS9+BqG1SH1e7DABUTaTY1B+iQm5rVOBZQirtgCqDiZGalMAgHy/YRA2QEJc jhymXkdQzgNklmYcqPNe9IAlCwYD3WG7rHqj4gXYX52U6btLZUorHOsG5M9twBkmOuCT tESQnZKxhNtbJU0bqQSY09a0HrUzmIFtvh8zk9WflyqllOufZCAUa1QGV38+cEvBhvTl GXp3vDgGpnqKrHvPy87Zce5MdHjwh1uvPZ6yakB/fZBuyjHNvFFhsdoR3jTV4eE2EaZp TTZQ== X-Received: by 10.180.74.142 with SMTP id t14mr27983779wiv.17.1414503286087; Tue, 28 Oct 2014 06:34:46 -0700 (PDT) Received: from localhost.localdomain ([193.51.194.208]) by mx.google.com with ESMTPSA id k10sm1867945wjb.28.2014.10.28.06.34.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Oct 2014 06:34:45 -0700 (PDT) From: Johan Oudinet To: buildroot@buildroot.org Date: Tue, 28 Oct 2014 14:33:38 +0100 Message-Id: <1414503232-28314-2-git-send-email-johan.oudinet@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1414503232-28314-1-git-send-email-johan.oudinet@gmail.com> References: <1414503232-28314-1-git-send-email-johan.oudinet@gmail.com> Subject: [Buildroot] [PATCH 01/15] package/pkg-autotools.mk: Factorize hooks. X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Define common macros only once (instead of as many times as there are inner-autotools-package calls). Factorize LIBTOOL_PATCH_HOOK and AUTORECONF_HOOK to avoid duplicated code. Signed-off-by: Johan Oudinet --- package/pkg-autotools.mk | 119 ++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 63 deletions(-) diff --git a/package/pkg-autotools.mk b/package/pkg-autotools.mk index 09f9412..65af6f0 100644 --- a/package/pkg-autotools.mk +++ b/package/pkg-autotools.mk @@ -46,6 +46,57 @@ endef # $(call AUTOCONF_AC_CHECK_FILE_VAL,/dev/random)=yes AUTOCONF_AC_CHECK_FILE_VAL = ac_cv_file_$(subst -,_,$(subst /,_,$(subst .,_,$(1)))) +# Recipe that patches libtool so it works properly with +# cross-compilation. +define PATCH_LIBTOOL + $(Q)if test "$($(PKG)_LIBTOOL_PATCH)" = "YES"; then \ + for i in `find $($(PKG)_SRCDIR) -name ltmain.sh`; do \ + ltmain_version=`sed -n '/^[ ]*VERSION=/{s/^[ ]*VERSION=//;p;q;}' $$$$i | \ + sed -e 's/\([0-9].[0-9]*\).*/\1/' -e 's/\"//'`; \ + if test $${ltmain_version} = 1.5; then \ + $(APPLY_PATCHES) $${i%/*} support/libtool buildroot-libtool-v1.5.patch; \ + elif test $${ltmain_version} = 2.2; then\ + $(APPLY_PATCHES) $${i%/*} support/libtool buildroot-libtool-v2.2.patch; \ + elif test $${ltmain_version} = 2.4; then\ + $(APPLY_PATCHES) $${i%/*} support/libtool buildroot-libtool-v2.4.patch; \ + fi \ + done \ + fi +endef + +# +# Hook to update config.sub and config.guess if needed +# +define UPDATE_CONFIG_HOOK + @$(call MESSAGE,"Updating config.sub and config.guess") + $(call CONFIG_UPDATE,$(@D)) +endef + +# +# Hook to patch libtool to make it work properly for cross-compilation +# +define LIBTOOL_PATCH_HOOK + @$(call MESSAGE,"Patching libtool") + $(call PATCH_LIBTOOL) +endef + +# +# Hook to gettextize the package if needed +# +define GETTEXTIZE_HOOK + @$(call MESSAGE,"Gettextizing") + $(Q)cd $($(PKG)_SRCDIR) && $(GETTEXTIZE) $($(PKG)_GETTEXTIZE_OPTS) +endef + +# +# Hook to autoreconf the package if needed +# +define AUTORECONF_HOOK + @$(call MESSAGE,"Autoreconfiguring") + $(Q)cd $($(PKG)_SRCDIR) && $($(PKG)_AUTORECONF_ENV) $(AUTORECONF) $($(PKG)_AUTORECONF_OPTS) + $(call PATCH_LIBTOOL) +endef + ################################################################################ # inner-autotools-package -- defines how the configuration, compilation and # installation of an autotools package should be done, implements a @@ -183,71 +234,8 @@ endef endif endif -# -# Hook to update config.sub and config.guess if needed -# -define UPDATE_CONFIG_HOOK - @$$(call MESSAGE,"Updating config.sub and config.guess") - $$(call CONFIG_UPDATE,$$(@D)) -endef - $(2)_POST_PATCH_HOOKS += UPDATE_CONFIG_HOOK -# -# Hook to patch libtool to make it work properly for cross-compilation -# -define LIBTOOL_PATCH_HOOK - @$$(call MESSAGE,"Patching libtool") - $$(Q)if test "$$($$(PKG)_LIBTOOL_PATCH)" = "YES" \ - -a "$$($$(PKG)_AUTORECONF)" != "YES"; then \ - for i in `find $$($$(PKG)_SRCDIR) -name ltmain.sh`; do \ - ltmain_version=`sed -n '/^[ ]*VERSION=/{s/^[ ]*VERSION=//;p;q;}' $$$$i | \ - sed -e 's/\([0-9].[0-9]*\).*/\1/' -e 's/\"//'`; \ - if test $$$${ltmain_version} = '1.5'; then \ - $$(APPLY_PATCHES) $$$${i%/*} support/libtool buildroot-libtool-v1.5.patch; \ - elif test $$$${ltmain_version} = "2.2"; then\ - $$(APPLY_PATCHES) $$$${i%/*} support/libtool buildroot-libtool-v2.2.patch; \ - elif test $$$${ltmain_version} = "2.4"; then\ - $$(APPLY_PATCHES) $$$${i%/*} support/libtool buildroot-libtool-v2.4.patch; \ - fi \ - done \ - fi -endef - -# default values are not evaluated yet, so don't rely on this defaulting to YES -ifneq ($$($(2)_LIBTOOL_PATCH),NO) -$(2)_POST_PATCH_HOOKS += LIBTOOL_PATCH_HOOK -endif - -# -# Hook to gettextize the package if needed -# -define GETTEXTIZE_HOOK - @$$(call MESSAGE,"Gettextizing") - $(Q)cd $$($$(PKG)_SRCDIR) && $$(GETTEXTIZE) $$($$(PKG)_GETTEXTIZE_OPTS) -endef - -# -# Hook to autoreconf the package if needed -# -define AUTORECONF_HOOK - @$$(call MESSAGE,"Autoreconfiguring") - $$(Q)cd $$($$(PKG)_SRCDIR) && $$($$(PKG)_AUTORECONF_ENV) $$(AUTORECONF) $$($$(PKG)_AUTORECONF_OPTS) - $$(Q)if test "$$($$(PKG)_LIBTOOL_PATCH)" = "YES"; then \ - for i in `find $$($$(PKG)_SRCDIR) -name ltmain.sh`; do \ - ltmain_version=`sed -n '/^[ ]*VERSION=/{s/^[ ]*VERSION=//;p;q;}' $$$$i | \ - sed -e 's/\([0-9].[0-9]*\).*/\1/' -e 's/\"//'`; \ - if test $$$${ltmain_version} = "1.5"; then \ - $$(APPLY_PATCHES) $$$${i%/*} support/libtool buildroot-libtool-v1.5.patch; \ - elif test $$$${ltmain_version} = "2.2"; then\ - $$(APPLY_PATCHES) $$$${i%/*} support/libtool buildroot-libtool-v2.2.patch; \ - elif test $$$${ltmain_version} = "2.4"; then\ - $$(APPLY_PATCHES) $$$${i%/*} support/libtool buildroot-libtool-v2.4.patch; \ - fi \ - done \ - fi -endef - # This must be repeated from inner-generic-package, otherwise we get an empty # _DEPENDENCIES if _AUTORECONF is YES. Also filter the result of _AUTORECONF # and _GETTEXTIZE away from the non-host rule @@ -265,6 +253,11 @@ $(2)_DEPENDENCIES += host-gettext endif $(2)_PRE_CONFIGURE_HOOKS += AUTORECONF_HOOK $(2)_DEPENDENCIES += host-automake host-autoconf host-libtool +else +# default values are not evaluated yet, so don't rely on this defaulting to YES +ifneq ($$($(2)_LIBTOOL_PATCH),NO) +$(2)_POST_PATCH_HOOKS += LIBTOOL_PATCH_HOOK +endif endif #