aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: ff6db1698c481d975a589b23bf936cceb9285b79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
cmake_minimum_required(VERSION 2.6)
if(${CMAKE_VERSION} STREQUAL "2.8.2")
  # bug http://vtk.org/Bug/view.php?id=11020
  message( WARNING "CMake/CPack version 2.8.2 will not create working .deb packages!")
endif(${CMAKE_VERSION} STREQUAL "2.8.2")

# This can be read from ${PROJECT_NAME} after project() is called
project(minetest)

set(VERSION_MAJOR 0)
set(VERSION_MINOR 2)
set(VERSION_PATCH 201109xx_dev)
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

# Configuration options

if(WIN32)
	set(RUN_IN_PLACE 1 CACHE BOOL "Run directly in source directory structure")
else()
	set(RUN_IN_PLACE 0 CACHE BOOL "Run directly in source directory structure")
endif()

set(BUILD_CLIENT 1 CACHE BOOL "Build client")
if(WIN32)
	set(BUILD_SERVER 0 CACHE BOOL "Build server")
else()
	set(BUILD_SERVER 1 CACHE BOOL "Build server")
endif()

set(WARN_ALL 1 CACHE BOOL "Enable -Wall for Release build")

if(NOT CMAKE_BUILD_TYPE)
	# Default to release
	set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
endif()

# Included stuff
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
include(${CMAKE_SOURCE_DIR}/cmake/Modules/misc.cmake)

# This is done here so that relative search paths are more reasnable
find_package(Irrlicht)

#
# Installation
#

if(WIN32)
	set(DATADIR "data")
	set(BINDIR "bin")
	set(DOCDIR "doc")
	set(EXAMPLE_CONF_DIR ".")
elseif(APPLE)
	# random placeholders
	set(DATADIR "share/${PROJECT_NAME}")
	set(BINDIR "bin")
	set(DOCDIR "share/doc/${PROJECT_NAME}")
	set(EXAMPLE_CONF_DIR ".")
elseif(UNIX) # Linux, BSD etc
	set(DATADIR "share/${PROJECT_NAME}")
	set(BINDIR "bin")
	set(DOCDIR "share/doc/${PROJECT_NAME}")
	set(EXAMPLE_CONF_DIR "share/doc/${PROJECT_NAME}")
endif()

install(FILES "doc/README.txt" DESTINATION "${DOCDIR}")
install(FILES "doc/changelog.txt" DESTINATION "${DOCDIR}")
install(FILES "minetest.conf.example" DESTINATION "${DOCDIR}")

#
# Subdirectories
# Be sure to add all relevant definitions above this
#

add_subdirectory(src)

# CPack

set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An InfiniMiner/Minecraft inspired game")
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
set(CPACK_PACKAGE_VENDOR "celeron55")
set(CPACK_PACKAGE_CONTACT "Perttu Ahola <celeron55@gmail.com>")

if(WIN32)
	# For some reason these aren't copied otherwise
	# NOTE: For some reason now it seems to work without these
	#if(BUILD_CLIENT)
	#	install(FILES bin/minetest.exe DESTINATION bin)
	#endif()
	#if(BUILD_SERVER)
	#	install(FILES bin/minetestserver.exe DESTINATION bin)
	#endif()

	set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32")

	set(CPACK_GENERATOR ZIP)

	# This might be needed for some installer
	#set(CPACK_PACKAGE_EXECUTABLES bin/minetest.exe "Minetest" bin/minetestserver.exe "Minetest Server")
elseif(APPLE)
	# TODO
	# see http://cmake.org/Wiki/CMake:CPackPackageGenerators#Bundle_.28OSX_only.29
	#
	set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-osx")
	set(CPACK_PACKAGE_ICON "")
	set(CPACK_BUNDLE_NAME ${PROJECT_NAME})
	set(CPACK_BUNDLE_ICON "")
	set(CPACK_BUNDLE_PLIST "")
	set(CPACK_BUNDLE_STARTUP_COMMAND "Contents/MacOS/${PROJECT_NAME}")
	set(CPACK_GENERATOR "Bundle")
else()
	set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-linux")
	set(CPACK_GENERATOR TGZ)
	set(CPACK_SOURCE_GENERATOR TGZ)
endif()

include(CPack)

