1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-23 06:03:04 +01:00

Sync with new libtoxcore build system

First try to use pkg-config to find libtoxcore, fall back to manual
checks if pkg-config is not available.

Improve ncurses search, should now find everything on OSX.
This commit is contained in:
Sergey 'Jin' Bostandzhyan 2013-08-24 05:15:15 +03:00
parent 8b6d50cd68
commit 2a46d48cdf
4 changed files with 173 additions and 114 deletions

View File

@ -20,6 +20,10 @@ LIBTOXCORE_SEARCH_LIBS=
LIBSODIUM_SEARCH_HEADERS= LIBSODIUM_SEARCH_HEADERS=
LIBSODIUM_SEARCH_LIBS= LIBSODIUM_SEARCH_LIBS=
LIBTOXCORE_FOUND="no"
NCURSES_FOUND="no"
NCURSES_WIDECHAR_SUPPORT="no"
AC_ARG_WITH(dependency-search, AC_ARG_WITH(dependency-search,
AC_HELP_STRING([--with-dependency-search=DIR], AC_HELP_STRING([--with-dependency-search=DIR],
[search for dependencies in DIR, i.e. look for libraries in [search for dependencies in DIR, i.e. look for libraries in
@ -38,7 +42,7 @@ fi
AC_ARG_WITH(libtoxcore-headers, AC_ARG_WITH(libtoxcore-headers,
AC_HELP_STRING([--with-libtoxcore-headers=DIR], AC_HELP_STRING([--with-libtoxcore-headers=DIR],
[search for libtoxcore header files in DIR]), [search for libtoxcore header files in DIR/tox]),
[ [
LIBTOXCORE_SEARCH_HEADERS="$withval" LIBTOXCORE_SEARCH_HEADERS="$withval"
AC_MSG_NOTICE([Will search for libtoxcore header files in $withval]) AC_MSG_NOTICE([Will search for libtoxcore header files in $withval])
@ -108,17 +112,19 @@ AC_CHECK_FUNCS(
# pkg-config based tests # pkg-config based tests
PKG_PROG_PKG_CONFIG PKG_PROG_PKG_CONFIG
NCURSES_WIDECHAR_SUPPORT="yes"
if test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG"; then
if test "$WIN32" != "xyes"; then if test "$WIN32" != "xyes"; then
PKG_CHECK_MODULES([NCURSES], [ncursesw], PKG_CHECK_MODULES([NCURSES], [ncursesw],
[], [
NCURSES_FOUND="yes"
NCURSES_WIDECHAR_SUPPORT="yes"
],
[ [
NCURSES_WIDECHAR_SUPPORT="no" NCURSES_WIDECHAR_SUPPORT="no"
PKG_CHECK_MODULES([NCURSES], [ncurses], PKG_CHECK_MODULES([NCURSES], [ncurses],
[], [],
[ [
AC_MSG_ERROR([required library ncursesw was not found on your system: $NCURSES_PKG_ERRORS]) AC_MSG_WARN([$NCURSES_PKG_ERRORS])
]) ])
]) ])
fi fi
@ -126,8 +132,77 @@ else
AC_MSG_WARN([pkg-config was not found on your sytem]) AC_MSG_WARN([pkg-config was not found on your sytem])
fi fi
if (test "x$NCURSES_FOUND" = "xno") && (test "$WIN32" != "xyes"); then
AC_PATH_PROG([CURSES_CONFIG], [ncursesw5-config], [no])
if test "x$CURSES_CONFIG" != "xno"; then
AC_MSG_CHECKING(ncurses cflags)
NCURSES_CFLAGS=`${CURSES_CONFIG} --cflags`
AC_MSG_RESULT($NCURSES_CFLAGS)
if (test -z "$PKG_CONFIG") || (test "x$WIN32" = "xyes"); then AC_MSG_CHECKING(ncurses libraries)
NCURSES_LIBS=`${CURSES_CONFIG} --libs`
AC_MSG_RESULT($NCURSES_LIBS)
AC_SUBST(NCURSES_CFLAGS)
AC_SUBST(NCURSES_LIBS)
NCURSES_FOUND="yes"
NCURSES_WIDECHAR_SUPPORT="yes"
fi
fi
if (test "x$NCURSES_FOUND" = "xno") && (test "$WIN32" != "xyes"); then
AC_PATH_PROG([CURSES_CONFIG], [ncursesw5.4-config], [no])
if test "x$CURSES_CONFIG" != "xno"; then
AC_MSG_CHECKING(ncurses cflags)
NCURSES_CFLAGS=`${CURSES_CONFIG} --cflags`
AC_MSG_RESULT($NCURSES_CFLAGS)
AC_MSG_CHECKING(ncurses libraries)
NCURSES_LIBS=`${CURSES_CONFIG} --libs`
AC_MSG_RESULT($NCURSES_LIBS)
AC_SUBST(NCURSES_CFLAGS)
AC_SUBST(NCURSES_LIBS)
NCURSES_FOUND="yes"
NCURSES_WIDECHAR_SUPPORT="yes"
fi
fi
if (test "x$NCURSES_FOUND" = "xno") && (test "$WIN32" != "xyes"); then
AC_PATH_PROG([CURSES_CONFIG], [ncurses5-config], [no])
if test "x$CURSES_CONFIG" != "xno"; then
AC_MSG_CHECKING(ncurses cflags)
NCURSES_CFLAGS=`${CURSES_CONFIG} --cflags`
AC_MSG_RESULT($NCURSES_CFLAGS)
AC_MSG_CHECKING(ncurses libraries)
NCURSES_LIBS=`${CURSES_CONFIG} --libs`
AC_MSG_RESULT($NCURSES_LIBS)
AC_SUBST(NCURSES_CFLAGS)
AC_SUBST(NCURSES_LIBS)
NCURSES_FOUND="yes"
fi
fi
if (test "x$NCURSES_FOUND" = "xno") && (test "$WIN32" != "xyes"); then
AC_PATH_PROG([CURSES_CONFIG], [ncurses5.4-config], [no])
if test "x$CURSES_CONFIG" != "xno"; then
AC_MSG_CHECKING(ncurses cflags)
NCURSES_CFLAGS=`${CURSES_CONFIG} --cflags`
AC_MSG_RESULT($NCURSES_CFLAGS)
AC_MSG_CHECKING(ncurses libraries)
NCURSES_LIBS=`${CURSES_CONFIG} --libs`
AC_MSG_RESULT($NCURSES_LIBS)
AC_SUBST(NCURSES_CFLAGS)
AC_SUBST(NCURSES_LIBS)
NCURSES_FOUND="yes"
fi
fi
if test "x$NCURSES_FOUND" = "xno"; then
AC_CHECK_HEADER([curses.h], AC_CHECK_HEADER([curses.h],
[], [],
[ [
@ -156,11 +231,15 @@ if (test -z "$PKG_CONFIG") || (test "x$WIN32" = "xyes"); then
) )
else else
AC_CHECK_LIB([ncursesw], [get_wch], AC_CHECK_LIB([ncursesw], [get_wch],
[], [
NCURSES_WIDECHAR_SUPPORT="yes"
],
[ [
unset ac_cv_lib_ncursesw_get_wch unset ac_cv_lib_ncursesw_get_wch
AC_CHECK_LIB([ncursesw], [get_wch], AC_CHECK_LIB([ncursesw], [get_wch],
[], [
NCURSES_WIDECHAR_SUPPORT="yes"
],
[ [
NCURSES_WIDECHAR_SUPPORT="no" NCURSES_WIDECHAR_SUPPORT="no"
AC_CHECK_LIB([ncurses], [clear], AC_CHECK_LIB([ncurses], [clear],
@ -188,38 +267,21 @@ if (test -z "$PKG_CONFIG") || (test "x$WIN32" = "xyes"); then
fi fi
fi fi
# sodium is included by Tox headers so we kind of need to know where it is if test -n "$PKG_CONFIG"; then
LIBSODIUM_CFLAGS= PKG_CHECK_MODULES(LIBTOXCORE, [libtoxcore],
CFLAGS_SAVE="$CFLAGS"
CPPFLAGS_SAVE="$CPPFLAGS"
if test -n "$LIBSODIUM_SEARCH_HEADERS"; then
CFLAGS="$CFLAGS -I$LIBSODIUM_SEARCH_HEADERS"
CPPFLAGS="$CFLAGS -I$LIBSODIUM_SEARCH_HEADERS"
AC_CHECK_HEADER(sodium.h,
[ [
LIBSODIUM_CFLAGS="-I$LIBSODIUM_SEARCH_HEADERS" LIBTOXCORE_FOUND="yes"
], ],
[ [
AC_MSG_ERROR([header files for required library libsodium was not found in requested location $LIBSODIUM_SEARCH_HEADERS]) AC_MSG_WARN([required library libsodium was not found in requested location $LIBSODIUM_SEARCH_LIBS])
] ])
)
else
AC_CHECK_HEADER(sodium.h,
[],
[
AC_MSG_ERROR([header files for required library libsodium was not found on your system, please check http://download.libsodium.org/libsodium/releases/])
]
)
fi fi
CFLAGS="$CFLAGS_SAVE"
CPPFLAGS="$CPPFLAGS_SAVE"
AC_SUBST(LIBSODIUM_CFLAGS)
if test "x$LIBTOXCORE_FOUND" = "xno"; then
LIBSODIUM_LIBS= LIBSODIUM_LIBS=
LIBSODIUM_LDFLAGS= LIBSODIUM_LDFLAGS=
LDFLAGS_SAVE="$LDFLAGS" LDFLAGS_SAVE="$LDFLAGS"
if test -n "$LIBSODIUM_SEARCH_LIBS"; then if test -n "$LIBSODIUM_SEARCH_LIBS"; then
LDFLAGS="$LDFLAGS -L$LIBSODIUM_SEARCH_LIBS" LDFLAGS="$LDFLAGS -L$LIBSODIUM_SEARCH_LIBS"
AC_CHECK_LIB(sodium, randombytes_random, AC_CHECK_LIB(sodium, randombytes_random,
[ [
@ -230,29 +292,29 @@ if test -n "$LIBSODIUM_SEARCH_LIBS"; then
AC_MSG_ERROR([required library libsodium was not found in requested location $LIBSODIUM_SEARCH_LIBS]) AC_MSG_ERROR([required library libsodium was not found in requested location $LIBSODIUM_SEARCH_LIBS])
] ]
) )
else else
AC_CHECK_LIB(sodium, randombytes_random, AC_CHECK_LIB(sodium, randombytes_random,
[], [],
[ [
AC_MSG_ERROR([required library libsodium was not found on your system, please check http://download.libsodium.org/libsodium/releases/]) AC_MSG_ERROR([required library libsodium was not found on your system, please check http://download.libsodium.org/libsodium/releases/])
] ]
) )
fi fi
LDFLAGS="$LDFLAGS_SAVE" LDFLAGS="$LDFLAGS_SAVE"
AC_SUBST(LIBSODIUM_LIBS) AC_SUBST(LIBSODIUM_LIBS)
AC_SUBST(LIBSODIUM_LDFLAGS) AC_SUBST(LIBSODIUM_LDFLAGS)
LIBTOXCORE_CFLAGS= LIBTOXCORE_CFLAGS=
CFLAGS_SAVE="$CFLAGS" CFLAGS_SAVE="$CFLAGS"
CPPFLAGS_SAVE="$CPPFLAGS" CPPFLAGS_SAVE="$CPPFLAGS"
if test -n "$LIBTOXCORE_SEARCH_HEADERS"; then if test -n "$LIBTOXCORE_SEARCH_HEADERS"; then
CFLAGS="$CFLAGS -I$LIBTOXCORE_SEARCH_HEADERS $LIBSODIUM_CFLAGS" CFLAGS="$CFLAGS -I$LIBTOXCORE_SEARCH_HEADERS"
CPPFLAGS="$CPPFLAGS -I$LIBTOXCORE_SEARCH_HEADERS $LIBSODIUM_CFLAGS" CPPFLAGS="$CPPFLAGS -I$LIBTOXCORE_SEARCH_HEADERS"
AC_CHECK_HEADER([tox.h], AC_CHECK_HEADER([tox/tox.h],
[ [
LIBTOXCORE_CFLAGS="-I$LIBTOXCORE_SEARCH_HEADERS" LIBTOXCORE_CFLAGS="-I$LIBTOXCORE_SEARCH_HEADERS"
], ],
@ -260,24 +322,22 @@ if test -n "$LIBTOXCORE_SEARCH_HEADERS"; then
AC_MSG_ERROR([headers for the toxcore library were not found on your system]) AC_MSG_ERROR([headers for the toxcore library were not found on your system])
] ]
) )
else else
CFLAGS="$CFLAGS $LIBSODIUM_CFLAGS" AC_CHECK_HEADER([tox/tox.h],
CPPFLAGS="$CPPFLAGS $LIBSODIUM_CFLAGS"
AC_CHECK_HEADER([tox.h],
[], [],
[ [
AC_MSG_ERROR([headers for the toxcore library were not found on your system]) AC_MSG_ERROR([headers for the toxcore library were not found on your system])
] ],
) )
fi fi
CFLAGS="$CFLAGS_SAVE" CFLAGS="$CFLAGS_SAVE"
CPPFLAGS="$CPPFLAGS_SAVE" CPPFLAGS="$CPPFLAGS_SAVE"
AC_SUBST(LIBTOXCORE_CFLAGS) AC_SUBST(LIBTOXCORE_CFLAGS)
LIBTOXCORE_LIBS= LIBTOXCORE_LIBS=
LIBTOXCORE_LDFLAGS= LIBTOXCORE_LDFLAGS=
LDFLAGS_SAVE="$LDFLAGS" LDFLAGS_SAVE="$LDFLAGS"
if test -n "$LIBTOXCORE_SEARCH_LIBS"; then if test -n "$LIBTOXCORE_SEARCH_LIBS"; then
LDFLAGS="$LDFLAGS $LIBSODIUM_LDFLAGS -L$LIBTOXCORE_SEARCH_LIBS $LIBSODIUM_LIBS" LDFLAGS="$LDFLAGS $LIBSODIUM_LDFLAGS -L$LIBTOXCORE_SEARCH_LIBS $LIBSODIUM_LIBS"
AC_CHECK_LIB([toxcore], [tox_new], AC_CHECK_LIB([toxcore], [tox_new],
[ [
@ -288,7 +348,7 @@ if test -n "$LIBTOXCORE_SEARCH_LIBS"; then
AC_MSG_ERROR([required library toxcore was not found on your system]) AC_MSG_ERROR([required library toxcore was not found on your system])
] ]
) )
else else
LDFLAGS="$LDFLAGS $LIBSODIUM_LDFLAGS $LIBSODIUM_LIBS" LDFLAGS="$LDFLAGS $LIBSODIUM_LDFLAGS $LIBSODIUM_LIBS"
AC_CHECK_LIB([toxcore], [tox_new], AC_CHECK_LIB([toxcore], [tox_new],
[], [],
@ -296,12 +356,11 @@ else
AC_MSG_ERROR([required library toxcore was not found on your system]) AC_MSG_ERROR([required library toxcore was not found on your system])
] ]
) )
fi
LDFLAGS="$LDFLAGS_SAVE"
AC_SUBST(LIBTOXCORE_LIBS)
AC_SUBST(LIBTOXCORE_LDFLAGS)
fi fi
LDFLAGS="$LDFLAGS_SAVE"
AC_SUBST(LIBTOXCORE_LIBS)
AC_SUBST(LIBTOXCORE_LDFLAGS)
TOXIC_VERSION="$PACKAGE_VERSION" TOXIC_VERSION="$PACKAGE_VERSION"
AC_PATH_PROG([GIT], [git], [no]) AC_PATH_PROG([GIT], [git], [no])

View File

@ -10,7 +10,7 @@
#include <stdint.h> #include <stdint.h>
#include <ctype.h> #include <ctype.h>
#include "tox.h" #include <tox/tox.h>
#include "friendlist.h" #include "friendlist.h"

View File

@ -25,7 +25,7 @@
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#include "tox.h" #include <tox/tox.h>
#include "configdir.h" #include "configdir.h"
#include "toxic_windows.h" #include "toxic_windows.h"

View File

@ -10,7 +10,7 @@
#include <wctype.h> #include <wctype.h>
#include <wchar.h> #include <wchar.h>
#include "tox.h" #include <tox/tox.h>
#define MAX_WINDOWS_NUM 32 #define MAX_WINDOWS_NUM 32
#define MAX_FRIENDS_NUM 100 #define MAX_FRIENDS_NUM 100