public inbox for smatch@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Makefile: Install database in a share directory
@ 2020-06-10  3:08 Gwendal Grignou
  2020-06-10 18:08 ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Gwendal Grignou @ 2020-06-10  3:08 UTC (permalink / raw)
  To: error27; +Cc: smatch, groeck, Gwendal Grignou

'make install' installs the database .schema files and other assets at
$DESTDIR/$(SHAREDIR)/smatch/smatch_data,
/usr/share/smatch/smatch_data by default.

This way the source code tree does not need to be present to run smatch,
and --data is not required as smatch is compiled to look for data assets
at the above location, in addition to the local directory.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
 Makefile | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile
index ec3a5a84..452e2537 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,8 @@ CFLAGS ?= -g
 DESTDIR ?=
 PREFIX ?= $(HOME)
 BINDIR ?= $(PREFIX)/bin
-MANDIR ?= $(PREFIX)/share/man
+SHAREDIR ?= $(PREFIX)/share
+MANDIR ?= $(SHAREDIR)/man
 
 PKG_CONFIG ?= pkg-config
 
@@ -85,9 +86,11 @@ PROGRAMS += test-linearize
 PROGRAMS += test-parsing
 PROGRAMS += test-unssa
 
-INST_PROGRAMS=smatch sparse cgcc
-INST_MAN1=sparse.1 cgcc.1
-
+INST_PROGRAMS = smatch sparse cgcc
+INST_MAN1 = sparse.1 cgcc.1
+INST_ASSETS = $(wildcard smatch_data/db/*.schema)
+INST_ASSETS += $(wildcard smatch_data/*)
+INST_ASSETS += $(wildcard smatch_data/db/kernel.*)
 
 all:
 
@@ -106,6 +109,7 @@ cflags += -DMULTIARCH_TRIPLET=\"$(MULTIARCH_TRIPLET)\"
 
 bindir := $(DESTDIR)$(BINDIR)
 man1dir := $(DESTDIR)$(MANDIR)/man1
+smatch_datadir := $(DESTDIR)$(SHAREDIR)/smatch
 
 ########################################################################
 # target specificities
@@ -197,8 +201,6 @@ Q := $(V:1=)
 
 ########################################################################
 
-SMATCHDATADIR=$(INSTALL_PREFIX)/share/smatch
-
 SMATCH_OBJS :=
 SMATCH_OBJS += avl.o
 SMATCH_OBJS += smatch_about_fn_ptr_arg.o
@@ -317,7 +319,7 @@ check_list_local.h:
 	touch check_list_local.h
 
 smatch.o: smatch.c $(LIB_H) smatch.h check_list.h check_list_local.h
-	$(CC) $(CFLAGS) -c smatch.c -DSMATCHDATADIR='"$(SMATCHDATADIR)"'
+	$(CC) $(CFLAGS) -c smatch.c -DSMATCHDATADIR='"$(smatch_datadir)"'
 
 $(SMATCH_OBJS) $(SMATCH_CHECKS): smatch.h smatch_slist.h smatch_extra.h avl.h
 
@@ -375,14 +377,15 @@ clean-check:
 	                  \) -exec rm {} \;
 
 
-install: install-bin install-man
+install: install-bin install-man install-assets
 install-bin: $(INST_PROGRAMS:%=$(bindir)/%)
 install-man: $(INST_MAN1:%=$(man1dir)/%)
+install-assets: $(INST_ASSETS:%=$(smatch_datadir)/%)
 
 $(bindir)/%: %
 	@echo "  INSTALL $@"
 	$(Q)install -D        $< $@ || exit 1;
-$(man1dir)/%: %
+$(man1dir)/% $(smatch_datadir)/%: %
 	@echo "  INSTALL $@"
 	$(Q)install -D -m 644 $< $@ || exit 1;
 
-- 
2.27.0.290.gba653c62da-goog

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

end of thread, other threads:[~2020-08-24  8:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-10  3:08 [PATCH] Makefile: Install database in a share directory Gwendal Grignou
2020-06-10 18:08 ` Dan Carpenter
2020-08-24  5:22   ` Gwendal Grignou
2020-08-24  8:54     ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox