diff --git a/.gitignore b/.gitignore
index 970419f..3fd2446 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,24 +1,3 @@
*.o
*.swp
package-query
-pq
-src/.deps/*
-aclocal.m4
-autom4te.cache
-compile
-config.guess
-config.h
-config.h.in
-config.log
-config.status
-config.sub
-configure
-depcomp
-install-sh
-libtool
-ltmain.sh
-Makefile
-Makefile.in
-m4/*
-missing
-stamp-h1
diff --git a/ChangeLog b/ChangeLog
deleted file mode 100644
index e69de29..0000000
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index c83c34a..0000000
--- a/Makefile.am
+++ /dev/null
@@ -1,4 +0,0 @@
-SUBDIRS = src doc
-
-ACLOCAL_AMFLAGS = -I m4
-
diff --git a/NEWS b/NEWS
deleted file mode 100644
index e69de29..0000000
diff --git a/autogen.sh b/autogen.sh
deleted file mode 100755
index 6cd70d8..0000000
--- a/autogen.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh -x
-
-libtoolize
-aclocal -I m4 --install
-autoheader
-automake --foreign --add-missing
-autoconf
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index 64fe693..0000000
--- a/configure.ac
+++ /dev/null
@@ -1,83 +0,0 @@
-# -*- Autoconf -*-
-# Process this file with autoconf to produce a configure script.
-
-AC_PREREQ(2.69)
-AC_INIT([package-query], [1.9], [https://github.com/archlinuxfr/package-query])
-AM_INIT_AUTOMAKE([-Wall])
-AC_CONFIG_MACRO_DIR([m4])
-AC_CONFIG_SRCDIR([src/package-query.c])
-AC_CONFIG_HEADER([config.h])
-
-
-
-AC_PROG_CC
-AC_PROG_LIBTOOL
-
-# Checks for header files.
-AC_CHECK_HEADERS([ctype.h getopt.h glob.h libintl.h limits.h locale.h regex.h signal.h sys/ioctl.h sys/stat.h sys/utsname.h])
-
-AC_CHECK_LIB([alpm], [alpm_version], ,
- AC_MSG_ERROR([pacman is needed to compile package-query]))
-PKG_CHECK_MODULES([alpm], [libalpm >= 11.0.0])
-
-AC_CHECK_LIB([yajl], [yajl_free], ,
- AC_MSG_ERROR([yajl is needed to compile package-query]))
-
-LIBCURL_CHECK_CONFIG([yes], [7.19.4])
-
-usegitver=no
-gitver=""
-AC_CHECK_PROGS([GIT], [git])
-if test "$GIT"; then
- AC_CHECK_FILE([.git/], hasgitdir=yes)
- if test "x$hasgitdir" = "xyes"; then
- gitver=$(git describe --abbrev=4)
- usegitver=yes
- AC_DEFINE([USE_GIT_VERSION], , [Use GIT version in version string])
- AC_SUBST([GIT_VERSION], [$gitver])
- fi
-fi
-AM_CONDITIONAL(USE_GIT_VERSION, test "x$usegitver" = "xyes")
-
-# Help line for root directory
-AC_ARG_WITH(root-dir,
- AS_HELP_STRING([--with-root-dir=path], [see pacman configuration]),
- [ROOTDIR=$withval], [ROOTDIR=/])
-
-AC_SUBST(ROOTDIR)
-
-AC_ARG_WITH(aur-url,
- AS_HELP_STRING([--with-aur-url=url], [default to https://aur.archlinux.org]),
- [AUR_BASE_URL=$withval], [AUR_BASE_URL=https://aur.archlinux.org])
-
-AC_SUBST(AUR_BASE_URL)
-AC_CONFIG_FILES([src/Makefile
-doc/Makefile
-Makefile
-])
-AC_OUTPUT
-
-echo "
-${PACKAGE_NAME}:
-
- Build information:
- source code location : ${srcdir}
- prefix : ${prefix}
- sysconfdir : $(eval echo ${sysconfdir})
- conf file : $(eval echo ${sysconfdir})/pacman.conf
- localstatedir : $(eval echo ${localstatedir})
- database dir : $(eval echo ${localstatedir})/lib/pacman/
- compiler : ${CC}
- compiler flags : ${CFLAGS}
-
- package-query version : ${PACKAGE_VERSION}
- using git version : ${usegitver}
- git ver : ${gitver}
-
- Variable information:
- root working directory : ${ROOTDIR}
- aur base url : ${AUR_BASE_URL}
-"
-
-
-
diff --git a/doc/Makefile.am b/doc/Makefile.am
deleted file mode 100644
index cb4eaf2..0000000
--- a/doc/Makefile.am
+++ /dev/null
@@ -1,4 +0,0 @@
-man_MANS =
-dist_man_MANS = package-query.8
-
-
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..914f1ae
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,137 @@
+project(
+ 'package-query', 'c',
+ version: '1.9',
+ license: 'GPL-2.0-or-later',
+ default_options: [
+ 'warning_level=2',
+ ],
+)
+
+compiler = meson.get_compiler('c')
+
+add_project_arguments(
+ '-D_GNU_SOURCE',
+ language: 'c'
+)
+
+# Checks for libraries
+alpm_dep = dependency ('libalpm', version: '>= 11.0.0')
+yajl_dep = dependency ('yajl')
+curl_dep = dependency ('libcurl', version: '>= 7.19.4')
+
+# Checks for header files
+check_headers = [
+ 'ctype.h',
+ 'getopt.h',
+ 'glob.h',
+ 'libintl.h',
+ 'limits.h',
+ 'locale.h',
+ 'regex.h',
+ 'signal.h',
+ 'sys/ioctl.h',
+ 'sys/stat.h',
+ 'sys/utsname.h',
+]
+
+foreach h: check_headers
+ if not compiler.has_header(h)
+ error('Header file @0@ not found.'.format(h))
+ endif
+endforeach
+
+# Define build configuration
+package_query_conf_data = configuration_data()
+
+aur_base_url = get_option('aur-url')
+root_dir = get_option('root-dir')
+pacman_conf = join_paths(get_option('prefix'), get_option('sysconfdir'), 'pacman.conf')
+pacman_db_path = join_paths(get_option('prefix'), get_option('localstatedir'), 'lib', 'pacman')
+
+package_query_conf_data.set_quoted('PACKAGE_NAME', meson.project_name())
+package_query_conf_data.set_quoted('PACKAGE_VERSION', meson.project_version())
+package_query_conf_data.set_quoted('AUR_BASE_URL', aur_base_url)
+package_query_conf_data.set_quoted('CONFFILE', pacman_conf)
+package_query_conf_data.set_quoted('DBPATH', pacman_db_path)
+package_query_conf_data.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
+package_query_conf_data.set_quoted('ROOTDIR', root_dir)
+
+# Compute git version
+git = find_program('git', required: false)
+
+if git.found()
+ git_describe = run_command(
+ git.path(),
+ '-C', meson.current_source_dir(),
+ 'describe', '--abbrev=4',
+ )
+endif
+
+if git.found() and git_describe.returncode() == 0
+ use_git_version = true
+ package_query_git_version = git_describe.stdout().strip()
+else
+ use_git_version = false
+ package_query_git_version = ''
+endif
+
+package_query_conf_data.set('USE_GIT_VERSION', use_git_version)
+package_query_conf_data.set_quoted('GIT_VERSION', package_query_git_version)
+
+# Generate config.h
+configure_file(
+ configuration: package_query_conf_data,
+ output: 'config.h',
+)
+
+# package-query executable
+package_query_sources = [
+ 'src/alpm-query.c',
+ 'src/alpm-query.h',
+ 'src/aur.c',
+ 'src/aur.h',
+ 'src/color.c',
+ 'src/color.h',
+ 'src/package-query.c',
+ 'src/util.c',
+ 'src/util.h',
+]
+
+package_query_dependencies = [
+ alpm_dep,
+ yajl_dep,
+ curl_dep,
+]
+
+executable(
+ 'package-query',
+ sources: package_query_sources,
+ dependencies: package_query_dependencies,
+ install: true,
+)
+
+# Man page
+install_man('doc/package-query.8')
+
+# Configuration summary
+message(
+ '\n@0@:\n'.format(meson.project_name())
+ + '\n'
+ + ' Build information:\n'
+ + ' source code location : @0@\n'.format(meson.current_source_dir())
+ + ' prefix : @0@\n'.format(get_option('prefix'))
+ + ' sysconfdir : @0@\n'.format(join_paths(get_option('prefix'), get_option('sysconfdir')))
+ + ' conf file : @0@\n'.format(pacman_conf)
+ + ' localstatedir : @0@\n'.format(join_paths(get_option('prefix'), get_option('localstatedir')))
+ + ' database dir : @0@\n'.format(pacman_db_path)
+ + ' compiler : @0@\n'.format(compiler.get_id())
+ + ' compilation type : @0@\n'.format(get_option('buildtype'))
+ + '\n'
+ + ' package-query version : @0@\n'.format(meson.project_version())
+ + ' using git version : @0@\n'.format(use_git_version)
+ + ' git ver : @0@\n'.format(package_query_git_version)
+ + '\n'
+ + ' Variable information:\n'
+ + ' root working directory : @0@\n'.format(root_dir)
+ + ' aur base url : @0@\n'.format(aur_base_url)
+)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..ddd262d
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,13 @@
+option(
+ 'aur-url',
+ description: 'AUR url',
+ type: 'string',
+ value: 'https://aur.archlinux.org'
+)
+
+option(
+ 'root-dir',
+ description: 'see pacman configuration',
+ type: 'string',
+ value: '/'
+)
diff --git a/src/Makefile.am b/src/Makefile.am
deleted file mode 100644
index 11eb67e..0000000
--- a/src/Makefile.am
+++ /dev/null
@@ -1,26 +0,0 @@
-# paths set at make time
-conffile = ${sysconfdir}/pacman.conf
-dbpath = ${localstatedir}/lib/pacman/
-
-AM_CFLAGS = -D_GNU_SOURCE
-AM_LDFLAGS = $(LIBCURL) $(LIBINTL)
-
-DEFS = -DLOCALEDIR=\"@localedir@\" \
- -DCONFFILE=\"$(conffile)\" \
- -DROOTDIR=\"$(ROOTDIR)\" \
- -DDBPATH=\"$(dbpath)\" \
- -DAUR_BASE_URL=\"$(AUR_BASE_URL)\" \
- @DEFS@
-if USE_GIT_VERSION
-DEFS += -DGIT_VERSION=\"$(GIT_VERSION)\"
-endif
-bin_PROGRAMS = package-query
-
-
-package_query_SOURCES = aur.h aur.c \
- alpm-query.h alpm-query.c \
- util.h util.c \
- color.h color.c \
- package-query.c
-
-
diff --git a/src/alpm-query.c b/src/alpm-query.c
index 0df1e49..65dd313 100644
--- a/src/alpm-query.c
+++ b/src/alpm-query.c
@@ -16,6 +16,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+#include "config.h"
+
#include
#include
#include
diff --git a/src/package-query.c b/src/package-query.c
index b185f72..64c81aa 100644
--- a/src/package-query.c
+++ b/src/package-query.c
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-#include
+#include "config.h"
#if defined(GIT_VERSION)
#undef PACKAGE_VERSION
#define PACKAGE_VERSION GIT_VERSION