summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore24
-rw-r--r--.travis.yml8
-rw-r--r--AUTHORS0
-rwxr-xr-xCMakeLists.txt67
-rw-r--r--ChangeLog0
-rw-r--r--INSTALL365
-rw-r--r--Makefile.am27
-rw-r--r--NEWS0
l---------README1
-rw-r--r--auto_tests/CMakeLists.txt22
-rw-r--r--auto_tests/Makefile.inc34
-rw-r--r--auto_tests/cmake/crypto_test.cmake10
-rw-r--r--auto_tests/cmake/friends_test.cmake10
-rw-r--r--auto_tests/cmake/messenger_test.cmake10
-rw-r--r--auto_tests/crypto_test.c2
-rw-r--r--auto_tests/friends_test.c4
-rw-r--r--auto_tests/messenger_test.c3
-rw-r--r--build/Makefile.am10
-rw-r--r--cmake/FindCheck.cmake46
-rw-r--r--cmake/FindCursesw.cmake47
-rw-r--r--cmake/FindLIBCONFIG.cmake20
-rw-r--r--cmake/FindNaCl.cmake17
-rw-r--r--cmake/FindSODIUM.cmake75
-rw-r--r--cmake/FindSphinx.cmake16
-rw-r--r--cmake/InstallPkgConfigFile.cmake78
-rw-r--r--configure.ac336
-rw-r--r--core/CMakeLists.txt45
-rw-r--r--docs/CMakeLists.txt38
-rw-r--r--libtoxcore.pc.in12
-rw-r--r--m4/pkg.m4199
-rw-r--r--other/CMakeLists.txt23
-rw-r--r--other/DHT_bootstrap.c4
-rw-r--r--other/Makefile.inc18
-rw-r--r--other/bootstrap_serverdaemon/CMakeLists.txt19
-rw-r--r--other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c4
-rw-r--r--other/bootstrap_serverdaemon/Makefile.inc23
-rw-r--r--other/bootstrap_serverdaemon/cmake/Modules/FindLibConfig.cmake73
-rw-r--r--other/cmake/DHT_bootstrap.cmake10
-rw-r--r--other/unused/timer.c290
-rw-r--r--other/unused/timer.h104
-rw-r--r--testing/CMakeLists.txt15
-rw-r--r--testing/DHT_test.c4
-rw-r--r--testing/Lossless_UDP_testclient.c4
-rw-r--r--testing/Lossless_UDP_testserver.c4
-rw-r--r--testing/Makefile.inc89
-rw-r--r--testing/Messenger_test.c2
-rw-r--r--testing/cmake/DHT_test.cmake10
-rw-r--r--testing/cmake/Lossless_UDP_testclient.cmake9
-rw-r--r--testing/cmake/Lossless_UDP_testserver.cmake9
-rw-r--r--testing/cmake/Messenger_test.cmake9
-rw-r--r--testing/cmake/crypto_speed_test.cmake9
-rw-r--r--testing/cmake/nTox.cmake12
-rw-r--r--testing/crypto_speed_test.c2
-rw-r--r--testing/nTox.h2
-rw-r--r--toxcore/DHT.c (renamed from core/DHT.c)0
-rw-r--r--toxcore/DHT.h (renamed from core/DHT.h)0
-rw-r--r--toxcore/LAN_discovery.c (renamed from core/LAN_discovery.c)0
-rw-r--r--toxcore/LAN_discovery.h (renamed from core/LAN_discovery.h)0
-rw-r--r--toxcore/Lossless_UDP.c (renamed from core/Lossless_UDP.c)0
-rw-r--r--toxcore/Lossless_UDP.h (renamed from core/Lossless_UDP.h)0
-rw-r--r--toxcore/Makefile.inc40
-rw-r--r--toxcore/Messenger.c (renamed from core/Messenger.c)0
-rw-r--r--toxcore/Messenger.h (renamed from core/Messenger.h)0
-rw-r--r--toxcore/friend_requests.c (renamed from core/friend_requests.c)0
-rw-r--r--toxcore/friend_requests.h (renamed from core/friend_requests.h)0
-rw-r--r--toxcore/net_crypto.c (renamed from core/net_crypto.c)0
-rw-r--r--toxcore/net_crypto.h (renamed from core/net_crypto.h)0
-rw-r--r--toxcore/network.c (renamed from core/network.c)0
-rw-r--r--toxcore/network.h (renamed from core/network.h)0
-rw-r--r--toxcore/packets.h (renamed from core/packets.h)0
-rw-r--r--toxcore/ping.c (renamed from core/ping.c)0
-rw-r--r--toxcore/ping.h (renamed from core/ping.h)0
-rw-r--r--toxcore/tox.c (renamed from core/tox.c)0
-rw-r--r--toxcore/tox.h (renamed from core/tox.h)0
-rw-r--r--toxcore/util.c (renamed from core/util.c)0
-rw-r--r--toxcore/util.h (renamed from core/util.h)0
76 files changed, 1198 insertions, 1116 deletions
diff --git a/.gitignore b/.gitignore
index 49ac783a..99f6cfe8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,7 +2,8 @@
2 2
3//nacl build 3//nacl build
4nacl/build/ 4nacl/build/
5build 5build/
6!build/Makefile.am
6sodium 7sodium
7 8
8CMakeCache.txt 9CMakeCache.txt
@@ -22,11 +23,32 @@ tags
22 23
23# Object files 24# Object files
24*.o 25*.o
26*.lo
27*.a
25 28
26# Executables 29# Executables
27*.exe 30*.exe
28*.out 31*.out
29*.app 32*.app
33*.swp
34*.la
35
36m4/*
37!m4/pkg.m4
38configure
39configure_aux
40Makefile.in
41aclocal.m4
42config.h*
43config.log
44config.status
45stamp-h1
46autom4te.cache
47libtoxcore.pc
48libtool
49
50.deps
51.libs
30 52
31#netbeans 53#netbeans
32nbproject 54nbproject
diff --git a/.travis.yml b/.travis.yml
index c8b479f8..931c27b5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -27,12 +27,10 @@ before_script:
27 - sudo apt-get install check 27 - sudo apt-get install check
28 28
29script: 29script:
30 - mkdir build && cd build 30 - autoreconf -i
31 - cmake .. 31 - ./configure
32 - make -j3 32 - make -j3
33 - make test 33 - make check
34# build docs separately
35 - make docs
36 34
37notifications: 35notifications:
38 email: false 36 email: false
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/AUTHORS
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100755
index cba0013c..00000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,67 +0,0 @@
1cmake_minimum_required(VERSION 2.6.0)
2
3set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
4
5option(SHARED_TOXCORE "Build Core as a shared library")
6
7if(WIN32)
8 option(SHARED_LIBSODIUM "Links libsodium as a shared library")
9else()
10 option(USE_NACL "Use NaCl library instead of libsodium")
11 option(NO_WIDECHAR "Do not use wide char, even if supported")
12endif()
13
14#OS X specific
15if(APPLE)
16 set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /opt/local/lib)
17 set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /opt/local/include)
18 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/opt/local/include" )
19 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/local/lib")
20endif()
21
22if(UNIX)
23 find_package(Cursesw REQUIRED)
24endif()
25
26if(USE_NACL)
27 find_package(NaCl REQUIRED)
28
29 include_directories(${NACL_INCLUDE_DIR})
30 add_definitions(-DVANILLA_NACL)
31
32 set(LINK_CRYPTO_LIBRARY ${NACL_LIBRARIES})
33else()
34 find_package(SODIUM REQUIRED)
35
36 include_directories(${SODIUM_INCLUDE_DIR})
37
38 set(LINK_CRYPTO_LIBRARY ${SODIUM_LIBRARIES})
39endif()
40
41#MinGW prints more warnings for -Wall than gcc does, thus causing build to fail
42if(NOT WIN32)
43 if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang"))
44 message(STATUS "==== ${CMAKE_C_COMPILER_ID} detected - Adding compiler flags ====")
45 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")
46 endif()
47endif()
48
49macro(linkCoreLibraries exe_name)
50 add_dependencies(${exe_name} toxcore)
51 target_link_libraries(${exe_name} toxcore
52 ${LINK_CRYPTO_LIBRARY})
53
54 if(WIN32)
55 target_link_libraries(${exe_name} ws2_32)
56 endif()
57endmacro()
58
59cmake_policy(SET CMP0011 NEW)
60
61add_subdirectory(core)
62add_subdirectory(testing)
63add_subdirectory(other)
64add_subdirectory(docs)
65if(UNIX)
66 add_subdirectory(auto_tests)
67endif()
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/ChangeLog
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 00000000..7d1c323b
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,365 @@
1Installation Instructions
2*************************
3
4Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
52006, 2007, 2008, 2009 Free Software Foundation, Inc.
6
7 Copying and distribution of this file, with or without modification,
8are permitted in any medium without royalty provided the copyright
9notice and this notice are preserved. This file is offered as-is,
10without warranty of any kind.
11
12Basic Installation
13==================
14
15 Briefly, the shell commands `./configure; make; make install' should
16configure, build, and install this package. The following
17more-detailed instructions are generic; see the `README' file for
18instructions specific to this package. Some packages provide this
19`INSTALL' file but do not implement all of the features documented
20below. The lack of an optional feature in a given package is not
21necessarily a bug. More recommendations for GNU packages can be found
22in *note Makefile Conventions: (standards)Makefile Conventions.
23
24 The `configure' shell script attempts to guess correct values for
25various system-dependent variables used during compilation. It uses
26those values to create a `Makefile' in each directory of the package.
27It may also create one or more `.h' files containing system-dependent
28definitions. Finally, it creates a shell script `config.status' that
29you can run in the future to recreate the current configuration, and a
30file `config.log' containing compiler output (useful mainly for
31debugging `configure').
32
33 It can also use an optional file (typically called `config.cache'
34and enabled with `--cache-file=config.cache' or simply `-C') that saves
35the results of its tests to speed up reconfiguring. Caching is
36disabled by default to prevent problems with accidental use of stale
37cache files.
38
39 If you need to do unusual things to compile the package, please try
40to figure out how `configure' could check whether to do them, and mail
41diffs or instructions to the address given in the `README' so they can
42be considered for the next release. If you are using the cache, and at
43some point `config.cache' contains results you don't want to keep, you
44may remove or edit it.
45
46 The file `configure.ac' (or `configure.in') is used to create
47`configure' by a program called `autoconf'. You need `configure.ac' if
48you want to change it or regenerate `configure' using a newer version
49of `autoconf'.
50
51 The simplest way to compile this package is:
52
53 1. `cd' to the directory containing the package's source code and type
54 `./configure' to configure the package for your system.
55
56 Running `configure' might take a while. While running, it prints
57 some messages telling which features it is checking for.
58
59 2. Type `make' to compile the package.
60
61 3. Optionally, type `make check' to run any self-tests that come with
62 the package, generally using the just-built uninstalled binaries.
63
64 4. Type `make install' to install the programs and any data files and
65 documentation. When installing into a prefix owned by root, it is
66 recommended that the package be configured and built as a regular
67 user, and only the `make install' phase executed with root
68 privileges.
69
70 5. Optionally, type `make installcheck' to repeat any self-tests, but
71 this time using the binaries in their final installed location.
72 This target does not install anything. Running this target as a
73 regular user, particularly if the prior `make install' required
74 root privileges, verifies that the installation completed
75 correctly.
76
77 6. You can remove the program binaries and object files from the
78 source code directory by typing `make clean'. To also remove the
79 files that `configure' created (so you can compile the package for
80 a different kind of computer), type `make distclean'. There is
81 also a `make maintainer-clean' target, but that is intended mainly
82 for the package's developers. If you use it, you may have to get
83 all sorts of other programs in order to regenerate files that came
84 with the distribution.
85
86 7. Often, you can also type `make uninstall' to remove the installed
87 files again. In practice, not all packages have tested that
88 uninstallation works correctly, even though it is required by the
89 GNU Coding Standards.
90
91 8. Some packages, particularly those that use Automake, provide `make
92 distcheck', which can by used by developers to test that all other
93 targets like `make install' and `make uninstall' work correctly.
94 This target is generally not run by end users.
95
96Compilers and Options
97=====================
98
99 Some systems require unusual options for compilation or linking that
100the `configure' script does not know about. Run `./configure --help'
101for details on some of the pertinent environment variables.
102
103 You can give `configure' initial values for configuration parameters
104by setting variables in the command line or in the environment. Here
105is an example:
106
107 ./configure CC=c99 CFLAGS=-g LIBS=-lposix
108
109 *Note Defining Variables::, for more details.
110
111Compiling For Multiple Architectures
112====================================
113
114 You can compile the package for more than one kind of computer at the
115same time, by placing the object files for each architecture in their
116own directory. To do this, you can use GNU `make'. `cd' to the
117directory where you want the object files and executables to go and run
118the `configure' script. `configure' automatically checks for the
119source code in the directory that `configure' is in and in `..'. This
120is known as a "VPATH" build.
121
122 With a non-GNU `make', it is safer to compile the package for one
123architecture at a time in the source code directory. After you have
124installed the package for one architecture, use `make distclean' before
125reconfiguring for another architecture.
126
127 On MacOS X 10.5 and later systems, you can create libraries and
128executables that work on multiple system types--known as "fat" or
129"universal" binaries--by specifying multiple `-arch' options to the
130compiler but only a single `-arch' option to the preprocessor. Like
131this:
132
133 ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
134 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
135 CPP="gcc -E" CXXCPP="g++ -E"
136
137 This is not guaranteed to produce working output in all cases, you
138may have to build one architecture at a time and combine the results
139using the `lipo' tool if you have problems.
140
141Installation Names
142==================
143
144 By default, `make install' installs the package's commands under
145`/usr/local/bin', include files under `/usr/local/include', etc. You
146can specify an installation prefix other than `/usr/local' by giving
147`configure' the option `--prefix=PREFIX', where PREFIX must be an
148absolute file name.
149
150 You can specify separate installation prefixes for
151architecture-specific files and architecture-independent files. If you
152pass the option `--exec-prefix=PREFIX' to `configure', the package uses
153PREFIX as the prefix for installing programs and libraries.
154Documentation and other data files still use the regular prefix.
155
156 In addition, if you use an unusual directory layout you can give
157options like `--bindir=DIR' to specify different values for particular
158kinds of files. Run `configure --help' for a list of the directories
159you can set and what kinds of files go in them. In general, the
160default for these options is expressed in terms of `${prefix}', so that
161specifying just `--prefix' will affect all of the other directory
162specifications that were not explicitly provided.
163
164 The most portable way to affect installation locations is to pass the
165correct locations to `configure'; however, many packages provide one or
166both of the following shortcuts of passing variable assignments to the
167`make install' command line to change installation locations without
168having to reconfigure or recompile.
169
170 The first method involves providing an override variable for each
171affected directory. For example, `make install
172prefix=/alternate/directory' will choose an alternate location for all
173directory configuration variables that were expressed in terms of
174`${prefix}'. Any directories that were specified during `configure',
175but not in terms of `${prefix}', must each be overridden at install
176time for the entire installation to be relocated. The approach of
177makefile variable overrides for each directory variable is required by
178the GNU Coding Standards, and ideally causes no recompilation.
179However, some platforms have known limitations with the semantics of
180shared libraries that end up requiring recompilation when using this
181method, particularly noticeable in packages that use GNU Libtool.
182
183 The second method involves providing the `DESTDIR' variable. For
184example, `make install DESTDIR=/alternate/directory' will prepend
185`/alternate/directory' before all installation names. The approach of
186`DESTDIR' overrides is not required by the GNU Coding Standards, and
187does not work on platforms that have drive letters. On the other hand,
188it does better at avoiding recompilation issues, and works well even
189when some directory options were not specified in terms of `${prefix}'
190at `configure' time.
191
192Optional Features
193=================
194
195 If the package supports it, you can cause programs to be installed
196with an extra prefix or suffix on their names by giving `configure' the
197option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
198
199 Some packages pay attention to `--enable-FEATURE' options to
200`configure', where FEATURE indicates an optional part of the package.
201They may also pay attention to `--with-PACKAGE' options, where PACKAGE
202is something like `gnu-as' or `x' (for the X Window System). The
203`README' should mention any `--enable-' and `--with-' options that the
204package recognizes.
205
206 For packages that use the X Window System, `configure' can usually
207find the X include and library files automatically, but if it doesn't,
208you can use the `configure' options `--x-includes=DIR' and
209`--x-libraries=DIR' to specify their locations.
210
211 Some packages offer the ability to configure how verbose the
212execution of `make' will be. For these packages, running `./configure
213--enable-silent-rules' sets the default to minimal output, which can be
214overridden with `make V=1'; while running `./configure
215--disable-silent-rules' sets the default to verbose, which can be
216overridden with `make V=0'.
217
218Particular systems
219==================
220
221 On HP-UX, the default C compiler is not ANSI C compatible. If GNU
222CC is not installed, it is recommended to use the following options in
223order to use an ANSI C compiler:
224
225 ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
226
227and if that doesn't work, install pre-built binaries of GCC for HP-UX.
228
229 On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
230parse its `<wchar.h>' header file. The option `-nodtk' can be used as
231a workaround. If GNU CC is not installed, it is therefore recommended
232to try
233
234 ./configure CC="cc"
235
236and if that doesn't work, try
237
238 ./configure CC="cc -nodtk"
239
240 On Solaris, don't put `/usr/ucb' early in your `PATH'. This
241directory contains several dysfunctional programs; working variants of
242these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
243in your `PATH', put it _after_ `/usr/bin'.
244
245 On Haiku, software installed for all users goes in `/boot/common',
246not `/usr/local'. It is recommended to use the following options:
247
248 ./configure --prefix=/boot/common
249
250Specifying the System Type
251==========================
252
253 There may be some features `configure' cannot figure out
254automatically, but needs to determine by the type of machine the package
255will run on. Usually, assuming the package is built to be run on the
256_same_ architectures, `configure' can figure that out, but if it prints
257a message saying it cannot guess the machine type, give it the
258`--build=TYPE' option. TYPE can either be a short name for the system
259type, such as `sun4', or a canonical name which has the form:
260
261 CPU-COMPANY-SYSTEM
262
263where SYSTEM can have one of these forms:
264
265 OS
266 KERNEL-OS
267
268 See the file `config.sub' for the possible values of each field. If
269`config.sub' isn't included in this package, then this package doesn't
270need to know the machine type.
271
272 If you are _building_ compiler tools for cross-compiling, you should
273use the option `--target=TYPE' to select the type of system they will
274produce code for.
275
276 If you want to _use_ a cross compiler, that generates code for a
277platform different from the build platform, you should specify the
278"host" platform (i.e., that on which the generated programs will
279eventually be run) with `--host=TYPE'.
280
281Sharing Defaults
282================
283
284 If you want to set default values for `configure' scripts to share,
285you can create a site shell script called `config.site' that gives
286default values for variables like `CC', `cache_file', and `prefix'.
287`configure' looks for `PREFIX/share/config.site' if it exists, then
288`PREFIX/etc/config.site' if it exists. Or, you can set the
289`CONFIG_SITE' environment variable to the location of the site script.
290A warning: not all `configure' scripts look for a site script.
291
292Defining Variables
293==================
294
295 Variables not defined in a site shell script can be set in the
296environment passed to `configure'. However, some packages may run
297configure again during the build, and the customized values of these
298variables may be lost. In order to avoid this problem, you should set
299them in the `configure' command line, using `VAR=value'. For example:
300
301 ./configure CC=/usr/local2/bin/gcc
302
303causes the specified `gcc' to be used as the C compiler (unless it is
304overridden in the site shell script).
305
306Unfortunately, this technique does not work for `CONFIG_SHELL' due to
307an Autoconf bug. Until the bug is fixed you can use this workaround:
308
309 CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
310
311`configure' Invocation
312======================
313
314 `configure' recognizes the following options to control how it
315operates.
316
317`--help'
318`-h'
319 Print a summary of all of the options to `configure', and exit.
320
321`--help=short'
322`--help=recursive'
323 Print a summary of the options unique to this package's
324 `configure', and exit. The `short' variant lists options used
325 only in the top level, while the `recursive' variant lists options
326 also present in any nested packages.
327
328`--version'
329`-V'
330 Print the version of Autoconf used to generate the `configure'
331 script, and exit.
332
333`--cache-file=FILE'
334 Enable the cache: use and save the results of the tests in FILE,
335 traditionally `config.cache'. FILE defaults to `/dev/null' to
336 disable caching.
337
338`--config-cache'
339`-C'
340 Alias for `--cache-file=config.cache'.
341
342`--quiet'
343`--silent'
344`-q'
345 Do not print messages saying which checks are being made. To
346 suppress all normal output, redirect it to `/dev/null' (any error
347 messages will still be shown).
348
349`--srcdir=DIR'
350 Look for the package's source code in directory DIR. Usually
351 `configure' can determine that directory automatically.
352
353`--prefix=DIR'
354 Use DIR as the installation prefix. *note Installation Names::
355 for more details, including other options available for fine-tuning
356 the installation locations.
357
358`--no-create'
359`-n'
360 Run the configure checks, but stop before creating any output
361 files.
362
363`configure' also accepts some other, not widely useful, options. Run
364`configure --help' for more details.
365
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 00000000..9f193782
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,27 @@
1SUBDIRS = build
2
3ACLOCAL_AMFLAGS = -I m4
4
5pkgconfigdir = $(libdir)/pkgconfig
6pkgconfig_DATA = $(top_srcdir)/libtoxcore.pc
7
8BUILT_SOURCES = $(top_srcdir)/libtoxcore.pc
9CLEANFILES = $(top_srcdir)/libtoxcore.pc
10
11
12EXTRA_DIST = \
13 $(top_srcdir)/libtoxcore.pc.in \
14 $(top_srcdir)/docs/install.rst \
15 $(top_srcdir)/docs/commands.rst \
16 $(top_srcdir)/docs/conf.py.in \
17 $(top_srcdir)/docs/index.rst \
18 $(top_srcdir)/docs/install.rst \
19 $(top_srcdir)/docs/start_guide.de.rst \
20 $(top_srcdir)/docs/start_guide.rst \
21 $(top_srcdir)/docs/updates/Crypto.md \
22 $(top_srcdir)/docs/updates/Spam-Prevention.md \
23 $(top_srcdir)/docs/updates/Symmetric-NAT-Transversal.md \
24 $(top_srcdir)/tools/README \
25 $(top_srcdir)/tools/astylerc \
26 $(top_srcdir)/tools/pre-commit
27
diff --git a/NEWS b/NEWS
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/NEWS
diff --git a/README b/README
new file mode 120000
index 00000000..42061c01
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
README.md \ No newline at end of file
diff --git a/auto_tests/CMakeLists.txt b/auto_tests/CMakeLists.txt
deleted file mode 100644
index c0b6aee4..00000000
--- a/auto_tests/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
1cmake_minimum_required(VERSION 2.6.0)
2cmake_policy(SET CMP0011 NEW)
3
4include_directories(${CHECK_INCLUDE_DIRS})
5
6find_package(Check REQUIRED)
7include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/messenger_test.cmake)
8include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/crypto_test.cmake)
9include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/friends_test.cmake)
10
11include( CTest )
12enable_testing()
13
14add_test(messenger messenger_test)
15add_test(crypto crypto_test)
16# TODO enable once test is fixed
17#add_test(friends friends_test)
18
19add_custom_target(
20 test COMMAND ${CMAKE_CTEST_COMMAND} -V
21 DEPENDS messenger_test crypto_test
22)
diff --git a/auto_tests/Makefile.inc b/auto_tests/Makefile.inc
new file mode 100644
index 00000000..bd883a79
--- /dev/null
+++ b/auto_tests/Makefile.inc
@@ -0,0 +1,34 @@
1if BUILD_TESTS
2
3TESTS = messenger_autotest crypto_test
4
5check_PROGRAMS = messenger_autotest crypto_test
6
7messenger_autotest_SOURCES = \
8 $(top_srcdir)/auto_tests/messenger_test.c
9
10messenger_autotest_CFLAGS = \
11 $(LIBSODIUM_CFLAGS) \
12 $(CHECK_CFLAGS)
13
14messenger_autotest_LDADD = \
15 $(LIBSODIUM_LDFLAGS) \
16 libtoxcore.la \
17 $(LIBSODIUM_LIBS) \
18 $(CHECK_LIBS)
19
20
21crypto_test_SOURCES = $(top_srcdir)/auto_tests/crypto_test.c
22
23crypto_test_CFLAGS = $(LIBSODIUM_CFLAGS) \
24 $(CHECK_CFLAGS)
25
26crypto_test_LDADD = $(LIBSODIUM_LDFLAGS) \
27 libtoxcore.la \
28 $(LIBSODIUM_LIBS) \
29 $(CHECK_LIBS)
30
31endif
32
33EXTRA_DIST += $(top_srcdir)/auto_tests/friends_test.c
34
diff --git a/auto_tests/cmake/crypto_test.cmake b/auto_tests/cmake/crypto_test.cmake
deleted file mode 100644
index 9ca9a331..00000000
--- a/auto_tests/cmake/crypto_test.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
1cmake_minimum_required(VERSION 2.6.0)
2project(crypto_test C)
3set(exe_name crypto_test)
4
5add_executable(${exe_name}
6 crypto_test.c)
7
8linkCoreLibraries(${exe_name})
9add_dependencies(${exe_name} Check)
10target_link_libraries(${exe_name} check)
diff --git a/auto_tests/cmake/friends_test.cmake b/auto_tests/cmake/friends_test.cmake
deleted file mode 100644
index 5c2d0fc6..00000000
--- a/auto_tests/cmake/friends_test.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
1cmake_minimum_required(VERSION 2.6.0)
2project(friends_test C)
3set(exe_name friends_test)
4
5add_executable(${exe_name}
6 friends_test.c)
7
8linkCoreLibraries(${exe_name})
9add_dependencies(${exe_name} Check)
10target_link_libraries(${exe_name} check)
diff --git a/auto_tests/cmake/messenger_test.cmake b/auto_tests/cmake/messenger_test.cmake
deleted file mode 100644
index 084586bb..00000000
--- a/auto_tests/cmake/messenger_test.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
1cmake_minimum_required(VERSION 2.6.0)
2project(messenger_test C)
3set(exe_name messenger_test)
4
5add_executable(${exe_name}
6 messenger_test.c)
7
8linkCoreLibraries(${exe_name})
9add_dependencies(${exe_name} Check)
10target_link_libraries(${exe_name} check)
diff --git a/auto_tests/crypto_test.c b/auto_tests/crypto_test.c
index 01c545c8..b3ce6259 100644
--- a/auto_tests/crypto_test.c
+++ b/auto_tests/crypto_test.c
@@ -1,4 +1,4 @@
1#include "../core/net_crypto.h" 1#include "../toxcore/net_crypto.h"
2#include <sys/types.h> 2#include <sys/types.h>
3#include <stdint.h> 3#include <stdint.h>
4#include <string.h> 4#include <string.h>
diff --git a/auto_tests/friends_test.c b/auto_tests/friends_test.c
index b6223489..0426c18d 100644
--- a/auto_tests/friends_test.c
+++ b/auto_tests/friends_test.c
@@ -18,8 +18,8 @@
18 * times. This is used both to ensure that we don't loop forever on a broken build, 18 * times. This is used both to ensure that we don't loop forever on a broken build,
19 * and that we don't get too slow with messaging. The current time is 15 seconds. */ 19 * and that we don't get too slow with messaging. The current time is 15 seconds. */
20 20
21#include "../core/friend_requests.h" 21#include "../toxcore/friend_requests.h"
22#include "../core/Messenger.h" 22#include "../toxcore/Messenger.h"
23#include <assert.h> 23#include <assert.h>
24#include <unistd.h> 24#include <unistd.h>
25#include <sys/mman.h> 25#include <sys/mman.h>
diff --git a/auto_tests/messenger_test.c b/auto_tests/messenger_test.c
index 9de69409..deac749b 100644
--- a/auto_tests/messenger_test.c
+++ b/auto_tests/messenger_test.c
@@ -10,7 +10,8 @@
10 * checking that status changes are received, messages can be sent, etc. 10 * checking that status changes are received, messages can be sent, etc.
11 * All of that is done in a separate test, with two local clients running. */ 11 * All of that is done in a separate test, with two local clients running. */
12 12
13#include "../core/Messenger.h" 13#include "../toxcore/Messenger.h"
14#include "../toxcore/Lossless_UDP.h"
14#include <sys/types.h> 15#include <sys/types.h>
15#include <stdint.h> 16#include <stdint.h>
16#include <string.h> 17#include <string.h>
diff --git a/build/Makefile.am b/build/Makefile.am
new file mode 100644
index 00000000..5cc735f9
--- /dev/null
+++ b/build/Makefile.am
@@ -0,0 +1,10 @@
1bin_PROGRAMS =
2noinst_PROGRAMS =
3noinst_bindir = $(top_builddir)/build
4EXTRA_DIST=
5
6include $(top_srcdir)/toxcore/Makefile.inc
7include $(top_srcdir)/other/Makefile.inc
8include $(top_srcdir)/testing/Makefile.inc
9include $(top_srcdir)/other/bootstrap_serverdaemon/Makefile.inc
10include $(top_srcdir)/auto_tests/Makefile.inc
diff --git a/cmake/FindCheck.cmake b/cmake/FindCheck.cmake
deleted file mode 100644
index e9e7f4d1..00000000
--- a/cmake/FindCheck.cmake
+++ /dev/null
@@ -1,46 +0,0 @@
1# - Try to find the CHECK libraries
2# Once done this will define
3#
4# CHECK_FOUND - system has check
5# CHECK_INCLUDE_DIR - the check include directory
6# CHECK_LIBRARIES - check library
7#
8# Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
9# Copyright (c) 2007 Bjoern Ricks <b.ricks@fh-osnabrueck.de>
10#
11# Redistribution and use is allowed according to the terms of the New
12# BSD license.
13# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
14
15
16INCLUDE( FindPkgConfig )
17
18# Take care about check.pc settings
19PKG_SEARCH_MODULE( CHECK check )
20
21# Look for CHECK include dir and libraries
22IF( NOT CHECK_FOUND )
23
24 FIND_PATH( CHECK_INCLUDE_DIR check.h )
25
26 FIND_LIBRARY( CHECK_LIBRARIES NAMES check )
27
28 IF ( CHECK_INCLUDE_DIR AND CHECK_LIBRARIES )
29 SET( CHECK_FOUND 1 )
30 IF ( NOT Check_FIND_QUIETLY )
31 MESSAGE ( STATUS "Found CHECK: ${CHECK_LIBRARIES}" )
32 ENDIF ( NOT Check_FIND_QUIETLY )
33 ELSE ( CHECK_INCLUDE_DIR AND CHECK_LIBRARIES )
34 IF ( Check_FIND_REQUIRED )
35 MESSAGE( FATAL_ERROR "Could NOT find CHECK" )
36 ELSE ( Check_FIND_REQUIRED )
37 IF ( NOT Check_FIND_QUIETLY )
38 MESSAGE( STATUS "Could NOT find CHECK" )
39 ENDIF ( NOT Check_FIND_QUIETLY )
40 ENDIF ( Check_FIND_REQUIRED )
41 ENDIF ( CHECK_INCLUDE_DIR AND CHECK_LIBRARIES )
42ENDIF( NOT CHECK_FOUND )
43
44# Hide advanced variables from CMake GUIs
45MARK_AS_ADVANCED( CHECK_INCLUDE_DIR CHECK_LIBRARIES )
46
diff --git a/cmake/FindCursesw.cmake b/cmake/FindCursesw.cmake
deleted file mode 100644
index bff02cec..00000000
--- a/cmake/FindCursesw.cmake
+++ /dev/null
@@ -1,47 +0,0 @@
1# - Find the curses include file and library
2#
3# CURSES_INCLUDE_DIR - the Curses include directory
4# CURSES_LIBRARIES - The libraries needed to use Curses
5# CURSES_HAVE_WIDE_CHAR - true if wide char is available
6# NO_WIDECHAR - Input variable, if set, disable wide char
7# ------------------------------------------------------------------------
8
9
10find_library(CURSES_LIBRARY "curses")
11find_library(CURSESW_LIBRARY "cursesw")
12
13find_library(NCURSES_LIBRARY "ncurses")
14find_library(NCURSESW_LIBRARY "ncursesw")
15
16if(NOT NO_WIDECHAR AND (CURSESW_LIBRARY OR NCURSESW_LIBRARY))
17 message(STATUS "Found wide character support")
18 set(CURSES_HAVE_WIDE_CHAR TRUE)
19 if(NCURSESW_LIBRARY)
20 set(CURSES_LIBRARIES ${NCURSESW_LIBRARY})
21 else()
22 set(CURSES_LIBRARIES ${CURSESW_LIBRARY})
23 endif()
24else()
25 message(STATUS "Could not found wide character support")
26 if(NCURSES_LIBRARY)
27 set(CURSES_LIBRARIES ${NCURSES_LIBRARY})
28 else()
29 set(CURSES_LIBRARIES ${CURSES_LIBRARY})
30 endif()
31endif()
32
33
34# We use curses.h not ncurses.h so let's not care about that for now
35
36if(CURSES_HAVE_WIDE_CHAR)
37 find_path(CURSES_INCLUDE_PATH curses.h PATH_SUFFIXES ncursesw)
38else()
39 find_path(CURSES_INCLUDE_PATH curses.h PATH_SUFFIXES ncurses)
40endif()
41
42set(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH})
43
44include(FindPackageHandleStandardArgs)
45find_package_handle_standard_args(Cursesw DEFAULT_MSG CURSES_INCLUDE_DIR CURSES_LIBRARIES)
46
47
diff --git a/cmake/FindLIBCONFIG.cmake b/cmake/FindLIBCONFIG.cmake
deleted file mode 100644
index b3ae4d11..00000000
--- a/cmake/FindLIBCONFIG.cmake
+++ /dev/null
@@ -1,20 +0,0 @@
1# Find LIBCONFIG
2#
3# LIBCONFIG_INCLUDE_DIR
4# LIBCONFIG_LIBRARY
5# LIBCONFIG_FOUND
6#
7
8if (UNIX)
9 find_package(PkgConfig QUIET)
10 pkg_check_modules(_LIBCONFIG QUIET libconfig)
11endif ()
12
13FIND_PATH(LIBCONFIG_INCLUDE_DIR NAMES libconfig.h HINTS ${_LIBCONFIG_INCLUDEDIR})
14
15FIND_LIBRARY(LIBCONFIG_LIBRARY NAMES config)
16
17INCLUDE(FindPackageHandleStandardArgs)
18FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBCONFIG DEFAULT_MSG LIBCONFIG_LIBRARY LIBCONFIG_INCLUDE_DIR)
19
20MARK_AS_ADVANCED(LIBCONFIG_INCLUDE_DIR LIBCONFIG_LIBRARY)
diff --git a/cmake/FindNaCl.cmake b/cmake/FindNaCl.cmake
deleted file mode 100644
index cdd6248a..00000000
--- a/cmake/FindNaCl.cmake
+++ /dev/null
@@ -1,17 +0,0 @@
1find_path(NACL_INCLUDE_DIR crypto_box.h
2 $ENV{NACL_INCLUDE_DIR} /usr/include/nacl/
3 DOC "Directory which contain NaCl headers")
4
5find_path(NACL_LIBRARY_DIR libnacl.a
6 $ENV{NACL_LIBRARY_DIR} /usr/lib/nacl
7 DOC "Directory which contain libnacl.a, cpucycles.o, and randombytes.o")
8
9if(NACL_LIBRARY_DIR)
10 set(NACL_LIBRARIES
11 "${NACL_LIBRARY_DIR}/cpucycles.o"
12 "${NACL_LIBRARY_DIR}/libnacl.a"
13 "${NACL_LIBRARY_DIR}/randombytes.o")
14endif()
15
16include(FindPackageHandleStandardArgs)
17find_package_handle_standard_args(NaCl DEFAULT_MSG NACL_INCLUDE_DIR NACL_LIBRARY_DIR NACL_LIBRARIES)
diff --git a/cmake/FindSODIUM.cmake b/cmake/FindSODIUM.cmake
deleted file mode 100644
index 6b0c2f23..00000000
--- a/cmake/FindSODIUM.cmake
+++ /dev/null
@@ -1,75 +0,0 @@
1# - Try to find SODIUM
2# Once done this will define
3#
4# SODIUM_ROOT_DIR - Set this variable to the root installation of CMocka
5#
6# Read-Only variables:
7# SODIUM_FOUND - system has SODIUM
8# SODIUM_INCLUDE_DIR - the SODIUM include directory
9# SODIUM_LIBRARIES - Link these to use SODIUM
10# SODIUM_DEFINITIONS - Compiler switches required for using SODIUM
11#
12#=============================================================================
13# Copyright (c) 2013 Andreas Schneider <asn@cryptomilk.org>
14#
15# Distributed under the OSI-approved BSD License (the "License");
16# see accompanying file Copyright.txt for details.
17#
18# This software is distributed WITHOUT ANY WARRANTY; without even the
19# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20# See the License for more information.
21#=============================================================================
22#
23
24set(_SODIUM_ROOT_HINTS
25)
26
27set(_SODIUM_ROOT_PATHS
28 "$ENV{PROGRAMFILES}/sodium"
29 "${CMAKE_SOURCE_DIR}/sodium"
30)
31
32find_path(SODIUM_ROOT_DIR
33 NAMES
34 include/sodium.h
35 HINTS
36 ${_SODIUM_ROOT_HINTS}
37 PATHS
38 ${_SODIUM_ROOT_PATHS}
39)
40mark_as_advanced(SODIUM_ROOT_DIR)
41
42find_path(SODIUM_INCLUDE_DIR
43 NAMES
44 sodium.h
45 PATHS
46 ${SODIUM_ROOT_DIR}/include
47)
48
49if(SHARED_LIBSODIUM)
50 set(WIN32_LIBSODIUM_FILENAME libsodium.dll.a)
51else()
52 set(WIN32_LIBSODIUM_FILENAME libsodium.a)
53endif()
54
55find_library(SODIUM_LIBRARY
56 NAMES
57 sodium
58 ${WIN32_LIBSODIUM_FILENAME}
59 PATHS
60 ${SODIUM_ROOT_DIR}/lib
61)
62
63if (SODIUM_LIBRARY)
64 set(SODIUM_LIBRARIES
65 ${SODIUM_LIBRARIES}
66 ${SODIUM_LIBRARY}
67 )
68endif (SODIUM_LIBRARY)
69
70include(FindPackageHandleStandardArgs)
71find_package_handle_standard_args(SODIUM DEFAULT_MSG SODIUM_LIBRARIES SODIUM_INCLUDE_DIR)
72
73# show the SODIUM_INCLUDE_DIR and SODIUM_LIBRARIES variables only in the advanced view
74mark_as_advanced(SODIUM_INCLUDE_DIR SODIUM_LIBRARIES)
75
diff --git a/cmake/FindSphinx.cmake b/cmake/FindSphinx.cmake
deleted file mode 100644
index 833bfd4d..00000000
--- a/cmake/FindSphinx.cmake
+++ /dev/null
@@ -1,16 +0,0 @@
1find_program(SPHINX_EXECUTABLE NAMES sphinx-build
2 HINTS
3 $ENV{SPHINX_DIR}
4 PATH_SUFFIXES bin
5 DOC "Sphinx documentation generator"
6)
7
8include(FindPackageHandleStandardArgs)
9
10find_package_handle_standard_args(Sphinx DEFAULT_MSG
11 SPHINX_EXECUTABLE
12)
13
14mark_as_advanced(
15 SPHINX_EXECUTABLE
16)
diff --git a/cmake/InstallPkgConfigFile.cmake b/cmake/InstallPkgConfigFile.cmake
deleted file mode 100644
index 7c4e5859..00000000
--- a/cmake/InstallPkgConfigFile.cmake
+++ /dev/null
@@ -1,78 +0,0 @@
1# A Macro to simplify creating a pkg-config file
2
3# install_pkg_config_file(<package-name>
4# [VERSION <version>]
5# [DESCRIPTION <description>]
6# [CFLAGS <cflag> ...]
7# [LIBS <lflag> ...]
8# [REQUIRES <required-package-name> ...])
9#
10# Create and install a pkg-config .pc file to CMAKE_INSTALL_PREFIX/lib/pkgconfig
11# assuming the following install layout:
12# libraries: CMAKE_INSTALL_PREFIX/lib
13# headers : CMAKE_INSTALL_PREFIX/include
14#
15# example:
16# add_library(mylib mylib.c)
17# install_pkg_config_file(mylib
18# DESCRIPTION My Library
19# CFLAGS
20# LIBS -lmylib
21# REQUIRES glib-2.0 lcm
22# VERSION 0.0.1)
23#
24#
25function(install_pkg_config_file)
26 list(GET ARGV 0 pc_name)
27 # TODO error check
28
29 set(pc_version 0.0.1)
30 set(pc_description ${pc_name})
31 set(pc_requires "")
32 set(pc_libs "")
33 set(pc_cflags "")
34 set(pc_fname "${CMAKE_BINARY_DIR}/lib/pkgconfig/${pc_name}.pc")
35
36 set(modewords LIBS CFLAGS REQUIRES VERSION DESCRIPTION)
37 set(curmode "")
38
39 # parse function arguments and populate pkg-config parameters
40 list(REMOVE_AT ARGV 0)
41 foreach(word ${ARGV})
42 list(FIND modewords ${word} mode_index)
43 if(${mode_index} GREATER -1)
44 set(curmode ${word})
45 elseif(curmode STREQUAL LIBS)
46 set(pc_libs "${pc_libs} ${word}")
47 elseif(curmode STREQUAL CFLAGS)
48 set(pc_cflags "${pc_cflags} ${word}")
49 elseif(curmode STREQUAL REQUIRES)
50 set(pc_requires "${pc_requires} ${word}")
51 elseif(curmode STREQUAL VERSION)
52 set(pc_version ${word})
53 set(curmode "")
54 elseif(curmode STREQUAL DESCRIPTION)
55 set(pc_description "${word}")
56 set(curmode "")
57 else(${mode_index} GREATER -1)
58 message("WARNING incorrect use of install_pkg_config_file (${word})")
59 break()
60 endif(${mode_index} GREATER -1)
61 endforeach(word)
62
63 # write the .pc file out
64 file(WRITE ${pc_fname}
65 "prefix=${CMAKE_INSTALL_PREFIX}\n"
66 "libdir=\${prefix}/lib\n"
67 "includedir=\${prefix}/include\n"
68 "\n"
69 "Name: ${pc_name}\n"
70 "Description: ${pc_description}\n"
71 "Requires: ${pc_requires}\n"
72 "Version: ${pc_version}\n"
73 "Libs: -L\${libdir} ${pc_libs}\n"
74 "Cflags: -I\${includedir} ${pc_cflags}\n")
75
76 # mark the .pc file for installation to the lib/pkgconfig directory
77 install(FILES ${pc_fname} DESTINATION lib/pkgconfig)
78endfunction(install_pkg_config_file)
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 00000000..248d87da
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,336 @@
1# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ([2.65])
5AC_INIT([tox], [0.0.0], [http://tox.im])
6AC_CONFIG_AUX_DIR(configure_aux)
7AC_CONFIG_SRCDIR([toxcore/net_crypto.c])
8AC_CONFIG_HEADERS([config.h])
9AM_INIT_AUTOMAKE([1.10 -Wall])
10m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
11AC_CONFIG_MACRO_DIR([m4])
12
13if test "x${prefix}" = "xNONE"; then
14 prefix="${ac_default_prefix}"
15fi
16
17BUILD_DHT_BOOTSTRAP_DAEMON="yes"
18BUILD_NTOX="yes"
19BUILD_TESTS="yes"
20
21NCURSES_FOUND="no"
22LIBCONFIG_FOUND="no"
23LIBCHECK_FOUND="no"
24
25AC_ARG_ENABLE([tests],
26 [AC_HELP_STRING([--disable-tests], [build unit tests (default: auto)]) ],
27 [
28 if test "x$enableval" = "xno"; then
29 BUILD_TESTS="no"
30 elif test "x$enableval" = "xyes"; then
31 BUILD_TESTS="yes"
32 fi
33 ]
34)
35
36AC_ARG_ENABLE([ntox],
37 [AC_HELP_STRING([--disable-ntox], [build nTox client (default: auto)]) ],
38 [
39 if test "x$enableval" = "xno"; then
40 BUILD_NTOX="no"
41 elif test "x$enableval" = "xyes"; then
42 BUILD_NTOX="yes"
43 fi
44 ]
45)
46
47AC_ARG_ENABLE([dht-bootstrap-daemon],
48 [AC_HELP_STRING([--disable-dht-boostrap-daemon], [build DHT bootstrap daemon (default: auto)]) ],
49 [
50 if test "x$enableval" = "xno"; then
51 BUILD_DHT_BOOTSTRAP_DAEMON="no"
52 elif test "x$enableval" = "xyes"; then
53 BUILD_DHT_BOOTSTRAP_DAEMON="yes"
54 fi
55 ]
56)
57
58DEPSEARCH=
59LIBSODIUM_SEARCH_HEADERS=
60LIBSODIUM_SEARCH_LIBS=
61
62AC_ARG_WITH(dependency-search,
63 AC_HELP_STRING([--with-dependency-search=DIR],
64 [search for dependencies in DIR, i.e. look for libraries in
65 DIR/lib and for headers in DIR/include]),
66 [
67 DEPSEARCH="$withval"
68 ]
69)
70
71if test -n "$DEPSEARCH"; then
72 CFLAGS="$CFLAGS -I$DEPSEARCH/include"
73 CPPFLAGS="$CPPFLAGS -I$DEPSEARCH/include"
74 LDFLAGS="$LDFLAGS -L$DEPSEARCH/lib"
75 export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$DEPSEARCH/lib/pkgconfig
76fi
77
78AC_ARG_WITH(libsodium-headers,
79 AC_HELP_STRING([--with-libsodium-headers=DIR],
80 [search for libsodium header files in DIR]),
81 [
82 LIBSODIUM_SEARCH_HEADERS="$withval"
83 AC_MSG_NOTICE([Will search for libsodium header files in $withval])
84 ]
85)
86
87AC_ARG_WITH(libsodium-libs,
88 AC_HELP_STRING([--with-libsodium-libs=DIR],
89 [search for libsodium libraries in DIR]),
90 [
91 LIBSODIUM_SEARCH_LIBS="$withval"
92 AC_MSG_NOTICE([Will search for libsodium libraries in $withval])
93 ]
94)
95
96# Checks for programs.
97AC_PROG_CC
98AM_PROG_CC_C_O
99AC_PROG_LIBTOOL
100
101WIN32=no
102AC_CANONICAL_HOST
103case $host_os in
104 *mingw*)
105 WIN32="yes"
106 AC_MSG_WARN([nTox is not supported on $host_os yet, disabling])
107 BUILD_NTOX="no"
108 ;;
109 *solaris*)
110 LIBS="$LIBS -lssp -lsocket -lnsl"
111 ;;
112esac
113AM_CONDITIONAL(WIN32, test "x$WIN32" = "xyes")
114
115# Checks for libraries.
116LIBSODIUM_LIBS=
117LIBSODIUM_LDFLAGS=
118LDFLAGS_SAVE="$LDFLAGS"
119if test -n "$LIBSODIUM_SEARCH_LIBS"; then
120 LDFLAGS="-L$LIBSODIUM_SEARCH_LIBS $LDFLAGS"
121 AC_CHECK_LIB(sodium, randombytes_random,
122 [
123 LIBSODIUM_LDFLAGS="-L$LIBSODIUM_SEARCH_LIBS"
124 LIBSODIUM_LIBS="-lsodium"
125 ],
126 [
127 AC_MSG_ERROR([required library libsodium was not found in requested location $LIBSODIUM_SEARCH_LIBS])
128 ]
129 )
130else
131 AC_CHECK_LIB(sodium, randombytes_random,
132 [],
133 [
134 AC_MSG_ERROR([required library libsodium was not found on your system, please check http://download.libsodium.org/libsodium/releases/])
135 ]
136 )
137fi
138
139LDFLAGS="$LDFLAGS_SAVE"
140AC_SUBST(LIBSODIUM_LIBS)
141AC_SUBST(LIBSODIUM_LDFLAGS)
142
143# Checks for header files.
144AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h])
145
146LIBSODIUM_CFLAGS=
147CFLAGS_SAVE="$CFLAGS"
148CPPFLAGS_SAVE="$CPPFLAGS"
149if test -n "$LIBSODIUM_SEARCH_HEADERS"; then
150 CFLAGS="-I$LIBSODIUM_SEARCH_HEADERS $CFLAGS"
151 CPPFLAGS="-I$LIBSODIUM_SEARCH_HEADERS $CPPFLAGS"
152 AC_CHECK_HEADER(sodium.h,
153 [
154 LIBSODIUM_CFLAGS="-I$LIBSODIUM_SEARCH_HEADERS"
155 ],
156 [
157 AC_MSG_ERROR([header files for required library libsodium was not found in requested location $LIBSODIUM_SEARCH_HEADERS])
158 ]
159 )
160else
161 AC_CHECK_HEADER(sodium.h,
162 [],
163 [
164 AC_MSG_ERROR([header files for required library libsodium was not found on your system, please check http://download.libsodium.org/libsodium/releases/])
165 ]
166 )
167fi
168CFLAGS="$CFLAGS_SAVE"
169CPPFLAGS="$CPPFLAGS_SAVE"
170AC_SUBST(LIBSODIUM_CFLAGS)
171
172# Checks for typedefs, structures, and compiler characteristics.
173AC_HEADER_STDBOOL
174AC_TYPE_INT16_T
175AC_TYPE_INT32_T
176AC_TYPE_PID_T
177AC_TYPE_SIZE_T
178AC_TYPE_UINT16_T
179AC_TYPE_UINT32_T
180AC_TYPE_UINT64_T
181AC_TYPE_UINT8_T
182
183# Checks for library functions.
184AC_FUNC_FORK
185AC_FUNC_MALLOC
186AC_FUNC_REALLOC
187AC_CHECK_FUNCS([gettimeofday memset socket strchr])
188
189# pkg-config based tests
190PKG_PROG_PKG_CONFIG
191
192if test -n "$PKG_CONFIG"; then
193 if test "x$BUILD_TESTS" = "xyes"; then
194 PKG_CHECK_MODULES([CHECK], [check],
195 [
196 LIBCHECK_FOUND="yes"
197 ],
198 [
199 AC_MSG_WARN([libcheck not found, not building unit tests: $CHECK_PKG_ERRORS])
200 BUILD_TESTS="no"
201 ])
202 fi
203
204 if test "x$BUILD_DHT_BOOTSTRAP_DAEMON" = "xyes"; then
205 PKG_CHECK_MODULES([LIBCONFIG], [libconfig >= 1.4.6],
206 [
207 LIBCONFIG_FOUND="yes"
208 ],
209 [
210 AC_MSG_WARN([$LIBCONFIG_PKG_ERRORS])
211 AC_MSG_WARN([libconfig not available, will not build DHT botstrap daemon])
212 BUILD_DHT_BOOTSTRAP_DAEMON="no"
213 ])
214 fi
215
216 if test "x$BUILD_NTOX" = "xyes"; then
217 PKG_CHECK_MODULES([NCURSES], [ncurses],
218 [
219 NCURSES_FOUND="yes"
220 ],
221 [
222 AC_MSG_WARN([$NCURSES_PKG_ERRORS])
223 ])
224 fi
225else
226 AC_MSG_WARN([pkg-config was not found on your sytem])
227fi
228
229if (test "x$BUILD_NTOX" = "xyes") && (test "x$NCURSES_FOUND" != "xyes"); then
230 AC_PATH_PROG([CURSES_CONFIG], [ncurses5-config], [no])
231 if test "x$CURSES_CONFIG" != "xno"; then
232 AC_MSG_CHECKING(ncurses cflags)
233 NCURSES_CFLAGS=`${CURSES_CONFIG} --cflags`
234 AC_MSG_RESULT($NCURSES_CFLAGS)
235
236 AC_MSG_CHECKING(ncurses libraries)
237 NCURSES_LIBS=`${CURSES_CONFIG} --libs`
238 AC_MSG_RESULT($NCURSES_LIBS)
239
240 AC_SUBST(NCURSES_CFLAGS)
241 AC_SUBST(NCURSES_LIBS)
242 NCURSES_FOUND="yes"
243 fi
244
245 if test "x$NCURSES_FOUND" != "xyes"; then
246 AC_CHECK_HEADER([curses.h],
247 [],
248 [
249 AC_MSG_WARN([not building nTox client because headers for the curses library were not found on your system])
250 BUILD_NTOX="no"
251 ]
252 )
253 if test "x$BUILD_NTOX" = "xyes"; then
254 AC_CHECK_LIB([ncurses], [clear],
255 [],
256 [
257 unset ac_cv_lib_ncurses_clear
258 AC_CHECK_LIB([ncurses], [clear],
259 [],
260 [
261 AC_MSG_WARN([not building nTox client because required library ncurses was not found on your system])
262 BUILD_NTOX="no"
263 ],
264 [
265 -ltinfo
266 ]
267 )
268 ]
269 )
270 fi
271 fi
272fi
273
274if (test "x$BUILD_DHT_BOOTSTRAP_DAEMON" = "xyes") && \
275 (test "x$LIBCONFIG_FOUND" = "xno"); then
276 AC_CHECK_HEADER(libconfig.h,
277 [],
278 [
279 AC_MSG_WARN([header files for library libconfig was not found on your system, not building DHT bootstrap daemon])
280 BUILD_DHT_BOOTSTRAP_DAEMON="no"
281 ]
282 )
283
284 if test "x$BUILD_DHT_BOOTSTRAP_DAEMON" = "xyes"; then
285 AC_CHECK_LIB(config, config_read,
286 [],
287 [
288 AC_MSG_WARN([library libconfig was not found on the system])
289 BUILD_DHT_BOOTSTRAP_DAEMON="no"
290 ]
291 )
292 fi
293fi
294
295if (test "x$BUILD_TESTS" = "xyes") && (test "x$LIBCHECK_FOUND" = "xno"); then
296 AC_CHECK_HEADER([check.h],
297 [],
298 [
299 AC_MSG_WARN([header file for check library was not found on your system, unit tests will be disabled])
300 BUILD_TESTS="no"
301 ]
302 )
303
304 if test "x$BUILD_TESTS" = "xyes"; then
305 AC_CHECK_LIB([check], [suite_create],
306 [],
307 [
308 AC_MSG_WARN([library check was not found on the system, unit tests will be disabled])
309 BUILD_TESTS="no"
310 ]
311 )
312 fi
313fi
314
315if test "x$WIN32" = "xyes"; then
316 AC_CHECK_LIB(ws2_32, main,
317 [
318 WINSOCK2_LIBS="-lws2_32"
319 AC_SUBST(WINSOCK2_LIBS)
320 ],
321 [
322 AC_MSG_ERROR([required library was not found on the system, please check your MinGW installation])
323 ]
324 )
325fi
326
327AM_CONDITIONAL(BUILD_DHT_BOOTSTRAP_DAEMON, test "x$BUILD_DHT_BOOTSTRAP_DAEMON" = "xyes")
328
329AM_CONDITIONAL(BUILD_TESTS, test "x$BUILD_TESTS" = "xyes")
330AM_CONDITIONAL(BUILD_NTOX, test "x$BUILD_NTOX" = "xyes")
331
332AC_CONFIG_FILES([Makefile
333 build/Makefile
334 libtoxcore.pc
335 ])
336AC_OUTPUT
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
deleted file mode 100644
index ecbb65c2..00000000
--- a/core/CMakeLists.txt
+++ /dev/null
@@ -1,45 +0,0 @@
1cmake_minimum_required(VERSION 2.6.0)
2project(toxcore C)
3
4set(core_sources
5 DHT.c
6 network.c
7 Lossless_UDP.c
8 net_crypto.c
9 friend_requests.c
10 LAN_discovery.c
11 Messenger.c
12 util.c
13 ping.c
14 tox.c)
15
16set(core_headers
17 DHT.h
18 network.h
19 Lossless_UDP.h
20 net_crypto.h
21 friend_requests.h
22 LAN_discovery.h
23 Messenger.h
24 util.h
25 ping.h)
26
27add_library(toxcore SHARED ${core_sources})
28add_library(toxcore_static ${core_sources})
29set_target_properties(toxcore_static PROPERTIES OUTPUT_NAME toxcore)
30
31target_link_libraries(toxcore ${LINK_CRYPTO_LIBRARY})
32
33install(TARGETS toxcore toxcore_static DESTINATION lib)
34install(FILES ${core_headers} DESTINATION include)
35
36if(WIN32)
37 target_link_libraries(toxcore ws2_32)
38endif()
39
40execute_process(COMMAND git rev-list HEAD --count OUTPUT_VARIABLE COMMIT)
41
42# Write pkgconfig-file:
43include(InstallPkgConfigFile)
44install_pkg_config_file(toxcore CFLAGS LIBS -ltoxcore REQUIRES VERSION 0.1.1_r${COMMIT})
45
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
deleted file mode 100644
index 4b281eb4..00000000
--- a/docs/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
1find_package(Sphinx QUIET)
2
3if(NOT DEFINED SPHINX_THEME)
4 set(SPHINX_THEME default)
5endif()
6
7if(NOT DEFINED SPHINX_THEME_DIR)
8 set(SPHINX_THEME_DIR)
9endif()
10
11# configured documentation tools and intermediate build results
12set(BINARY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/_build")
13
14# Sphinx cache with pickled ReST documents
15set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees")
16
17# HTML output directory
18set(SPHINX_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/html")
19
20configure_file(
21 "${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in"
22 "${BINARY_BUILD_DIR}/conf.py"
23 @ONLY)
24
25if(SPHINX_FOUND)
26 add_custom_target(docs
27 ${SPHINX_EXECUTABLE}
28 -b html
29 -c "${BINARY_BUILD_DIR}"
30 -d "${SPHINX_CACHE_DIR}"
31 "${CMAKE_CURRENT_SOURCE_DIR}"
32 "${SPHINX_HTML_DIR}"
33 COMMENT "Building HTML documentation with Sphinx")
34else()
35 add_custom_target(docs
36 echo "Please install python-sphinx to build the docs or read the docs online: https://projecttox.readthedocs.org/en/latest"
37- COMMENT "No sphinx executable found")
38endif()
diff --git a/libtoxcore.pc.in b/libtoxcore.pc.in
new file mode 100644
index 00000000..7286f43b
--- /dev/null
+++ b/libtoxcore.pc.in
@@ -0,0 +1,12 @@
1prefix=@prefix@
2exec_prefix=@exec_prefix@
3libdir=@libdir@
4includedir=@includedir@
5
6Name: libtoxcore
7Description: Tox protocol library
8Requires:
9Version: @PACKAGE_VERSION@
10Libs: -L${libdir} -ltoxcore @LIBS@
11Cflags: -I${includedir}/tox
12
diff --git a/m4/pkg.m4 b/m4/pkg.m4
new file mode 100644
index 00000000..f26f84c9
--- /dev/null
+++ b/m4/pkg.m4
@@ -0,0 +1,199 @@
1# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
2# serial 1 (pkg-config-0.24)
3#
4# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14# General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19#
20# As a special exception to the GNU General Public License, if you
21# distribute this file as part of a program that contains a
22# configuration script generated by Autoconf, you may include it under
23# the same distribution terms that you use for the rest of that program.
24
25# PKG_PROG_PKG_CONFIG([MIN-VERSION])
26# ----------------------------------
27AC_DEFUN([PKG_PROG_PKG_CONFIG],
28[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
29m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
30m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
31AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
32AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
33AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
34
35if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
36 AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
37fi
38if test -n "$PKG_CONFIG"; then
39 _pkg_min_version=m4_default([$1], [0.9.0])
40 AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
41 if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
42 AC_MSG_RESULT([yes])
43 else
44 AC_MSG_RESULT([no])
45 PKG_CONFIG=""
46 fi
47fi[]dnl
48])# PKG_PROG_PKG_CONFIG
49
50# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
51#
52# Check to see whether a particular set of modules exists. Similar
53# to PKG_CHECK_MODULES(), but does not set variables or print errors.
54#
55# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
56# only at the first occurence in configure.ac, so if the first place
57# it's called might be skipped (such as if it is within an "if", you
58# have to call PKG_CHECK_EXISTS manually
59# --------------------------------------------------------------
60AC_DEFUN([PKG_CHECK_EXISTS],
61[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
62if test -n "$PKG_CONFIG" && \
63 AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
64 m4_default([$2], [:])
65m4_ifvaln([$3], [else
66 $3])dnl
67fi])
68
69# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
70# ---------------------------------------------
71m4_define([_PKG_CONFIG],
72[if test -n "$$1"; then
73 pkg_cv_[]$1="$$1"
74 elif test -n "$PKG_CONFIG"; then
75 PKG_CHECK_EXISTS([$3],
76 [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
77 test "x$?" != "x0" && pkg_failed=yes ],
78 [pkg_failed=yes])
79 else
80 pkg_failed=untried
81fi[]dnl
82])# _PKG_CONFIG
83
84# _PKG_SHORT_ERRORS_SUPPORTED
85# -----------------------------
86AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
87[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
88if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
89 _pkg_short_errors_supported=yes
90else
91 _pkg_short_errors_supported=no
92fi[]dnl
93])# _PKG_SHORT_ERRORS_SUPPORTED
94
95
96# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
97# [ACTION-IF-NOT-FOUND])
98#
99#
100# Note that if there is a possibility the first call to
101# PKG_CHECK_MODULES might not happen, you should be sure to include an
102# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
103#
104#
105# --------------------------------------------------------------
106AC_DEFUN([PKG_CHECK_MODULES],
107[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
108AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
109AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
110
111pkg_failed=no
112AC_MSG_CHECKING([for $1])
113
114_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
115_PKG_CONFIG([$1][_LIBS], [libs], [$2])
116
117m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
118and $1[]_LIBS to avoid the need to call pkg-config.
119See the pkg-config man page for more details.])
120
121if test $pkg_failed = yes; then
122 AC_MSG_RESULT([no])
123 _PKG_SHORT_ERRORS_SUPPORTED
124 if test $_pkg_short_errors_supported = yes; then
125 $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
126 else
127 $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
128 fi
129 # Put the nasty error message in config.log where it belongs
130 echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
131
132 m4_default([$4], [AC_MSG_ERROR(
133[Package requirements ($2) were not met:
134
135$$1_PKG_ERRORS
136
137Consider adjusting the PKG_CONFIG_PATH environment variable if you
138installed software in a non-standard prefix.
139
140_PKG_TEXT])[]dnl
141 ])
142elif test $pkg_failed = untried; then
143 AC_MSG_RESULT([no])
144 m4_default([$4], [AC_MSG_FAILURE(
145[The pkg-config script could not be found or is too old. Make sure it
146is in your PATH or set the PKG_CONFIG environment variable to the full
147path to pkg-config.
148
149_PKG_TEXT
150
151To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
152 ])
153else
154 $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
155 $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
156 AC_MSG_RESULT([yes])
157 $3
158fi[]dnl
159])# PKG_CHECK_MODULES
160
161
162# PKG_INSTALLDIR(DIRECTORY)
163# -------------------------
164# Substitutes the variable pkgconfigdir as the location where a module
165# should install pkg-config .pc files. By default the directory is
166# $libdir/pkgconfig, but the default can be changed by passing
167# DIRECTORY. The user can override through the --with-pkgconfigdir
168# parameter.
169AC_DEFUN([PKG_INSTALLDIR],
170[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
171m4_pushdef([pkg_description],
172 [pkg-config installation directory @<:@]pkg_default[@:>@])
173AC_ARG_WITH([pkgconfigdir],
174 [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
175 [with_pkgconfigdir=]pkg_default)
176AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
177m4_popdef([pkg_default])
178m4_popdef([pkg_description])
179]) dnl PKG_INSTALLDIR
180
181
182# PKG_NOARCH_INSTALLDIR(DIRECTORY)
183# -------------------------
184# Substitutes the variable noarch_pkgconfigdir as the location where a
185# module should install arch-independent pkg-config .pc files. By
186# default the directory is $datadir/pkgconfig, but the default can be
187# changed by passing DIRECTORY. The user can override through the
188# --with-noarch-pkgconfigdir parameter.
189AC_DEFUN([PKG_NOARCH_INSTALLDIR],
190[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
191m4_pushdef([pkg_description],
192 [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
193AC_ARG_WITH([noarch-pkgconfigdir],
194 [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
195 [with_noarch_pkgconfigdir=]pkg_default)
196AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
197m4_popdef([pkg_default])
198m4_popdef([pkg_description])
199]) dnl PKG_NOARCH_INSTALLDIR
diff --git a/other/CMakeLists.txt b/other/CMakeLists.txt
deleted file mode 100644
index 7e6c9eb9..00000000
--- a/other/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
1cmake_minimum_required(VERSION 2.6.0)
2
3cmake_policy(SET CMP0011 NEW)
4
5if(WIN32)
6 file(MAKE_DIRECTORY "$ENV{APPDATA}/.config/tox")
7 file(INSTALL DHTservers DESTINATION "$ENV{APPDATA}/.config/tox")
8else()
9 set(HOME "$ENV{HOME}")
10 if(APPLE)
11 file(MAKE_DIRECTORY ${HOME}/Library/Application\ Support/.config/tox)
12 file(INSTALL DHTservers DESTINATION ${HOME}/Library/Application\ Support/.config/tox)
13 else()
14 file(MAKE_DIRECTORY ${HOME}/.config/tox)
15 file(INSTALL DHTservers DESTINATION ${HOME}/.config/tox)
16 endif()
17endif()
18
19include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_bootstrap.cmake)
20
21if(LINUX)
22 add_subdirectory(bootstrap_serverdaemon)
23endif()
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c
index c0d4fcc6..0bf71312 100644
--- a/other/DHT_bootstrap.c
+++ b/other/DHT_bootstrap.c
@@ -27,8 +27,8 @@
27 * 27 *
28 */ 28 */
29 29
30#include "../core/DHT.h" 30#include "../toxcore/DHT.h"
31#include "../core/friend_requests.h" 31#include "../toxcore/friend_requests.h"
32#include "../testing/misc_tools.h" 32#include "../testing/misc_tools.h"
33 33
34//Sleep function (x = milliseconds) 34//Sleep function (x = milliseconds)
diff --git a/other/Makefile.inc b/other/Makefile.inc
new file mode 100644
index 00000000..10ef55a3
--- /dev/null
+++ b/other/Makefile.inc
@@ -0,0 +1,18 @@
1noinst_PROGRAMS += DHT_bootstrap
2
3DHT_bootstrap_SOURCES = $(top_srcdir)/other/DHT_bootstrap.c \
4 $(top_srcdir)/toxcore/DHT.h \
5 $(top_srcdir)/toxcore/friend_requests.h \
6 $(top_srcdir)/testing/misc_tools.h \
7 $(top_srcdir)/testing/misc_tools.c
8
9DHT_bootstrap_CFLAGS = -I$(top_srcdir)/other \
10 $(LIBSODIUM_CFLAGS)
11
12DHT_bootstrap_LDADD = $(LIBSODIUM_LDFLAGS) \
13 libtoxcore.la \
14 $(LIBSODIUM_LIBS) \
15 $(WINSOCK2_LIBS)
16
17EXTRA_DIST += $(top_srcdir)/other/DHTservers \
18 $(top_srcdir)/other/tox.png
diff --git a/other/bootstrap_serverdaemon/CMakeLists.txt b/other/bootstrap_serverdaemon/CMakeLists.txt
deleted file mode 100644
index 512179f3..00000000
--- a/other/bootstrap_serverdaemon/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
1cmake_minimum_required(VERSION 2.6.0)
2project(DHT_bootstrap_daemon C)
3
4set(exe_name DHT_bootstrap_daemon)
5
6find_package(LIBCONFIG REQUIRED)
7
8include_directories(${LIBCONFIG_INCLUDE_DIR})
9
10add_executable(${exe_name}
11 DHT_bootstrap_daemon.c)
12
13target_link_libraries(${exe_name}
14 ${LIBCONFIG_LIBRARY})
15
16linkCoreLibraries(${exe_name})
17
18set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
19find_package(LibConfig REQUIRED)
diff --git a/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c b/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c
index 46409b76..eec4e39f 100644
--- a/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c
+++ b/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c
@@ -32,8 +32,8 @@
32#include <arpa/inet.h> /* htons() */ 32#include <arpa/inet.h> /* htons() */
33#include <string.h> /* strcpy() */ 33#include <string.h> /* strcpy() */
34 34
35#include "../../core/DHT.h" 35#include "../../toxcore/DHT.h"
36#include "../../core/friend_requests.h" 36#include "../../toxcore/friend_requests.h"
37 37
38#define DEFAULT_PORT 33445 38#define DEFAULT_PORT 33445
39#define DEFAULT_PID_FILE "bootstrap_server.pid" 39#define DEFAULT_PID_FILE "bootstrap_server.pid"
diff --git a/other/bootstrap_serverdaemon/Makefile.inc b/other/bootstrap_serverdaemon/Makefile.inc
new file mode 100644
index 00000000..1320b761
--- /dev/null
+++ b/other/bootstrap_serverdaemon/Makefile.inc
@@ -0,0 +1,23 @@
1if BUILD_DHT_BOOTSTRAP_DAEMON
2
3noinst_PROGRAMS += DHT_bootstrap_daemon
4
5DHT_bootstrap_daemon_SOURCES = \
6 $(top_srcdir)/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c
7
8DHT_bootstrap_daemon_CFLAGS = \
9 -I$(top_srcdir)/other/bootstrap_serverdaemon \
10 $(LIBSODIUM_CFLAGS) \
11 $(LIBCONFIG_CFLAGS)
12
13DHT_bootstrap_daemon_LDADD = \
14 $(LIBSODIUM_LDFLAGS) \
15 libtoxcore.la \
16 $(LIBCONFIG_LIBS) \
17 $(LIBSODIUM_LIBS)
18
19endif
20
21EXTRA_DIST += \
22 $(top_srcdir)/other/bootstrap_serverdaemon/server.cfg \
23 $(top_srcdir)/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.sh
diff --git a/other/bootstrap_serverdaemon/cmake/Modules/FindLibConfig.cmake b/other/bootstrap_serverdaemon/cmake/Modules/FindLibConfig.cmake
deleted file mode 100644
index 7d6270e6..00000000
--- a/other/bootstrap_serverdaemon/cmake/Modules/FindLibConfig.cmake
+++ /dev/null
@@ -1,73 +0,0 @@
1#Ref: https://github.com/schnorr/pajeng/blob/master/cmake/FindLibConfig.cmake
2#
3# This module defines
4# LIBCONFIG_INCLUDE_DIR, where to find cppunit include files, etc.
5# LIBCONFIG_LIBRARIES, the libraries to link against to use CppUnit.
6# LIBCONFIG_STATIC_LIBRARIY_PATH
7# LIBCONFIG_FOUND, If false, do not try to use CppUnit.
8
9# also defined, but not for general use are
10# LIBCONFIG_LIBRARY, where to find the CUnit library.
11
12#MESSAGE("Searching for libconfig library")
13
14FIND_PATH(LIBCONFIG_INCLUDE_DIR libconfig.h
15 /usr/local/include
16 /usr/include
17)
18
19FIND_PATH(LIBCONFIGPP_INCLUDE_DIR libconfig.h++
20 /usr/local/include
21 /usr/include
22)
23
24FIND_LIBRARY(LIBCONFIG_LIBRARY config
25 /usr/local/lib
26 /usr/lib
27)
28
29FIND_LIBRARY(LIBCONFIGPP_LIBRARY config++
30 /usr/local/lib
31 /usr/lib
32)
33
34FIND_LIBRARY(LIBCONFIG_STATIC_LIBRARY "libconfig${CMAKE_STATIC_LIBRARY_SUFFIX}"
35 /usr/local/lib
36 /usr/lib
37)
38
39FIND_LIBRARY(LIBCONFIGPP_STATIC_LIBRARY "libconfig++${CMAKE_STATIC_LIBRARY_SUFFIX}"
40 /usr/local/lib
41 /usr/lib
42)
43
44
45IF(LIBCONFIG_INCLUDE_DIR)
46 IF(LIBCONFIG_LIBRARY)
47 SET(LIBCONFIG_FOUND TRUE)
48 SET(LIBCONFIG_LIBRARIES ${LIBCONFIG_LIBRARY})
49 SET(LIBCONFIG_STATIC_LIBRARY_PATH ${LIBCONFIG_STATIC_LIBRARY})
50 ENDIF(LIBCONFIG_LIBRARY)
51ENDIF(LIBCONFIG_INCLUDE_DIR)
52
53IF(LIBCONFIGPP_INCLUDE_DIR)
54 IF(LIBCONFIGPP_LIBRARY)
55 SET(LIBCONFIGPP_FOUND TRUE)
56 SET(LIBCONFIGPP_LIBRARIES ${LIBCONFIGPP_LIBRARY})
57 SET(LIBCONFIGPP_STATIC_LIBRARY_PATH ${LIBCONFIGPP_STATIC_LIBRARY})
58 ENDIF(LIBCONFIGPP_LIBRARY)
59ENDIF(LIBCONFIGPP_INCLUDE_DIR)
60
61IF (LIBCONFIG_FOUND)
62 IF (NOT LibConfig_FIND_QUIETLY)
63 MESSAGE(STATUS "Found LibConfig++: ${LIBCONFIGPP_LIBRARIES}" )
64 MESSAGE(STATUS "Found LibConfig: ${LIBCONFIG_LIBRARIES}")
65 MESSAGE(STATUS "static LibConfig path: ${LIBCONFIG_STATIC_LIBRARY_PATH}")
66 ENDIF (NOT LibConfig_FIND_QUIETLY)
67ELSE (LIBCONFIG_FOUND)
68 IF (LibConfig_FIND_REQUIRED)
69 MESSAGE(SEND_ERROR "Could NOT find LibConfig")
70 ENDIF (LibConfig_FIND_REQUIRED)
71ENDIF (LIBCONFIG_FOUND)
72
73MARK_AS_ADVANCED(LIBCONFIG_INCLUDE_DIR LIBCONFIG_LIBRARIES)
diff --git a/other/cmake/DHT_bootstrap.cmake b/other/cmake/DHT_bootstrap.cmake
deleted file mode 100644
index 403522ab..00000000
--- a/other/cmake/DHT_bootstrap.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
1cmake_minimum_required(VERSION 2.6.0)
2project(DHT_bootstrap C)
3
4set(exe_name DHT_bootstrap)
5
6add_executable(${exe_name}
7 DHT_bootstrap.c
8 ../testing/misc_tools.c)
9
10linkCoreLibraries(${exe_name})
diff --git a/other/unused/timer.c b/other/unused/timer.c
deleted file mode 100644
index 29190921..00000000
--- a/other/unused/timer.c
+++ /dev/null
@@ -1,290 +0,0 @@
1#define __STDC_FORMAT_MACROS
2#include <inttypes.h>
3
4#include "timer.h"
5#include "network.h"
6
7/*
8A nested linked list increases efficiency of insertions.
9Depending on the number of timers we have, we might need to have nested linked lists
10in order to improve insertion efficiency.
11The code below is preperation for that end, should it be necessary.
12
13typedef struct {
14 struct timer_package* _next;
15 union {
16 timer_packet* _inner;
17 timer* queue;
18 };
19 uint64_t pkgtime;
20} timer_package;
21
22timer_package* timer_package_pool;
23
24static timer_package* new_package()
25{
26 timer_package* ret;
27 if (timer_package_pool) {
28 ret = timer_package_pool;
29 timer_package_pool = timer_package_pool->_next;
30 } else {
31 ret = calloc(1, sizeof(struct timer_package));
32 }
33 return ret;
34}
35
36static void delete_package(timer_package* p)
37{
38 p->_next = timer_package_pool;
39 timer_package_pool = p;
40}
41*/
42
43enum timer_state {
44 STATE_INACTIVE = 0,
45 STATE_ACTIVE,
46 STATE_CALLBACK
47};
48
49struct timer {
50 enum timer_state state;
51 timer *_prev;
52 timer *_next;
53 timer_callback cb;
54 void *userdata;
55 uint64_t deadline;
56};
57
58static timer *timer_main_queue;
59static timer *timer_us_queue; /* hi-speed queue */
60
61inline static void timer_dequeue(timer *t, timer **queue)
62{
63 if (t->state == STATE_INACTIVE) return; /* not in a queue */
64
65 if (t->_prev) {
66 t->_prev->_next = t->_next;
67 } else {
68 *queue = t->_next;
69 }
70
71 if (t->_next) t->_next->_prev = t->_prev;
72
73 t->state = STATE_INACTIVE;
74}
75
76static void timer_enqueue(timer *t, timer **queue, timer *prev)
77{
78 t->state = STATE_ACTIVE;
79
80 while (true) {
81 if (!*queue) {
82 t->_next = 0;
83 t->_prev = prev;
84 *queue = t;
85 return;
86 }
87
88 if ((*queue)->deadline > t->deadline) {
89 (*queue)->_prev = t;
90 t->_next = *queue;
91 t->_prev = prev;
92 *queue = t;
93 return;
94 }
95
96 prev = *queue;
97 queue = &((*queue)->_next);
98 }
99}
100
101/*** interface ***/
102
103void timer_init()
104{
105 /* Nothing needs to be done... yet. */
106}
107
108/* Do not depend on fields being zeroed */
109static timer *timer_pool; /* timer_pool is SINGLY LINKED!! */
110
111timer *new_timer(void)
112{
113 timer *ret;
114
115 if (timer_pool) {
116 ret = timer_pool;
117 timer_pool = timer_pool->_next;
118 } else {
119 ret = calloc(1, sizeof(struct timer));
120 }
121
122 ret->state = STATE_INACTIVE;
123 return ret;
124}
125
126void delete_timer(timer *t)
127{
128 timer_dequeue(t, &timer_main_queue);
129 t->_next = timer_pool;
130 t->state = STATE_INACTIVE;
131 timer_pool = t;
132}
133
134void timer_setup(timer *t, timer_callback cb, void *userarg)
135{
136 t->cb = cb;
137 t->userdata = userarg;
138}
139
140void *timer_get_userdata(timer *t)
141{
142 return t->userdata;
143}
144
145static void timer_delay_us(timer *t, int us)
146{
147 t->deadline += us;
148 timer **queue = t->_prev ? &(t->_prev->_next) : &timer_main_queue;
149 timer_dequeue(t, &timer_main_queue);
150 timer_enqueue(t, queue, t->_prev);
151}
152
153/* Starts the timer so that it's called in sec seconds in the future.
154 * A non-positive value of sec results in the callback being called immediately.
155 * This function may be called again after a timer has been started to adjust
156 * the expiry time. */
157void timer_start(timer *t, int sec)
158{
159 uint64_t newdeadline = current_time() + sec * US_PER_SECOND;
160
161 if (timer_is_active(t)) {
162 if (t->deadline < newdeadline) {
163 timer_delay_us(t, newdeadline - t->deadline);
164 return;
165 }
166
167 timer_dequeue(t, &timer_main_queue);
168 }
169
170 t->deadline = newdeadline;
171 timer_enqueue(t, &timer_main_queue, 0);
172}
173
174/* Stops the timer. Returns -1 if the timer was not active. */
175int timer_stop(timer *t)
176{
177 int ret = timer_is_active(t) ? -1 : 0;
178 timer_dequeue(t, &timer_main_queue);
179 return ret;
180}
181
182/* Adds additionalsec seconds to the timer.
183 * Returns -1 and does nothing if the timer was not active. */
184int timer_delay(timer *t, int additonalsec)
185{
186 if (!timer_is_active(t)) return -1;
187
188 timer_delay_us(t, additonalsec * US_PER_SECOND);
189 return 0;
190}
191
192static uint64_t timer_diff(timer *t, uint64_t time)
193{
194 if (t->deadline <= time) return 0;
195
196 return time - t->deadline;
197}
198
199/* Returns the time remaining on a timer in seconds.
200 * Returns -1 if the timer is not active.
201 * Returns 0 if the timer has expired and will be called upon the next call to timer_poll. */
202int timer_time_remaining(timer *t)
203{
204 if (!timer_is_active(t)) return -1;
205
206 return timer_diff(t, current_time()) / US_PER_SECOND;
207}
208
209bool timer_is_active(timer *t)
210{
211 return t->state != STATE_INACTIVE;
212}
213
214/* Single-use timer.
215 * Creates a new timer, preforms setup and starts it. */
216void timer_single(timer_callback cb, void *userarg, int sec)
217{
218 timer *t = new_timer();
219 timer_setup(t, cb, userarg);
220 timer_start(t, sec);
221}
222
223/* Single-use microsecond timer. */
224void timer_us(timer_callback cb, void *userarg, int us)
225{
226 timer *t = new_timer();
227 timer_setup(t, cb, userarg);
228 t->deadline = current_time() + us;
229 t->state = STATE_ACTIVE;
230 timer_enqueue(t, &timer_us_queue, 0);
231}
232
233uint64_t prevtime = 0;
234void timer_poll(void)
235{
236 uint64_t time = current_time();
237
238 /* Handle millisecond timers */
239 while (timer_us_queue) {
240 if (timer_diff(timer_us_queue, time) != 0) break;
241
242 timer *t = timer_us_queue;
243 timer_dequeue(t, &timer_us_queue);
244 t->cb(0, t->userdata);
245 delete_timer(t);
246 }
247
248 if (time - prevtime > US_PER_SECOND || prevtime == 0 || prevtime > time) {
249 /* time moving backwards is just a sanity check */
250 prevtime = time;
251
252 while (timer_main_queue) {
253 if (timer_diff(timer_main_queue, time) != 0) break;
254
255 timer *t = timer_main_queue;
256 t->state = STATE_CALLBACK;
257 int rv = t->cb(t, t->userdata);
258
259 if (rv != 0) {
260 timer_dequeue(t, &timer_main_queue);
261 delete_timer(t);
262 continue;
263 }
264
265 if (t->state != STATE_ACTIVE) {
266 timer_dequeue(t, &timer_main_queue);
267 }
268 }
269 }
270}
271
272/*** Internal Testing ***/
273
274/* I do not want to expose internals to the public,
275 * which is why internals testing is done this way. */
276void timer_internal_tests(bool (*assert)(bool, char *))
277{
278
279}
280
281void timer_debug_print()
282{
283 timer *t = timer_main_queue;
284 printf("Queue:\n");
285
286 while (t) {
287 printf("%" PRIu64 " (%" PRIu64 ") : %s\n", t->deadline, t->deadline / US_PER_SECOND, (char *)t->userdata);
288 t = t->_next;
289 }
290}
diff --git a/other/unused/timer.h b/other/unused/timer.h
deleted file mode 100644
index 15491326..00000000
--- a/other/unused/timer.h
+++ /dev/null
@@ -1,104 +0,0 @@
1/* timer.h
2 *
3 * Timing subsystem. Provides deadline timers.
4 * All times are aliased to a second for efficiency.
5 *
6 * Timer Guarantees:
7 * - The callback will not be called before the timer expires.
8 * - The callback will be called sometime after the timer expires,
9 * on a best effort basis.
10 * - If timer_poll is called at least once a second, the callback
11 * will be called at most one second after it expires.
12 *
13 * Copyright (C) 2013 Tox project All Rights Reserved.
14 *
15 * This file is part of Tox.
16 *
17 * Tox is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
21 *
22 * Tox is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
29 *
30 */
31
32#ifndef TIMER_H
33#define TIMER_H
34
35#include <stdint.h>
36#include <stdbool.h>
37
38#define US_PER_SECOND 1000000 /* 1 s = 10^6 us */
39
40struct timer;
41typedef struct timer timer;
42
43/* If time_callback returns a non-zero value, timer t is deleted.
44 * You may call any of the timer functions within the callback:
45 * For example, you may call timer_start to restart the timer from
46 * within a callback. */
47typedef int (*timer_callback)(timer *t, void *userarg);
48
49/* Initisalise timer subsystem */
50void timer_init(void);
51
52/* Poll. (I will eventually replace all polling in Tox with an async system.) */
53void timer_poll(void);
54
55/* Creates a new timer. Does not enqueue/start it. */
56timer *new_timer(void);
57
58/* Destroys a timer instance. */
59void delete_timer(timer *t);
60
61/* Sets up the timer callback. */
62void timer_setup(timer *t, timer_callback cb, void *userarg);
63
64/* Accessor Function. */
65void *timer_get_userdata(timer *t);
66
67/* Starts the timer so that it's called in sec seconds in the future from now.
68 * A non-positive value of sec results in the callback being called immediately.
69 * This function may be called again after a timer has been started to adjust
70 * the expiry time. */
71void timer_start(timer *t, int sec);
72
73/* Stops the timer. Returns -1 if the timer was not active. */
74int timer_stop(timer *t);
75
76/* Adds additionalsec seconds to the timer.
77 * Returns -1 and does nothing if the timer was not active. */
78int timer_delay(timer *t, int additonalsec);
79
80/* Returns the time remaining on a timer in seconds.
81 * Returns -1 if the timer is not active.
82 * Returns 0 if the timer has expired and the callback hasn't been called yet. */
83int timer_time_remaining(timer *t);
84
85/* Determines if timer is active. Returns TRUE if it is active */
86bool timer_is_active(timer *t);
87
88/* Single-use timer.
89 * Creates a new timer, preforms setup and starts it.
90 * Callback must return a non-zero value to prevent memory leak. */
91void timer_single(timer_callback cb, void *userarg, int sec);
92
93/* Single-use microsecond timer.
94 * Creates a new timer, preforms setup and starts it.
95 * Please do not use this when accuracy is not absolutely required.
96 * Use when one needs to time a period < 1 s.
97 * Use the more coarse timers above for periods > 5 s.
98 * WARNING: the callback will be called with NULL as the first argument */
99void timer_us(timer_callback cb, void *userarg, int us);
100
101/* Internal Testing */
102void timer_internal_tests(bool( *)(bool, char *));
103
104#endif
diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt
deleted file mode 100644
index 9bab6efb..00000000
--- a/testing/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
1cmake_minimum_required(VERSION 2.6.0)
2
3cmake_policy(SET CMP0011 NEW)
4
5include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_test.cmake)
6include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testclient.cmake)
7include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testserver.cmake)
8include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Messenger_test.cmake)
9include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/crypto_speed_test.cmake)
10
11if(WIN32)
12 #Do nothing
13else()
14 include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox.cmake)
15endif()
diff --git a/testing/DHT_test.c b/testing/DHT_test.c
index 53369794..d14f9781 100644
--- a/testing/DHT_test.c
+++ b/testing/DHT_test.c
@@ -28,8 +28,8 @@
28 */ 28 */
29 29
30//#include "../core/network.h" 30//#include "../core/network.h"
31#include "../core/DHT.h" 31#include "../toxcore/DHT.h"
32#include "../core/friend_requests.h" 32#include "../toxcore/friend_requests.h"
33#include "misc_tools.h" 33#include "misc_tools.h"
34 34
35#include <string.h> 35#include <string.h>
diff --git a/testing/Lossless_UDP_testclient.c b/testing/Lossless_UDP_testclient.c
index 09e9e0a3..af349863 100644
--- a/testing/Lossless_UDP_testclient.c
+++ b/testing/Lossless_UDP_testclient.c
@@ -28,8 +28,8 @@
28 * 28 *
29 */ 29 */
30 30
31#include "../core/network.h" 31#include "../toxcore/network.h"
32#include "../core/Lossless_UDP.h" 32#include "../toxcore/Lossless_UDP.h"
33 33
34#ifdef WIN32 34#ifdef WIN32
35 35
diff --git a/testing/Lossless_UDP_testserver.c b/testing/Lossless_UDP_testserver.c
index a82b787a..5c2cabd0 100644
--- a/testing/Lossless_UDP_testserver.c
+++ b/testing/Lossless_UDP_testserver.c
@@ -28,8 +28,8 @@
28 * 28 *
29 */ 29 */
30 30
31#include "../core/network.h" 31#include "../toxcore/network.h"
32#include "../core/Lossless_UDP.h" 32#include "../toxcore/Lossless_UDP.h"
33 33
34//Sleep function (x = milliseconds) 34//Sleep function (x = milliseconds)
35#ifdef WIN32 35#ifdef WIN32
diff --git a/testing/Makefile.inc b/testing/Makefile.inc
new file mode 100644
index 00000000..067b6ead
--- /dev/null
+++ b/testing/Makefile.inc
@@ -0,0 +1,89 @@
1if BUILD_NTOX
2
3bin_PROGRAMS += nTox
4
5nTox_SOURCES = $(top_srcdir)/testing/misc_tools.h \
6 $(top_srcdir)/testing/misc_tools.c \
7 $(top_srcdir)/testing/nTox.h \
8 $(top_srcdir)/testing/nTox.c
9
10nTox_CFLAGS = $(LIBSODIUM_CFLAGS) \
11 $(NCURSES_CFLAGS)
12
13nTox_LDADD = $(LIBSODIUM_LDFLAGS) \
14 libtoxcore.la \
15 $(LIBSODIUM_LIBS) \
16 $(NCURSES_LIBS)
17
18endif
19
20
21noinst_PROGRAMS += DHT_test \
22 Lossless_UDP_testclient \
23 Lossless_UDP_testserver \
24 Messenger_test \
25 crypto_speed_test
26
27DHT_test_SOURCES = $(top_srcdir)/testing/DHT_test.c \
28 $(top_srcdir)/testing/misc_tools.h \
29 $(top_srcdir)/testing/misc_tools.c
30
31DHT_test_CFLAGS = $(LIBSODIUM_CFLAGS)
32
33DHT_test_LDADD = $(LIBSODIUM_LDFLAGS) \
34 libtoxcore.la \
35 $(LIBSODIUM_LIBS) \
36 $(WINSOCK2_LIBS)
37
38
39Lossless_UDP_testclient_SOURCES = \
40 $(top_srcdir)/testing/Lossless_UDP_testclient.c
41
42Lossless_UDP_testclient_CFLAGS = \
43 $(LIBSODIUM_CFLAGS)
44
45Lossless_UDP_testclient_LDADD = \
46 $(LIBSODIUM_LDFLAGS) \
47 libtoxcore.la \
48 $(LIBSODIUM_LIBS) \
49 $(WINSOCK2_LIBS)
50
51
52Lossless_UDP_testserver_SOURCES = \
53 $(top_srcdir)/testing/Lossless_UDP_testserver.c
54
55Lossless_UDP_testserver_CFLAGS = \
56 $(LIBSODIUM_CFLAGS)
57
58Lossless_UDP_testserver_LDADD = \
59 $(LIBSODIUM_LDFLAGS) \
60 libtoxcore.la \
61 $(LIBSODIUM_LIBS) \
62 $(WINSOCK2_LIBS)
63
64
65Messenger_test_SOURCES = \
66 $(top_srcdir)/testing/Messenger_test.c \
67 $(top_srcdir)/testing/misc_tools.h \
68 $(top_srcdir)/testing/misc_tools.c
69
70Messenger_test_CFLAGS = $(LIBSODIUM_CFLAGS)
71
72Messenger_test_LDADD = $(LIBSODIUM_LDFLAGS) \
73 libtoxcore.la \
74 $(LIBSODIUM_LIBS) \
75 $(WINSOCK2_LIBS)
76
77
78crypto_speed_test_SOURCES = \
79 $(top_srcdir)/testing/crypto_speed_test.c
80
81crypto_speed_test_CFLAGS = \
82 $(LIBSODIUM_CFLAGS)
83
84crypto_speed_test_LDADD = \
85 $(LIBSODIUM_LDFLAGS) \
86 libtoxcore.la \
87 $(LIBSODIUM_LIBS) \
88 $(WINSOCK2_LIBS)
89
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c
index c76584d7..19fd9ab7 100644
--- a/testing/Messenger_test.c
+++ b/testing/Messenger_test.c
@@ -37,7 +37,7 @@
37 * 37 *
38 */ 38 */
39 39
40#include "../core/Messenger.h" 40#include "../toxcore/Messenger.h"
41#include "misc_tools.h" 41#include "misc_tools.h"
42 42
43#ifdef WIN32 43#ifdef WIN32
diff --git a/testing/cmake/DHT_test.cmake b/testing/cmake/DHT_test.cmake
deleted file mode 100644
index bb5bf05f..00000000
--- a/testing/cmake/DHT_test.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
1cmake_minimum_required(VERSION 2.6.0)
2project(DHT_test C)
3
4set(exe_name DHT_test)
5
6add_executable(${exe_name}
7 DHT_test.c
8 misc_tools.c)
9
10linkCoreLibraries(${exe_name})
diff --git a/testing/cmake/Lossless_UDP_testclient.cmake b/testing/cmake/Lossless_UDP_testclient.cmake
deleted file mode 100644
index 5f651807..00000000
--- a/testing/cmake/Lossless_UDP_testclient.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
1cmake_minimum_required(VERSION 2.6.0)
2project(Lossless_UDP_testclient C)
3
4set(exe_name Lossless_UDP_testclient)
5
6add_executable(${exe_name}
7 Lossless_UDP_testclient.c)
8
9linkCoreLibraries(${exe_name})
diff --git a/testing/cmake/Lossless_UDP_testserver.cmake b/testing/cmake/Lossless_UDP_testserver.cmake
deleted file mode 100644
index 26f9302e..00000000
--- a/testing/cmake/Lossless_UDP_testserver.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
1cmake_minimum_required(VERSION 2.6.0)
2project(Lossless_UDP_testserver C)
3
4set(exe_name Lossless_UDP_testserver)
5
6add_executable(${exe_name}
7 Lossless_UDP_testserver.c)
8
9linkCoreLibraries(${exe_name})
diff --git a/testing/cmake/Messenger_test.cmake b/testing/cmake/Messenger_test.cmake
deleted file mode 100644
index 15fcd77b..00000000
--- a/testing/cmake/Messenger_test.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
1cmake_minimum_required(VERSION 2.6.0)
2project(Messenger_test C)
3
4set(exe_name Messenger_test)
5
6add_executable(${exe_name}
7 Messenger_test.c misc_tools.c)
8
9linkCoreLibraries(${exe_name})
diff --git a/testing/cmake/crypto_speed_test.cmake b/testing/cmake/crypto_speed_test.cmake
deleted file mode 100644
index c269af5b..00000000
--- a/testing/cmake/crypto_speed_test.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
1cmake_minimum_required(VERSION 2.6.0)
2project(crypto_speed_test C)
3
4set(exe_name crypto_speed_test)
5
6add_executable(${exe_name}
7 crypto_speed_test.c)
8
9linkCoreLibraries(${exe_name})
diff --git a/testing/cmake/nTox.cmake b/testing/cmake/nTox.cmake
deleted file mode 100644
index 44476b8f..00000000
--- a/testing/cmake/nTox.cmake
+++ /dev/null
@@ -1,12 +0,0 @@
1cmake_minimum_required(VERSION 2.6.0)
2project(nTox C)
3
4set(exe_name nTox)
5
6add_executable(${exe_name}
7 nTox.c misc_tools.c)
8
9target_link_libraries(${exe_name}
10 ncurses)
11
12linkCoreLibraries(${exe_name})
diff --git a/testing/crypto_speed_test.c b/testing/crypto_speed_test.c
index a61b30e8..b06c25e1 100644
--- a/testing/crypto_speed_test.c
+++ b/testing/crypto_speed_test.c
@@ -28,7 +28,7 @@ double get_time()
28 28
29#endif 29#endif
30 30
31#include "../core/net_crypto.h" 31#include "../toxcore/net_crypto.h"
32#include <stdlib.h> 32#include <stdlib.h>
33#include <time.h> 33#include <time.h>
34 34
diff --git a/testing/nTox.h b/testing/nTox.h
index b27a956f..df9d404a 100644
--- a/testing/nTox.h
+++ b/testing/nTox.h
@@ -35,7 +35,7 @@
35#include <arpa/inet.h> 35#include <arpa/inet.h>
36#include <sys/types.h> 36#include <sys/types.h>
37#include <netdb.h> 37#include <netdb.h>
38#include "../core/tox.h" 38#include "../toxcore/tox.h"
39 39
40#define STRING_LENGTH 256 40#define STRING_LENGTH 256
41#define HISTORY 50 41#define HISTORY 50
diff --git a/core/DHT.c b/toxcore/DHT.c
index 533425c4..533425c4 100644
--- a/core/DHT.c
+++ b/toxcore/DHT.c
diff --git a/core/DHT.h b/toxcore/DHT.h
index 6295581b..6295581b 100644
--- a/core/DHT.h
+++ b/toxcore/DHT.h
diff --git a/core/LAN_discovery.c b/toxcore/LAN_discovery.c
index 49f52ce7..49f52ce7 100644
--- a/core/LAN_discovery.c
+++ b/toxcore/LAN_discovery.c
diff --git a/core/LAN_discovery.h b/toxcore/LAN_discovery.h
index 5a790331..5a790331 100644
--- a/core/LAN_discovery.h
+++ b/toxcore/LAN_discovery.h
diff --git a/core/Lossless_UDP.c b/toxcore/Lossless_UDP.c
index c30eb903..c30eb903 100644
--- a/core/Lossless_UDP.c
+++ b/toxcore/Lossless_UDP.c
diff --git a/core/Lossless_UDP.h b/toxcore/Lossless_UDP.h
index 176e86ce..176e86ce 100644
--- a/core/Lossless_UDP.h
+++ b/toxcore/Lossless_UDP.h
diff --git a/toxcore/Makefile.inc b/toxcore/Makefile.inc
new file mode 100644
index 00000000..2fd93a22
--- /dev/null
+++ b/toxcore/Makefile.inc
@@ -0,0 +1,40 @@
1LIBTOXCORE_VERSION = 0:0:0
2
3lib_LTLIBRARIES = libtoxcore.la
4
5libtoxcore_la_include_HEADERS = \
6 $(top_srcdir)/toxcore/tox.h
7
8libtoxcore_la_includedir = $(includedir)/tox
9
10libtoxcore_la_SOURCES = $(top_srcdir)/toxcore/DHT.h \
11 $(top_srcdir)/toxcore/DHT.c \
12 $(top_srcdir)/toxcore/network.h \
13 $(top_srcdir)/toxcore/network.c \
14 $(top_srcdir)/toxcore/Lossless_UDP.h \
15 $(top_srcdir)/toxcore/Lossless_UDP.c \
16 $(top_srcdir)/toxcore/net_crypto.h \
17 $(top_srcdir)/toxcore/net_crypto.c \
18 $(top_srcdir)/toxcore/friend_requests.h \
19 $(top_srcdir)/toxcore/friend_requests.c \
20 $(top_srcdir)/toxcore/LAN_discovery.h \
21 $(top_srcdir)/toxcore/LAN_discovery.c \
22 $(top_srcdir)/toxcore/Messenger.h \
23 $(top_srcdir)/toxcore/Messenger.c \
24 $(top_srcdir)/toxcore/packets.h \
25 $(top_srcdir)/toxcore/ping.h \
26 $(top_srcdir)/toxcore/ping.c \
27 $(top_srcdir)/toxcore/tox.h \
28 $(top_srcdir)/toxcore/tox.c \
29 $(top_srcdir)/toxcore/util.h \
30 $(top_srcdir)/toxcore/util.c
31
32libtoxcore_la_CFLAGS = -I$(top_srcdir) \
33 -I$(top_srcdir)/toxcore \
34 $(LIBSODIUM_CFLAGS)
35
36libtoxcore_la_LDFLAGS = -version-info $(LIBTOXCORE_VERSION) \
37 $(LIBSODIUM_LDFLAGS)
38
39libtoxcore_la_LIBS = $(LIBSODIUM_LIBS) \
40 $(WINSOCK2_LIBS)
diff --git a/core/Messenger.c b/toxcore/Messenger.c
index c5dd8a40..c5dd8a40 100644
--- a/core/Messenger.c
+++ b/toxcore/Messenger.c
diff --git a/core/Messenger.h b/toxcore/Messenger.h
index e808529f..e808529f 100644
--- a/core/Messenger.h
+++ b/toxcore/Messenger.h
diff --git a/core/friend_requests.c b/toxcore/friend_requests.c
index d8c6858b..d8c6858b 100644
--- a/core/friend_requests.c
+++ b/toxcore/friend_requests.c
diff --git a/core/friend_requests.h b/toxcore/friend_requests.h
index 2ebd557b..2ebd557b 100644
--- a/core/friend_requests.h
+++ b/toxcore/friend_requests.h
diff --git a/core/net_crypto.c b/toxcore/net_crypto.c
index f421c37d..f421c37d 100644
--- a/core/net_crypto.c
+++ b/toxcore/net_crypto.c
diff --git a/core/net_crypto.h b/toxcore/net_crypto.h
index 81670993..81670993 100644
--- a/core/net_crypto.h
+++ b/toxcore/net_crypto.h
diff --git a/core/network.c b/toxcore/network.c
index 2bcf7d61..2bcf7d61 100644
--- a/core/network.c
+++ b/toxcore/network.c
diff --git a/core/network.h b/toxcore/network.h
index 3547f79b..3547f79b 100644
--- a/core/network.h
+++ b/toxcore/network.h
diff --git a/core/packets.h b/toxcore/packets.h
index 4f410fb3..4f410fb3 100644
--- a/core/packets.h
+++ b/toxcore/packets.h
diff --git a/core/ping.c b/toxcore/ping.c
index 55d4d261..55d4d261 100644
--- a/core/ping.c
+++ b/toxcore/ping.c
diff --git a/core/ping.h b/toxcore/ping.h
index c04ec80e..c04ec80e 100644
--- a/core/ping.h
+++ b/toxcore/ping.h
diff --git a/core/tox.c b/toxcore/tox.c
index a97e52bc..a97e52bc 100644
--- a/core/tox.c
+++ b/toxcore/tox.c
diff --git a/core/tox.h b/toxcore/tox.h
index bdfac1d6..bdfac1d6 100644
--- a/core/tox.h
+++ b/toxcore/tox.h
diff --git a/core/util.c b/toxcore/util.c
index 6f346db1..6f346db1 100644
--- a/core/util.c
+++ b/toxcore/util.c
diff --git a/core/util.h b/toxcore/util.h
index 5209c2ca..5209c2ca 100644
--- a/core/util.h
+++ b/toxcore/util.h