Improve Autotools build system for libgeany
[geany-mirror.git] / m4 / geany-lib.m4
blob90323342dcea00c93629f9b9bdd4857d72baf5a5
1 AC_DEFUN([GEANY_LIB_INIT],
4 dnl In the future, if we want to use libtool/library versioning, we can
5 dnl set these variables accordingly. For now its the same as if not specified (0:0:0)
6         libgeany_current=0
7         libgeany_revision=0
8         libgeany_age=0
10 dnl Try and see if we can use -fvisibility compiler option and GCC`s
11 dnl `__attribute__((visibility(...)))` extension and use it if so.
12         AC_MSG_CHECKING([whether compiler supports -fvisibility])
13         libgeany_backup_cflags=$CFLAGS
14         CFLAGS=-fvisibility=hidden
15         AC_TRY_COMPILE([], [
16                         __attribute__ ((visibility ("default")))
17                         int main(int argc, char **argv) { return 0; }
18                 ], [
19                         LIBGEANY_CFLAGS="${CFLAGS}"
20                         AC_MSG_RESULT([yes])
21                 ], [
22                         LIBGEANY_CFLAGS=""
23                         AC_MSG_RESULT([no])
24                 ])
25         CFLAGS="${libgeany_backup_cflags}"
27 dnl Try and see if we can use our list of dynamically exported symbols with
28 dnl the linker and use it if so.
29         AC_MSG_CHECKING([whether linker supports --dynamic-list])
30         libgeany_backup_ldflags=$LDFLAGS
31         LDFLAGS=-Wl,--dynamic-list="${srcdir}/src/dynamicsymbols.list"
32         AC_LINK_IFELSE([
33                         AC_LANG_PROGRAM([], [])
34                 ], [
35                         LIBGEANY_LIBS="-Wl,--dynamic-list=\"\$(top_srcdir)/src/dynamicsymbols.list\""
36                         AC_MSG_RESULT([yes])
37                 ], [
38                         LIBGEANY_LIBS=""
39                         AC_MSG_RESULT([no])
40                 ])
41         LDFLAGS="${libgeany_backup_ldflags}"
43         LIBGEANY_LIBS="${LIBGEANY_LIBS} -version-info ${libgeany_current}:${libgeany_revision}:${libgeany_age}"
45         AC_SUBST([LIBGEANY_CFLAGS])
46         AC_SUBST([LIBGEANY_LIBS])