]> git.sesse.net Git - plocate/commitdiff
Switch build systems to Meson.
authorSteinar H. Gunderson <steinar+git@gunderson.no>
Thu, 8 Oct 2020 08:09:56 +0000 (10:09 +0200)
committerSteinar H. Gunderson <steinar+git@gunderson.no>
Thu, 8 Oct 2020 08:28:36 +0000 (10:28 +0200)
Makefile [deleted file]
README
meson.build [new file with mode: 0644]

diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index dc96d75..0000000
--- a/Makefile
+++ /dev/null
@@ -1,39 +0,0 @@
-CC ?= gcc
-CXX ?= g++
-CXXFLAGS ?= -O2 -g -Wall -std=gnu++17
-CPPFLAGS=-ITurboPFor-Integer-Compression/
-LDFLAGS ?=
-INSTALL ?= install
-PREFIX ?= /usr/local
-URING_LIBS = $(shell pkg-config --libs liburing)
-
-ifeq ($(URING_LIBS),)
-  CPPFLAGS += -DWITHOUT_URING
-endif
-
-all: plocate plocate-build
-
-plocate: plocate.o io_uring_engine.o
-       $(CXX) -o $@ $^ -lzstd $(URING_LIBS) $(LDFLAGS)
-
-plocate-build: plocate-build.o
-       $(CXX) -o $@ $^ -lzstd $(LDFLAGS)
-
-clean:
-       $(RM) plocate.o plocate-build.o io_uring_engine.o bench.o plocate plocate-build bench
-       ! [ -d TurboPFor-Integer-Compression/ ] || ( cd TurboPFor-Integer-Compression/ && $(MAKE) clean )
-
-install: all
-       $(INSTALL) -m 2755 -g mlocate plocate $(PREFIX)/bin/
-       $(INSTALL) -m 0755 plocate-build $(PREFIX)/sbin/
-       $(INSTALL) -m 0755 update-plocate.sh /etc/cron.daily/plocate
-
-bench.o: bench.cpp turbopfor.h
-
-TurboPFor-Integer-Compression/libic.a:
-       cd TurboPFor-Integer-Compression/ && $(MAKE)
-
-bench: bench.o io_uring_engine.o TurboPFor-Integer-Compression/libic.a
-       $(CXX) -o $@ $^ $(URING_LIBS) $(LDFLAGS)
-
-.PHONY: clean install
diff --git a/README b/README
index bae21703fdf73e8fe429bf429347df054722090a..64d9522a5a6b393fc5c539bfd4371de257ef9619 100644 (file)
--- a/README
+++ b/README
@@ -2,13 +2,20 @@ plocate, a locate based on posting lists, consuming mlocate inputs
 and making a much faster index. Does not support querying by regex,
 case-insensitivity or really any options.
 
-Alpha stage; file format is subject to change. To build, run make.
+Alpha stage; file format is subject to change. To build, run
+
+  meson obj
+  cd obj
+  ninja
 
 If you wish to run some tests of the TurboPFor implementation against
 the reference implementation, you can run:
 
   git clone https://github.com/powturbo/TurboPFor-Integer-Compression
-  make -j8 bench
+  ( cd TurboPFor-Integer-Compression && make -j8 )
+  cd obj
+  ninja reconfigure
+  ninja bench
 
 Copyright 2020 Steinar H. Gunderson <steinar+git@gunderson.no>.
 Licensed under the GNU General Public License, either version 2,
diff --git a/meson.build b/meson.build
new file mode 100644 (file)
index 0000000..e8c37f0
--- /dev/null
@@ -0,0 +1,37 @@
+project('plocate', 'cpp', default_options: ['buildtype=debugoptimized','cpp_std=c++17'], version: '1.0.0-pre')
+
+cxx = meson.get_compiler('cpp')
+uringdep = dependency('liburing', required: false)
+zstddep = dependency('libzstd')
+
+if not uringdep.found()
+       add_project_arguments('-DWITHOUT_URING', language: 'cpp')
+endif
+
+executable('plocate', ['plocate.cpp', 'io_uring_engine.cpp'],
+       dependencies: [uringdep, zstddep],
+       install: true,
+       install_mode: ['rwxr-sr-x', 'root', 'mlocate'])
+executable('plocate-build', 'plocate-build.cpp',
+       dependencies: [zstddep],
+       install: true,
+       install_dir: get_option('sbindir'))
+
+install_data('update-plocate.sh',
+       install_dir: '/etc/cron.daily',
+       rename: 'plocate')
+
+# Requires having TurboPFor checked out, so not built by default.
+# Unless you have a recent Meson, there's no apparently good way
+# of calling into that directory to run make, and we're not
+# replicating their build system, so it has to be manual.
+pfordir = meson.source_root() + '/TurboPFor-Integer-Compression'
+if run_command('[', '-r', pfordir + '/libic.a', ']').returncode() == 0
+       turbopfordep = declare_dependency(
+               include_directories: include_directories('TurboPFor-Integer-Compression'),
+               dependencies: meson.get_compiler('cpp').find_library('ic', dirs: pfordir))
+       executable('bench', ['bench.cpp', 'io_uring_engine.cpp'],
+               dependencies: [uringdep, turbopfordep],
+               build_by_default: false,
+               install: false)
+endif