From patchwork Sat Aug 30 12:48:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 4813411 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BC8889F3EC for ; Sat, 30 Aug 2014 12:48:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BD49020136 for ; Sat, 30 Aug 2014 12:48:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B92DB2012F for ; Sat, 30 Aug 2014 12:48:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751247AbaH3Ms2 (ORCPT ); Sat, 30 Aug 2014 08:48:28 -0400 Received: from top.free-electrons.com ([176.31.233.9]:52842 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751007AbaH3MsR (ORCPT ); Sat, 30 Aug 2014 08:48:17 -0400 Received: by mail.free-electrons.com (Postfix, from userid 106) id 0BF32757; Sat, 30 Aug 2014 14:48:18 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from localhost (189.64.128.77.rev.sfr.net [77.128.64.189]) by mail.free-electrons.com (Postfix) with ESMTPSA id 7FFFBE8; Sat, 30 Aug 2014 14:48:17 +0200 (CEST) From: Thomas Petazzoni To: linux-btrfs@vger.kernel.org Cc: Thomas Petazzoni Subject: [PATCH 2/2] Improve static building and installation Date: Sat, 30 Aug 2014 14:48:10 +0200 Message-Id: <1409402890-22860-3-git-send-email-thomas.petazzoni@free-electrons.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1409402890-22860-1-git-send-email-thomas.petazzoni@free-electrons.com> References: <1409402890-22860-1-git-send-email-thomas.petazzoni@free-electrons.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This commit improves the static-only building of btrfs-progs, and adds support for installing the static only tools: - It now ensures that all programs are built statically, not only a small subset of them, by defining 'progs_static' from the existing 'progs' variable. - It changes the order of libraries in the btrfs-%.static rule so that -lpthread (part of STATIC_LIBS) appears *after* the '$($(subst -,_,$(subst .static,,$@)-libs))' logic, which brings in -lcom_err. This is needed because libcom_err.a uses the semaphore functions, which are available in the pthread library. - Adds the necessary rules to generate the btrfsck.static link and btrfstune.static binary. - Adds an 'install-static' target to install the static binaries. Note that they are renamed to not carry a '.static' suffix. Signed-off-by: Thomas Petazzoni --- Makefile | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 926885f..93e264b 100644 --- a/Makefile +++ b/Makefile @@ -50,6 +50,8 @@ progs = mkfs.btrfs btrfs-debug-tree btrfsck \ btrfs btrfs-map-logical btrfs-image btrfs-zero-log btrfs-convert \ btrfs-find-root btrfstune btrfs-show-super +progs_static = $(foreach p,$(progs),$(p).static) + # external libs required by various binaries; for btrfs-foo, # specify btrfs_foo_libs = ; see $($(subst...)) rules below btrfs_convert_libs = -lext2fs -lcom_err @@ -141,7 +143,7 @@ test: # NOTE: For static compiles, you need to have all the required libs # static equivalent available # -static: btrfs.static mkfs.btrfs.static btrfs-find-root.static +static: $(progs_static) version.h: @echo " [SH] $@" @@ -174,8 +176,8 @@ $(lib_links): btrfs-%.static: $(static_objects) btrfs-%.static.o $(static_libbtrfs_objects) @echo " [LD] $@" $(Q)$(CC) $(STATIC_CFLAGS) -o $@ $@.o $(static_objects) \ - $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS) \ - $($(subst -,_,$(subst .static,,$@)-libs)) + $(static_libbtrfs_objects) $(STATIC_LDFLAGS) \ + $($(subst -,_,$(subst .static,,$@)-libs)) $(STATIC_LIBS) btrfs-%: $(objects) $(libs) btrfs-%.o @echo " [LD] $@" @@ -196,6 +198,10 @@ btrfsck: btrfs @echo " [LN] $@" $(Q)$(LN) -f btrfs btrfsck +btrfsck.static: btrfs.static + @echo " [LN] $@" + $(Q)$(LN) -f $^ $@ + mkfs.btrfs: $(objects) $(libs) mkfs.o @echo " [LD] $@" $(Q)$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS) @@ -209,6 +215,11 @@ btrfstune: $(objects) $(libs) btrfstune.o @echo " [LD] $@" $(Q)$(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS) +btrfstune.static: $(static_objects) btrfstune.static.o $(static_libbtrfs_objects) + @echo " [LD] $@" + $(Q)$(CC) $(STATIC_CFLAGS) -o $@ btrfstune.static.o $(static_objects) \ + $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS) + dir-test: $(objects) $(libs) dir-test.o @echo " [LD] $@" $(Q)$(CC) $(CFLAGS) -o dir-test $(objects) dir-test.o $(LDFLAGS) $(LIBS) @@ -258,6 +269,11 @@ install: $(libs) $(progs) $(INSTALLDIRS) $(INSTALL) -m755 -d $(DESTDIR)$(incdir) $(INSTALL) -m644 $(headers) $(DESTDIR)$(incdir) +install-static: $(progs_static) $(INSTALLDIRS) + for p in $(progs_static) ; do \ + $(INSTALL) -D -m755 $$p $(DESTDIR)$(bindir)/`basename $$p .static` ; \ + done + $(INSTALLDIRS): @echo "Making install in $(patsubst install-%,%,$@)" $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst install-%,%,$@) install