diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | BUILD.md | 15 | ||||
-rw-r--r-- | Makefile.mac | 28 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | client.c | 6 | ||||
-rw-r--r-- | mach.c | 22 | ||||
-rw-r--r-- | mach.h | 14 | ||||
-rw-r--r-- | main.c | 6 |
8 files changed, 96 insertions, 3 deletions
@@ -27,3 +27,7 @@ | |||
27 | *.i*86 | 27 | *.i*86 |
28 | *.x86_64 | 28 | *.x86_64 |
29 | *.hex | 29 | *.hex |
30 | |||
31 | # tuntox related, not needed in repo | ||
32 | tuntox | ||
33 | gitversion.h | ||
@@ -4,4 +4,17 @@ | |||
4 | * cd tuntox | 4 | * cd tuntox |
5 | * make | 5 | * make |
6 | 6 | ||
7 | The makefile creates a static binary by default. If you're not a fan of static binaries, remove "-static" from LDFLAGS. One reason to do so may be if you'd like to resolve hostnames on the tuntox server (invoke client with -L 80:reddit.com:80 instead of -L 80:198.41.208.138:80). Static linking breaks hostname resolution, but IMHO the pros overweight the cons. | 7 | The makefile creates a static binary by default. If you're not a fan of static binaries, remove `-static` from `LDFLAGS`. |
8 | |||
9 | One reason to do so may be if you'd like to resolve hostnames on the tuntox server (invoke client with `-L 80:reddit.com:80` instead of `-L 80:198.41.208.138:80`). | ||
10 | |||
11 | Static linking breaks hostname resolution, but IMHO the pros overweight the cons. | ||
12 | |||
13 | ## MacOS build | ||
14 | Basically the same as above but: | ||
15 | |||
16 | * static compiling is removed - you can't do this on MacOS platform (no, just don't) | ||
17 | * because of removed `-static` you can't resolve hostnames (you can always put it into `hosts` file in your system) | ||
18 | |||
19 | If you'd like to build on Mac do: `make -f Makefile.mac` | ||
20 | |||
diff --git a/Makefile.mac b/Makefile.mac new file mode 100644 index 0000000..ee41cda --- /dev/null +++ b/Makefile.mac | |||
@@ -0,0 +1,28 @@ | |||
1 | SOURCES = $(wildcard *.c) | ||
2 | DEPS=libtoxcore | ||
3 | CC=gcc | ||
4 | CFLAGS=-g #-std=c99 | ||
5 | CFLAGS += $(shell pkg-config --cflags $(DEPS)) | ||
6 | LDFLAGS=-g -lm | ||
7 | LDFLAGS += $(shell pkg-config --libs $(DEPS)) | ||
8 | OBJECTS=$(SOURCES:.c=.o) | ||
9 | INCLUDES = $(wildcard *.h) | ||
10 | |||
11 | all: cscope.out tuntox | ||
12 | |||
13 | gitversion.h: .git/HEAD .git/index | ||
14 | echo "#define GITVERSION \"$(shell git rev-parse HEAD)\"" > $@ | ||
15 | |||
16 | gitversion.c: gitversion.h | ||
17 | |||
18 | .c.o: $(INCLUDES) | ||
19 | $(CC) $(CFLAGS) $< -c -o $@ | ||
20 | |||
21 | tuntox: $(OBJECTS) $(INCLUDES) | ||
22 | $(CC) -o $@ $(OBJECTS) -ltoxcore $(LDFLAGS) /usr/local/lib/libsodium.a /usr/local/lib/libtoxcore.a | ||
23 | |||
24 | cscope.out: | ||
25 | cscope -bv ./*.[ch] | ||
26 | |||
27 | clean: | ||
28 | rm -rf *.o tuntox gitversion.h | ||
@@ -8,6 +8,8 @@ Tuntox is a single binary which may run in client mode or server mode. As a rule | |||
8 | 8 | ||
9 | If you don't know what Tox is - it's an instant messenger protocol which is fully P2P, supports audio/video calls and file transfers. Unlike Skype it's fully open and unlike, say, XMPP - the calls and file transfers actually work. Go download a client from http://utox.org/ or read more at https://tox.im/ | 9 | If you don't know what Tox is - it's an instant messenger protocol which is fully P2P, supports audio/video calls and file transfers. Unlike Skype it's fully open and unlike, say, XMPP - the calls and file transfers actually work. Go download a client from http://utox.org/ or read more at https://tox.im/ |
10 | 10 | ||
11 | [![Coverity Scan Build Status](https://scan.coverity.com/projects/5690/badge.svg)](https://scan.coverity.com/projects/5690) | ||
12 | |||
11 | ## Binary | 13 | ## Binary |
12 | 14 | ||
13 | Get the binaries from Releases tab on github. Just download the correct file for your architecture, execute chmod +x and you're done. The binaries are signed with my PGP key, [11C1 B15A 5D5D D662 E469 928A EBDA 6B97 4ED3 D2B7](https://keybase.io/gdr). | 15 | Get the binaries from Releases tab on github. Just download the correct file for your architecture, execute chmod +x and you're done. The binaries are signed with my PGP key, [11C1 B15A 5D5D D662 E469 928A EBDA 6B97 4ED3 D2B7](https://keybase.io/gdr). |
@@ -68,6 +70,6 @@ Tuntox is piggybacking on the Tox protocol, which itself has not been audited by | |||
68 | 70 | ||
69 | Sorry about GPLv3 - both toxcore and utox (from which I borrowed some code) are GPLv3. | 71 | Sorry about GPLv3 - both toxcore and utox (from which I borrowed some code) are GPLv3. |
70 | 72 | ||
71 | Thank you to the toxcore and utox developers without whom this program would never exist. [Donate to Tox](https://donate.tox.im/) so they can get a proper audit. | 73 | Thank you to the toxcore and utox developers without whom this program would never exist. |
72 | 74 | ||
73 | Thank you Mr_4551 for your help and motivation. | 75 | Thank you Mr_4551 for your help and motivation. |
@@ -1,4 +1,10 @@ | |||
1 | #include <time.h> | 1 | #include <time.h> |
2 | |||
3 | /* MacOS related */ | ||
4 | #ifdef __MACH__ | ||
5 | #include "mach.h" | ||
6 | #endif | ||
7 | |||
2 | #include "log.h" | 8 | #include "log.h" |
3 | #include "main.h" | 9 | #include "main.h" |
4 | #include "client.h" | 10 | #include "client.h" |
@@ -0,0 +1,22 @@ | |||
1 | #ifdef __MACH__ | ||
2 | #include "mach.h" | ||
3 | |||
4 | /* there is no clock_gettime on MacOS platform */ | ||
5 | int clock_gettime(int clk_id, struct timespec *t) | ||
6 | { | ||
7 | mach_timebase_info_data_t timebase; | ||
8 | mach_timebase_info(&timebase); | ||
9 | |||
10 | uint64_t time; | ||
11 | |||
12 | time = mach_absolute_time(); | ||
13 | |||
14 | double nseconds = ((double)time * (double)timebase.numer) / ((double)timebase.denom); | ||
15 | double seconds = ((double)time * (double)timebase.numer) / ((double)timebase.denom * 1e9); | ||
16 | |||
17 | t->tv_sec = seconds; | ||
18 | t->tv_nsec = nseconds; | ||
19 | |||
20 | return 0; | ||
21 | } | ||
22 | #endif | ||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef _MACH_H | ||
2 | #define _MACH_H | ||
3 | |||
4 | #include <time.h> | ||
5 | #include <mach/mach_time.h> | ||
6 | |||
7 | // there is no CLOCK_REALTIME or CLOCK_MONOTONIC on MacOS platform | ||
8 | #define CLOCK_REALTIME 0 | ||
9 | #define CLOCK_MONOTONIC 0 | ||
10 | |||
11 | // MacOS doesn't support the flag MSG_NOSIGNAL | ||
12 | #define MSG_NOSIGNAL SO_NOSIGPIPE | ||
13 | |||
14 | #endif \ No newline at end of file | ||
@@ -3,6 +3,10 @@ | |||
3 | #include "tox_bootstrap.h" | 3 | #include "tox_bootstrap.h" |
4 | #include "log.h" | 4 | #include "log.h" |
5 | 5 | ||
6 | #ifdef __MACH__ | ||
7 | #include "mach.h" | ||
8 | #endif | ||
9 | |||
6 | static struct Tox_Options tox_options; | 10 | static struct Tox_Options tox_options; |
7 | Tox *tox; | 11 | Tox *tox; |
8 | int client_socket = 0; | 12 | int client_socket = 0; |
@@ -1135,7 +1139,7 @@ int main(int argc, char *argv[]) | |||
1135 | do_daemonize(); | 1139 | do_daemonize(); |
1136 | } | 1140 | } |
1137 | 1141 | ||
1138 | on_exit(cleanup, NULL); | 1142 | atexit(cleanup); |
1139 | 1143 | ||
1140 | print_version(); | 1144 | print_version(); |
1141 | 1145 | ||