Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to meson buildsystem #139

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Empty file removed ChangeLog
Empty file.
4 changes: 0 additions & 4 deletions Makefile.am

This file was deleted.

Empty file removed NEWS
Empty file.
7 changes: 0 additions & 7 deletions autogen.sh

This file was deleted.

83 changes: 0 additions & 83 deletions configure.ac

This file was deleted.

4 changes: 0 additions & 4 deletions doc/Makefile.am

This file was deleted.

137 changes: 137 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -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)
)
13 changes: 13 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -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: '/'
)
26 changes: 0 additions & 26 deletions src/Makefile.am

This file was deleted.

2 changes: 2 additions & 0 deletions src/alpm-query.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
Expand Down
2 changes: 1 addition & 1 deletion src/package-query.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <config.h>
#include "config.h"
#if defined(GIT_VERSION)
#undef PACKAGE_VERSION
#define PACKAGE_VERSION GIT_VERSION
Expand Down