summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMartijn van Beurden <mvanb1@gmail.com>2022-01-01 15:13:14 +0100
committerMartijn van Beurden <mvanb1@gmail.com>2022-04-15 09:36:15 +0200
commit7dd7f94822c5bbb9284f4240878c07c383ef524f (patch)
treea4df3649926698a8800d1a3d58367938107624ef /include
parentecede0bc72bd051d3c3e05440beb35c0c34b4b34 (diff)
downloadflac-7dd7f94822c5bbb9284f4240878c07c383ef524f.tar.gz
Fix building both static and shared libs on MinGW with autotools
When building both static and shared libs on MinGW with autotools, the build broke down without any error message. This commit makes such a build work
Diffstat (limited to 'include')
-rw-r--r--include/FLAC++/export.h13
-rw-r--r--include/FLAC/export.h13
2 files changed, 20 insertions, 6 deletions
diff --git a/include/FLAC++/export.h b/include/FLAC++/export.h
index d8dccf54..2d7a8c97 100644
--- a/include/FLAC++/export.h
+++ b/include/FLAC++/export.h
@@ -55,16 +55,23 @@
*
* \{
*/
+
+/* This has grown quite complicated. FLAC__NO_DLL is used by MSVC sln
+ * files and CMake, which build either static or shared. autotools can
+ * build static, shared or **both**. Therefore, DLL_EXPORT, which is set
+ * by libtool, must override FLAC__NO_DLL on building shared components
+ */
+#if defined(_WIN32)
-#if defined(FLAC__NO_DLL)
+#if defined(FLAC__NO_DLL) && !(defined(DLL_EXPORT))
#define FLACPP_API
-
-#elif defined(_WIN32)
+#else
#ifdef FLACPP_API_EXPORTS
#define FLACPP_API __declspec(dllexport)
#else
#define FLACPP_API __declspec(dllimport)
#endif
+#endif
#elif defined(FLAC__USE_VISIBILITY_ATTR)
#define FLACPP_API __attribute__ ((visibility ("default")))
diff --git a/include/FLAC/export.h b/include/FLAC/export.h
index 3e3e7648..40f8cea8 100644
--- a/include/FLAC/export.h
+++ b/include/FLAC/export.h
@@ -56,15 +56,22 @@
* \{
*/
-#if defined(FLAC__NO_DLL)
-#define FLAC_API
+/* This has grown quite complicated. FLAC__NO_DLL is used by MSVC sln
+ * files and CMake, which build either static or shared. autotools can
+ * build static, shared or **both**. Therefore, DLL_EXPORT, which is set
+ * by libtool, must override FLAC__NO_DLL on building shared components
+ */
+#if defined(_WIN32)
-#elif defined(_WIN32)
+#if defined(FLAC__NO_DLL) && !(defined(DLL_EXPORT))
+#define FLAC_API
+#else
#ifdef FLAC_API_EXPORTS
#define FLAC_API __declspec(dllexport)
#else
#define FLAC_API __declspec(dllimport)
#endif
+#endif
#elif defined(FLAC__USE_VISIBILITY_ATTR)
#define FLAC_API __attribute__ ((visibility ("default")))