From 99da1e7f1bba113fec9a81496a50e983552a110c Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Tue, 25 Feb 2014 14:11:37 +0100 Subject: [PATCH 01/11] Removed "-Wno-deprecated" from COMPILE_FLAGS This feature is new to GCC 4.4, while OpenBSD uses 4.2.1 --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 23a97dc..818c4fc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -4,7 +4,7 @@ CFLAGS=@CFLAGS@ LDFLAGS=@LDFLAGS@ CPPFLAGS=@CPPFLAGS@ DEFS=@DEFS@ -COMPILE_FLAGS=${CFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Wextra -Werror -Wno-deprecated -fno-strict-aliasing -fno-omit-frame-pointer -ggdb +COMPILE_FLAGS=${CFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Wextra -Werror -fno-strict-aliasing -fno-omit-frame-pointer -ggdb EXTRA_LIBS=@LIBS@ @EXTRA_LIBS@ LOCAL_LDFLAGS=-rdynamic -ggdb ${EXTRA_LIBS} From dc251f2b36e33639c4742cfc8ee0736d1fb51ce7 Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Tue, 25 Feb 2014 16:33:29 +0100 Subject: [PATCH 02/11] Stop tracking generated files * files, generated as side-effect of running ``configure'' script, * files, generated by ``configure'' script (Makefile, config.h), * ``telegram'' binary. All these files are setup-dependent and differ between targets. --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 5761abc..09500b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,7 @@ *.o +Makefile +autom4te.cache +config.h +config.log +config.status +telegram From eff4555d52498cf808116e3c8b4329c974ee9ec4 Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Tue, 25 Feb 2014 14:44:26 +0100 Subject: [PATCH 03/11] Don't tracked Makefile and config.h Both files are generated by ``configure'' script. Given that they: 1. may change after running ``configure'' and 2. are setup-dependent there's no need to track them anyway. --- Makefile | 35 ----------- config.h | 178 ------------------------------------------------------- 2 files changed, 213 deletions(-) delete mode 100644 Makefile delete mode 100644 config.h diff --git a/Makefile b/Makefile deleted file mode 100644 index bc91bb0..0000000 --- a/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -srcdir=. - -CFLAGS=-g -O2 -I/usr/include/lua5.2 -LDFLAGS= -CPPFLAGS= -DEFS=-DHAVE_CONFIG_H -COMPILE_FLAGS=${CFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Wextra -Werror -Wno-deprecated -fno-strict-aliasing -fno-omit-frame-pointer -ggdb - -EXTRA_LIBS=-lconfig -lcrypto -lz -lm -lreadline -llua5.2 -ldl -LOCAL_LDFLAGS=-rdynamic -ggdb ${EXTRA_LIBS} -LINK_FLAGS=${LDFLAGS} ${LOCAL_LDFLAGS} - -HEADERS= ${srcdir}/constants.h ${srcdir}/include.h ${srcdir}/interface.h ${srcdir}/LICENSE.h ${srcdir}/loop.h ${srcdir}/mtproto-client.h ${srcdir}/mtproto-common.h ${srcdir}/net.h ${srcdir}/no-preview.h ${srcdir}/queries.h ${srcdir}/structures.h ${srcdir}/telegram.h ${srcdir}/tree.h ${srcdir}/config.h ${srcdir}/binlog.h ${srcdir}/tools.h ${srcdir}/lua-tg.h -INCLUDE=-I. -I${srcdir} -CC=gcc -OBJECTS=main.o loop.o interface.o net.o mtproto-common.o mtproto-client.o queries.o structures.o binlog.o tools.o lua-tg.o - -.SUFFIXES: - -.SUFFIXES: .c .h .o - -all: telegram - -${OBJECTS}: ${HEADERS} - -telegram: ${OBJECTS} - ${CC} ${OBJECTS} ${LINK_FLAGS} -o $@ - -.c.o : - ${CC} ${COMPILE_FLAGS} ${INCLUDE} -c $< -o $@ - - -clean: - rm -rf *.o telegram config.log config.status > /dev/null || echo "all clean" - diff --git a/config.h b/config.h deleted file mode 100644 index 5f54b0c..0000000 --- a/config.h +++ /dev/null @@ -1,178 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the `alarm' function. */ -#define HAVE_ALARM 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ARPA_INET_H 1 - -/* Define to 1 if you have the `endpwent' function. */ -#define HAVE_ENDPWENT 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_EXECINFO_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LAUXLIB_H 1 - -/* Define to 1 if you have the `config' library (-lconfig). */ -#define HAVE_LIBCONFIG 1 - -/* Define to 1 if you have the `crypto' library (-lcrypto). */ -#define HAVE_LIBCRYPTO 1 - -/* Define to 1 if you have the `edit' library (-ledit). */ -/* #undef HAVE_LIBEDIT */ - -/* Define to 1 if you have the `m' library (-lm). */ -#define HAVE_LIBM 1 - -/* Define to 1 if you have the `z' library (-lz). */ -#define HAVE_LIBZ 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LUACONF_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LUALIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LUA_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_MACH_MACH_H */ - -/* Define to 1 if your system has a GNU libc compatible `malloc' function, and - to 0 otherwise. */ -#define HAVE_MALLOC 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MALLOC_H 1 - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `memset' function. */ -#define HAVE_MEMSET 1 - -/* Define to 1 if you have the `mkdir' function. */ -#define HAVE_MKDIR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_NETDB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_NETINET_IN_H 1 - -/* Define to 1 if your system has a GNU libc compatible `realloc' function, - and to 0 otherwise. */ -#define HAVE_REALLOC 1 - -/* Define to 1 if you have the `select' function. */ -#define HAVE_SELECT 1 - -/* Define to 1 if you have the `socket' function. */ -#define HAVE_SOCKET 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strdup' function. */ -#define HAVE_STRDUP 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strndup' function. */ -#define HAVE_STRNDUP 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SOCKET_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_TERMIOS_H 1 - -/* Define to 1 if you have the `uname' function. */ -#define HAVE_UNAME 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "telegram" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "telegram 0.1" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "telegram" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "0.1" - -/* Use custom prog name */ -/* #undef PROG_NAME */ - -/* Use libedit */ -/* #undef READLINE_EDIT */ - -/* Use gnu libreadline */ -#define READLINE_GNU 1 - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* use lua */ -#define USE_LUA 1 - -/* Define to `int' if doesn't define. */ -/* #undef gid_t */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -/* #undef inline */ -#endif - -/* Define to rpl_malloc if the replacement function should be used. */ -/* #undef malloc */ - -/* Define to rpl_realloc if the replacement function should be used. */ -/* #undef realloc */ - -/* Define to `unsigned int' if does not define. */ -/* #undef size_t */ - -/* Define to `int' if doesn't define. */ -/* #undef uid_t */ From f50ae8a80f6dc8d8f0aabf2417b73da43d0dd38b Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Tue, 25 Feb 2014 15:25:57 +0100 Subject: [PATCH 04/11] Added support for OpenBSD --- mtproto-client.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mtproto-client.c b/mtproto-client.c index 19c9a9c..6ea6def 100644 --- a/mtproto-client.c +++ b/mtproto-client.c @@ -31,7 +31,7 @@ #include #include #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__OpenBSD__) #include #endif #include @@ -58,6 +58,10 @@ #define __builtin_bswap32(x) bswap32(x) #endif +#if defined(__OpenBSD__) +#define __builtin_bswap32(x) __swap32gen(x) +#endif + #define sha1 SHA1 #include "mtproto-common.h" @@ -1720,7 +1724,7 @@ int rpc_execute (struct connection *c, int op, int len) { logprintf ( "have %d Response bytes\n", Response_len); } -#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined (__CYGWIN__) +#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined (__CYGWIN__) setsockopt (c->fd, IPPROTO_TCP, TCP_QUICKACK, (int[]){0}, 4); #endif int o = c_state; @@ -1728,19 +1732,19 @@ int rpc_execute (struct connection *c, int op, int len) { switch (o) { case st_reqpq_sent: process_respq_answer (c, Response/* + 8*/, Response_len/* - 12*/); -#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined (__CYGWIN__) +#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined (__CYGWIN__) setsockopt (c->fd, IPPROTO_TCP, TCP_QUICKACK, (int[]){0}, 4); #endif return 0; case st_reqdh_sent: process_dh_answer (c, Response/* + 8*/, Response_len/* - 12*/); -#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined (__CYGWIN__) +#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined (__CYGWIN__) setsockopt (c->fd, IPPROTO_TCP, TCP_QUICKACK, (int[]){0}, 4); #endif return 0; case st_client_dh_sent: process_auth_complete (c, Response/* + 8*/, Response_len/* - 12*/); -#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined (__CYGWIN__) +#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined (__CYGWIN__) setsockopt (c->fd, IPPROTO_TCP, TCP_QUICKACK, (int[]){0}, 4); #endif return 0; @@ -1750,7 +1754,7 @@ int rpc_execute (struct connection *c, int op, int len) { } else { process_rpc_message (c, (void *)(Response/* + 8*/), Response_len/* - 12*/); } -#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined (__CYGWIN__) +#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined (__CYGWIN__) setsockopt (c->fd, IPPROTO_TCP, TCP_QUICKACK, (int[]){0}, 4); #endif return 0; @@ -1778,7 +1782,7 @@ int tc_becomes_ready (struct connection *c) { assert (write_out (c, &byte, 1) == 1); flush_out (c); -#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined (__CYGWIN__) +#if !defined(__MACH__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined (__CYGWIN__) setsockopt (c->fd, IPPROTO_TCP, TCP_QUICKACK, (int[]){0}, 4); #endif int o = c_state; From 0783d303628170adc058967cd9aea0468be85d38 Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Tue, 25 Feb 2014 16:45:50 +0100 Subject: [PATCH 05/11] Update ax_lua.m4 Updated ax_lua.m4 to current version from GNU Autoconf Archive's git repository with additional patch to support OpenBSD.[1] Regenerated ``configure'' script. DOcumented changes. --- [1] https://savannah.gnu.org/patch/index.php?8355 --- README.md | 15 ++++++++++++++- ax_lua.m4 | 25 ++++++++++++++++--------- configure | 29 ++++++++++++++++++++--------- 3 files changed, 50 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 0818a6e..4c8375d 100644 --- a/README.md +++ b/README.md @@ -65,9 +65,22 @@ Install these ports: Then build: - $ env CC=clang CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib LUA=/usr/local/bin/lua52 LUA_INCLUDE=-I/usr/local/include/lua52 LUA_LIB=-llua-5.2 ./configure + $ env CC=clang CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ./configure $ make +#### OpenBSD + +Install these packages (or *ports*): + +* libconfig (*devel/libconfig*) +* libexecinfo (*devel/libexecinfo*) +* lua >= 5.2 (*lang/lua/5.2*) + +Then build: + + $ CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" ./configure + $ make + #### Other UNIX If you manage to launch it on other UNIX, please let me know. diff --git a/ax_lua.m4 b/ax_lua.m4 index c6f5974..d9f4773 100644 --- a/ax_lua.m4 +++ b/ax_lua.m4 @@ -109,6 +109,7 @@ # * /usr/include/lua/X.Y # * /usr/include/luaXY # * /usr/local/include/luaX.Y +# * /usr/local/include/lua-X.Y # * /usr/local/include/lua/X.Y # * /usr/local/include/luaXY # @@ -182,7 +183,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 20 +#serial 21 dnl ========================================================================= dnl AX_PROG_LUA([MINIMUM-VERSION], [TOO-BIG-VERSION], @@ -195,7 +196,7 @@ AC_DEFUN([AX_PROG_LUA], dnl Find a Lua interpreter. m4_define_default([_AX_LUA_INTERPRETER_LIST], - [lua lua5.2 lua5.1 lua50]) + [lua lua5.2 lua52 lua5.1 lua51 lua50]) m4_if([$1], [], [ dnl No version check is needed. Find any Lua interpreter. @@ -259,7 +260,7 @@ AC_DEFUN([AX_PROG_LUA], AC_CACHE_CHECK([for $ax_display_LUA version], [ax_cv_lua_version], [ ax_cv_lua_version=`$LUA -e "print(_VERSION)" | \ sed "s|^Lua \(.*\)|\1|" | \ - grep -o "^@<:@0-9@:>@\+\\.@<:@0-9@:>@\+"` + grep -E -o "^@<:@0-9@:>@+\.@<:@0-9@:>@+"` ]) AS_IF([test "x$ax_cv_lua_version" = 'x'], [AC_MSG_ERROR([invalid Lua version number])]) @@ -364,7 +365,7 @@ dnl ========================================================================= AC_DEFUN([_AX_LUA_CHK_VER], [ _ax_test_ver=`$1 -e "print(_VERSION)" 2>/dev/null | \ - sed "s|^Lua \(.*\)|\1|" | grep -o "^@<:@0-9@:>@\+\\.@<:@0-9@:>@\+"` + sed "s|^Lua \(.*\)|\1|" | grep -E -o "^@<:@0-9@:>@+\.@<:@0-9@:>@+"` AS_IF([test "x$_ax_test_ver" = 'x'], [_ax_test_ver='0']) AX_COMPARE_VERSION([$_ax_test_ver], [ge], [$2]) @@ -431,6 +432,7 @@ AC_DEFUN([AX_LUA_HEADERS], /usr/include/lua/$LUA_VERSION \ /usr/include/lua$LUA_SHORT_VERSION \ /usr/local/include/lua$LUA_VERSION \ + /usr/local/include/lua-$LUA_VERSION \ /usr/local/include/lua/$LUA_VERSION \ /usr/local/include/lua$LUA_SHORT_VERSION \ ]) @@ -490,7 +492,7 @@ int main(int argc, char ** argv) ], [ ax_cv_lua_header_version=`./conftest$EXEEXT p | \ sed "s|^Lua \(.*\)|\1|" | \ - grep -o "^@<:@0-9@:>@\+\\.@<:@0-9@:>@\+"` + grep -E -o "^@<:@0-9@:>@+\.@<:@0-9@:>@+"` ], [ax_cv_lua_header_version='unknown']) CPPFLAGS=$_ax_lua_saved_cppflags @@ -575,10 +577,15 @@ AC_DEFUN([AX_LUA_LIBS], dnl Try to find the Lua libs. _ax_lua_saved_libs=$LIBS LIBS="$LIBS $LUA_LIB" - AC_SEARCH_LIBS([lua_load], [lua$LUA_VERSION lua$LUA_SHORT_VERSION lua], - [_ax_found_lua_libs='yes'], - [_ax_found_lua_libs='no'], - [$_ax_lua_extra_libs]) + AC_SEARCH_LIBS([lua_load], + [ lua$LUA_VERSION \ + lua$LUA_SHORT_VERSION \ + lua-$LUA_VERSION \ + lua-$LUA_SHORT_VERSION \ + lua], + [_ax_found_lua_libs='yes'], + [_ax_found_lua_libs='no'], + [$_ax_lua_extra_libs]) LIBS=$_ax_lua_saved_libs AS_IF([test "x$ac_cv_search_lua_load" != 'xno' && diff --git a/configure b/configure index dd2e8ef..0b1cb9b 100755 --- a/configure +++ b/configure @@ -2279,6 +2279,7 @@ ac_config_headers="$ac_config_headers config.h" # * /usr/include/lua/X.Y # * /usr/include/luaXY # * /usr/local/include/luaX.Y +# * /usr/local/include/lua-X.Y # * /usr/local/include/lua/X.Y # * /usr/local/include/luaXY # @@ -2352,7 +2353,7 @@ ac_config_headers="$ac_config_headers config.h" # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 20 +#serial 21 @@ -4049,7 +4050,7 @@ $as_echo "enabled" >&6; } if test "x$LUA" = 'x'; then : - for ac_prog in lua lua5.2 lua5.1 lua50 + for ac_prog in lua lua5.2 lua52 lua5.1 lua51 lua50 do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -4126,7 +4127,7 @@ if ${ax_cv_lua_version+:} false; then : else ax_cv_lua_version=`$LUA -e "print(_VERSION)" | \ sed "s|^Lua \(.*\)|\1|" | \ - grep -o "^[0-9]\+\\.[0-9]\+"` + grep -E -o "^[0-9]+\.[0-9]+"` fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_lua_version" >&5 @@ -4290,6 +4291,7 @@ done /usr/include/lua/$LUA_VERSION \ /usr/include/lua$LUA_SHORT_VERSION \ /usr/local/include/lua$LUA_VERSION \ + /usr/local/include/lua-$LUA_VERSION \ /usr/local/include/lua/$LUA_VERSION \ /usr/local/include/lua$LUA_SHORT_VERSION \ ; do @@ -4363,7 +4365,7 @@ _ACEOF if ac_fn_c_try_run "$LINENO"; then : ax_cv_lua_header_version=`./conftest$EXEEXT p | \ sed "s|^Lua \(.*\)|\1|" | \ - grep -o "^[0-9]\+\\.[0-9]\+"` + grep -E -o "^[0-9]+\.[0-9]+"` else ax_cv_lua_header_version='unknown' @@ -4643,7 +4645,11 @@ return lua_load (); return 0; } _ACEOF -for ac_lib in '' lua$LUA_VERSION lua$LUA_SHORT_VERSION lua; do +for ac_lib in '' lua$LUA_VERSION \ + lua$LUA_SHORT_VERSION \ + lua-$LUA_VERSION \ + lua-$LUA_SHORT_VERSION \ + lua; do if test -z "$ac_lib"; then ac_res="none required" else @@ -4713,7 +4719,7 @@ $as_echo "enabled" >&6; } if test "x$LUA" = 'x'; then : - for ac_prog in lua lua5.2 lua5.1 lua50 + for ac_prog in lua lua5.2 lua52 lua5.1 lua51 lua50 do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -4790,7 +4796,7 @@ if ${ax_cv_lua_version+:} false; then : else ax_cv_lua_version=`$LUA -e "print(_VERSION)" | \ sed "s|^Lua \(.*\)|\1|" | \ - grep -o "^[0-9]\+\\.[0-9]\+"` + grep -E -o "^[0-9]+\.[0-9]+"` fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_lua_version" >&5 @@ -4954,6 +4960,7 @@ done /usr/include/lua/$LUA_VERSION \ /usr/include/lua$LUA_SHORT_VERSION \ /usr/local/include/lua$LUA_VERSION \ + /usr/local/include/lua-$LUA_VERSION \ /usr/local/include/lua/$LUA_VERSION \ /usr/local/include/lua$LUA_SHORT_VERSION \ ; do @@ -5027,7 +5034,7 @@ _ACEOF if ac_fn_c_try_run "$LINENO"; then : ax_cv_lua_header_version=`./conftest$EXEEXT p | \ sed "s|^Lua \(.*\)|\1|" | \ - grep -o "^[0-9]\+\\.[0-9]\+"` + grep -E -o "^[0-9]+\.[0-9]+"` else ax_cv_lua_header_version='unknown' @@ -5307,7 +5314,11 @@ return lua_load (); return 0; } _ACEOF -for ac_lib in '' lua$LUA_VERSION lua$LUA_SHORT_VERSION lua; do +for ac_lib in '' lua$LUA_VERSION \ + lua$LUA_SHORT_VERSION \ + lua-$LUA_VERSION \ + lua-$LUA_SHORT_VERSION \ + lua; do if test -z "$ac_lib"; then ac_res="none required" else From 6a44fe7dea48c35f0e4d806dc775878907803a8c Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Tue, 25 Feb 2014 16:57:35 +0100 Subject: [PATCH 06/11] On OpenBSD `telegram` should be linked with '-lcurses' --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c8375d..232ec0f 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ Install these packages (or *ports*): Then build: - $ CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" ./configure + $ CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" LIBS="-lcurses" ./configure $ make #### Other UNIX From 1ab7185fdc5925bac4cb67f955d3b810753f00dd Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Wed, 26 Feb 2014 10:15:35 +0100 Subject: [PATCH 07/11] Added "-Wno-deprecated-declarations" to COMPILE_FLAGS --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 818c4fc..200252c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -4,7 +4,7 @@ CFLAGS=@CFLAGS@ LDFLAGS=@LDFLAGS@ CPPFLAGS=@CPPFLAGS@ DEFS=@DEFS@ -COMPILE_FLAGS=${CFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Wextra -Werror -fno-strict-aliasing -fno-omit-frame-pointer -ggdb +COMPILE_FLAGS=${CFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb EXTRA_LIBS=@LIBS@ @EXTRA_LIBS@ LOCAL_LDFLAGS=-rdynamic -ggdb ${EXTRA_LIBS} From b64159aff7e780afa30d8e083ea13f304db6c17c Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Thu, 27 Feb 2014 00:46:44 +0100 Subject: [PATCH 08/11] When using libedit also search for curses --- README.md | 2 +- configure | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 1 + 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 232ec0f..4c8375d 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ Install these packages (or *ports*): Then build: - $ CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" LIBS="-lcurses" ./configure + $ CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" ./configure $ make #### Other UNIX diff --git a/configure b/configure index 0b1cb9b..e774e18 100755 --- a/configure +++ b/configure @@ -3467,6 +3467,62 @@ $as_echo "#define READLINE_GNU 1" >>confdefs.h else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetnum" >&5 +$as_echo_n "checking for library containing tgetnum... " >&6; } +if ${ac_cv_search_tgetnum+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char tgetnum (); +int +main () +{ +return tgetnum (); + ; + return 0; +} +_ACEOF +for ac_lib in '' ncursesw ncurses curses; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_tgetnum=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_tgetnum+:} false; then : + break +fi +done +if ${ac_cv_search_tgetnum+:} false; then : + +else + ac_cv_search_tgetnum=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_tgetnum" >&5 +$as_echo "$ac_cv_search_tgetnum" >&6; } +ac_res=$ac_cv_search_tgetnum +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_set_prompt in -ledit" >&5 $as_echo_n "checking for rl_set_prompt in -ledit... " >&6; } if ${ac_cv_lib_edit_rl_set_prompt+:} false; then : diff --git a/configure.ac b/configure.ac index f17039d..f3cf689 100644 --- a/configure.ac +++ b/configure.ac @@ -22,6 +22,7 @@ AC_CHECK_LIB([readline], [rl_save_prompt], [ EXTRA_LIBS="${EXTRA_LIBS} -lreadline" ; ] ], [ + AC_SEARCH_LIBS([tgetnum], [ncursesw ncurses curses]) AC_CHECK_LIB([edit], [rl_set_prompt]) AC_DEFINE([READLINE_EDIT], [1], [Use libedit]) [ EXTRA_LIBS="${EXTRA_LIBS} -ledit" ; ] From f3fb958ce44f8bfa860711251cc06d13c141b02e Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Thu, 27 Feb 2014 00:52:30 +0100 Subject: [PATCH 09/11] LUA_INCLUDE belongs to CPPFLAGS, not CFLAGS --- configure | 4 ++-- configure.ac | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure b/configure index e774e18..a8fbb6a 100755 --- a/configure +++ b/configure @@ -4755,7 +4755,7 @@ else fi EXTRA_LIBS="${EXTRA_LIBS} ${LUA_LIB}" ; - CFLAGS="${CFLAGS} ${LUA_INCLUDE}" ; + CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}" ; $as_echo "#define USE_LUA 1" >>confdefs.h @@ -5424,7 +5424,7 @@ else fi EXTRA_LIBS="${EXTRA_LIBS} ${LUA_LIB}" ; - CFLAGS="${CFLAGS} ${LUA_INCLUDE}" ; + CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}" ; $as_echo "#define USE_LUA 1" >>confdefs.h diff --git a/configure.ac b/configure.ac index f3cf689..61465b0 100644 --- a/configure.ac +++ b/configure.ac @@ -55,7 +55,7 @@ AC_ARG_ENABLE(liblua,[--enable-liblua/--disable-liblua], AX_LUA_HEADERS([],[AC_MSG_ERROR([No lua headers found. Try --disable-liblua])]) AX_LUA_LIBS([],[AC_MSG_ERROR([No lua libs found. Try --disable-liblua])]) [EXTRA_LIBS="${EXTRA_LIBS} ${LUA_LIB}" ; ] - [CFLAGS="${CFLAGS} ${LUA_INCLUDE}" ; ] + [CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}" ; ] AC_DEFINE(USE_LUA,1,[use lua]) ], [ @@ -69,7 +69,7 @@ AC_ARG_ENABLE(liblua,[--enable-liblua/--disable-liblua], AX_LUA_HEADERS([],[AC_MSG_ERROR([No lua headers found. Try --disable-liblua])]) AX_LUA_LIBS([],[AC_MSG_ERROR([No lua libs found. Try --disable-liblua])]) [EXTRA_LIBS="${EXTRA_LIBS} ${LUA_LIB}" ; ] - [CFLAGS="${CFLAGS} ${LUA_INCLUDE}" ; ] + [CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}" ; ] AC_DEFINE(USE_LUA,1,[use lua]) ], [ From 5dc4a61322a68cb59d98fe1ff3efa9e6195807ac Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Thu, 27 Feb 2014 01:06:44 +0100 Subject: [PATCH 10/11] Add /usr/local/include and /usr/local/lib to CPPFLAGS and LDFLAGS This allows to avoid extra options for BSDs and strangle Linux systems, where some libraries may be installed under "/usr/local" prefix. --- configure | 4 ++++ configure.ac | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/configure b/configure index a8fbb6a..0a54e9f 100755 --- a/configure +++ b/configure @@ -3171,6 +3171,10 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu +# BSD locations for headers and libraries from packages, Linux locations for self-compiled stuff. +CPPFLAGS="$CPPFLAGS -I/usr/local/include" +LDFLAGS="$LDFLAGS -L/usr/local/lib" + # Checks for libraries. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqrt in -lm" >&5 diff --git a/configure.ac b/configure.ac index 61465b0..6b0f5d7 100644 --- a/configure.ac +++ b/configure.ac @@ -8,6 +8,10 @@ m4_include([ax_lua.m4]) # Checks for programs. AC_PROG_CC +# BSD locations for headers and libraries from packages, Linux locations for self-compiled stuff. +CPPFLAGS="$CPPFLAGS -I/usr/local/include" +LDFLAGS="$LDFLAGS -L/usr/local/lib" + # Checks for libraries. AC_CHECK_LIB([m], [sqrt]) AC_SEARCH_LIBS([clock_gettime], [rt]) From c373008400893f97ba0da4d8be93e66ab45f13b7 Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Thu, 27 Feb 2014 01:09:56 +0100 Subject: [PATCH 11/11] Clean up and merge Linux and BSD instructions * Now BSDs don't require setting environment for configure. * No default Makefile any more. --- README.md | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 4c8375d..748d6e3 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,15 @@ or download and extract zip $ wget https://github.com/vysheng/tg/archive/master.zip -O tg-master.zip $ unzip tg-master.zip && cd tg-master -#### Linux +#### Linux and BSDs + +Install libs: readline or libedit, openssl and (if you want to use config) libconfig and liblua. +If you do not want to use them pass options --disable-libconfig and --disable-liblua respectively. -Install libs: readline openssl and (if you want to use config) libconfig and liblua. -If you do not want to use them pass options --disable-libconfig and --disable-liblua respectively On ubuntu use: $ sudo apt-get install libreadline-dev libconfig-dev libssl-dev lua5.2 liblua5.2-dev + On gentoo: $ sudo emerge -av sys-libs/readline dev-libs/libconfig dev-libs/openssl dev-lang/lua @@ -34,7 +36,13 @@ On Fedora: $ sudo yum install lua-devel openssl-devel libconfig-devel readline-devel -Default Makefile uses liblua5.2 from ubuntu. If you use different version of liblua or linux you have to run ./configure script or you will get some strange compilation error. +On FreeBSD: + + $ pkg install libconfig libexecinfo lua52 + +On OpenBSD: + + $ pkg_add libconfig libexecinfo lua Then @@ -55,31 +63,6 @@ The client depends on [readline library](http://cnswww.cns.cwru.edu/php/chet/rea Thanks to [@jfontan](https://github.com/vysheng/tg/issues/3#issuecomment-28293731) for this solution. -#### FreeBSD - -Install these ports: - -* devel/libconfig -* devel/libexecinfo -* lang/lua52 - -Then build: - - $ env CC=clang CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ./configure - $ make - -#### OpenBSD - -Install these packages (or *ports*): - -* libconfig (*devel/libconfig*) -* libexecinfo (*devel/libexecinfo*) -* lua >= 5.2 (*lang/lua/5.2*) - -Then build: - - $ CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" ./configure - $ make #### Other UNIX