Commit 9fce9be3 authored by Iñigo Martínez's avatar Iñigo Martínez Committed by Kai Lüke

build: Port to meson build system

parent 42c6045d
icon_sizes = [
'16x16',
'22x22',
'24x24',
'32x32',
'48x48',
'256x256'
]
foreach icon_size: icon_sizes
install_data(
'hicolor/' + icon_size + '/gnome-disks.png',
install_dir: join_paths(gdu_datadir, 'icons', 'hicolor', icon_size, 'apps')
)
endforeach
scalable_icons = files(
'hicolor/scalable/gnome-disks-state-standby-symbolic.svg',
'hicolor/scalable/gnome-disks-symbolic.svg'
)
install_data(
scalable_icons,
install_dir: join_paths(gdu_datadir, 'icons', 'hicolor', 'scalable', 'apps')
)
subdir('icons')
desktops = [
'org.gnome.DiskUtility.desktop',
'gnome-disk-image-mounter.desktop',
'gnome-disk-image-writer.desktop'
]
foreach desktop: desktops
i18n.merge_file (
desktop,
type: 'desktop',
input: desktop + '.in',
output: desktop,
po_dir: po_dir,
install: true,
install_dir: join_paths(gdu_datadir, 'applications')
)
endforeach
service_conf = configuration_data()
service_conf.set('bindir', gdu_bindir)
service = 'org.gnome.DiskUtility.service'
configure_file(
input: service + '.in',
output: service,
install: true,
install_dir: join_paths(gdu_datadir, 'dbus-1', 'services'),
configuration: service_conf
)
install_data(
'org.gnome.Disks.gschema.xml',
install_dir: join_paths(gdu_datadir, 'glib-2.0', 'schemas')
)
info = 'org.gnome.DiskUtility.metainfo.xml'
i18n.merge_file(
info,
input: 'org.gnome.DiskUtility.appdata.xml.in',
output: info,
po_dir: po_dir,
install: true,
install_dir: join_paths(gdu_datadir, 'metainfo')
)
xsltproc_cmd = [
find_program('xsltproc'),
'--output', '@OUTPUT@',
'--nonet',
'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl',
'@INPUT@'
]
mans = [
'gnome-disks',
'gnome-disk-image-mounter'
]
foreach man: mans
output = man + '.1'
custom_target(
output,
input: man + '.xml',
output: output,
command: xsltproc_cmd,
install: true,
install_dir: join_paths(gdu_mandir, 'man1')
)
endforeach
project(
'GNOME Disk Utility', 'c',
version: '3.25.2',
license: 'GPL2.0',
default_options: [
'buildtype=debugoptimized',
'warning_level=1'
],
meson_version: '>= 0.41.0'
)
gdu_name = 'gnome-disk-utility'
gdu_version = meson.project_version()
gdu_prefix = get_option('prefix')
gdu_bindir = join_paths(gdu_prefix, get_option('bindir'))
gdu_datadir = join_paths(gdu_prefix, get_option('datadir'))
gdu_libexecdir = join_paths(gdu_prefix, get_option('libexecdir'))
gdu_localedir = join_paths(gdu_prefix, get_option('localedir'))
gdu_mandir = join_paths(gdu_prefix, get_option('mandir'))
gdu_sysconfdir = join_paths(gdu_prefix, get_option('sysconfdir'))
cc = meson.get_compiler('c')
config_h = configuration_data()
# package
set_defines = [
['PACKAGE', gdu_name],
['PACKAGE_BUGREPORT', 'http://bugzilla.gnome.org/enter_bug.cgi?product=' + gdu_name],
['PACKAGE_NAME', meson.project_name()],
['PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(), gdu_version)],
['PACKAGE_TARNAME', gdu_name],
['PACKAGE_URL', ''],
['PACKAGE_VERSION', gdu_version],
['VERSION', gdu_version],
['GETTEXT_PACKAGE', gdu_name]
]
foreach define: set_defines
config_h.set_quoted(define[0], define[1])
endforeach
# headers
check_headers = [
['HAVE_DLFCN_H', 'dlfcn.h'],
['HAVE_INTTYPES_H', 'inttypes.h'],
['HAVE_MEMORY_H', 'memory.h'],
['HAVE_STDINT_H', 'stdint.h'],
['HAVE_STDLIB_H', 'stdlib.h'],
['HAVE_STRINGS_H', 'strings.h'],
['HAVE_STRING_H', 'string.h'],
['HAVE_SYS_STAT_H', 'sys/stat.h'],
['HAVE_SYS_TYPES_H', 'sys/types.h'],
['HAVE_UNISTD_H', 'unistd.h']
]
foreach header: check_headers
if cc.has_header(header[1])
config_h.set(header[0], true)
endif
endforeach
# functions
check_functions = [
['HAVE_DCGETTEXT', 'dcgettext'],
['HAVE_GETTEXT', 'gettext'],
['HAVE_ICONV', 'iconv'],
['HAVE_MEMSET', 'memset'],
['HAVE_SETLOCALE', 'setlocale'],
['HAVE_STRSTR', 'strstr']
]
if host_machine.system().contains('darwin')
check_functions += [
['HAVE_CFLOCALECOPYCURRENT', 'CFLocaleCopyCurrent'],
['HAVE_CFPREFERENCESCOPYAPPVALUE', 'CFPreferencesCopyAppValue']
]
endif
foreach func: check_functions
if cc.has_function(func[1])
config_h.set(func[0], true)
endif
endforeach
message('Checking for valid fallocate() function')
fallocate_src = '''
#include <unistd.h>
#include <sys/types.h>
#include <linux/falloc.h>
#include <fcntl.h>
int main() {
long ret;
ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0xfffffffful, 0xfffffffful);
if (ret != 0) {
return 1;
}
};
'''
config_h.set('HAVE_FALLOCATE', cc.run(fallocate_src).returncode())
# compiler flags
common_flags = ['-DHAVE_CONFIG_H']
gdu_cflags = []
buildtype = get_option('buildtype')
if buildtype == 'debug' or buildtype == 'debugoptimized'
test_cflags = [
'-fno-strict-aliasing',
'-Wcast-align',
'-Wdeclaration-after-statement',
'-Wformat=2',
'-Winit-self',
'-Winline',
'-Wmissing-declarations',
'-Wmissing-format-attribute',
'-Wmissing-include-dirs',
'-Wmissing-noreturn',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wno-error=missing-field-initializers',
'-Wno-error=unused-parameter',
'-Wno-missing-field-initializers',
'-Wno-unused-parameter',
'-Wold-style-definition',
'-Wpacked',
'-Wredundant-decls',
'-Wshadow',
'-Wsign-compare',
'-Wstrict-aliasing',
'-Wstrict-prototypes',
'-Wswitch-default',
'-Wswitch-enum',
'-Wundef',
'-Wunused-but-set-variable',
'-Wwrite-strings'
]
foreach cflag: test_cflags
if cc.has_argument(cflag)
gdu_cflags += [cflag]
endif
endforeach
endif
add_project_arguments(common_flags + gdu_cflags, language: 'c')
gmodule_dep = dependency('gmodule-2.0')
gio_unix_dep = dependency('gio-unix-2.0', version: '>= 2.31.0')
udisk_dep = dependency('udisks2', version: '>= 2.1.1')
gtk_dep = dependency('gtk+-3.0', version: '>= 3.16.0')
libsecret_dep = dependency('libsecret-1', version: '>= 0.7')
pwquality_dep = dependency('pwquality', version: '>= 1.0.0')
libcanberra_dep = dependency('libcanberra-gtk3', version: '>= 0.1')
dvdread_dep = dependency('dvdread', version: '>= 4.2.0')
libnotify_dep = dependency('libnotify', version: '>= 0.7')
liblzma_dep = dependency('liblzma', version: '>= 5.0.5')
m_dep = cc.find_library('m')
# *** Check for libsystemd ***
enable_libsystemd = get_option('enable-libsystemd')
if enable_libsystemd
libsystemd_dep = dependency('libsystemd', version: '>= 209', required: false)
config_h.set('HAVE_LIBSYSTEMD', libsystemd_dep.found(),
description: 'Define to 1 if libsystemd is available')
endif
configure_file(
output: 'config.h',
configuration: config_h
)
gnome = import('gnome')
i18n = import('i18n')
po_dir = join_paths(meson.source_root(), 'po')
top_inc = include_directories('.', 'src')
subdir('src/libgdu')
subdir('src/disks')
subdir('src/disk-image-mounter')
# *** gnome-settings-daemon plug-in ***
enable_gsd_plugin = get_option('enable-gsd-plugin')
if enable_gsd_plugin
subdir('src/notify')
endif
subdir('data')
subdir('po')
subdir('doc/man')
meson.add_install_script('meson_post_install.py')
output = '\n gnome-disk-utility ' + gdu_version + '\n'
output += ' =========================\n\n'
output += ' prefix: ' + gdu_prefix + '\n'
output += ' bindir: ' + gdu_bindir + '\n'
output += ' datadir: ' + gdu_datadir + '\n'
output += ' libexecdir: ' + gdu_libexecdir + '\n'
output += ' localedir: ' + gdu_localedir + '\n'
output += ' mandir: ' + gdu_mandir + '\n'
output += ' sysconfdir: ' + gdu_sysconfdir + '\n\n'
output += ' Use libsystemd: ' + enable_libsystemd.to_string() + '\n'
output += ' Build g-s-d plug-in: ' + enable_gsd_plugin.to_string() + '\n\n'
output += ' compiler: ' + cc.get_id() + '\n'
output += ' cflags: ' + ' '.join(gdu_cflags) + '\n'
message(output)
option('enable-libsystemd', type: 'boolean', value: true, description: 'build with libsystemd')
option('enable-gsd-plugin', type: 'boolean', value: true, description: 'build gnome-settings-daemon plug-in')
#!/usr/bin/env python3
import os
import subprocess
install_prefix = os.environ['MESON_INSTALL_PREFIX']
icondir = os.path.join(install_prefix, 'share', 'icons', 'hicolor')
schemadir = os.path.join(install_prefix, 'share', 'glib-2.0', 'schemas')
if not os.environ.get('DESTDIR'):
print('Update icon cache...')
subprocess.call(['gtk-update-icon-cache', '-f', '-t', icondir])
print('Compiling gsettings schemas...')
subprocess.call(['glib-compile-schemas', schemadir])
i18n.gettext(gdu_name, preset: 'glib')
name = 'gnome-disk-image-mounter'
deps = [
gmodule_dep,
gio_unix_dep,
udisk_dep,
gtk_dep,
libgdu_dep
]
cflags = [
'-DPACKAGE_DATA_DIR="@0@"'.format(gdu_datadir),
'-DG_LOG_DOMAIN="@0@"'.format(name),
'-DGNOMELOCALEDIR="@0@"'.format(gdu_localedir)
]
executable(
name,
['main.c'] + libgduenumtypes,
include_directories: top_inc,
dependencies: deps,
c_args: cflags,
install: true,
install_dir: gdu_bindir
)
name = 'GNOME-Disks'
enum_headers = files('gduenums.h')
sources = files(
'gduapplication.c',
'gduatasmartdialog.c',
'gdubenchmarkdialog.c',
'gduchangepassphrasedialog.c',
'gducreatediskimagedialog.c',
'gducreatefilesystemwidget.c',
'gducreatepartitiondialog.c',
'gducrypttabdialog.c',
'gdudevicetreemodel.c',
'gdudisksettingsdialog.c',
'gdudvdsupport.c',
'gduestimator.c',
'gdufilesystemdialog.c',
'gduformatdiskdialog.c',
'gduformatvolumedialog.c',
'gdufstabdialog.c',
'gdulocaljob.c',
'gdunewdiskimagedialog.c',
'gdupartitiondialog.c',
'gdupasswordstrengthwidget.c',
'gdurestorediskimagedialog.c',
'gduunlockdialog.c',
'gduvolumegrid.c',
'gduwindow.c',
'gduxzdecompressor.c',
'main.c'
)
resource_data = files(
'ui/about-dialog.ui',
'ui/app-menu.ui',
'ui/benchmark-dialog.ui',
'ui/change-passphrase-dialog.ui',
'ui/create-disk-image-dialog.ui',
'ui/create-partition-dialog.ui',
'ui/disk-settings-dialog.ui',
'ui/disks.ui',
'ui/edit-crypttab-dialog.ui',
'ui/edit-dos-partition-dialog.ui',
'ui/edit-gpt-partition-dialog.ui',
'ui/edit-filesystem-dialog.ui',
'ui/edit-fstab-dialog.ui',
'ui/edit-partition-dialog.ui',
'ui/erase-multiple-disks-dialog.ui',
'ui/filesystem-create.ui',
'ui/format-disk-dialog.ui',
'ui/format-volume-dialog.ui',
'ui/gdu.css',
'ui/new-disk-image-dialog.ui',
'ui/restore-disk-image-dialog.ui',
'ui/smart-dialog.ui',
'ui/unlock-device-dialog.ui'
)
sources += gnome.compile_resources(
'resources',
'gnome-disks.gresource.xml',
source_dir: '.',
dependencies: resource_data,
export: true
)
enum = 'gduenumtypes'
sources += gnome.mkenums(
enum,
sources: enum_headers,
c_template: enum + '.c.template',
h_template: enum + '.h.template'
)
deps = [
gmodule_dep,
gio_unix_dep,
udisk_dep,
gtk_dep,
libsecret_dep,
pwquality_dep,
libcanberra_dep,
dvdread_dep,
liblzma_dep,
libgdu_dep,
m_dep
]
cflags = [
'-DPACKAGE_DATA_DIR="@0@"'.format(gdu_datadir),
'-DG_LOG_DOMAIN="@0@"'.format(name),
'-DGNOMELOCALEDIR="@0@"'.format(gdu_localedir)
]
executable(
name.to_lower(),
sources,
include_directories: top_inc,
dependencies: deps,
c_args: cflags,
install: true,
install_dir: gdu_bindir
)
enum_headers = files('libgduenums.h')
sources = files('gduutils.c')
enum = 'libgduenumtypes'
libgduenumtypes = gnome.mkenums(
enum,
sources: enum_headers,
c_template: enum + '.c.template',
h_template: enum + '.h.template'
)
deps = [
gmodule_dep,
gio_unix_dep,
udisk_dep,
gtk_dep,
libsecret_dep,
pwquality_dep,
m_dep
]
if enable_libsystemd
deps += libsystemd_dep
endif
cflags = [
'-DPACKAGE_DATA_DIR="@0@"'.format(gdu_datadir),
'-DG_LOG_DOMAIN="libgdu"',
'-DGNOMELOCALEDIR="@0@"'.format(gdu_localedir)
]
libgdu = static_library(
'gdu',
sources: sources + libgduenumtypes,
include_directories: top_inc,
dependencies: deps,
c_args: cflags
)
libgdu_dep = declare_dependency(
link_with: libgdu,
include_directories: include_directories('.'),
dependencies: deps
)
sources = files(
'gdusdmonitor.c',
'main.c'
)
deps = [
gmodule_dep,
gio_unix_dep,
udisk_dep,
gtk_dep,
libnotify_dep
]
executable(
'gsd-disk-utility-notify',
sources,
include_directories: top_inc,
dependencies: deps,
install: true,
install_dir: gdu_libexecdir
)
desktop_conf = configuration_data()
desktop_conf.set('libexecdir', gdu_libexecdir)
desktop = 'org.gnome.SettingsDaemon.DiskUtilityNotify.desktop'
configure_file(
input: desktop + '.in',
output: desktop,
configuration: desktop_conf,
install: true,
install_dir: join_paths(gdu_sysconfdir, 'xdg', 'autostart')
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment