linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 00/38] Makefile reognization
@ 2017-11-11 14:23 Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 01/38] build: make PREFIX overwritable from the environment Luc Van Oostenryck
                   ` (38 more replies)
  0 siblings, 39 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:23 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

The goal of this series is to reorganize sparse's Makefile
in order to offer a few features asked by the distros:
1) allow CFLAGS & CPPFLAGS to be taken from the command line
2) allow PREFIX to be taken from the environment
Support for pkg-config is removed as well as some old crufts.

This cleanup is based on a previous series by Uwe Kleine-König
and further inspired by a patch and a need from Jeff Layton.

The changes since v1 are:
*) fold the two patches concerning the removal of shared lib support
*) remove the patch using git-clean for 'make clean'

The changes since v2 are:
*) change a commit message to make explicit the fact that
   quiet's commands abbreviated part are also issued for V=1
*) add a convenience rule for running a single test via:
        make validation/<name-of-testfile>.t

The changes since v3 are:
*) make the name 'local.mk' be configurable instead of
   the renaming that was done.
*) move '-fno-strict-aliasing' out of the overridable CFLAGS
*) rename the ...{_OBJS,_LDFLAGS,_LDLIBS} to ...{-objs,-ldflags,-ldlibs}
   to be consistent about the private 'cflags'.

The series is available at:
  git://github.com/lucvoo/sparse.git make-cleanup-v4

Luc Van Oostenryck (32):
  build: fix effectiveness of generated dependencies
  build: remove unused support for pkgconfig
  build: use '-objs' instead of '_EXTRA_DEPS'
  build: use '-ldlibs' instead of '_EXTRA_OBJS'
  build: allow target-specific CFLAGS, CPPFLAGS, LDFLAGS & LDLIBS
  build: allow CFLAGS & friends from command line
  build: avoid rule-specific CFLAGS
  build: use $LIBS directly in the dependency list
  build: no need to use wildcards for generated dependencies
  build: reuse rule for ALL_OBJS
  build: CHECKER_FLAGS=-Wno-vla for all targets
  build: move tests near their use
  build: add note about overwritable vars
  build: remove references to unexisting pre-process.h
  build: move clean & clean-check together
  build: make clean targets quieter
  build: remove rule for shared lib, it's unused
  build: normalize rules
  build: remove the dist rule since unused
  build: use one line per item
  build: allow the name 'local.mk' to be configurable via the environment
  build: use standard rules for install
  build: remove unused QUIET_INST_SH
  build: let quiet commands use less indentation
  build: simplify quiet commands
  build: simplify clean pattern
  build: add *.o to clean-check pattern
  build: avoid foreach
  build: reorg & add comment
  build: use a single space before assignments
  build: add rule to run a single test
  build: let -fno-strict-aliasing be a mandatory flag

Uwe Kleine-König (6):
  build: make PREFIX overwritable from the environment
  build: put comment about local.mk to the place where it is included
  build: drop BASIC_CFLAGS and ALL_CFLAGS
  build: drop -g from LDFLAGS
  build: pass CPPFLAGS to compiler
  build: only generate version.h when needed

 .gitignore   |   3 +-
 Makefile     | 322 ++++++++++++++++++++++++++++++-----------------------------
 sparse.pc.in |   9 --
 3 files changed, 163 insertions(+), 171 deletions(-)
 delete mode 100644 sparse.pc.in

-- 
CC: Uwe Kleine-König <uwe@kleine-koenig.org>
CC: Jeff Layton <jlayton@redhat.com>
CC: Josh Triplett <josh@joshtriplett.org>
CC: Ramsay Jones <ramsay@ramsayjones.plus.com>

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v4 01/38] build: make PREFIX overwritable from the environment
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
@ 2017-11-11 14:24 ` 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
                   ` (37 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

From: Uwe Kleine-König <uwe@kleine-koenig.org>

This way I can just use

	env PREFIX=/usr make install

on the command line to install sparse into the system.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index d03417641..e011df3cc 100644
--- a/Makefile
+++ b/Makefile
@@ -54,7 +54,7 @@ BASIC_CFLAGS += -Wp,-MD,$(@D)/.$(@F).d
 endif
 
 DESTDIR=
-PREFIX=$(HOME)
+PREFIX ?= $(HOME)
 BINDIR=$(PREFIX)/bin
 LIBDIR=$(PREFIX)/lib
 MANDIR=$(PREFIX)/share/man
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 02/38] build: put comment about local.mk to the place where it is included
  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 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 03/38] build: drop BASIC_CFLAGS and ALL_CFLAGS Luc Van Oostenryck
                   ` (36 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

From: Uwe Kleine-König <uwe@kleine-koenig.org>

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 Makefile | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index e011df3cc..ddb4c5e3d 100644
--- a/Makefile
+++ b/Makefile
@@ -22,11 +22,6 @@ CHECKER = ./cgcc -no-compile
 CHECKER_FLAGS =
 
 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS)
