diff mbox

[6/6] build: replace *_EXTRA_OBJS by local assignments to LDFLAGS and LOADLIBES

Message ID 20171004132605.24734-7-uwe@kleine-koenig.org (mailing list archive)
State Rejected, archived
Headers show

Commit Message

Uwe Kleine-König Oct. 4, 2017, 1:26 p.m. UTC
This allows to drop the magic to handle *_EXTRA_OBJS.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
---
 Makefile | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Christopher Li Oct. 6, 2017, 7:19 p.m. UTC | #1
On Wed, Oct 4, 2017 at 6:26 AM, Uwe Kleine-König <uwe@kleine-koenig.org> wrote:
> ---
>  Makefile | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index f6c577c02143..50e7b99b6107 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -62,8 +62,8 @@ INST_MAN1=sparse.1 cgcc.1
>  ifeq ($(HAVE_LIBXML),yes)
>  PROGRAMS+=c2xml
>  INST_PROGRAMS+=c2xml
> -c2xml_EXTRA_OBJS = `$(PKG_CONFIG) --libs libxml-2.0`
> -LIBXML_CFLAGS := $(shell $(PKG_CONFIG) --cflags libxml-2.0)
> +c2xml: LOADLIBES += $(shell $(PKG_CONFIG) --libs libxml-2.0)
> +c2xml: CFLAGS += $(shell $(PKG_CONFIG) --cflags libxml-2.0)


This is by design.

The problem with target specific variable is that, you can't easily
access it out side of the target specific scope.

For example in the debug target branch, it go through a loop
to process all objects, including the extra objects. You can't do that if
you use target specific variables.

 $(foreach @F,$(PROGRAMS),$(eval $(@F): $(EXTRA_OBJS) $(LIBS)))
-$(foreach @F,$(PROGRAMS),$(eval debug/$(@F): $(addprefix debug/,
$(EXTRA_OBJS)) $(DBG_LIBS)))
+$(foreach @F,$(PROGRAMS),$(eval dbgbuild/$(@F): $(addprefix
dbgbuild/, $(EXTRA_OBJS)) $(DBG_LIBS)))

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Luc Van Oostenryck Nov. 4, 2017, 1:10 p.m. UTC | #2
On Wed, Oct 04, 2017 at 03:26:05PM +0200, Uwe Kleine-König wrote:
> This allows to drop the magic to handle *_EXTRA_OBJS.

I like it, especially for CFLAGS and LDFLAGS, but it also make things
slightly more complex to correctly support selfcheck.

-- Luc Van Oostenryck
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/Makefile b/Makefile
index f6c577c02143..50e7b99b6107 100644
--- a/Makefile
+++ b/Makefile
@@ -62,8 +62,8 @@  INST_MAN1=sparse.1 cgcc.1
 ifeq ($(HAVE_LIBXML),yes)
 PROGRAMS+=c2xml
 INST_PROGRAMS+=c2xml
-c2xml_EXTRA_OBJS = `$(PKG_CONFIG) --libs libxml-2.0`
-LIBXML_CFLAGS := $(shell $(PKG_CONFIG) --cflags libxml-2.0)
+c2xml: LOADLIBES += $(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
@@ -76,7 +76,7 @@  INST_PROGRAMS += test-inspect
 test-inspect_EXTRA_DEPS := ast-model.o ast-view.o ast-inspect.o
 test-inspect_OBJS := test-inspect.o $(test-inspect_EXTRA_DEPS)
 $(test-inspect_OBJS) $(test-inspect_OBJS:.o=.sc): CFLAGS += $(GTK_CFLAGS)
-test-inspect_EXTRA_OBJS := $(GTK_LIBS)
+test-inspect: LOADLIBES += $(GTK_LIBS)
 else
 $(warning Your system does not have gtk3/gtk2, disabling test-inspect)
 endif
@@ -94,7 +94,8 @@  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_EXTRA_OBJS := $(LLVM_LIBS) $(LLVM_LDFLAGS)
+sparse-llvm: LDFLAGS += $(LLVM_LDFLAGS)
+sparse-llvm: LOADLIBES += $(LLVM_LIBS)
 else
 $(warning LLVM 3.0 or later required. Your system has version $(LLVM_VERSION) installed.)
 endif
@@ -190,7 +191,7 @@  compile_EXTRA_DEPS = compile-i386.o
 
 $(foreach p,$(PROGRAMS),$(eval $(p): $($(p)_EXTRA_DEPS) $(LIBS)))
 $(PROGRAMS): % : %.o 
-	$(QUIET_LINK)$(LD) $(LDFLAGS) $(TARGET_ARCH) $^ $(LOADLIBES) $(LDLIBS) -o $@ $($@_EXTRA_OBJS)
+	$(QUIET_LINK)$(LD) $(LDFLAGS) $(TARGET_ARCH) $^ $(LOADLIBES) $(LDLIBS) -o $@
 
 $(LIB_FILE): $(LIB_OBJS)
 	$(QUIET_AR)$(AR) rcs $@ $(LIB_OBJS)