Define GEANY_{EXPORT,API}_SYMBOL from the build system
This makes it easier to define it consistently to what the compiler and platform supports, and avoids having to include a special header everywhere, which is some kind of a problem for separate libraries like TagManager and especially Scintilla. As we only use these macros from the source and not the headers, it is fine for it to be defined to a configure-time check from the build system. Warning: Although Waf and Windows makefiles are updated they are not tested an will probably required tuning.
This commit is contained in:
parent
2bfd394803
commit
9644fb0ae2
@ -1,5 +1,42 @@
|
||||
dnl checks whether the compiler supports GCC4-style visibility
|
||||
AC_DEFUN([GCC4_VISIBILITY],
|
||||
[
|
||||
have_gcc4_visibility=no
|
||||
AC_MSG_CHECKING([whether compiler supports GCC4-style visibility])
|
||||
gcc_visibility_backup_cflags=$CFLAGS
|
||||
CFLAGS=-fvisibility=hidden
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([[__attribute__((visibility("default")))
|
||||
int main(int argc, char **argv) { return 0; }]])],
|
||||
[have_gcc4_visibility=yes])
|
||||
AC_MSG_RESULT([$have_gcc4_visibility])
|
||||
CFLAGS="${gcc_visibility_backup_cflags}"
|
||||
])
|
||||
|
||||
dnl Checks and fills LIBGEANY_EXPORT_CFLAGS
|
||||
AC_DEFUN([GEANY_EXPORT],
|
||||
[
|
||||
AC_REQUIRE([GEANY_CHECK_MINGW])
|
||||
AC_REQUIRE([GCC4_VISIBILITY])
|
||||
|
||||
dnl FIXME: better way to detect Windows?
|
||||
AM_COND_IF([MINGW], [win32=yes], [win32=false])
|
||||
|
||||
export_CFLAGS=
|
||||
AS_IF([test x$win32 = xyes],
|
||||
[export_CFLAGS='-DGEANY_EXPORT_SYMBOL="__declspec(dllexport)"'],
|
||||
[test x$have_gcc4_visibility = xyes],
|
||||
[export_CFLAGS='-fvisibility=hidden -DGEANY_EXPORT_SYMBOL="__attribute__((visibility(\"default\")))"'],
|
||||
[dnl GEANY_EXPORT_SYMBOL expands to nothing
|
||||
export_CFLAGS='-DGEANY_EXPORT_SYMBOL'])
|
||||
|
||||
LIBGEANY_EXPORT_CFLAGS="${export_CFLAGS} -DGEANY_API_SYMBOL=GEANY_EXPORT_SYMBOL"
|
||||
|
||||
AC_SUBST([LIBGEANY_EXPORT_CFLAGS])
|
||||
])
|
||||
|
||||
AC_DEFUN([GEANY_LIB_INIT],
|
||||
[
|
||||
AC_REQUIRE([GEANY_EXPORT])
|
||||
|
||||
dnl In the future, if we want to use libtool/library versioning, we can
|
||||
dnl set these variables accordingly. For now its the same as if not specified (0:0:0)
|
||||
@ -7,23 +44,7 @@ dnl set these variables accordingly. For now its the same as if not specified (0
|
||||
libgeany_revision=0
|
||||
libgeany_age=0
|
||||
|
||||
dnl Try and see if we can use -fvisibility compiler option and GCC`s
|
||||
dnl `__attribute__((visibility(...)))` extension and use it if so.
|
||||
AC_MSG_CHECKING([whether compiler supports -fvisibility])
|
||||
libgeany_backup_cflags=$CFLAGS
|
||||
CFLAGS=-fvisibility=hidden
|
||||
AC_TRY_COMPILE([], [
|
||||
__attribute__ ((visibility ("default")))
|
||||
int main(int argc, char **argv) { return 0; }
|
||||
], [
|
||||
LIBGEANY_CFLAGS="${CFLAGS}"
|
||||
AC_MSG_RESULT([yes])
|
||||
], [
|
||||
LIBGEANY_CFLAGS=""
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
CFLAGS="${libgeany_backup_cflags}"
|
||||
|
||||
LIBGEANY_CFLAGS="${LIBGEANY_EXPORT_CFLAGS}"
|
||||
LIBGEANY_LDFLAGS="-version-info ${libgeany_current}:${libgeany_revision}:${libgeany_age}"
|
||||
|
||||
AC_SUBST([LIBGEANY_CFLAGS])
|
||||
|
@ -32,7 +32,9 @@ vpath %.h ../src ../include ../lexlib
|
||||
vpath %.cxx ../src ../lexlib ../lexers
|
||||
|
||||
INCLUDEDIRS=-I ../include -I ../src -I ../lexlib
|
||||
CXXBASEFLAGS=-Wall -Wno-missing-braces -Wno-char-subscripts -DGTK -DSCI_LEXER $(INCLUDEDIRS)
|
||||
CXXBASEFLAGS=-Wall -Wno-missing-braces -Wno-char-subscripts -DGTK -DSCI_LEXER $(INCLUDEDIRS) \
|
||||
-DGEANY_EXPORT_SYMBOL="__declspec(dllexport)" \
|
||||
-DGEANY_API_SYMBOL=GEANY_EXPORT_SYMBOL
|
||||
|
||||
ifdef THREADS
|
||||
THREADFLAGS=
|
||||
|
@ -44,7 +44,6 @@ SRCS = \
|
||||
navqueue.c navqueue.h \
|
||||
notebook.c notebook.h \
|
||||
osx.c osx.h \
|
||||
pluginexport.h \
|
||||
plugins.c plugins.h \
|
||||
pluginutils.c pluginutils.h \
|
||||
prefix.c prefix.h \
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "geanyobject.h"
|
||||
#include "keybindingsprivate.h"
|
||||
#include "msgwindow.h"
|
||||
#include "pluginexport.h"
|
||||
#include "prefs.h"
|
||||
#include "projectprivate.h"
|
||||
#include "sciwrappers.h"
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include "main.h"
|
||||
#include "msgwindow.h"
|
||||
#include "navqueue.h"
|
||||
#include "pluginexport.h"
|
||||
#include "plugins.h"
|
||||
#include "pluginutils.h"
|
||||
#include "prefs.h"
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "encodings.h"
|
||||
#include "filetypes.h"
|
||||
#include "main.h"
|
||||
#include "pluginexport.h"
|
||||
#include "support.h"
|
||||
#include "utils.h"
|
||||
#include "ui_utils.h"
|
||||
|
@ -44,7 +44,6 @@
|
||||
#include "msgwindow.h"
|
||||
#include "navqueue.h"
|
||||
#include "notebook.h"
|
||||
#include "pluginexport.h"
|
||||
#include "project.h"
|
||||
#include "sciwrappers.h"
|
||||
#include "sidebar.h"
|
||||
|
@ -48,7 +48,6 @@
|
||||
#include "highlighting.h"
|
||||
#include "keybindings.h"
|
||||
#include "main.h"
|
||||
#include "pluginexport.h"
|
||||
#include "prefs.h"
|
||||
#include "projectprivate.h"
|
||||
#include "sciwrappers.h"
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "app.h"
|
||||
#include "callbacks.h"
|
||||
#include "documentprivate.h"
|
||||
#include "pluginexport.h"
|
||||
#include "support.h"
|
||||
#include "ui_utils.h"
|
||||
#include "utils.h"
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "geany.h"
|
||||
#include "geanyobject.h"
|
||||
#include "highlighting.h"
|
||||
#include "pluginexport.h"
|
||||
#include "projectprivate.h"
|
||||
#include "sciwrappers.h"
|
||||
#include "support.h"
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "document.h"
|
||||
#include "editor.h"
|
||||
#include "filetypesprivate.h"
|
||||
#include "pluginexport.h"
|
||||
#include "sciwrappers.h"
|
||||
#include "support.h"
|
||||
#include "symbols.h"
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include "msgwindow.h"
|
||||
#include "navqueue.h"
|
||||
#include "notebook.h"
|
||||
#include "pluginexport.h"
|
||||
#include "prefs.h"
|
||||
#include "sciwrappers.h"
|
||||
#include "sidebar.h"
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include "msgwindow.h"
|
||||
#include "navqueue.h"
|
||||
#include "notebook.h"
|
||||
#include "pluginexport.h"
|
||||
#include "plugins.h"
|
||||
#include "prefs.h"
|
||||
#include "printing.h"
|
||||
|
@ -6,7 +6,9 @@ DEFINES = -DHAVE_CONFIG_H \
|
||||
-DGEANY_LOCALEDIR=\"\" \
|
||||
-DGEANY_LIBDIR=\"\" \
|
||||
-DGEANY_PREFIX=\"\" \
|
||||
-DGTK
|
||||
-DGTK \
|
||||
-DGEANY_EXPORT_SYMBOL="__declspec(dllexport)" \
|
||||
-DGEANY_API_SYMBOL=GEANY_EXPORT_SYMBOL
|
||||
|
||||
.SUFFIXES: .c .o .h .a
|
||||
WINDRES = windres.exe
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "keybindings.h"
|
||||
#include "main.h"
|
||||
#include "navqueue.h"
|
||||
#include "pluginexport.h"
|
||||
#include "prefs.h"
|
||||
#include "support.h"
|
||||
#include "ui_utils.h"
|
||||
|
@ -32,7 +32,6 @@
|
||||
|
||||
#include "document.h"
|
||||
#include "geanyobject.h"
|
||||
#include "pluginexport.h"
|
||||
#include "sciwrappers.h"
|
||||
#include "toolbar.h"
|
||||
#include "utils.h"
|
||||
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* pluginexport.h - this file is part of Geany, a fast and lightweight IDE
|
||||
*
|
||||
* Copyright 2014 Matthew Brush <mbrush@codebrainz.ca>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef GEANY_PLUGINEXPORT_H
|
||||
#define GEANY_PLUGINEXPORT_H 1
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
# define GEANY_EXPORT_SYMBOL __declspec(dllexport)
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
# define GEANY_EXPORT_SYMBOL __attribute__((visibility ("default")))
|
||||
#else
|
||||
# define GEANY_API_SYMBOL
|
||||
#endif
|
||||
|
||||
#define GEANY_API_SYMBOL GEANY_EXPORT_SYMBOL
|
||||
|
||||
#endif /* GEANY_PLUGINEXPORT_H */
|
@ -34,7 +34,6 @@
|
||||
#include "app.h"
|
||||
#include "geanyobject.h"
|
||||
#include "plugindata.h"
|
||||
#include "pluginexport.h"
|
||||
#include "pluginprivate.h"
|
||||
#include "plugins.h"
|
||||
#include "support.h"
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "geanyobject.h"
|
||||
#include "keyfile.h"
|
||||
#include "main.h"
|
||||
#include "pluginexport.h"
|
||||
#include "projectprivate.h"
|
||||
#include "sidebar.h"
|
||||
#include "stash.h"
|
||||
|
@ -37,7 +37,6 @@
|
||||
|
||||
#include "sciwrappers.h"
|
||||
|
||||
#include "pluginexport.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <string.h>
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "encodings.h"
|
||||
#include "keyfile.h"
|
||||
#include "msgwindow.h"
|
||||
#include "pluginexport.h"
|
||||
#include "prefs.h"
|
||||
#include "sciwrappers.h"
|
||||
#include "stash.h"
|
||||
|
@ -78,7 +78,6 @@
|
||||
|
||||
#include "stash.h"
|
||||
|
||||
#include "pluginexport.h" /* for GEANY_API_SYMBOL */
|
||||
#include "support.h" /* only for _("text") */
|
||||
#include "utils.h" /* only for foreach_*, utils_get_setting_*(). Stash should not depend on Geany. */
|
||||
|
||||
|
@ -47,7 +47,6 @@
|
||||
#include "geanyobject.h"
|
||||
#include "main.h"
|
||||
#include "navqueue.h"
|
||||
#include "pluginexport.h"
|
||||
#include "sciwrappers.h"
|
||||
#include "sidebar.h"
|
||||
#include "support.h"
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "geany.h"
|
||||
#include "geanymenubuttonaction.h"
|
||||
#include "geanyobject.h"
|
||||
#include "pluginexport.h"
|
||||
#include "support.h"
|
||||
#include "toolbar.h"
|
||||
#include "ui_utils.h"
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "keyfile.h"
|
||||
#include "main.h"
|
||||
#include "msgwindow.h"
|
||||
#include "pluginexport.h"
|
||||
#include "prefs.h"
|
||||
#include "project.h"
|
||||
#include "sciwrappers.h"
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "app.h"
|
||||
#include "dialogs.h"
|
||||
#include "document.h"
|
||||
#include "pluginexport.h"
|
||||
#include "prefs.h"
|
||||
#include "sciwrappers.h"
|
||||
#include "support.h"
|
||||
|
@ -29,7 +29,9 @@ GTK_INCLUDES= \
|
||||
|
||||
INCLUDEDIRS=-I ../ctags -I ../ -I . $(GTK_INCLUDES)
|
||||
|
||||
CBASEFLAGS=-Wall -pipe -mms-bitfields -DGEANY_PRIVATE -DPACKAGE=\"geany\" -Wno-missing-braces -Wno-char-subscripts $(INCLUDEDIRS)
|
||||
CBASEFLAGS=-Wall -pipe -mms-bitfields -DGEANY_PRIVATE -DPACKAGE=\"geany\" -Wno-missing-braces -Wno-char-subscripts $(INCLUDEDIRS) \
|
||||
-DGEANY_EXPORT_SYMBOL="__declspec(dllexport)" \
|
||||
-DGEANY_API_SYMBOL=GEANY_EXPORT_SYMBOL
|
||||
ifdef DEBUG
|
||||
CFLAGS= -O0 -g $(CBASEFLAGS)
|
||||
else
|
||||
|
@ -34,7 +34,6 @@
|
||||
#define LIBCTAGS_DEFINED
|
||||
#include "tm_source_file.h"
|
||||
#include "tm_tag.h"
|
||||
#include "../src/pluginexport.h" /* for GEANY_API_SYMBOL */
|
||||
|
||||
|
||||
static TMSourceFile *current_source_file = NULL;
|
||||
|
@ -32,7 +32,6 @@
|
||||
|
||||
#include "tm_workspace.h"
|
||||
#include "tm_tag.h"
|
||||
#include "../src/pluginexport.h" /* for GEANY_API_SYMBOL */
|
||||
|
||||
|
||||
/* when changing, always keep the three sort criteria below in sync */
|
||||
|
13
wscript
13
wscript
@ -305,6 +305,19 @@ but you then may not have a local copy of the HTML manual.'''
|
||||
|
||||
conf.write_config_header('config.h', remove=False)
|
||||
|
||||
# GEANY_EXPORT_SYMBOL and GEANY_API_SYMBOL
|
||||
# FIXME: should I put quoting in the appended values or are they passed as-is?
|
||||
if is_win32:
|
||||
conf.env.append_value('CFLAGS', ['-DGEANY_EXPORT_SYMBOL=__declspec(dllexport)'])
|
||||
# FIXME: check for -fvisibility and the __attribute__((visibility)), or
|
||||
# at least for GCC >= 4
|
||||
elif conf.env['CC_NAME'] == 'gcc':
|
||||
conf.env.append_value('CFLAGS', ['-fvisibility=hidden',
|
||||
'-DGEANY_EXPORT_SYMBOL=__attribute__((visibility("default")))'])
|
||||
else: # unknown, define to nothing
|
||||
conf.env.append_value('CFLAGS', ['-DGEANY_EXPORT_SYMBOL='])
|
||||
conf.env.append_value('CFLAGS', ['-DGEANY_API_SYMBOL=GEANY_EXPORT_SYMBOL'])
|
||||
|
||||
# some more compiler flags
|
||||
conf.env.append_value('CFLAGS', ['-DHAVE_CONFIG_H'])
|
||||
if conf.env['CC_NAME'] == 'gcc' and '-O' not in ''.join(conf.env['CFLAGS']):
|
||||
|
Loading…
x
Reference in New Issue
Block a user