-#
-# For debugging, put this in local.mk:
-#
-#     CFLAGS += -O0 -DDEBUG -g3 -gdwarf-2
-#
 
 HAVE_LIBXML:=$(shell $(PKG_CONFIG) --exists libxml-2.0 2>/dev/null && echo 'yes')
 HAVE_GCC_DEP:=$(shell touch .gcc-test.c && 				\
@@ -167,6 +162,10 @@ SED_PC_CMD = 's|@version@|$(VERSION)|g;		\
 
 
 # Allow users to override build settings without dirtying their trees
+# For debugging, put this in local.mk:
+#
+#     CFLAGS += -O0 -DDEBUG -g3 -gdwarf-2
+#
 -include local.mk
 
 
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 03/38] build: drop BASIC_CFLAGS and ALL_CFLAGS
  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 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 04/38] build: drop -g from LDFLAGS Luc Van Oostenryck
                   ` (35 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

From: Uwe Kleine-König <uwe@kleine-koenig.org>

There is no good reason to not use plain CFLAGS for all usages.
This simplifies understanding the Makefile for the casual reader.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 Makefile | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile
index ddb4c5e3d..069dae6c8 100644
--- a/Makefile
+++ b/Makefile
@@ -21,8 +21,6 @@ PKG_CONFIG = pkg-config
 CHECKER = ./cgcc -no-compile
 CHECKER_FLAGS =
 
-ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS)
-
 HAVE_LIBXML:=$(shell $(PKG_CONFIG) --exists libxml-2.0 2>/dev/null && echo 'yes')
 HAVE_GCC_DEP:=$(shell touch .gcc-test.c && 				\
 		$(CC) -c -Wp,-MD,.gcc-test.d .gcc-test.c 2>/dev/null && \
@@ -39,13 +37,13 @@ LLVM_CONFIG:=llvm-config
 HAVE_LLVM:=$(shell $(LLVM_CONFIG) --version >/dev/null 2>&1 && echo 'yes')
 
 GCC_BASE := $(shell $(CC) --print-file-name=)
-BASIC_CFLAGS = -DGCC_BASE=\"$(GCC_BASE)\"
+CFLAGS += -DGCC_BASE=\"$(GCC_BASE)\"
 
 MULTIARCH_TRIPLET := $(shell $(CC) -print-multiarch 2>/dev/null)
-BASIC_CFLAGS += -DMULTIARCH_TRIPLET=\"$(MULTIARCH_TRIPLET)\"
+CFLAGS += -DMULTIARCH_TRIPLET=\"$(MULTIARCH_TRIPLET)\"
 
 ifeq ($(HAVE_GCC_DEP),yes)
-BASIC_CFLAGS += -Wp,-MD,$(@D)/.$(@F).d
+CFLAGS += -Wp,-MD,$(@D)/.$(@F).d
 endif
 
 DESTDIR=
@@ -96,7 +94,7 @@ 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: BASIC_CFLAGS += $(LLVM_CFLAGS)
+sparse-llvm.o: CFLAGS += $(LLVM_CFLAGS)
 sparse-llvm_EXTRA_OBJS := $(LLVM_LIBS) $(LLVM_LDFLAGS)
 else
 $(warning LLVM 3.0 or later required. Your system has version $(LLVM_VERSION) installed.)
@@ -122,7 +120,7 @@ LIB_OBJS= target.o parse.o tokenize.o pre-process.o symbol.o lib.o scope.o \
 LIB_FILE= libsparse.a
 SLIB_FILE= libsparse.so
 
-# If you add $(SLIB_FILE) to this, you also need to add -fpic to BASIC_CFLAGS above.
+# If you add $(SLIB_FILE) to this, you also need to add -fpic to CFLAGS above.
 # Doing so incurs a noticeable performance hit, and Sparse does not have a
 # stable shared library interface, so this does not occur by default.  If you
 # really want a shared library, you may want to build Sparse twice: once
@@ -212,10 +210,10 @@ c2xml.o c2xml.sc: CFLAGS += $(LIBXML_CFLAGS)
 pre-process.sc: CHECKER_FLAGS += -Wno-vla
 
 %.o: %.c $(LIB_H)
-	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
+	$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $<
 
 %.sc: %.c sparse
-	$(QUIET_CHECK) $(CHECKER) $(CHECKER_FLAGS) -c $(ALL_CFLAGS) $<
+	$(QUIET_CHECK) $(CHECKER) $(CHECKER_FLAGS) -c $(CFLAGS) $<
 
 ALL_OBJS :=  $(LIB_OBJS) $(foreach p,$(PROGRAMS),$(p).o $($(p)_EXTRA_DEPS))
 selfcheck: $(ALL_OBJS:.o=.sc)
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 04/38] build: drop -g from LDFLAGS
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (2 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 03/38] build: drop BASIC_CFLAGS and ALL_CFLAGS Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 05/38] build: pass CPPFLAGS to compiler Luc Van Oostenryck
                   ` (34 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

From: Uwe Kleine-König <uwe@kleine-koenig.org>

-g is a compiler option that is ignored by the linker. So it should be
included in CFLAGS (it already is) but not LDFLAGS.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Makefile b/Makefile
index 069dae6c8..39b34f901 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,6 @@ OS = linux
 CC = gcc
 CFLAGS = -O2 -finline-functions -fno-strict-aliasing -g
 CFLAGS += -Wall -Wwrite-strings
-LDFLAGS += -g
 LD = gcc
 AR = ar
 PKG_CONFIG = pkg-config
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 05/38] build: pass CPPFLAGS to compiler
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (3 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 04/38] build: drop -g from LDFLAGS Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 06/38] build: fix effectiveness of generated dependencies Luc Van Oostenryck
                   ` (33 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

From: Uwe Kleine-König <uwe@kleine-koenig.org>

Debian packages use CPPFLAGS to pass -D_FORTIFY_SOURCE=2 for hardening.

Originally-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 39b34f901..f1af83e32 100644
--- a/Makefile
+++ b/Makefile
@@ -209,10 +209,10 @@ c2xml.o c2xml.sc: CFLAGS += $(LIBXML_CFLAGS)
 pre-process.sc: CHECKER_FLAGS += -Wno-vla
 
 %.o: %.c $(LIB_H)
-	$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $<
+	$(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
 
 %.sc: %.c sparse
-	$(QUIET_CHECK) $(CHECKER) $(CHECKER_FLAGS) -c $(CFLAGS) $<
+	$(QUIET_CHECK) $(CHECKER) $(CHECKER_FLAGS) $(CFLAGS) $(CPPFLAGS) -c $<
 
 ALL_OBJS :=  $(LIB_OBJS) $(foreach p,$(PROGRAMS),$(p).o $($(p)_EXTRA_DEPS))
 selfcheck: $(ALL_OBJS:.o=.sc)
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 06/38] build: fix effectiveness of generated dependencies
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (4 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 05/38] build: pass CPPFLAGS to compiler Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 07/38] build: remove unused support for pkgconfig Luc Van Oostenryck
                   ` (32 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

Commit fb8734e3f "Makefile: clean up and simplify" added blindly
$(LIB_H) as dependency to all .o targets.
This completely defeat the purpose of generated dependencies.

Fix this by removing this unneeded dependency.

Fixes: fb8734e3fa18619277f54f131a9b898ce7171645
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index f1af83e32..bc4469410 100644
--- a/Makefile
+++ b/Makefile
@@ -208,7 +208,7 @@ c2xml.o c2xml.sc: CFLAGS += $(LIBXML_CFLAGS)
 
 pre-process.sc: CHECKER_FLAGS += -Wno-vla
 
-%.o: %.c $(LIB_H)
+%.o: %.c
 	$(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
 
 %.sc: %.c sparse
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 07/38] build: remove unused support for pkgconfig
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (5 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 06/38] build: fix effectiveness of generated dependencies Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 08/38] build: use '-objs' instead of '_EXTRA_DEPS' Luc Van Oostenryck
                   ` (31 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

Sparse being a library was installed as such and with support for
pkgconfig.

However, it seems that sparse is only used for its tools and not
as a library (at least not as an external one) and currently
doesn't offer a stable interface.

For now, remove the support for this, it will be easy enough to
restore it if there is a new need.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 .gitignore   |  1 -
 Makefile     | 27 +++------------------------
 sparse.pc.in |  9 ---------
 3 files changed, 3 insertions(+), 34 deletions(-)
 delete mode 100644 sparse.pc.in

diff --git a/.gitignore b/.gitignore
index 44218a2fe..9f996dc87 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,7 +7,6 @@
 
 # generated
 pre-process.h
-sparse.pc
 version.h
 
 # programs
diff --git a/Makefile b/Makefile
index bc4469410..bd8a08f13 100644
--- a/Makefile
+++ b/Makefile
@@ -48,11 +48,8 @@ endif
 DESTDIR=
 PREFIX ?= $(HOME)
 BINDIR=$(PREFIX)/bin
-LIBDIR=$(PREFIX)/lib
 MANDIR=$(PREFIX)/share/man
 MAN1DIR=$(MANDIR)/man1
-INCLUDEDIR=$(PREFIX)/include
-PKGCONFIGDIR=$(LIBDIR)/pkgconfig
 
 PROGRAMS=test-lexing test-parsing obfuscate compile graph sparse \
 	 test-linearize example test-unssa test-dissect ctags
@@ -105,9 +102,6 @@ else
 $(warning Your system does not have llvm, disabling sparse-llvm)
 endif
 
-LIB_H=    token.h parse.h lib.h symbol.h scope.h expression.h target.h \
-	  linearize.h bitmap.h ident-list.h compat.h flow.h allocate.h \
-	  storage.h ptrlist.h dissect.h
 
 LIB_OBJS= target.o parse.o tokenize.o pre-process.o symbol.o lib.o scope.o \
 	  expression.o show-parse.o evaluate.o expand.o inline.o linearize.o \
@@ -151,12 +145,6 @@ define INSTALL_FILE
 
 endef
 
-SED_PC_CMD = 's|@version@|$(VERSION)|g;		\
-	      s|@prefix@|$(PREFIX)|g;		\
-	      s|@libdir@|$(LIBDIR)|g;		\
-	      s|@includedir@|$(INCLUDEDIR)|g'
-
-
 
 # Allow users to override build settings without dirtying their trees
 # For debugging, put this in local.mk:
@@ -166,24 +154,15 @@ SED_PC_CMD = 's|@version@|$(VERSION)|g;		\
 -include local.mk
 
 
-all: $(PROGRAMS) sparse.pc
+all: $(PROGRAMS)
 
-all-installable: $(INST_PROGRAMS) $(LIBS) $(LIB_H) sparse.pc
+all-installable: $(INST_PROGRAMS)
 
 install: all-installable
 	$(Q)install -d $(DESTDIR)$(BINDIR)
-	$(Q)install -d $(DESTDIR)$(LIBDIR)
 	$(Q)install -d $(DESTDIR)$(MAN1DIR)
-	$(Q)install -d $(DESTDIR)$(INCLUDEDIR)/sparse
-	$(Q)install -d $(DESTDIR)$(PKGCONFIGDIR)
 	$(foreach f,$(INST_PROGRAMS),$(call INSTALL_EXEC,$f,$(BINDIR)))
 	$(foreach f,$(INST_MAN1),$(call INSTALL_FILE,$f,$(MAN1DIR)))
-	$(foreach f,$(LIBS),$(call INSTALL_FILE,$f,$(LIBDIR)))
-	$(foreach f,$(LIB_H),$(call INSTALL_FILE,$f,$(INCLUDEDIR)/sparse))
-	$(call INSTALL_FILE,sparse.pc,$(PKGCONFIGDIR))
-
-sparse.pc: sparse.pc.in
-	$(QUIET_GEN)sed $(SED_PC_CMD) sparse.pc.in > sparse.pc
 
 
 compile_EXTRA_DEPS = compile-i386.o
@@ -219,7 +198,7 @@ selfcheck: $(ALL_OBJS:.o=.sc)
 
 
 clean: clean-check
-	rm -f *.[oa] .*.d *.so $(PROGRAMS) $(SLIB_FILE) pre-process.h sparse.pc version.h
+	rm -f *.[oa] .*.d *.so $(PROGRAMS) $(SLIB_FILE) pre-process.h version.h
 
 dist:
 	@if test "$(SPARSE_VERSION)" != "v$(VERSION)" ; then \
diff --git a/sparse.pc.in b/sparse.pc.in
deleted file mode 100644
index f1281c97a..000000000
--- a/sparse.pc.in
+++ /dev/null
@@ -1,9 +0,0 @@
-prefix=@prefix@
-libdir=@libdir@
-includedir=@includedir@

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 08/38] build: use '-objs' instead of '_EXTRA_DEPS'
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (6 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 07/38] build: remove unused support for pkgconfig Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 09/38] build: use '-ldlibs' instead of '_EXTRA_OBJS' Luc Van Oostenryck
                   ` (30 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

Some programs are composed of several source files other than the
main one. These files need then to be added at linking time.
These extra file are currently specified using variables named
"<program-name>_EXTRA_DEPS" but the way these variables are used
make that they can only hold .o files (or .a ones) and are not
some kind of generic dependencie.

Make this explicit by using the suffix '-objs' instead.

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

diff --git a/Makefile b/Makefile
index bd8a08f13..fa86c09a1 100644
--- a/Makefile
+++ b/Makefile
@@ -70,9 +70,9 @@ GTK_CFLAGS := $(shell $(PKG_CONFIG) --cflags gtk+-$(GTK_VERSION))
 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-$(GTK_VERSION))
 PROGRAMS += test-inspect
 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-objs := test-inspect.o
