linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: "Luc Van Oostenryck" <luc.vanoostenryck@gmail.com>,
	"Uwe Kleine-König" <uwe@kleine-koenig.org>,
	"Jeff Layton" <jlayton@redhat.com>,
	"Josh Triplett" <josh@joshtriplett.org>,
	"Ramsay Jones" <ramsay@ramsayjones.plus.com>
Subject: [PATCH v4 10/38] build: allow target-specific CFLAGS, CPPFLAGS, LDFLAGS & LDLIBS
Date: Sat, 11 Nov 2017 15:24:09 +0100	[thread overview]
Message-ID: <20171111142437.67359-11-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20171111142437.67359-1-luc.vanoostenryck@gmail.com>

This a preparatory step to allow these flags to be overriden
from the command line.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 Makefile | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index ba0cb2093..4da421de1 100644
--- a/Makefile
+++ b/Makefile
@@ -59,8 +59,8 @@ INST_MAN1=sparse.1 cgcc.1
 ifeq ($(HAVE_LIBXML),yes)
 PROGRAMS+=c2xml
 INST_PROGRAMS+=c2xml
-c2xml-ldlibs = `$(PKG_CONFIG) --libs libxml-2.0`
-LIBXML_CFLAGS := $(shell $(PKG_CONFIG) --cflags libxml-2.0)
+c2xml-ldlibs := $(shell $(PKG_CONFIG) --libs libxml-2.0)
+c2xml-cflags := $(shell $(PKG_CONFIG) --cflags libxml-2.0)
 else
 $(warning Your system does not have libxml, disabling c2xml)
 endif
@@ -90,8 +90,9 @@ LLVM_LIBS := $(shell $(LLVM_CONFIG) --libs)
 LLVM_LIBS += $(shell $(LLVM_CONFIG) --system-libs 2>/dev/null)
 PROGRAMS += $(LLVM_PROGS)
 INST_PROGRAMS += sparse-llvm sparsec
-sparse-llvm.o: CFLAGS += $(LLVM_CFLAGS)
-sparse-llvm-ldlibs := $(LLVM_LIBS) $(LLVM_LDFLAGS)
+sparse-llvm-cflags := $(LLVM_CFLAGS)
+sparse-llvm-ldflags := $(LLVM_LDFLAGS)
+sparse-llvm-ldlibs := $(LLVM_LIBS)
 else
 $(warning LLVM 3.0 or later required. Your system has version $(LLVM_VERSION) installed.)
 endif
@@ -167,9 +168,11 @@ install: all-installable
 
 compile-objs:= compile-i386.o
 
+ldflags += $($(@)-ldflags) $(LDFLAGS)
+ldlibs  += $($(@)-ldlibs)  $(LDLIBS)
 $(foreach p,$(PROGRAMS),$(eval $(p): $($(p)-objs) $(LIBS)))
 $(PROGRAMS): % : %.o 
-	$(QUIET_LINK)$(LD) $(LDFLAGS) -o $@ $^ $($@-ldlibs)
+	$(QUIET_LINK)$(LD) $(ldflags) -o $@ $^ $(ldlibs)
 
 $(LIB_FILE): $(LIB_OBJS)
 	$(QUIET_AR)$(AR) rcs $@ $(LIB_OBJS)
@@ -183,15 +186,15 @@ ifneq ($(DEP_FILES),)
 include $(DEP_FILES)
 endif
 
-c2xml.o c2xml.sc: CFLAGS += $(LIBXML_CFLAGS)
 
 pre-process.sc: CHECKER_FLAGS += -Wno-vla
 
+cflags   += $($(*)-cflags) $(CPPFLAGS) $(CFLAGS)
 %.o: %.c
-	$(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+	$(QUIET_CC)$(CC) $(cflags) -c -o $@ $<
 
 %.sc: %.c sparse
-	$(QUIET_CHECK) $(CHECKER) $(CHECKER_FLAGS) $(CFLAGS) $(CPPFLAGS) -c $<
+	$(QUIET_CHECK) $(CHECKER) $(CHECKER_FLAGS) $(cflags) -c $<
 
 ALL_OBJS :=  $(LIB_OBJS) $(foreach p,$(PROGRAMS),$(p).o $($(p)-objs))
 selfcheck: $(ALL_OBJS:.o=.sc)
-- 
2.14.0


  parent reply	other threads:[~2017-11-11 14:25 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 01/38] build: make PREFIX overwritable from the environment Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 02/38] build: put comment about local.mk to the place where it is included Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 03/38] build: drop BASIC_CFLAGS and ALL_CFLAGS Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 04/38] build: drop -g from LDFLAGS Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 05/38] build: pass CPPFLAGS to compiler Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 06/38] build: fix effectiveness of generated dependencies Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 07/38] build: remove unused support for pkgconfig Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 08/38] build: use '-objs' instead of '_EXTRA_DEPS' Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 09/38] build: use '-ldlibs' instead of '_EXTRA_OBJS' Luc Van Oostenryck
2017-11-11 14:24 ` Luc Van Oostenryck [this message]
2017-11-11 14:24 ` [PATCH v4 11/38] build: allow CFLAGS & friends from command line Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 12/38] build: avoid rule-specific CFLAGS Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 13/38] build: use $LIBS directly in the dependency list Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 14/38] build: no need to use wildcards for generated dependencies Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 15/38] build: reuse rule for ALL_OBJS Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 16/38] build: CHECKER_FLAGS=-Wno-vla for all targets Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 17/38] build: move tests near their use Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 18/38] build: only generate version.h when needed Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 19/38] build: add note about overwritable vars Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 20/38] build: remove references to unexisting pre-process.h Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 21/38] build: move clean & clean-check together Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 22/38] build: make clean targets quieter Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 23/38] build: remove rule for shared lib, it's unused Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 24/38] build: normalize rules Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 25/38] build: remove the dist rule since unused Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 26/38] build: use one line per item Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 27/38] build: allow the name 'local.mk' to be configurable via the environment Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 28/38] build: use standard rules for install Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 29/38] build: remove unused QUIET_INST_SH Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 30/38] build: let quiet commands use less indentation Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 31/38] build: simplify quiet commands Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 32/38] build: simplify clean pattern Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 33/38] build: add *.o to clean-check pattern Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 34/38] build: avoid foreach Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 35/38] build: reorg & add comment Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 36/38] build: use a single space before assignments Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 37/38] build: add rule to run a single test Luc Van Oostenryck
2017-11-11 14:24 ` [PATCH v4 38/38] build: let -fno-strict-aliasing be a mandatory flag Luc Van Oostenryck
2017-11-17  9:23 ` [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171111142437.67359-11-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=jlayton@redhat.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=ramsay@ramsayjones.plus.com \
    --cc=uwe@kleine-koenig.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).