summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--src/gtk2_in_qt5.cpp2
-rw-r--r--src/host.c4
-rw-r--r--src/instance.c1
-rw-r--r--src/suil_config.h113
-rw-r--r--wscript19
6 files changed, 119 insertions, 23 deletions
diff --git a/NEWS b/NEWS
index 9476c2e..0674d22 100644
--- a/NEWS
+++ b/NEWS
@@ -1,8 +1,9 @@
suil (0.10.9) unstable;
* Clean up minor code issues
+ * Remove the need for a generated configuration header
- -- David Robillard <d@drobilla.net> Tue, 15 Dec 2020 20:55:16 +0000
+ -- David Robillard <d@drobilla.net> Fri, 01 Jan 2021 18:03:42 +0000
suil (0.10.8) stable;
diff --git a/src/gtk2_in_qt5.cpp b/src/gtk2_in_qt5.cpp
index 496350e..bb34989 100644
--- a/src/gtk2_in_qt5.cpp
+++ b/src/gtk2_in_qt5.cpp
@@ -16,7 +16,7 @@
*/
#include "dylib.h"
-#include "suil_config.h"
+#include "suil_config.h" // IWYU pragma: keep
#include "suil_internal.h"
#include "lv2/core/lv2.h"
diff --git a/src/host.c b/src/host.c
index 67936be..aee42c5 100644
--- a/src/host.c
+++ b/src/host.c
@@ -65,7 +65,7 @@ suil_host_free(SuilHost* host)
}
}
-#ifdef SUIL_WITH_X11
+#if USE_X11
static void
suil_load_init_module(const char* module_name)
{
@@ -94,7 +94,7 @@ suil_init(int* argc, char*** argv, SuilArg key, ...)
suil_argc = argc ? *argc : 0;
suil_argv = argv ? *argv : NULL;
-#ifdef SUIL_WITH_X11
+#if USE_X11
suil_load_init_module("suil_x11");
#endif
}
diff --git a/src/instance.c b/src/instance.c
index 2511c64..1099ec4 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -15,7 +15,6 @@
*/
#include "dylib.h"
-#include "suil_config.h"
#include "suil_internal.h"
#include "lv2/core/lv2.h"
diff --git a/src/suil_config.h b/src/suil_config.h
new file mode 100644
index 0000000..a025d4d
--- /dev/null
+++ b/src/suil_config.h
@@ -0,0 +1,113 @@
+/*
+ Copyright 2021 David Robillard <http://drobilla.net>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+/*
+ Configuration header that defines reasonable defaults at compile time.
+
+ This allows compile-time configuration from the command line (typically via
+ the build system) while still allowing the source to be built without any
+ configuration. The build system can define SUIL_NO_DEFAULT_CONFIG to disable
+ defaults, in which case it must define things like HAVE_FEATURE to enable
+ features. The design here ensures that compiler warnings or
+ include-what-you-use will catch any mistakes.
+
+ Note that suil loads modules at runtime, so the default configuration
+ contains paths which are likely not what you want.
+*/
+
+#ifndef SUIL_CONFIG_H
+#define SUIL_CONFIG_H
+
+// Define version unconditionally so a warning will catch a mismatch
+#define SUIL_VERSION "0.10.9"
+
+#if !defined(SUIL_NO_DEFAULT_CONFIG)
+
+// X11 (requires loading an init module)
+# ifndef HAVE_X11
+# ifdef __has_include
+# if __has_include(<X11/Xlib.h>)
+# define HAVE_X11
+# endif
+# endif
+# endif
+
+#endif // !defined(SUIL_NO_DEFAULT_CONFIG)
+
+/*
+ Make corresponding USE_FEATURE defines based on the HAVE_FEATURE defines from
+ above or the command line. The code checks for these using #if (not #ifdef),
+ so there will be an undefined warning if it checks for an unknown feature,
+ and this header is always required by any code that checks for features, even
+ if the build system defines them all.
+*/
+
+#ifdef HAVE_X11
+# define USE_X11 1
+#else
+# define USE_X11 0
+#endif
+
+/*
+ Define required values. These are always used as a fallback, even with
+ LILV_NO_DEFAULT_CONFIG, since they must be defined for the build to work.
+*/
+
+// Directory of loadable wrapper modules
+#ifndef SUIL_MODULE_DIR
+# ifdef _WIN32
+# define SUIL_MODULE_DIR "C:\\Program Files\\Common Files\\Suil\\lib"
+# else
+# define SUIL_MODULE_DIR "/usr/local/lib/suil-0"
+# endif
+#endif
+
+// Separator between directories in a path
+#ifndef SUIL_DIR_SEP
+# define SUIL_DIR_SEP "/"
+#endif
+
+// Prefix for loadable module filenames
+#ifndef SUIL_MODULE_PREFIX
+# ifdef _WIN32
+# define SUIL_MODULE_PREFIX ""
+# else
+# define SUIL_MODULE_PREFIX "lib"
+# endif
+#endif
+
+// Extension for loadable module filenames
+#ifndef SUIL_MODULE_EXT
+# if defined(__APPLE__)
+# define SUIL_MODULE_EXT ".dylib"
+# elif defined(_WIN32)
+# define SUIL_MODULE_EXT ".dll"
+# else
+# define SUIL_MODULE_EXT ".so"
+# endif
+#endif
+
+// Gtk2 library to load when embedding in Qt
+#ifndef SUIL_GTK2_LIB_NAME
+# define SUIL_GTK2_LIB_NAME "libgtk-x11-2.0.so.0"
+#endif
+
+// Gtk3 library to load when embedding in Qt
+#ifndef SUIL_GTK3_LIB_NAME
+# define SUIL_GTK3_LIB_NAME "libgtk-x11-3.0.so.0"
+#endif
+
+#endif // SUIL_CONFIG_H
diff --git a/wscript b/wscript
index 59a0302..538c566 100644
--- a/wscript
+++ b/wscript
@@ -180,7 +180,6 @@ def configure(conf):
conf.define('SUIL_MODULE_DIR',
conf.env.LIBDIR + '/suil-' + SUIL_MAJOR_VERSION)
- conf.define('SUIL_DIR_SEP', '/')
conf.define('SUIL_GTK2_LIB_NAME', conf.options.gtk2_lib_name)
conf.define('SUIL_GTK3_LIB_NAME', conf.options.gtk3_lib_name)
@@ -217,29 +216,13 @@ def configure(conf):
if conf.env.HAVE_X11:
enable_module('SUIL_WITH_X11')
- module_prefix = ''
- module_ext = ''
- if conf.env.PARDEBUG:
- module_ext += 'D'
- if conf.env.DEST_OS == 'win32':
- module_ext += '.dll'
- elif conf.env.DEST_OS == 'darwin':
- module_prefix = 'lib'
- module_ext += '.dylib'
- else:
- module_prefix = 'lib'
- module_ext += '.so'
-
- conf.define('SUIL_MODULE_PREFIX', module_prefix)
- conf.define('SUIL_MODULE_EXT', module_ext)
-
conf.run_env.append_unique('SUIL_MODULE_DIR', [conf.build_path()])
# Set up environment for building/using as a subproject
autowaf.set_lib_env(conf, 'suil', SUIL_VERSION,
include_path=str(conf.path.find_node('include')))
- conf.write_config_header('suil_config.h', remove=False)
+ conf.define('SUIL_NO_DEFAULT_CONFIG', 1)
autowaf.display_summary(
conf,