+test-inspect-objs += ast-model.o ast-view.o ast-inspect.o
+$(test-inspect-objs) $(test-inspect-objs:.o=.sc): CFLAGS += $(GTK_CFLAGS)
 test-inspect_EXTRA_OBJS := $(GTK_LIBS)
 else
 $(warning Your system does not have gtk3/gtk2, disabling test-inspect)
@@ -165,9 +165,9 @@ install: all-installable
 	$(foreach f,$(INST_MAN1),$(call INSTALL_FILE,$f,$(MAN1DIR)))
 
 
-compile_EXTRA_DEPS = compile-i386.o
+compile-objs:= compile-i386.o
 
-$(foreach p,$(PROGRAMS),$(eval $(p): $($(p)_EXTRA_DEPS) $(LIBS)))
+$(foreach p,$(PROGRAMS),$(eval $(p): $($(p)-objs) $(LIBS)))
 $(PROGRAMS): % : %.o 
 	$(QUIET_LINK)$(LD) $(LDFLAGS) -o $@ $^ $($@_EXTRA_OBJS)
 
@@ -193,7 +193,7 @@ pre-process.sc: CHECKER_FLAGS += -Wno-vla
 %.sc: %.c sparse
 	$(QUIET_CHECK) $(CHECKER) $(CHECKER_FLAGS) $(CFLAGS) $(CPPFLAGS) -c $<
 
