From patchwork Tue Feb 18 11:22:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 24836 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-fa0-f72.google.com (mail-fa0-f72.google.com [209.85.161.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 69F77203BE for ; Tue, 18 Feb 2014 11:22:14 +0000 (UTC) Received: by mail-fa0-f72.google.com with SMTP id s1sf17722023fas.11 for ; Tue, 18 Feb 2014 03:22:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:in-reply-to:user-agent:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-disposition; bh=PTlHehcgYQop/3RPhi9QkopNSM1dYEKQpDJDBM6Vapk=; b=hOrNv8T/6Uxm2r3ngcSl1/2WlMuf4kZeUtn5lJ3YnGPZuCmsvwG0bezMfVGHNxJpQV Co8YbQcwIvYszpm10Xz1Nuj38piKxFPcNe0dE+uaTsAPFiUicXeWKSjAbnU5a5Z9lOM0 ERem1joYUv80SLueOnP5mulAYri5guBY8j48taPVqf51M8k/UnzZmsgFBFpLGDeZGVEU ZqEsGs9VDvHpdxfDE0XeetzEzx3pstBqkO/GviI0lWg41FLvWDsrezs9N/9SkTkLn9Dz EIHHVkFwcCDKxrgvWoY1QOJ3GmPVuxhu4CsCF6oFzThR7O4VGyJ7KUhB5okpYmvGU2/i G04A== X-Gm-Message-State: ALoCoQl4yKZbBGrJz0B8Rkb2T4TzoL+WK2I6BUrmiZo1hI5yN3Q98KqQodfUd+Tbs4dpJjYOmRbj X-Received: by 10.112.78.34 with SMTP id y2mr600033lbw.24.1392722531949; Tue, 18 Feb 2014 03:22:11 -0800 (PST) X-BeenThere: lng-odp@linaro.org Received: by 10.152.243.7 with SMTP id wu7ls315938lac.29.gmail; Tue, 18 Feb 2014 03:22:11 -0800 (PST) X-Received: by 10.112.146.202 with SMTP id te10mr309992lbb.67.1392722531710; Tue, 18 Feb 2014 03:22:11 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com [209.85.215.49]) by mx.google.com with ESMTPS id g9si30946698lam.3.2014.02.18.03.22.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 03:22:11 -0800 (PST) Received-SPF: neutral (google.com: 209.85.215.49 is neither permitted nor denied by best guess record for domain of anders.roxell@linaro.org) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id y1so11854432lam.8 for ; Tue, 18 Feb 2014 03:22:11 -0800 (PST) X-Received: by 10.152.23.132 with SMTP id m4mr21570851laf.34.1392722531427; Tue, 18 Feb 2014 03:22:11 -0800 (PST) Received: from 8470w (c-853670d5.07-21-73746f28.cust.bredbandsbolaget.se. [213.112.54.133]) by mx.google.com with ESMTPSA id y2sm31415208lal.10.2014.02.18.03.22.10 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 18 Feb 2014 03:22:10 -0800 (PST) Date: Tue, 18 Feb 2014 12:22:07 +0100 From: Anders Roxell To: Petri Savolainen Cc: lng-odp@linaro.org Subject: Re: [lng-odp] Re: [PATCH] Makefiles: Allow CFLAGS to overide the build Message-ID: <20140218112207.GD3517@8470w> References: <1392675389-26607-1-git-send-email-mike.holmes@linaro.org> <2b98325d-9086-4a5c-ada0-f5c7dfe81e17@linaro.org> MIME-Version: 1.0 In-Reply-To: <2b98325d-9086-4a5c-ada0-f5c7dfe81e17@linaro.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Original-Sender: anders.roxell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.215.49 is neither permitted nor denied by best guess record for domain of anders.roxell@linaro.org) smtp.mail=anders.roxell@linaro.org Precedence: list Mailing-list: list lng-odp@linaro.org; contact lng-odp+owners@linaro.org List-ID: X-Google-Group-Id: 474323889996 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Content-Disposition: inline On 2014-02-17 23:55, Petri Savolainen wrote: > > > On Tuesday, 18 February 2014 00:16:29 UTC+2, Mike Holmes wrote: > > > > Signed-off-by: Mike Holmes > > > --- > > > > CFLAGS is usually expected to take effect on a build if applied from the > > command line when calling make, or if it is set in the environment. > > > > Examples are when building with CLANG, -Wno-error must be applied to > > allow CLANG warnings which are a superset of gcc to cause the build to > > fail. e.g. make CC=clang CFLAGS=-Wno-error > > > > When building with optimizations off and with -g for debugging, it must > > be possible to alter the defaults, in ODPs case these defaults are in > > Makefile.inc > > > > e.g. make CFLAGS=-O3 > > > > .checkpatch.conf | 1 + > > Makefile.inc | 16 ++++++++-------- > > platform/linux-generic/Makefile | 10 +++++----- > > test/api_test/Makefile | 6 +++--- > > test/example/Makefile | 2 +- > > test/packet/Makefile | 4 ++-- > > test/packet_netmap/Makefile | 6 +++--- > > 7 files changed, 23 insertions(+), 22 deletions(-) > > > > diff --git a/.checkpatch.conf b/.checkpatch.conf > > index e1a25c8..9076410 100644 > > --- a/.checkpatch.conf > > +++ b/.checkpatch.conf > > @@ -1,3 +1,4 @@ > > --no-tree > > --strict > > --ignore=NEW_TYPEDEFS > > +--ignore=DEPRECATED_VARIABLE > > diff --git a/Makefile.inc b/Makefile.inc > > index 7dea028..75a4829 100644 > > --- a/Makefile.inc > > +++ b/Makefile.inc > > @@ -4,17 +4,17 @@ > > # SPDX-License-Identifier: BSD-3-Clause > > > > PLATFORM ?= linux-generic > > -CFLAGS += -DODP_DEBUG=1 > > -#CFLAGS += -O3 > > -CFLAGS += -O0 -g > > +EXTRA_CFLAGS += -DODP_DEBUG=1 > > +#EXTRA_CFLAGS += -O3 > > +EXTRA_CFLAGS += -O0 -g > > > > As I said earlier, -O3 must be used by default. It must be used in > regression testing. Otherwise we have code soon that does not compile with > -O3, or compiles but has bugs with optimization. > > -Petri > > > > > > OBJ_DIR = ./obj > > DESTDIR ?= $(ODP_ROOT)/build > > > > -CFLAGS += -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes > > -CFLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith > > -CFLAGS += -Wcast-align -Wnested-externs -Wcast-qual -Wformat-nonliteral > > -CFLAGS += -Wformat-security -Wundef -Wwrite-strings > > +EXTRA_CFLAGS += -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes > > +EXTRA_CFLAGS += -Wmissing-declarations -Wold-style-definition > > -Wpointer-arith > > +EXTRA_CFLAGS += -Wcast-align -Wnested-externs -Wcast-qual > > -Wformat-nonliteral > > +EXTRA_CFLAGS += -Wformat-security -Wundef -Wwrite-strings > > > > CC ?= gcc > > LD ?= gcc > > @@ -26,5 +26,5 @@ RMDIR := rm -rf > > RM := rm -f > > COPY := cp -r > > > > -CFLAGS += -pthread > > +EXTRA_EXTRA_CFLAGS += -pthread > > LDFLAGS += -pthread > > diff --git a/platform/linux-generic/Makefile > > b/platform/linux-generic/Makefile > > index f665683..9828ee4 100644 > > --- a/platform/linux-generic/Makefile > > +++ b/platform/linux-generic/Makefile > > @@ -32,12 +32,12 @@ ODP_ROOT = ../.. > > LIB_DIR = ./lib > > DOC_DIR = ./doc > > > > -CFLAGS += -I$(ODP_ROOT)/include > > -CFLAGS += -I./include > > -CFLAGS += -I./include/api > > +EXTRA_CFLAGS += -I$(ODP_ROOT)/include > > +EXTRA_CFLAGS += -I./include > > +EXTRA_CFLAGS += -I./include/api > > > > ifeq ($(ODP_HAVE_NETMAP),yes) > > -CFLAGS += -DODP_HAVE_NETMAP > > +EXTRA_CFLAGS += -DODP_HAVE_NETMAP > > endif > > > > include $(ODP_ROOT)/Makefile.inc > > @@ -92,7 +92,7 @@ $(DOC_DIR): > > # > > $(OBJ_DIR)/%.o: ./source/%.c > > $(ECHO) Compiling $< > > - $(CC) -c -MD $(CFLAGS) -o $@ $< > > + $(CC) -c -MD $(EXTRA_CFLAGS) $(CFLAGS) -o $@ $< > > > > # > > # Lib rule > > diff --git a/test/api_test/Makefile b/test/api_test/Makefile > > index 15c18f4..741fbe4 100644 > > --- a/test/api_test/Makefile > > +++ b/test/api_test/Makefile > > @@ -12,12 +12,12 @@ ODP_ATOMIC = odp_atomic > > ODP_SHM = odp_shm > > ODP_RING = odp_ring > > > > -CFLAGS += -I$(ODP_ROOT)/platform/linux-generic/include > > +EXTRA_CFLAGS += -I$(ODP_ROOT)/platform/linux-generic/include > > > > include ../Makefile.inc > > include $(ODP_ROOT)/Makefile.inc > > > > -CFLAGS += -I$(ODP_TEST_ROOT)/api_test > > +EXTRA_CFLAGS += -I$(ODP_TEST_ROOT)/api_test > > > > ATOMIC_OBJS = > > ATOMIC_OBJS += $(OBJ_DIR)/odp_common.o > > @@ -52,7 +52,7 @@ $(OBJ_DIR): $(DESTDIR)/lib/libodp.a > > # > > $(OBJ_DIR)/%.o: %.c > > $(ECHO) Compiling $< > > - $(CC) -c -MD $(CFLAGS) -o $@ $< > > + $(CC) -c -MD $(EXTRA_CFLAGS) $(CFLAGS) -o $@ $< > > > > # > > # Link rule > > diff --git a/test/example/Makefile b/test/example/Makefile > > index d43e780..8064977 100644 > > --- a/test/example/Makefile > > +++ b/test/example/Makefile > > @@ -30,7 +30,7 @@ $(OBJ_DIR): $(DESTDIR)/lib/libodp.a > > # > > $(OBJ_DIR)/%.o: %.c > > $(ECHO) Compiling $< > > - $(CC) -c -MD $(CFLAGS) -o $@ $< > > + $(CC) -c -MD $(EXTRA_CFLAGS) $(CFLAGS) -o $@ $< > > > > # > > # Link rule > > diff --git a/test/packet/Makefile b/test/packet/Makefile > > index f1cb7d9..c66b37c 100644 > > --- a/test/packet/Makefile > > +++ b/test/packet/Makefile > > @@ -9,7 +9,7 @@ ODP_APP = odp_packet > > include ../Makefile.inc > > include $(ODP_ROOT)/Makefile.inc > > > > -CFLAGS += -I$(ODP_TEST_ROOT)/packet > > +EXTRA_CFLAGS += -I$(ODP_TEST_ROOT)/packet > > > > OBJS = > > OBJS += $(OBJ_DIR)/odp_example_pktio.o > > @@ -32,7 +32,7 @@ $(OBJ_DIR): $(DESTDIR)/lib/libodp.a > > # > > $(OBJ_DIR)/%.o: %.c > > $(ECHO) Compiling $< > > - $(CC) -c -MD $(CFLAGS) -o $@ $< > > + $(CC) -c -MD $(EXTRA_CFLAGS) $(CFLAGS) -o $@ $< > > > > # > > # Link rule > > diff --git a/test/packet_netmap/Makefile b/test/packet_netmap/Makefile > > index 5febb33..d92d113 100644 > > --- a/test/packet_netmap/Makefile > > +++ b/test/packet_netmap/Makefile > > @@ -6,8 +6,8 @@ > > ODP_ROOT = ../.. > > ODP_APP = odp_packet > > > > -CFLAGS += -DODP_HAVE_NETMAP > > -CFLAGS += -O0 -g > > +EXTRA_CFLAGS += -DODP_HAVE_NETMAP > > +EXTRA_CFLAGS += -O0 -g > > > > include ../Makefile.inc > > include $(ODP_ROOT)/Makefile.inc > > @@ -33,7 +33,7 @@ $(OBJ_DIR): $(DESTDIR)/lib/libodp.a > > # > > $(OBJ_DIR)/%.o: %.c > > $(ECHO) Compiling $< > > - $(CC) -c -MD $(CFLAGS) -o $@ $< > > + $(CC) -c -MD $(EXTRA_CFLAGS) $(CFLAGS) -o $@ $< > > > > # > > # Link rule > > -- > > 1.8.3.2 > > > > > > -- > You received this message because you are subscribed to the Google Groups "LNG ODP Sub-team - lng-odp@linaro.org" group. > To unsubscribe from this group and stop receiving emails from it, send an email to lng-odp+unsubscribe@linaro.org. > To post to this group, send email to lng-odp@linaro.org. > Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/. > To view this discussion on the web visit https://groups.google.com/a/linaro.org/d/msgid/lng-odp/2b98325d-9086-4a5c-ada0-f5c7dfe81e17%40linaro.org. > For more options, visit https://groups.google.com/a/linaro.org/groups/opt_out. Petri Mike, Would this solve the problems? For clang you need to specify: make CC=clang EXTRA_CFLAGS=-Wno-error would that work? Drawback with this solution is that we can't use -O3 + ODP_DBG macro, do we want that? if yes, then we just need to change: ifeq ($(ODP_DEBUG), 1) to ifeq ($(a_good_name), 1) ideas of a good name? diff --git a/Makefile.inc b/Makefile.inc index 523385d..b35e030 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -4,17 +4,24 @@ # SPDX-License-Identifier: BSD-3-Clause PLATFORM ?= linux-generic -CFLAGS += -DODP_DEBUG=1 -CFLAGS += -O3 -#CFLAGS += -O0 -g +ODP_DEBUG ?= 0 OBJ_DIR = ./obj DESTDIR ?= $(ODP_ROOT)/build +EXTRA_CFLAGS ?= CFLAGS += -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes CFLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith CFLAGS += -Wcast-align -Wnested-externs -Wcast-qual -Wformat-nonliteral CFLAGS += -Wformat-security -Wundef -Wwrite-strings +CFLAGS += $(EXTRA_CFLAGS) +CFLAGS += -DODP_DEBUG=$(ODP_DEBUG) + +ifeq ($(ODP_DEBUG), 1) + CFLAGS += -O0 -g +else + CFLAGS += -O3 +endif CC ?= gcc LD ?= gcc