From 2a46d48cdf1a7547724530abaf0b241eb1ec8fcf Mon Sep 17 00:00:00 2001 From: Sergey 'Jin' Bostandzhyan Date: Sat, 24 Aug 2013 05:15:15 +0300 Subject: [PATCH] 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. --- configure.ac | 281 +++++++++++++++++++++++++++----------------- src/friendlist.c | 2 +- src/main.c | 2 +- src/toxic_windows.h | 2 +- 4 files changed, 173 insertions(+), 114 deletions(-) diff --git a/configure.ac b/configure.ac index 2226f9f..fd2b89b 100644 --- a/configure.ac +++ b/configure.ac @@ -20,6 +20,10 @@ LIBTOXCORE_SEARCH_LIBS= LIBSODIUM_SEARCH_HEADERS= LIBSODIUM_SEARCH_LIBS= +LIBTOXCORE_FOUND="no" +NCURSES_FOUND="no" +NCURSES_WIDECHAR_SUPPORT="no" + AC_ARG_WITH(dependency-search, AC_HELP_STRING([--with-dependency-search=DIR], [search for dependencies in DIR, i.e. look for libraries in @@ -38,7 +42,7 @@ fi AC_ARG_WITH(libtoxcore-headers, 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" AC_MSG_NOTICE([Will search for libtoxcore header files in $withval]) @@ -108,17 +112,19 @@ AC_CHECK_FUNCS( # pkg-config based tests PKG_PROG_PKG_CONFIG -NCURSES_WIDECHAR_SUPPORT="yes" if test -n "$PKG_CONFIG"; then if test "$WIN32" != "xyes"; then PKG_CHECK_MODULES([NCURSES], [ncursesw], - [], + [ + NCURSES_FOUND="yes" + NCURSES_WIDECHAR_SUPPORT="yes" + ], [ NCURSES_WIDECHAR_SUPPORT="no" 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 @@ -126,8 +132,77 @@ else AC_MSG_WARN([pkg-config was not found on your sytem]) 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], [], [ @@ -156,11 +231,15 @@ if (test -z "$PKG_CONFIG") || (test "x$WIN32" = "xyes"); then ) else AC_CHECK_LIB([ncursesw], [get_wch], - [], + [ + NCURSES_WIDECHAR_SUPPORT="yes" + ], [ unset ac_cv_lib_ncursesw_get_wch AC_CHECK_LIB([ncursesw], [get_wch], - [], + [ + NCURSES_WIDECHAR_SUPPORT="yes" + ], [ NCURSES_WIDECHAR_SUPPORT="no" AC_CHECK_LIB([ncurses], [clear], @@ -188,120 +267,100 @@ if (test -z "$PKG_CONFIG") || (test "x$WIN32" = "xyes"); then fi fi -# sodium is included by Tox headers so we kind of need to know where it is -LIBSODIUM_CFLAGS= -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, +if test -n "$PKG_CONFIG"; then + PKG_CHECK_MODULES(LIBTOXCORE, [libtoxcore], [ - 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]) - ] - ) -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 -CFLAGS="$CFLAGS_SAVE" -CPPFLAGS="$CPPFLAGS_SAVE" -AC_SUBST(LIBSODIUM_CFLAGS) - - -LIBSODIUM_LIBS= -LIBSODIUM_LDFLAGS= -LDFLAGS_SAVE="$LDFLAGS" -if test -n "$LIBSODIUM_SEARCH_LIBS"; then - LDFLAGS="$LDFLAGS -L$LIBSODIUM_SEARCH_LIBS" - AC_CHECK_LIB(sodium, randombytes_random, - [ - LIBSODIUM_LDFLAGS="-L$LIBSODIUM_SEARCH_LIBS" - LIBSODIUM_LIBS="-lsodium" - ], - [ - AC_MSG_ERROR([required library libsodium was not found in requested location $LIBSODIUM_SEARCH_LIBS]) - ] - ) -else - 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_WARN([required library libsodium was not found in requested location $LIBSODIUM_SEARCH_LIBS]) + ]) fi -LDFLAGS="$LDFLAGS_SAVE" -AC_SUBST(LIBSODIUM_LIBS) -AC_SUBST(LIBSODIUM_LDFLAGS) +if test "x$LIBTOXCORE_FOUND" = "xno"; then + LIBSODIUM_LIBS= + LIBSODIUM_LDFLAGS= + LDFLAGS_SAVE="$LDFLAGS" + if test -n "$LIBSODIUM_SEARCH_LIBS"; then + LDFLAGS="$LDFLAGS -L$LIBSODIUM_SEARCH_LIBS" + AC_CHECK_LIB(sodium, randombytes_random, + [ + LIBSODIUM_LDFLAGS="-L$LIBSODIUM_SEARCH_LIBS" + LIBSODIUM_LIBS="-lsodium" + ], + [ + AC_MSG_ERROR([required library libsodium was not found in requested location $LIBSODIUM_SEARCH_LIBS]) + ] + ) + else + 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/]) + ] + ) + fi + + LDFLAGS="$LDFLAGS_SAVE" + AC_SUBST(LIBSODIUM_LIBS) + AC_SUBST(LIBSODIUM_LDFLAGS) -LIBTOXCORE_CFLAGS= -CFLAGS_SAVE="$CFLAGS" -CPPFLAGS_SAVE="$CPPFLAGS" + LIBTOXCORE_CFLAGS= + CFLAGS_SAVE="$CFLAGS" + CPPFLAGS_SAVE="$CPPFLAGS" -if test -n "$LIBTOXCORE_SEARCH_HEADERS"; then - CFLAGS="$CFLAGS -I$LIBTOXCORE_SEARCH_HEADERS $LIBSODIUM_CFLAGS" - CPPFLAGS="$CPPFLAGS -I$LIBTOXCORE_SEARCH_HEADERS $LIBSODIUM_CFLAGS" - AC_CHECK_HEADER([tox.h], - [ - LIBTOXCORE_CFLAGS="-I$LIBTOXCORE_SEARCH_HEADERS" - ], - [ - AC_MSG_ERROR([headers for the toxcore library were not found on your system]) - ] - ) -else - CFLAGS="$CFLAGS $LIBSODIUM_CFLAGS" - CPPFLAGS="$CPPFLAGS $LIBSODIUM_CFLAGS" - AC_CHECK_HEADER([tox.h], - [], - [ - AC_MSG_ERROR([headers for the toxcore library were not found on your system]) - ] - ) + if test -n "$LIBTOXCORE_SEARCH_HEADERS"; then + CFLAGS="$CFLAGS -I$LIBTOXCORE_SEARCH_HEADERS" + CPPFLAGS="$CPPFLAGS -I$LIBTOXCORE_SEARCH_HEADERS" + AC_CHECK_HEADER([tox/tox.h], + [ + LIBTOXCORE_CFLAGS="-I$LIBTOXCORE_SEARCH_HEADERS" + ], + [ + AC_MSG_ERROR([headers for the toxcore library were not found on your system]) + ] + ) + else + AC_CHECK_HEADER([tox/tox.h], + [], + [ + AC_MSG_ERROR([headers for the toxcore library were not found on your system]) + ], + ) + fi + CFLAGS="$CFLAGS_SAVE" + CPPFLAGS="$CPPFLAGS_SAVE" + AC_SUBST(LIBTOXCORE_CFLAGS) + + LIBTOXCORE_LIBS= + LIBTOXCORE_LDFLAGS= + LDFLAGS_SAVE="$LDFLAGS" + if test -n "$LIBTOXCORE_SEARCH_LIBS"; then + LDFLAGS="$LDFLAGS $LIBSODIUM_LDFLAGS -L$LIBTOXCORE_SEARCH_LIBS $LIBSODIUM_LIBS" + AC_CHECK_LIB([toxcore], [tox_new], + [ + LIBTOXCORE_LDFLAGS="-L$LIBTOXCORE_SEARCH_LIBS" + LIBTOXCORE_LIBS="-ltoxcore" + ], + [ + AC_MSG_ERROR([required library toxcore was not found on your system]) + ] + ) + else + LDFLAGS="$LDFLAGS $LIBSODIUM_LDFLAGS $LIBSODIUM_LIBS" + AC_CHECK_LIB([toxcore], [tox_new], + [], + [ + 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 -CFLAGS="$CFLAGS_SAVE" -CPPFLAGS="$CPPFLAGS_SAVE" -AC_SUBST(LIBTOXCORE_CFLAGS) - -LIBTOXCORE_LIBS= -LIBTOXCORE_LDFLAGS= -LDFLAGS_SAVE="$LDFLAGS" -if test -n "$LIBTOXCORE_SEARCH_LIBS"; then - LDFLAGS="$LDFLAGS $LIBSODIUM_LDFLAGS -L$LIBTOXCORE_SEARCH_LIBS $LIBSODIUM_LIBS" - AC_CHECK_LIB([toxcore], [tox_new], - [ - LIBTOXCORE_LDFLAGS="-L$LIBTOXCORE_SEARCH_LIBS" - LIBTOXCORE_LIBS="-ltoxcore" - ], - [ - AC_MSG_ERROR([required library toxcore was not found on your system]) - ] - ) -else - LDFLAGS="$LDFLAGS $LIBSODIUM_LDFLAGS $LIBSODIUM_LIBS" - AC_CHECK_LIB([toxcore], [tox_new], - [], - [ - AC_MSG_ERROR([required library toxcore was not found on your system]) - ] - ) -fi -LDFLAGS="$LDFLAGS_SAVE" -AC_SUBST(LIBTOXCORE_LIBS) -AC_SUBST(LIBTOXCORE_LDFLAGS) - - TOXIC_VERSION="$PACKAGE_VERSION" AC_PATH_PROG([GIT], [git], [no]) diff --git a/src/friendlist.c b/src/friendlist.c index b198656..768ab7f 100644 --- a/src/friendlist.c +++ b/src/friendlist.c @@ -10,7 +10,7 @@ #include #include -#include "tox.h" +#include #include "friendlist.h" diff --git a/src/main.c b/src/main.c index 390099a..7c8e1ac 100644 --- a/src/main.c +++ b/src/main.c @@ -25,7 +25,7 @@ #include #endif -#include "tox.h" +#include #include "configdir.h" #include "toxic_windows.h" diff --git a/src/toxic_windows.h b/src/toxic_windows.h index 34edf6f..f93b775 100644 --- a/src/toxic_windows.h +++ b/src/toxic_windows.h @@ -10,7 +10,7 @@ #include #include -#include "tox.h" +#include #define MAX_WINDOWS_NUM 32 #define MAX_FRIENDS_NUM 100