From cd039dbe697f95601f04ce4e93306074ea97346c Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 8 Oct 2020 10:09:56 +0200 Subject: [PATCH] Switch build systems to Meson. --- Makefile | 39 --------------------------------------- README | 11 +++++++++-- meson.build | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 41 deletions(-) delete mode 100644 Makefile create mode 100644 meson.build diff --git a/Makefile b/Makefile deleted file mode 100644 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 bae2170..64d9522 100644 --- 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 . Licensed under the GNU General Public License, either version 2, diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..e8c37f0 --- /dev/null +++ b/meson.build @@ -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 -- 2.39.2