Issue #5, Describe routable prefix, the -R option
[6bed4] / CMakeLists.txt
1 project (6bed4 C)
2 cmake_minimum_required (VERSION 2.6)
3 set (VERSION "0.0.1")
4 cmake_policy (SET CMP0053 NEW)
5
6 add_definitions (-DLINUX)
7
8 option (DEBUG
9         "Switch on output and flags that aid developpers in debugging"
10         OFF)
11
12 if (DEBUG)
13         add_compile_options (-DDEBUG -ggdb3 -O0 -fstack-protector)
14 endif()
15
16 add_executable (6bed4peer "src/6bed4peer.c")
17 add_executable (6bed4router "src/6bed4router.c")
18
19 install (PROGRAMS
20         ${CMAKE_BINARY_DIR}/6bed4peer
21         ${CMAKE_BINARY_DIR}/6bed4router
22         DESTINATION sbin)
23 install (FILES
24         ${CMAKE_SOURCE_DIR}/doc/man/6bed4peer.man
25         ${CMAKE_SOURCE_DIR}/doc/man/6bed4router.man
26         DESTINATION ${SHARE_INSTALL_PREFIX}/man/man8)
27
28
29 #
30 # Setup a number of parameters.  Until we get 6bed4 standardised,
31 # these are preliminary values that MUST NOT be assumed static.
32 #
33 # This is why CMake will present a warning, but it will still
34 # go ahead with the values.  They can be changed at will using
35 # any tool that interacts with the CMakeCache.txt file or that
36 # overrides the settings at build time.
37 #
38 # Please beware that the values contain the information in a
39 # number of different forms.  In a perfect world, we would
40 # derive values from one another.  In a portable world, for
41 # now at least, we resort to letting you maintain consistency.
42 #
43
44 if (NOT ND_OPT_DESTINATION_LINKADDR)
45         message ("\nSTEALING an experimental Neighbor Discovery Option Type 253 for Destination Link-Layer Address -- please configure your local override\n")
46         set (ND_OPT_DESTINATION_LINKADDR 253
47                 CACHE STRING "Neighbor Discovery Option Type for Destination Link-Layer Address; Configure an unused value until this is standardised"
48         )
49 else ()
50         message (WARNING
51                 "Using experimental Neighbour Discovery Option Type ${ND_OPT_DESTINATION_LINKADDR}")
52 endif ()
53
54 if (NOT UDP_PORT_6BED4)
55         message ("\nSTEALING an experimental UDP port number 25790 or 0x64be -- please configure your local override\n")
56         set (UDP_PORT_6BED4 25790
57                 CACHE STRING "Decimal UDP Port to use in this 6bed4 setup; Must be consistent with other settings that mention it in different forms; Configure an unused value until this is standardised"
58         )
59         set (SERVER_6BED4_PORT_TXT "\"25790\""
60                 CACHE STRING "Decimal string representation of the UDP Port to use; Must be consistent with UDP_PORT_6BED4"
61         )
62         set (SERVER_6BED4_PORT_BINSTR "\"\\xbe\\x64\""
63                 CACHE STRING "Binary string representation of the UDP Port to use; Unsigned 16 bits in network byte order; Must be consistent with UDP_PORT_6BED4"
64         )
65 else ()
66         message (WARNING
67                 "Using experimental UDP port number ${UDP_PORT_6BED4}")
68 endif ()
69
70 if (NOT SERVER_6BED4_IPV4_TXT)
71         message ("\nSTEALING an expermental 6bed4 server IP address 145.136.0.1 -- please configure your local override\n")
72         set (SERVER_6BED4_IPV4_TXT "\"145.136.0.1\""
73                 CACHE STRING "String representation of decimal IP address of the 6bed4 server to use; Must be consistent with other settings that mention it in different forms"
74         )
75         set (SERVER_6BED4_IPV4_INT32 252183167
76                 CACHE STRING "Unsinged 32-bit integer form of the IP address of the 6bed4 server; Higher bits are for coarser routing; Must be consistent with SERVER_6BED4_IPV4_TXT"
77         )
78         set (SERVER_6BED4_IPV4_INT0 145
79                 CACHE STRING "Decimal form of the byte 1/4 of the IP address of the 6bed4 server; Must be consistent with SERVER_6BED4_IPV4_TXT"
80         )
81         set (SERVER_6BED4_IPV4_INT1 136
82                 CACHE STRING "Decimal form of the byte 2/4 of the IP address of the 6bed4 server; Must be consistent with SERVER_6BED4_IPV4_TXT"
83         )
84         set (SERVER_6BED4_IPV4_INT2 0
85                 CACHE STRING "Decimal form of the byte 3/4 of the IP address of the 6bed4 server; Must be consistent with SERVER_6BED4_IPV4_TXT"
86         )
87         set (SERVER_6BED4_IPV4_INT3 1
88                 CACHE STRING "Decimal form of the byte 4/4 of the IP address of the 6bed4 server; Must be consistent with SERVER_6BED4_IPV4_TXT"
89         )
90         set (SERVER_6BED4_IPV4_BINSTR "\"\\x91\\x88\\x00\\x01\""
91                 CACHE STRING "Binary string representation of the IP address of the 6bed4 server; Must be consistent with SERVER_6BED4_IPV4_TXT"
92         )
93 else ()
94         message (WARNING
95                 "Using experimental server IP address ${SERVER_6BED4_IPV4_TXT}")
96 endif ()
97
98 set (SERVER_6BED4_IPV4_PORT_TXT "\"145.136.0.1:25790\""
99         CACHE STRING "Textual representation of the 6bed4 server IPv4 address and port number; Must be consistent with SERVER_6BED4_IPV4_TXT and UDP_PORT_6BED4"
100 )
101 set (SERVER_6BED4_PORT_IPV4_ADDRSTR "\"\\xbe\\x64\\x91\\x88\\x00\\x01\""
102         CACHE STRING "Binary string representation of the 6bed4 server port number followed by the IPv4 address; Must be the concatenation of SERVER_6BED4_PORT_BINSTR and SERVER_6BED4_IPV4_BINSTR"
103 )
104 set (SERVER_6BED4_PORT_IPV4_MACSTR "\"\\xbc\\x64\\x91\\x88\\x00\\x01\""
105         CACHE STRING "Binary string representation of the 6bed4 server port number and IPv4 address as a MAC address; Must be equal to SERVER_6BED4_PORT_IPV4_ADDRSTR except for an applied XOR with 0x02 on the first byte"
106 )
107
108 set (INTERFACE_NAME_6BED4 "6bed4"
109         CACHE STRING "The name of the network interface created by 6bed4peer and 6bed4router.  The default name is \"6bed4\" which may conflict with local naming policies for interfaces, or scripts.  It is the clearest name, so it is the default, but you can override it if you need to.")
110
111 option (LOCAL_OVERRIDES_PORT0 "Addresses PREFIX6BED4:x:x:0:x have no meaning to 6bed4 and will be treated as local addresses of the 6bed4router" ON)
112
113
114 configure_file (
115         ${CMAKE_SOURCE_DIR}/src/nonstd.h.in
116         ${CMAKE_BINARY_DIR}/src/nonstd.h
117         IMMEDIATE @ONLY
118 )
119
120 include_directories (${CMAKE_BINARY_DIR}/src)
121
122 add_definitions (-DINTERFACE_NAME_6BED4="${INTERFACE_NAME_6BED4}")
123
124 if (LOCAL_OVERRIDES_PORT0)
125         add_definitions (-DLOCAL_OVERRIDES_PORT0=yes)
126 endif ()
127
128
129 #
130 # Packaging
131 #
132 include (CPack)