-ALL_OBJS :=  $(LIB_OBJS) $(foreach p,$(PROGRAMS),$(p).o $($(p)_EXTRA_DEPS))
+ALL_OBJS :=  $(LIB_OBJS) $(foreach p,$(PROGRAMS),$(p).o $($(p)-objs))
 selfcheck: $(ALL_OBJS:.o=.sc)
 
 
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 09/38] build: use '-ldlibs' instead of '_EXTRA_OBJS'
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (7 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 08/38] build: use '-objs' instead of '_EXTRA_DEPS' Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 10/38] build: allow target-specific CFLAGS, CPPFLAGS, LDFLAGS & LDLIBS Luc Van Oostenryck
                   ` (29 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

Some of the programs need to link with some external libraries.
For some reasons, these libraries are specified via variables named:
"<target>_EXTRA_OBJS".

Use the '-ldlibs' prefix instead to better reflect the real use.

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

diff --git a/Makefile b/Makefile
index fa86c09a1..ba0cb2093 100644
--- a/Makefile
+++ b/Makefile
@@ -59,7 +59,7 @@ INST_MAN1=sparse.1 cgcc.1
 ifeq ($(HAVE_LIBXML),yes)
 PROGRAMS+=c2xml
 INST_PROGRAMS+=c2xml
-c2xml_EXTRA_OBJS = `$(PKG_CONFIG) --libs libxml-2.0`
+c2xml-ldlibs = `$(PKG_CONFIG) --libs libxml-2.0`
 LIBXML_CFLAGS := $(shell $(PKG_CONFIG) --cflags libxml-2.0)
 else
 $(warning Your system does not have libxml, disabling c2xml)
@@ -73,7 +73,7 @@ INST_PROGRAMS += test-inspect
 test-inspect-objs := test-inspect.o
 test-inspect-objs += ast-model.o ast-view.o ast-inspect.o
 $(test-inspect-objs) $(test-inspect-objs:.o=.sc): CFLAGS += $(GTK_CFLAGS)
-test-inspect_EXTRA_OBJS := $(GTK_LIBS)
+test-inspect-ldlibs := $(GTK_LIBS)
 else
 $(warning Your system does not have gtk3/gtk2, disabling test-inspect)
 endif
@@ -91,7 +91,7 @@ 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-ldlibs := $(LLVM_LIBS) $(LLVM_LDFLAGS)
 else
 $(warning LLVM 3.0 or later required. Your system has version $(LLVM_VERSION) installed.)
 endif
@@ -169,7 +169,7 @@ compile-objs:= compile-i386.o
 
 $(foreach p,$(PROGRAMS),$(eval $(p): $($(p)-objs) $(LIBS)))
 $(PROGRAMS): % : %.o 
-	$(QUIET_LINK)$(LD) $(LDFLAGS) -o $@ $^ $($@_EXTRA_OBJS)
+	$(QUIET_LINK)$(LD) $(LDFLAGS) -o $@ $^ $($@-ldlibs)
 
 $(LIB_FILE): $(LIB_OBJS)
 	$(QUIET_AR)$(AR) rcs $@ $(LIB_OBJS)
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 10/38] build: allow target-specific CFLAGS, CPPFLAGS, LDFLAGS & LDLIBS
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (8 preceding siblings ...)
  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
  2017-11-11 14:24 ` [PATCH v4 11/38] build: allow CFLAGS & friends from command line Luc Van Oostenryck
                   ` (28 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

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


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 11/38] build: allow CFLAGS & friends from command line
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (9 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 10/38] build: allow target-specific CFLAGS, CPPFLAGS, LDFLAGS & LDLIBS Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 12/38] build: avoid rule-specific CFLAGS Luc Van Oostenryck
                   ` (27 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

This allow distros or devs to override the default CFLAGS,
CPPFLAGS, LDFLAGS, ...

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

diff --git a/Makefile b/Makefile
index 4da421de1..8a06b75a5 100644
--- a/Makefile
+++ b/Makefile
@@ -36,13 +36,13 @@ LLVM_CONFIG:=llvm-config
 HAVE_LLVM:=$(shell $(LLVM_CONFIG) --version >/dev/null 2>&1 && echo 'yes')
 
 GCC_BASE := $(shell $(CC) --print-file-name=)
-CFLAGS += -DGCC_BASE=\"$(GCC_BASE)\"
+cflags += -DGCC_BASE=\"$(GCC_BASE)\"
 
 MULTIARCH_TRIPLET := $(shell $(CC) -print-multiarch 2>/dev/null)
-CFLAGS += -DMULTIARCH_TRIPLET=\"$(MULTIARCH_TRIPLET)\"
+cflags += -DMULTIARCH_TRIPLET=\"$(MULTIARCH_TRIPLET)\"
 
 ifeq ($(HAVE_GCC_DEP),yes)
-CFLAGS += -Wp,-MD,$(@D)/.$(@F).d
+cflags += -Wp,-MD,$(@D)/.$(@F).d
 endif
 
 DESTDIR=
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 12/38] build: avoid rule-specific CFLAGS
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (10 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 11/38] build: allow CFLAGS & friends from command line Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 13/38] build: use $LIBS directly in the dependency list Luc Van Oostenryck
                   ` (26 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

Those are not evil but it's for consistency with the remaining.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 8a06b75a5..c66f730af 100644
--- a/Makefile
+++ b/Makefile
@@ -72,7 +72,7 @@ PROGRAMS += test-inspect
 INST_PROGRAMS += test-inspect
 test-inspect-objs := test-inspect.o
 test-inspect-objs += ast-model.o ast-view.o ast-inspect.o
-$(test-inspect-objs) $(test-inspect-objs:.o=.sc): CFLAGS += $(GTK_CFLAGS)
+$(foreach p,$(test-inspect-objs:.o=),$(eval $(p)-cflags := $(GTK_CFLAGS)))
 test-inspect-ldlibs := $(GTK_LIBS)
 else
 $(warning Your system does not have gtk3/gtk2, disabling test-inspect)
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 13/38] build: use $LIBS directly in the dependency list
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (11 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 12/38] build: avoid rule-specific CFLAGS Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 14/38] build: no need to use wildcards for generated dependencies Luc Van Oostenryck
                   ` (25 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

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

diff --git a/Makefile b/Makefile
index c66f730af..61271e19f 100644
--- a/Makefile
+++ b/Makefile
@@ -170,8 +170,8 @@ compile-objs:= compile-i386.o
 
 ldflags += $($(@)-ldflags) $(LDFLAGS)
 ldlibs  += $($(@)-ldlibs)  $(LDLIBS)
-$(foreach p,$(PROGRAMS),$(eval $(p): $($(p)-objs) $(LIBS)))
-$(PROGRAMS): % : %.o 
+$(foreach p,$(PROGRAMS),$(eval $(p): $($(p)-objs)))
+$(PROGRAMS): % : %.o $(LIBS)
 	$(QUIET_LINK)$(LD) $(ldflags) -o $@ $^ $(ldlibs)
 
 $(LIB_FILE): $(LIB_OBJS)
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 14/38] build: no need to use wildcards for generated dependencies
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (12 preceding siblings ...)
  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 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 15/38] build: reuse rule for ALL_OBJS Luc Van Oostenryck
                   ` (24 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

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

diff --git a/Makefile b/Makefile
index 61271e19f..1a71ef01b 100644
--- a/Makefile
+++ b/Makefile
@@ -180,11 +180,10 @@ $(LIB_FILE): $(LIB_OBJS)
 $(SLIB_FILE): $(LIB_OBJS)
 	$(QUIET_LINK)$(CC) $(LDFLAGS) -Wl,-soname,$@ -shared -o $@ $(LIB_OBJS)
 
-DEP_FILES := $(wildcard .*.o.d)
+OBJS := $(LIB_OBJS) $(PROGRAMS:%=%.o) $(foreach p,$(PROGRAMS),$($(p)_OBJS))
+DEPS := $(OBJS:%.o=.%.o.d)
 
-ifneq ($(DEP_FILES),)
-include $(DEP_FILES)
-endif
+-include $(DEPS)
 
 
 pre-process.sc: CHECKER_FLAGS += -Wno-vla
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 15/38] build: reuse rule for ALL_OBJS
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (13 preceding siblings ...)
  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 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 16/38] build: CHECKER_FLAGS=-Wno-vla for all targets Luc Van Oostenryck
                   ` (23 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

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

diff --git a/Makefile b/Makefile
index 1a71ef01b..2df5aa2c9 100644
--- a/Makefile
+++ b/Makefile
@@ -180,7 +180,7 @@ $(LIB_FILE): $(LIB_OBJS)
 $(SLIB_FILE): $(LIB_OBJS)
 	$(QUIET_LINK)$(CC) $(LDFLAGS) -Wl,-soname,$@ -shared -o $@ $(LIB_OBJS)
 
-OBJS := $(LIB_OBJS) $(PROGRAMS:%=%.o) $(foreach p,$(PROGRAMS),$($(p)_OBJS))
+OBJS := $(LIB_OBJS) $(PROGRAMS:%=%.o) $(foreach p,$(PROGRAMS),$($(p)-objs))
 DEPS := $(OBJS:%.o=.%.o.d)
 
 -include $(DEPS)
@@ -195,8 +195,7 @@ cflags   += $($(*)-cflags) $(CPPFLAGS) $(CFLAGS)
 %.sc: %.c sparse
 	$(QUIET_CHECK) $(CHECKER) $(CHECKER_FLAGS) $(cflags) -c $<
 
-ALL_OBJS :=  $(LIB_OBJS) $(foreach p,$(PROGRAMS),$(p).o $($(p)-objs))
-selfcheck: $(ALL_OBJS:.o=.sc)
+selfcheck: $(OBJS:.o=.sc)
 
 
 clean: clean-check
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 16/38] build: CHECKER_FLAGS=-Wno-vla for all targets
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (14 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 15/38] build: reuse rule for ALL_OBJS Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 17/38] build: move tests near their use Luc Van Oostenryck
                   ` (22 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 Makefile | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 2df5aa2c9..2cbea4278 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ LD = gcc
 AR = ar
 PKG_CONFIG = pkg-config
 CHECKER = ./cgcc -no-compile
-CHECKER_FLAGS =
+CHECKER_FLAGS = -Wno-vla
 
 HAVE_LIBXML:=$(shell $(PKG_CONFIG) --exists libxml-2.0 2>/dev/null && echo 'yes')
 HAVE_GCC_DEP:=$(shell touch .gcc-test.c && 				\
@@ -186,8 +186,6 @@ DEPS := $(OBJS:%.o=.%.o.d)
 -include $(DEPS)
 
 
-pre-process.sc: CHECKER_FLAGS += -Wno-vla

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 17/38] build: move tests near their use
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (15 preceding siblings ...)
  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 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 18/38] build: only generate version.h when needed Luc Van Oostenryck
                   ` (21 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

No functional changes here, just moving things around.

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

diff --git a/Makefile b/Makefile
index 2cbea4278..975b5e72d 100644
--- a/Makefile
+++ b/Makefile
@@ -20,20 +20,33 @@ PKG_CONFIG = pkg-config
 CHECKER = ./cgcc -no-compile
 CHECKER_FLAGS = -Wno-vla
 
-HAVE_LIBXML:=$(shell $(PKG_CONFIG) --exists libxml-2.0 2>/dev/null && echo 'yes')
-HAVE_GCC_DEP:=$(shell touch .gcc-test.c && 				\
-		$(CC) -c -Wp,-MD,.gcc-test.d .gcc-test.c 2>/dev/null && \
-		echo 'yes'; rm -f .gcc-test.d .gcc-test.o .gcc-test.c)
+DESTDIR=
+PREFIX ?= $(HOME)
+BINDIR=$(PREFIX)/bin
+MANDIR=$(PREFIX)/share/man
+MAN1DIR=$(MANDIR)/man1
 
-GTK_VERSION:=3.0
-HAVE_GTK:=$(shell $(PKG_CONFIG) --exists gtk+-$(GTK_VERSION) 2>/dev/null && echo 'yes')
-ifneq ($(HAVE_GTK),yes)
-	GTK_VERSION:=2.0
-	HAVE_GTK:=$(shell $(PKG_CONFIG) --exists gtk+-$(GTK_VERSION) 2>/dev/null && echo 'yes')
-endif
+# Allow users to override build settings without dirtying their trees
+# For debugging, put this in local.mk:
+#
+#     CFLAGS += -O0 -DDEBUG -g3 -gdwarf-2
+#
+-include local.mk
 
-LLVM_CONFIG:=llvm-config
-HAVE_LLVM:=$(shell $(LLVM_CONFIG) --version >/dev/null 2>&1 && echo 'yes')
+
+PROGRAMS=test-lexing test-parsing obfuscate compile graph sparse \
+	 test-linearize example test-unssa test-dissect ctags
+INST_PROGRAMS=sparse cgcc
+INST_MAN1=sparse.1 cgcc.1
+
+LIB_OBJS= target.o parse.o tokenize.o pre-process.o symbol.o lib.o scope.o \
+	  expression.o show-parse.o evaluate.o expand.o inline.o linearize.o \
+	  char.o sort.o allocate.o compat-$(OS).o ptrlist.o \
+	  builtin.o \
+	  stats.o \
+	  flow.o cse.o simplify.o memops.o liveness.o storage.o unssa.o dissect.o
+
+all:
 
 GCC_BASE := $(shell $(CC) --print-file-name=)
 cflags += -DGCC_BASE=\"$(GCC_BASE)\"
@@ -41,21 +54,16 @@ cflags += -DGCC_BASE=\"$(GCC_BASE)\"
 MULTIARCH_TRIPLET := $(shell $(CC) -print-multiarch 2>/dev/null)
 cflags += -DMULTIARCH_TRIPLET=\"$(MULTIARCH_TRIPLET)\"
 
+# Can we use GCC's generated dependencies?
+HAVE_GCC_DEP:=$(shell touch .gcc-test.c && 				\
+		$(CC) -c -Wp,-MD,.gcc-test.d .gcc-test.c 2>/dev/null && \
+		echo 'yes'; rm -f .gcc-test.d .gcc-test.o .gcc-test.c)
 ifeq ($(HAVE_GCC_DEP),yes)
 cflags += -Wp,-MD,$(@D)/.$(@F).d
 endif
 
-DESTDIR=
-PREFIX ?= $(HOME)
-BINDIR=$(PREFIX)/bin
-MANDIR=$(PREFIX)/share/man
-MAN1DIR=$(MANDIR)/man1
-
-PROGRAMS=test-lexing test-parsing obfuscate compile graph sparse \
-	 test-linearize example test-unssa test-dissect ctags
-INST_PROGRAMS=sparse cgcc
-INST_MAN1=sparse.1 cgcc.1
-
+# Can we use libxml (needed for c2xml)?
+HAVE_LIBXML:=$(shell $(PKG_CONFIG) --exists libxml-2.0 2>/dev/null && echo 'yes')
 ifeq ($(HAVE_LIBXML),yes)
 PROGRAMS+=c2xml
 INST_PROGRAMS+=c2xml
@@ -65,6 +73,13 @@ else
 $(warning Your system does not have libxml, disabling c2xml)
 endif
 
+# Can we use gtk (needed for test-inspect)
+GTK_VERSION:=3.0
+HAVE_GTK:=$(shell $(PKG_CONFIG) --exists gtk+-$(GTK_VERSION) 2>/dev/null && echo 'yes')
+ifneq ($(HAVE_GTK),yes)
+GTK_VERSION:=2.0
+HAVE_GTK:=$(shell $(PKG_CONFIG) --exists gtk+-$(GTK_VERSION) 2>/dev/null && echo 'yes')
+endif
 ifeq ($(HAVE_GTK),yes)
 GTK_CFLAGS := $(shell $(PKG_CONFIG) --cflags gtk+-$(GTK_VERSION))
 GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-$(GTK_VERSION))
