Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build cygwin #4

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
27 changes: 13 additions & 14 deletions README-Cygwin.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,52 @@ Install [Cygwin](https://www.cygwin.com/) and cygwin's package manager, [apt-cyg

In Cygwin Terminal, install compiler and tools :

apt-cyg install cygwin32-gcc-core cygwin32-gcc-g++ gcc-core gcc-g++ make wget patch diffutils grep tar gzip
apt-cyg install cygwin32-gcc-core cygwin32-gcc-g++ gcc-core gcc-g++ make patch diffutils grep tar gzip

Now you have a compiler, but no libraries. You need readline, openssl, libconfig, liblua, python and libjansson to use telegram-cli's full functionality.


Then Clone GitHub Repository in Cygwin Terminal
Clone tg Repository in Cygwin Terminal :

git clone --recursive https://github.com/vysheng/tg.git


In Cygwin Terminal, type:
In Cygwin Terminal, type :

apt-cyg install libevent-devel openssl-devel libreadline-devel lua-devel python3
(Install package 'python' to use Python 2.7, or install package 'python3' to use Python 3)
# (Choose 'python' instead of 'python3' to use Python 2.7 instead of Python 3)

libconfig and libjansson is not in cygwin's package, so you should compile yourself.

Compile libconfig
Compile libconfig :

wget http://www.hyperrealm.com/libconfig/libconfig-1.5.tar.gz
tar xvf libconfig-1.5.tar.gz && cd libconfig-1.5
./configure
make && make install && cd ..

Compile libjansson
Compile libjansson :

wget http://www.digip.org/jansson/releases/jansson-2.7.tar.gz
tar xvf jansson-2.7.tar.gz && cd jansson-2.7
./configure
make && make install && cd ..

Then, go to tg directory then generate Makefile.
Patch Makefile.in and compile :

cd tg
patch -p1 < build-cygwin.patch
./configure

We need to patch Makefile and loop.c to compile in cygwin. Download this [patch](https://gist.github.com/ied206/d774a445f36004d263ab) then untar. Then, patch in tg directory.

patch -p1 < telegram-cli-cygwin.patch

Then
make

If the patch doesn't work, modify Makefile.in manually :
remove -fPIC from COMPILE_FLAGS
remove -rdynamic from LOCAL_LDFLAGS

After compile is done, **telegram-cli.exe** will be generated in **bin** directory.

To run telegram-cli, type

bin/telegram-cli -k tg-server.pub

**Caution**: A binary compiled with Cygwin should be run in Cygwin Terminal.
**Caution**: A binary compiled with Cygwin is recommended to run in Cygwin Terminal.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ 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
make

#### Windows

In Windows, you should compile with Cygwin, which has POSIX API functionality.
Follow instructions at [READMD-Cygwin.md](https://github.com/vysheng/tg/blob/master/README-Cygwin.md).

#### Other UNIX

If you manage to launch it on other UNIX, please let me know.
Expand Down
15 changes: 7 additions & 8 deletions telegram-cli-cygwin.patch → build-cygwin.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
Binary files tg/.git/index and tg-cygwin/.git/index differ
diff -urN tg/Makefile tg-cygwin/Makefile
--- tg/Makefile 2015-06-16 12:39:34.931053900 +0900
+++ tg-cygwin/Makefile 2015-06-16 12:44:12.584342300 +0900
diff -urN tg/Makefile.in tg-cygwin/Makefile.in
--- tg/Makefile.in 2015-06-19 23:25:30.972865200 +0900
+++ tg-cygwin/Makefile.in 2015-06-19 23:26:07.870665200 +0900
@@ -4,9 +4,9 @@
LDFLAGS= -L/usr/local/lib -L/usr/lib -L/usr/lib -L/usr/lib
CPPFLAGS= -I/usr/local/include -I/usr/include -I/usr/include -I/usr/include/python3.4m -I/usr/include
DEFS=-DHAVE_CONFIG_H
LDFLAGS=@LDFLAGS@ @OPENSSL_LDFLAGS@
CPPFLAGS=@CPPFLAGS@ @OPENSSL_INCLUDES@
DEFS=@DEFS@
-COMPILE_FLAGS=${CFLAGS} ${CPFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Werror -Wextra -Wno-missing-field-initializers -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC
+COMPILE_FLAGS=${CFLAGS} ${CPFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Werror -Wextra -Wno-missing-field-initializers -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter
EXTRA_LIBS=-ljansson -lconfig -lz -levent -lm -lreadline -llua-5.2 -lpython3.4m -lssl -lcrypto
EXTRA_LIBS=@LIBS@ @EXTRA_LIBS@ @OPENSSL_LIBS@
-LOCAL_LDFLAGS=-rdynamic -ggdb -levent ${EXTRA_LIBS} -ldl -lpthread -lutil
+LOCAL_LDFLAGS=-ggdb -levent ${EXTRA_LIBS} -ldl -lpthread -lutil
LINK_FLAGS=${LDFLAGS} ${LOCAL_LDFLAGS}
Expand Down