From 2e8b5209c8f4efebfb51cf0165ced9e967394765 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Thu, 12 May 2016 14:13:30 +0200 Subject: btrfs-progs: build: add support for debugging builds Add an easy way to build a debugging version, without optimizations and with debugging info by default. Any overrides can be done via DEBUG_CFLAGS that are added on top of the defaults. Can be combined with V, C or W options. Usage: $ make D=1 Signed-off-by: David Sterba --- Makefile.in | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'Makefile.in') diff --git a/Makefile.in b/Makefile.in index dadfd409..7e65efb8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -10,7 +10,9 @@ # Tuning by variables (environment or make arguments): # V=1 verbose, print command lines (default: quiet) # C=1 run checker before compilation (default checker: sparse) +# D=1 debugging build, turn off optimizations # W=123 build with warnings (default: off) +# DEBUG_CFLAGS additional compiler flags for debugging build # EXTRA_CFLAGS additional compiler flags # EXTRA_LDFLAGS additional linker flags # @@ -36,13 +38,20 @@ DISABLE_BTRFSCONVERT = @DISABLE_BTRFSCONVERT@ EXTRA_CFLAGS := EXTRA_LDFLAGS := +DEBUG_CFLAGS_DEFAULT = -O0 -U_FORTIFY_SOURCE -ggdb3 +DEBUG_CFLAGS_INTERNAL = +DEBUG_CFLAGS := + # Common build flags CFLAGS = @CFLAGS@ \ -include config.h \ -DBTRFS_FLAT_INCLUDES \ -D_XOPEN_SOURCE=700 \ -fno-strict-aliasing \ - -fPIC $(EXTRAWARN_CFLAGS) $(EXTRA_CFLAGS) + -fPIC \ + $(EXTRAWARN_CFLAGS) \ + $(DEBUG_CFLAGS_INTERNAL) \ + $(EXTRA_CFLAGS) LDFLAGS = @LDFLAGS@ \ -rdynamic $(EXTRA_LDFLAGS) @@ -107,6 +116,10 @@ else Q = @ endif +ifeq ("$(origin D)", "command line") + DEBUG_CFLAGS_INTERNAL = $(DEBUG_CFLAGS_DEFAULT) $(DEBUG_CFLAGS) +endif + MAKEOPTS = --no-print-directory Q=$(Q) # build all by default -- cgit v1.2.3