@@ -78,6 +93,9 @@ else
 $(warning Your system does not have gtk3/gtk2, disabling test-inspect)
 endif
 
+# Can we use LLVM (needed for ... sparse-llvm)?
+LLVM_CONFIG:=llvm-config
+HAVE_LLVM:=$(shell $(LLVM_CONFIG) --version >/dev/null 2>&1 && echo 'yes')
 ifeq ($(HAVE_LLVM),yes)
 ifeq ($(shell uname -m | grep -q '\(i386\|x86\)' && echo ok),ok)
 LLVM_VERSION:=$(shell $(LLVM_CONFIG) --version)
@@ -103,14 +121,6 @@ else
 $(warning Your system does not have llvm, disabling sparse-llvm)
 endif
 
-
-LIB_OBJS= target.o parse.o tokenize.o pre-process.o symbol.o lib.o scope.o \
-	  expression.o show-parse.o evaluate.o expand.o inline.o linearize.o \
-	  char.o sort.o allocate.o compat-$(OS).o ptrlist.o \
-	  builtin.o \
-	  stats.o \
-	  flow.o cse.o simplify.o memops.o liveness.o storage.o unssa.o dissect.o
-
 LIB_FILE= libsparse.a
 SLIB_FILE= libsparse.so
 
@@ -147,13 +157,6 @@ define INSTALL_FILE
 endef
 
 
