diff --git a/src/meson.build b/src/meson.build index 6bb34e39..1e772eca 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,3 +1,18 @@ +conf_data = configuration_data() +module_dir = '' +if get_option('buildtype') == 'debug' + module_dir = join_paths(meson.current_build_dir(), 'servers') +else + module_dir = join_paths(get_option('prefix'), get_option('libdir'), 'vsgi-@0@/servers'.format(api_version)) +endif + +conf_data.set('MODULE_DIR', module_dir) +vsgi_config_name = 'vsgi-config.vala' +vsgi_config = configure_file( + input: vsgi_config_name + '.in', + output: vsgi_config_name, + configuration: conf_data) + vsgi_sources = files( 'vsgi.vala', 'vsgi-application.vala', @@ -16,16 +31,16 @@ vsgi_sources = files( 'vsgi-server-module.vala', 'vsgi-server.vala', 'vsgi-socket-server.vala', - 'vsgi-tee-output-stream.vala') + 'vsgi-tee-output-stream.vala', + join_paths(meson.current_build_dir(), vsgi_config_name)) + + vsgi_lib = library('vsgi-' + api_version, vsgi_sources, dependencies: [glib, gobject, gio, gio_unix, gmodule, soup, libsystemd, openssl, posix], vala_header: 'vsgi.h', vala_gir: 'VSGI-@0@.gir'.format(api_version), - build_rpath: join_paths(meson.current_build_dir(), 'servers'), - link_args: ['-Wl,--disable-new-dtags'], install: true, - install_dir: [true, 'include/vsgi-' + api_version, true, true], - install_rpath: join_paths(get_option('prefix'), get_option('libdir'), 'vsgi-@0@/servers'.format(api_version))) + install_dir: [true, 'include/vsgi-' + api_version, true, true]) install_data('vsgi-@0@.deps'.format(api_version), install_dir: 'share/vala/vapi') diff --git a/src/vsgi-config.vala.in b/src/vsgi-config.vala.in new file mode 100644 index 00000000..3d725965 --- /dev/null +++ b/src/vsgi-config.vala.in @@ -0,0 +1,20 @@ +/* + * This file is part of Valum. + * + * Valum is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * Valum is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Valum. If not, see . + */ + +namespace VSGI.Config { + public const string MODULE_PATH_FALLBACK = "@MODULE_DIR@"; +} \ No newline at end of file diff --git a/src/vsgi-server-module.vala b/src/vsgi-server-module.vala index ffd4c754..3571b863 100644 --- a/src/vsgi-server-module.vala +++ b/src/vsgi-server-module.vala @@ -57,8 +57,17 @@ public class VSGI.ServerModule : TypeModule { } construct { - // trim the suffix from 'build_path' - path = Module.build_path (directory, "vsgi-%s".printf (name))[0:- Module.SUFFIX.length - 1]; + string module_file_name = "vsgi-%s".printf (name); + string module_path = Module.build_path (directory, module_file_name); + File module_file = File.new_for_path (module_path); + + if (module_file.query_exists ()) { + // trim the suffix from 'build_path' + path = module_path[0:- Module.SUFFIX.length - 1]; + } else { + // trim the suffix from 'build_path' + path = Module.build_path (Config.MODULE_PATH_FALLBACK, module_file_name)[0:- Module.SUFFIX.length - 1]; + } } public override bool load () {