com"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * */ /* * * Purpose: This is a direct implementation of the Secure Remote Password * Protocol version 6a as described by * http://srp.stanford.edu/design.html * * Author: tom.cocagne@gmail.com (Tom Cocagne) * * Dependencies: LibGMP * * Usage: Refer to test_srp.c for a demonstration * * Notes: * This library allows multiple combinations of hashing algorithms and * prime number constants. For authentication to succeed, the hash and * prime number constants must match between * srp_create_salted_verification_key(), srp_user_new(), * and srp_verifier_new(). A recommended approach is to determine the * desired level of security for an application and globally define the * hash and prime number constants to the predetermined values. * * As one might suspect, more bits means more security. As one might also * suspect, more bits also means more processing time. The test_srp.c * program can be easily modified to profile various combinations of * hash & prime number pairings. */ #pragma once struct SRPVerifier; struct SRPUser; typedef enum { SRP_NG_1024, SRP_NG_2048, SRP_NG_4096, SRP_NG_8192, SRP_NG_CUSTOM } SRP_NGType; typedef enum { /*SRP_SHA1,*/ /*SRP_SHA224,*/ SRP_SHA256, /*SRP_SHA384, SRP_SHA512*/ } SRP_HashAlgorithm; typedef enum { SRP_ERR, SRP_OK, } SRP_Result; // clang-format off /* Sets the memory functions used by srp. * Note: this doesn't set the memory functions used by gmp, * but it is supported to have different functions for srp and gmp. * Don't call this after you have already allocated srp structures. */ void srp_set_memory_functions( void *(*new_srp_alloc) (size_t), void *(*new_srp_realloc) (void *, size_t), void (*new_srp_free) (void *)); /* Out: bytes_v, len_v * * The caller is responsible for freeing the memory allocated for bytes_v * * The n_hex and g_hex parameters should be 0 unless SRP_NG_CUSTOM is used for ng_type. * If provided, they must contain ASCII text of the hexidecimal notation. * * If bytes_s == NULL, it is filled with random data. * The caller is responsible for freeing. * * Returns SRP_OK on success, and SRP_ERR on error. * bytes_s might be in this case invalid, don't free it. */ SRP_Result srp_create_salted_verification_key(SRP_HashAlgorithm alg, SRP_NGType ng_type, const char *username_for_verifier, const unsigned char *password, size_t len_password, unsigned char **bytes_s, size_t *len_s, unsigned char **bytes_v, size_t *len_v, const char *n_hex, const char *g_hex); /* Out: bytes_B, len_B. * * On failure, bytes_B will be set to NULL and len_B will be set to 0 * * The n_hex and g_hex parameters should be 0 unless SRP_NG_CUSTOM is used for ng_type * * If bytes_b == NULL, random data is used for b. * * Returns pointer to SRPVerifier on success, and NULL on error. */ struct SRPVerifier* srp_verifier_new(SRP_HashAlgorithm alg, SRP_NGType ng_type, const char *username, const unsigned char *bytes_s, size_t len_s, const unsigned char *bytes_v, size_t len_v, const unsigned char *bytes_A, size_t len_A, const unsigned char *bytes_b, size_t len_b, unsigned char** bytes_B, size_t *len_B, const char* n_hex, const char* g_hex); // clang-format on void srp_verifier_delete(struct SRPVerifier *ver); // srp_verifier_verify_session must have been called before int srp_verifier_is_authenticated(struct SRPVerifier *ver); const char *srp_verifier_get_username(struct SRPVerifier *ver); /* key_length may be null */ const unsigned char *srp_verifier_get_session_key( struct SRPVerifier *ver, size_t *key_length); size_t srp_verifier_get_session_key_length(struct SRPVerifier *ver); /* Verifies session, on success, it writes bytes_HAMK. * user_M must be exactly srp_verifier_get_session_key_length() bytes in size */ void srp_verifier_verify_session( struct SRPVerifier *ver, const unsigned char *user_M, unsigned char **bytes_HAMK); /*******************************************************************************/ /* The n_hex and g_hex parameters should be 0 unless SRP_NG_CUSTOM is used for ng_type */ struct SRPUser *srp_user_new(SRP_HashAlgorithm alg, SRP_NGType ng_type, const char *username, const char *username_for_verifier, const unsigned char *bytes_password, size_t len_password, const char *n_hex, const char *g_hex); void srp_user_delete(struct SRPUser *usr); int srp_user_is_authenticated(struct SRPUser *usr); const char *srp_user_get_username(struct SRPUser *usr); /* key_length may be null */ const unsigned char *srp_user_get_session_key(struct SRPUser *usr, size_t *key_length); size_t srp_user_get_session_key_length(struct SRPUser *usr); // clang-format off /* Output: username, bytes_A, len_A. * If you don't want it get written, set username to NULL. * If bytes_a == NULL, random data is used for a. */ SRP_Result srp_user_start_authentication(struct SRPUser* usr, char **username, const unsigned char *bytes_a, size_t len_a, unsigned char **bytes_A, size_t* len_A); /* Output: bytes_M, len_M (len_M may be null and will always be * srp_user_get_session_key_length() bytes in size) */ void srp_user_process_challenge(struct SRPUser *usr, const unsigned char *bytes_s, size_t len_s, const unsigned char *bytes_B, size_t len_B, unsigned char **bytes_M, size_t *len_M); // clang-format on /* bytes_HAMK must be exactly srp_user_get_session_key_length() bytes in size */ void srp_user_verify_session(struct SRPUser *usr, const unsigned char *bytes_HAMK);