-# Allow users to override build settings without dirtying their trees
-# For debugging, put this in local.mk:
-#
-#     CFLAGS += -O0 -DDEBUG -g3 -gdwarf-2
-#
--include local.mk

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 18/38] build: only generate version.h when needed
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (16 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 17/38] build: move tests near their use Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 19/38] build: add note about overwritable vars Luc Van Oostenryck
                   ` (20 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

From: Uwe Kleine-König <uwe@kleine-koenig.org>

This way version.h isn't generated when running $(make clean) but only
when lib.c is about to be compiled.

This simplifies packaging for Debian because the package building programs
abort when there are additional files after $(make clean).

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 Makefile | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index 975b5e72d..ce57ed3cb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,5 @@
 VERSION=0.5.1
 
-# Generating file version.h if current version has changed
-SPARSE_VERSION:=$(shell git describe 2>/dev/null || echo '$(VERSION)')
-VERSION_H := $(shell cat version.h 2>/dev/null)
-ifneq ($(lastword $(VERSION_H)),"$(SPARSE_VERSION)")
-$(info $(shell echo '     GEN      'version.h))
-$(shell echo '#define SPARSE_VERSION "$(SPARSE_VERSION)"' > version.h)
-endif
-
 OS = linux
 
 
@@ -199,6 +191,18 @@ cflags   += $($(*)-cflags) $(CPPFLAGS) $(CFLAGS)
 selfcheck: $(OBJS:.o=.sc)
 
 
+SPARSE_VERSION:=$(shell git describe 2>/dev/null || echo '$(VERSION)')
+lib.o: version.h
+version.h: FORCE
+	@echo '#define SPARSE_VERSION "$(SPARSE_VERSION)"' > version.h.tmp
+	@if cmp -s version.h version.h.tmp; then \
+		rm version.h.tmp; \
+	else \
+		echo    '     GEN      '$@; \
+		mv version.h.tmp version.h; \
+	fi
+
+
 clean: clean-check
 	rm -f *.[oa] .*.d *.so $(PROGRAMS) $(SLIB_FILE) pre-process.h version.h
 
@@ -220,3 +224,5 @@ clean-check:
 	                 -o -name "*.c.error.got" \
 	                 -o -name "*.c.error.diff" \
 	                 \) -exec rm {} \;
+
+.PHONY: FORCE
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 19/38] build: add note about overwritable vars
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (17 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 18/38] build: only generate version.h when needed Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 20/38] build: remove references to unexisting pre-process.h Luc Van Oostenryck
                   ` (19 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

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

diff --git a/Makefile b/Makefile
index ce57ed3cb..f1f210e27 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,7 @@
 VERSION=0.5.1
 
+########################################################################
+# The following variables can be overwritten from the command line
 OS = linux
 
 
@@ -24,6 +26,7 @@ MAN1DIR=$(MANDIR)/man1
 #     CFLAGS += -O0 -DDEBUG -g3 -gdwarf-2
 #
 -include local.mk
+########################################################################
 
 
 PROGRAMS=test-lexing test-parsing obfuscate compile graph sparse \
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 20/38] build: remove references to unexisting pre-process.h
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (18 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 19/38] build: add note about overwritable vars Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 21/38] build: move clean & clean-check together Luc Van Oostenryck
                   ` (18 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 .gitignore | 1 -
 Makefile   | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 9f996dc87..ab976e76b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,7 +6,6 @@
 .*.swp
 
 # generated
-pre-process.h
 version.h
 
 # programs
diff --git a/Makefile b/Makefile
index f1f210e27..983b4647d 100644
--- a/Makefile
+++ b/Makefile
@@ -207,7 +207,7 @@ version.h: FORCE
 
 
 clean: clean-check
-	rm -f *.[oa] .*.d *.so $(PROGRAMS) $(SLIB_FILE) pre-process.h version.h
+	rm -f *.[oa] .*.d *.so $(PROGRAMS) $(SLIB_FILE) version.h
 
 dist:
 	@if test "$(SPARSE_VERSION)" != "v$(VERSION)" ; then \
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 21/38] build: move clean & clean-check together
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (19 preceding siblings ...)
  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 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 22/38] build: make clean targets quieter Luc Van Oostenryck
                   ` (17 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

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

diff --git a/Makefile b/Makefile
index 983b4647d..400187887 100644
--- a/Makefile
+++ b/Makefile
@@ -206,9 +206,6 @@ version.h: FORCE
 	fi
 
 
-clean: clean-check
-	rm -f *.[oa] .*.d *.so $(PROGRAMS) $(SLIB_FILE) version.h

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 22/38] build: make clean targets quieter
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (20 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 21/38] build: move clean & clean-check together Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 23/38] build: remove rule for shared lib, it's unused Luc Van Oostenryck
                   ` (16 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

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

diff --git a/Makefile b/Makefile
index 400187887..18b9c75dd 100644
--- a/Makefile
+++ b/Makefile
@@ -218,9 +218,10 @@ check: all
 
 
 clean: clean-check
-	rm -f *.[oa] .*.d *.so $(PROGRAMS) $(SLIB_FILE) version.h
+	@rm -f *.[oa] .*.d *.so $(PROGRAMS) $(SLIB_FILE) version.h
 clean-check:
-	find validation/ \( -name "*.c.output.expected" \
+	@echo '     CLEAN'
+	@find validation/ \( -name "*.c.output.expected" \
 	                 -o -name "*.c.output.got" \
 	                 -o -name "*.c.output.diff" \
 	                 -o -name "*.c.error.expected" \
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 23/38] build: remove rule for shared lib, it's unused
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (21 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 22/38] build: make clean targets quieter Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 24/38] build: normalize rules Luc Van Oostenryck
                   ` (15 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

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

diff --git a/Makefile b/Makefile
index 18b9c75dd..70220e841 100644
--- a/Makefile
+++ b/Makefile
@@ -116,16 +116,7 @@ else
 $(warning Your system does not have llvm, disabling sparse-llvm)
 endif
 
-LIB_FILE= libsparse.a
-SLIB_FILE= libsparse.so
-
-# If you add $(SLIB_FILE) to this, you also need to add -fpic to CFLAGS above.
-# Doing so incurs a noticeable performance hit, and Sparse does not have a
-# stable shared library interface, so this does not occur by default.  If you
-# really want a shared library, you may want to build Sparse twice: once
-# without -fpic to get all the Sparse tools, and again with -fpic to get the
-# shared library.
-LIBS=$(LIB_FILE)
+LIBS := libsparse.a
 
 #
 # Pretty print
@@ -172,12 +163,9 @@ $(foreach p,$(PROGRAMS),$(eval $(p): $($(p)-objs)))
 $(PROGRAMS): % : %.o $(LIBS)
 	$(QUIET_LINK)$(LD) $(ldflags) -o $@ $^ $(ldlibs)
 
-$(LIB_FILE): $(LIB_OBJS)
+libsparse.a: $(LIB_OBJS)
 	$(QUIET_AR)$(AR) rcs $@ $(LIB_OBJS)
 
-$(SLIB_FILE): $(LIB_OBJS)
-	$(QUIET_LINK)$(CC) $(LDFLAGS) -Wl,-soname,$@ -shared -o $@ $(LIB_OBJS)

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 24/38] build: normalize rules
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (22 preceding siblings ...)
  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 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 25/38] build: remove the dist rule since unused Luc Van Oostenryck
                   ` (14 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

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

diff --git a/Makefile b/Makefile
index 70220e841..cc8044915 100644
--- a/Makefile
+++ b/Makefile
@@ -161,10 +161,10 @@ ldflags += $($(@)-ldflags) $(LDFLAGS)
 ldlibs  += $($(@)-ldlibs)  $(LDLIBS)
 $(foreach p,$(PROGRAMS),$(eval $(p): $($(p)-objs)))
 $(PROGRAMS): % : %.o $(LIBS)
-	$(QUIET_LINK)$(LD) $(ldflags) -o $@ $^ $(ldlibs)
+	$(QUIET_LINK)$(LD) $(ldflags) $^ $(ldlibs) -o $@
 
 libsparse.a: $(LIB_OBJS)
-	$(QUIET_AR)$(AR) rcs $@ $(LIB_OBJS)
+	$(QUIET_AR)$(AR) rcs $@ $^
 
 OBJS := $(LIB_OBJS) $(PROGRAMS:%=%.o) $(foreach p,$(PROGRAMS),$($(p)-objs))
 DEPS := $(OBJS:%.o=.%.o.d)
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 25/38] build: remove the dist rule since unused
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (23 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 24/38] build: normalize rules Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 26/38] build: use one line per item Luc Van Oostenryck
                   ` (13 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

The last .tar.gz was for v0.5.0 in 2014.

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

diff --git a/Makefile b/Makefile
index cc8044915..6d90bfbef 100644
--- a/Makefile
+++ b/Makefile
@@ -194,13 +194,6 @@ version.h: FORCE
 	fi
 
 
-dist:
-	@if test "$(SPARSE_VERSION)" != "v$(VERSION)" ; then \
-		echo 'Update VERSION in the Makefile before running "make dist".' ; \
-		exit 1 ; \
-	fi
-	git archive --format=tar --prefix=sparse-$(VERSION)/ HEAD^{tree} | gzip -9 > sparse-$(VERSION).tar.gz

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 26/38] build: use one line per item
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (24 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 25/38] build: remove the dist rule since unused Luc Van Oostenryck
@ 2017-11-11 14:24 ` 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
                   ` (12 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

This help to minimize merge conflicts.

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

diff --git a/Makefile b/Makefile
index 6d90bfbef..7f136e87e 100644
--- a/Makefile
+++ b/Makefile
@@ -29,17 +29,52 @@ MAN1DIR=$(MANDIR)/man1
 ########################################################################
 
 
-PROGRAMS=test-lexing test-parsing obfuscate compile graph sparse \
-	 test-linearize example test-unssa test-dissect ctags
+LIB_OBJS :=
+LIB_OBJS += allocate.o
+LIB_OBJS += builtin.o
+LIB_OBJS += char.o
+LIB_OBJS += compat-$(OS).o
+LIB_OBJS += cse.o
+LIB_OBJS += dissect.o
+LIB_OBJS += evaluate.o
+LIB_OBJS += expand.o
+LIB_OBJS += expression.o
+LIB_OBJS += flow.o
+LIB_OBJS += inline.o
+LIB_OBJS += lib.o
+LIB_OBJS += linearize.o
+LIB_OBJS += liveness.o
+LIB_OBJS += memops.o
+LIB_OBJS += parse.o
+LIB_OBJS += pre-process.o
+LIB_OBJS += ptrlist.o
+LIB_OBJS += scope.o
+LIB_OBJS += show-parse.o
+LIB_OBJS += simplify.o
+LIB_OBJS += sort.o
+LIB_OBJS += stats.o
+LIB_OBJS += storage.o
+LIB_OBJS += symbol.o
+LIB_OBJS += target.o
+LIB_OBJS += tokenize.o
+LIB_OBJS += unssa.o
+
+PROGRAMS :=
+PROGRAMS += compile
+PROGRAMS += ctags
+PROGRAMS += example
+PROGRAMS += graph
+PROGRAMS += obfuscate
+PROGRAMS += sparse
+PROGRAMS += test-dissect
+PROGRAMS += test-lexing
+PROGRAMS += test-linearize
+PROGRAMS += test-parsing
+PROGRAMS += test-unssa
+
 INST_PROGRAMS=sparse cgcc
 INST_MAN1=sparse.1 cgcc.1
 
-LIB_OBJS= target.o parse.o tokenize.o pre-process.o symbol.o lib.o scope.o \
-	  expression.o show-parse.o evaluate.o expand.o inline.o linearize.o \
-	  char.o sort.o allocate.o compat-$(OS).o ptrlist.o \
-	  builtin.o \
-	  stats.o \
-	  flow.o cse.o simplify.o memops.o liveness.o storage.o unssa.o dissect.o
 
 all:
 
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 27/38] build: allow the name 'local.mk' to be configurable via the environment
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (25 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 26/38] build: use one line per item Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 28/38] build: use standard rules for install Luc Van Oostenryck
                   ` (11 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

So people who like this file to be a hidden one or to be an
out-of-tree file or simply who don't like the name, can choose
whatever suits them the best.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 .gitignore | 1 +
 Makefile   | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index ab976e76b..bc00736d7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,6 +37,7 @@ series
 
 # local makefile
 local.mk
+.*.mk
 
 # cscope and Qt files
 cscope.out
diff --git a/Makefile b/Makefile
index 7f136e87e..e4efefa1e 100644
--- a/Makefile
+++ b/Makefile
@@ -25,7 +25,8 @@ MAN1DIR=$(MANDIR)/man1
 #
 #     CFLAGS += -O0 -DDEBUG -g3 -gdwarf-2
 #
--include local.mk
+SPARSE_LOCAL_CONFIG ?= local.mk
+-include ${SPARSE_LOCAL_CONFIG}
 ########################################################################
 
 
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 28/38] build: use standard rules for install
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (26 preceding siblings ...)
  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 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 29/38] build: remove unused QUIET_INST_SH Luc Van Oostenryck
                   ` (10 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

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

diff --git a/Makefile b/Makefile
index e4efefa1e..afb76a994 100644
--- a/Makefile
+++ b/Makefile
@@ -168,31 +168,11 @@ QUIET_LINK    = $(Q:@=@echo    '     LINK     '$@;)
 QUIET_INST_SH = $(Q:@=echo -n  '     INSTALL  ';)
 QUIET_INST    = $(Q:@=@echo -n '     INSTALL  ';)
 
-define INSTALL_EXEC
-	$(QUIET_INST)install -v $1 $(DESTDIR)$2/$1 || exit 1;
-
-endef
-
-define INSTALL_FILE
-	$(QUIET_INST)install -v -m 644 $1 $(DESTDIR)$2/$1 || exit 1;
-
-endef
-
 
+compile_OBJS := compile-i386.o
 
 all: $(PROGRAMS)
 
-all-installable: $(INST_PROGRAMS)
-
-install: all-installable
-	$(Q)install -d $(DESTDIR)$(BINDIR)
-	$(Q)install -d $(DESTDIR)$(MAN1DIR)
-	$(foreach f,$(INST_PROGRAMS),$(call INSTALL_EXEC,$f,$(BINDIR)))
-	$(foreach f,$(INST_MAN1),$(call INSTALL_FILE,$f,$(MAN1DIR)))
-
-
-compile-objs:= compile-i386.o

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 29/38] build: remove unused QUIET_INST_SH
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (27 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 28/38] build: use standard rules for install Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 30/38] build: let quiet commands use less indentation Luc Van Oostenryck
                   ` (9 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Makefile b/Makefile
index afb76a994..38ae80f8b 100644
--- a/Makefile
+++ b/Makefile
@@ -165,7 +165,6 @@ QUIET_AR      = $(Q:@=@echo    '     AR       '$@;)
 QUIET_GEN     = $(Q:@=@echo    '     GEN      '$@;)
 QUIET_LINK    = $(Q:@=@echo    '     LINK     '$@;)
 # We rely on the -v switch of install to print 'file -> $install_dir/file'
-QUIET_INST_SH = $(Q:@=echo -n  '     INSTALL  ';)
 QUIET_INST    = $(Q:@=@echo -n '     INSTALL  ';)
 
 
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 30/38] build: let quiet commands use less indentation
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (28 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 29/38] build: remove unused QUIET_INST_SH Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 31/38] build: simplify quiet commands Luc Van Oostenryck
                   ` (8 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

Now it does the same as done in the kernel: 2 + 8.

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

diff --git a/Makefile b/Makefile
index 38ae80f8b..5b3cd66f9 100644
--- a/Makefile
+++ b/Makefile
@@ -159,13 +159,13 @@ LIBS := libsparse.a
 #
 V	      = @
 Q	      = $(V:1=)
-QUIET_CC      = $(Q:@=@echo    '     CC       '$@;)
-QUIET_CHECK   = $(Q:@=@echo    '     CHECK    '$<;)
-QUIET_AR      = $(Q:@=@echo    '     AR       '$@;)
-QUIET_GEN     = $(Q:@=@echo    '     GEN      '$@;)
-QUIET_LINK    = $(Q:@=@echo    '     LINK     '$@;)
+QUIET_CC      = $(Q:@=@echo    "  CC      $@";)
+QUIET_CHECK   = $(Q:@=@echo    "  CHECK   $<";)
+QUIET_AR      = $(Q:@=@echo    "  AR      $@";)
+QUIET_GEN     = $(Q:@=@echo    "  GEN     $@";)
+QUIET_LINK    = $(Q:@=@echo    "  LINK    $@";)
 # We rely on the -v switch of install to print 'file -> $install_dir/file'
-QUIET_INST    = $(Q:@=@echo -n '     INSTALL  ';)
+QUIET_INST    = $(Q:@=@echo -n "  INSTALL ";)
 
 
 compile_OBJS := compile-i386.o
@@ -204,7 +204,7 @@ version.h: FORCE
 	@if cmp -s version.h version.h.tmp; then \
 		rm version.h.tmp; \
 	else \
-		echo    '     GEN      '$@; \
+		echo "  GEN     $@"; \
 		mv version.h.tmp version.h; \
 	fi
 
@@ -216,7 +216,7 @@ check: all
 clean: clean-check
 	@rm -f *.[oa] .*.d $(PROGRAMS) version.h
 clean-check:
-	@echo '     CLEAN'
+	@echo "  CLEAN"
 	@find validation/ \( -name "*.c.output.expected" \
 	                 -o -name "*.c.output.got" \
 	                 -o -name "*.c.output.diff" \
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 31/38] build: simplify quiet commands
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (29 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 30/38] build: let quiet commands use less indentation Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 32/38] build: simplify clean pattern Luc Van Oostenryck
                   ` (7 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

The current mechanism for the quiet commands, what's
hiding the true command and emitting instead things like:
	CC      target.o
is, IMO, somehow unneedlessly sophisticated and this doesn't help
to understand what's happening and to adapt things when needed.

Change this by using simple 'echo' commands and make's '@' to
display the short command and hiding the long one.

Warning: There is a small change in behaviour with this:
  previously, when displaying the non-quiet commands with
  'make V=1' the quiet ones were not emitted. Now, with this
  patch, the short/quiet command is emitted in both case.

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

diff --git a/Makefile b/Makefile
index 5b3cd66f9..bf2f82042 100644
--- a/Makefile
+++ b/Makefile
@@ -159,13 +159,6 @@ LIBS := libsparse.a
 #
 V	      = @
 Q	      = $(V:1=)
-QUIET_CC      = $(Q:@=@echo    "  CC      $@";)
-QUIET_CHECK   = $(Q:@=@echo    "  CHECK   $<";)
-QUIET_AR      = $(Q:@=@echo    "  AR      $@";)
-QUIET_GEN     = $(Q:@=@echo    "  GEN     $@";)
-QUIET_LINK    = $(Q:@=@echo    "  LINK    $@";)
-# We rely on the -v switch of install to print 'file -> $install_dir/file'
-QUIET_INST    = $(Q:@=@echo -n "  INSTALL ";)
 
 
 compile_OBJS := compile-i386.o
@@ -176,10 +169,12 @@ ldflags += $($(@)-ldflags) $(LDFLAGS)
 ldlibs  += $($(@)-ldlibs)  $(LDLIBS)
 $(foreach p,$(PROGRAMS),$(eval $(p): $($(p)-objs)))
 $(PROGRAMS): % : %.o $(LIBS)
-	$(QUIET_LINK)$(LD) $(ldflags) $^ $(ldlibs) -o $@
+	@echo "  LD      $@"
+	$(Q)$(LD) $(ldflags) $^ $(ldlibs) -o $@
 
 libsparse.a: $(LIB_OBJS)
-	$(QUIET_AR)$(AR) rcs $@ $^
+	@echo "  AR      $@"
+	$(Q)$(AR) rcs $@ $^
 
 OBJS := $(LIB_OBJS) $(PROGRAMS:%=%.o) $(foreach p,$(PROGRAMS),$($(p)-objs))
 DEPS := $(OBJS:%.o=.%.o.d)
@@ -189,10 +184,12 @@ DEPS := $(OBJS:%.o=.%.o.d)
 
 cflags   += $($(*)-cflags) $(CPPFLAGS) $(CFLAGS)
 %.o: %.c
-	$(QUIET_CC)$(CC) $(cflags) -c -o $@ $<
+	@echo "  CC      $@"
+	$(Q)$(CC) $(cflags) -c -o $@ $<
 
 %.sc: %.c sparse
-	$(QUIET_CHECK) $(CHECKER) $(CHECKER_FLAGS) $(cflags) -c $<
+	@echo "  CHECK   $<"
+	$(Q) $(CHECKER) $(CHECKER_FLAGS) $(cflags) -c $<
 
 selfcheck: $(OBJS:.o=.sc)
 
@@ -234,8 +231,10 @@ install-bin: $(INST_PROGRAMS:%=$(DESTDIR)$(BINDIR)/%)
 install-man: $(INST_MAN1:%=$(DESTDIR)$(MAN1DIR)/%)
 
 $(DESTDIR)$(BINDIR)/%: %
-	$(QUIET_INST)install -v        $< $@ || exit 1;
+	@echo "  INSTALL $@"
+	$(Q)install        $< $@ || exit 1;
 $(DESTDIR)$(MAN1DIR)/%: %
-	$(QUIET_INST)install -v -m 644 $< $@ || exit 1;
+	@echo "  INSTALL $@"
+	$(Q)install -m 644 $< $@ || exit 1;
 
 .PHONY: FORCE
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 32/38] build: simplify clean pattern
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (30 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 31/38] build: simplify quiet commands Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 33/38] build: add *.o to clean-check pattern Luc Van Oostenryck
                   ` (6 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

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

diff --git a/Makefile b/Makefile
index bf2f82042..d0e616ba5 100644
--- a/Makefile
+++ b/Makefile
@@ -214,13 +214,9 @@ clean: clean-check
 	@rm -f *.[oa] .*.d $(PROGRAMS) version.h
 clean-check:
 	@echo "  CLEAN"
-	@find validation/ \( -name "*.c.output.expected" \
-	                 -o -name "*.c.output.got" \
-	                 -o -name "*.c.output.diff" \
-	                 -o -name "*.c.error.expected" \
-	                 -o -name "*.c.error.got" \
-	                 -o -name "*.c.error.diff" \
-	                 \) -exec rm {} \;
+	@find validation/ \( -name "*.c.output.*" \
+			  -o -name "*.c.error.*" \
+	                  \) -exec rm {} \;
 
 
 install: $(INST_PROGRAMS) $(INST_MAN1) install-dirs install-bin install-man
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 33/38] build: add *.o to clean-check pattern
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (31 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 32/38] build: simplify clean pattern Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 34/38] build: avoid foreach Luc Van Oostenryck
                   ` (5 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

.o files are also created in the validation directory
(currently only tmp.o, for sparse-llvm/sparsec testing).

Aso remove them during make clean-check.

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

diff --git a/Makefile b/Makefile
index d0e616ba5..e57934c92 100644
--- a/Makefile
+++ b/Makefile
@@ -216,6 +216,7 @@ clean-check:
 	@echo "  CLEAN"
 	@find validation/ \( -name "*.c.output.*" \
 			  -o -name "*.c.error.*" \
+			  -o -name "*.o" \
 	                  \) -exec rm {} \;
 
 
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 34/38] build: avoid foreach
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (32 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 33/38] build: add *.o to clean-check pattern Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 35/38] build: reorg & add comment Luc Van Oostenryck
                   ` (4 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

(g)make foreach can be quite handy but it also make
Makefiles much less declarative and thus harder to read.

Avoid them by adding the few needed assignments & dependencies.

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

diff --git a/Makefile b/Makefile
index e57934c92..d67f54afe 100644
--- a/Makefile
+++ b/Makefile
@@ -85,6 +85,9 @@ cflags += -DGCC_BASE=\"$(GCC_BASE)\"
 MULTIARCH_TRIPLET := $(shell $(CC) -print-multiarch 2>/dev/null)
 cflags += -DMULTIARCH_TRIPLET=\"$(MULTIARCH_TRIPLET)\"
 
+compile: compile-i386.o
+EXTRA_OBJS += compile-i386.o
+
 # Can we use GCC's generated dependencies?
 HAVE_GCC_DEP:=$(shell touch .gcc-test.c && 				\
 		$(CC) -c -Wp,-MD,.gcc-test.d .gcc-test.c 2>/dev/null && \
@@ -113,13 +116,15 @@ HAVE_GTK:=$(shell $(PKG_CONFIG) --exists gtk+-$(GTK_VERSION) 2>/dev/null && echo
 endif
 ifeq ($(HAVE_GTK),yes)
 GTK_CFLAGS := $(shell $(PKG_CONFIG) --cflags gtk+-$(GTK_VERSION))
-GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-$(GTK_VERSION))
+ast-view-cflags := $(GTK_CFLAGS)
+ast-model-cflags := $(GTK_CFLAGS)
+ast-inspect-cflags := $(GTK_CFLAGS)
+test-inspect-cflags := $(GTK_CFLAGS)
+test-inspect-ldlibs := $(shell $(PKG_CONFIG) --libs gtk+-$(GTK_VERSION))
+test-inspect: ast-model.o ast-view.o ast-inspect.o
+EXTRA_OBJS += ast-model.o ast-view.o ast-inspect.o
 PROGRAMS += test-inspect
 INST_PROGRAMS += test-inspect
-test-inspect-objs := test-inspect.o
-test-inspect-objs += ast-model.o ast-view.o ast-inspect.o
-$(foreach p,$(test-inspect-objs:.o=),$(eval $(p)-cflags := $(GTK_CFLAGS)))
-test-inspect-ldlibs := $(GTK_LIBS)
 else
 $(warning Your system does not have gtk3/gtk2, disabling test-inspect)
 endif
@@ -161,13 +166,10 @@ V	      = @
 Q	      = $(V:1=)
 
 
-compile_OBJS := compile-i386.o

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 35/38] build: reorg & add comment
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (33 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 34/38] build: avoid foreach Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 36/38] build: use a single space before assignments Luc Van Oostenryck
                   ` (3 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

No functionnal changes here, only shuffling a few lines around,
adding separators and adding a few comments

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

diff --git a/Makefile b/Makefile
index d67f54afe..92bf9e726 100644
--- a/Makefile
+++ b/Makefile
@@ -85,6 +85,9 @@ cflags += -DGCC_BASE=\"$(GCC_BASE)\"
 MULTIARCH_TRIPLET := $(shell $(CC) -print-multiarch 2>/dev/null)
 cflags += -DMULTIARCH_TRIPLET=\"$(MULTIARCH_TRIPLET)\"
 
+########################################################################
+# target specificities
+
 compile: compile-i386.o
 EXTRA_OBJS += compile-i386.o
 
@@ -157,15 +160,15 @@ else
 $(warning Your system does not have llvm, disabling sparse-llvm)
 endif
 
+########################################################################
 LIBS := libsparse.a
+OBJS := $(LIB_OBJS) $(EXTRA_OBJS) $(PROGRAMS:%=%.o)
 
-#
 # Pretty print
-#
 V	      = @
 Q	      = $(V:1=)
 
-
+########################################################################
 all: $(PROGRAMS)
 
 ldflags += $($(@)-ldflags) $(LDFLAGS)
@@ -178,11 +181,6 @@ libsparse.a: $(LIB_OBJS)
 	@echo "  AR      $@"
 	$(Q)$(AR) rcs $@ $^
 
-OBJS := $(LIB_OBJS) $(EXTRA_OBJS) $(PROGRAMS:%=%.o)
-DEPS := $(OBJS:%.o=.%.o.d)
-
--include $(DEPS)

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 36/38] build: use a single space before assignments
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (34 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 35/38] build: reorg & add comment Luc Van Oostenryck
@ 2017-11-11 14:24 ` Luc Van Oostenryck
  2017-11-11 14:24 ` [PATCH v4 37/38] build: add rule to run a single test Luc Van Oostenryck
                   ` (2 subsequent siblings)
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

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

diff --git a/Makefile b/Makefile
index 92bf9e726..2c70d904b 100644
--- a/Makefile
+++ b/Makefile
@@ -165,8 +165,8 @@ LIBS := libsparse.a
 OBJS := $(LIB_OBJS) $(EXTRA_OBJS) $(PROGRAMS:%=%.o)
 
 # Pretty print
-V	      = @
-Q	      = $(V:1=)
+V := @
+Q := $(V:1=)
 
 ########################################################################
 all: $(PROGRAMS)
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 37/38] build: add rule to run a single test
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (35 preceding siblings ...)
  2017-11-11 14:24 ` [PATCH v4 36/38] build: use a single space before assignments Luc Van Oostenryck
@ 2017-11-11 14:24 ` 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
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

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

diff --git a/Makefile b/Makefile
index 2c70d904b..a2d3e8c89 100644
--- a/Makefile
+++ b/Makefile
@@ -208,6 +208,8 @@ version.h: FORCE
 
 check: all
 	$(Q)cd validation && ./test-suite
+validation/%.t: FORCE
+	@validation/test-suite single $*.c
 
 
 clean: clean-check
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 38/38] build: let -fno-strict-aliasing be a mandatory flag
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (36 preceding siblings ...)
  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 ` Luc Van Oostenryck
  2017-11-17  9:23 ` [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-11 14:24 UTC (permalink / raw)
  To: linux-sparse
  Cc: Luc Van Oostenryck, Uwe Kleine-König, Jeff Layton,
	Josh Triplett, Ramsay Jones

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 Makefile | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index a2d3e8c89..f26c1f962 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ OS = linux
 
 
 CC = gcc
-CFLAGS = -O2 -finline-functions -fno-strict-aliasing -g
+CFLAGS = -O2 -finline-functions -g
 CFLAGS += -Wall -Wwrite-strings
 LD = gcc
 AR = ar
@@ -79,6 +79,11 @@ INST_MAN1=sparse.1 cgcc.1
 
 all:
 
+########################################################################
+# common flags/options/...
+
+cflags = -fno-strict-aliasing
+
 GCC_BASE := $(shell $(CC) --print-file-name=)
 cflags += -DGCC_BASE=\"$(GCC_BASE)\"
 
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 00/38] Makefile reognization
  2017-11-11 14:23 [PATCH v4 00/38] Makefile reognization Luc Van Oostenryck
                   ` (37 preceding siblings ...)
  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 ` Luc Van Oostenryck
  38 siblings, 0 replies; 40+ messages in thread
From: Luc Van Oostenryck @ 2017-11-17  9:23 UTC (permalink / raw)
  To: linux-sparse
  Cc: Uwe Kleine-König, Jeff Layton, Josh Triplett, Ramsay Jones

On Sat, Nov 11, 2017 at 03:23:59PM +0100, Luc Van Oostenryck wrote:
> The goal of this series is to reorganize sparse's Makefile
> in order to offer a few features asked by the distros:
> 1) allow CFLAGS & CPPFLAGS to be taken from the command line
> 2) allow PREFIX to be taken from the environment
> Support for pkg-config is removed as well as some old crufts.
> 
> This cleanup is based on a previous series by Uwe Kleine-König
> and further inspired by a patch and a need from Jeff Layton.
> 
> The changes since v1 are:
> *) fold the two patches concerning the removal of shared lib support
> *) remove the patch using git-clean for 'make clean'
> 
> The changes since v2 are:
> *) change a commit message to make explicit the fact that
>    quiet's commands abbreviated part are also issued for V=1
> *) add a convenience rule for running a single test via:
>         make validation/<name-of-testfile>.t
> 
> The changes since v3 are:
> *) make the name 'local.mk' be configurable instead of
>    the renaming that was done.
> *) move '-fno-strict-aliasing' out of the overridable CFLAGS
> *) rename the ...{_OBJS,_LDFLAGS,_LDLIBS} to ...{-objs,-ldflags,-ldlibs}
>    to be consistent about the private 'cflags'.

This has now been pushed to my dev tree at:
	git://github.com/lucvoo/sparse.git master

-- Luc Van Oostenryck 

^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2017-11-17  9:23 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH v4 10/38] build: allow target-specific CFLAGS, CPPFLAGS, LDFLAGS & LDLIBS Luc Van Oostenryck
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

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).