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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
|
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -330,18 +330,29 @@
# in the top level CMakeLists.txt, to ensure a consistent
# header file layout across the entire project.
#
-set(ENABLE_BUNDLED_LIBCORO ON)
-include(BuildLibCORO)
-libcoro_build()
-add_dependencies(build_bundled_libs coro)
+option(ENABLE_BUNDLED_LIBCORO "Enable building of the bundled libcoro" ON)
+if (ENABLE_BUNDLED_LIBCORO)
+ include(BuildLibCORO)
+ libcoro_build()
+ add_dependencies(build_bundled_libs coro)
+else()
+ set(LIBCORO_FIND_REQUIRED ON)
+ find_package(LibCORO)
+endif()
#
# LibGOPT
#
-include(BuildLibGOPT)
-libgopt_build()
-add_dependencies(build_bundled_libs gopt)
+option(ENABLE_BUNDLED_LIBGOPT "Enable building of the bundled gopt" ON)
+if (ENABLE_BUNDLED_LIBGOPT)
+ include(BuildLibGOPT)
+ libgopt_build()
+ add_dependencies(build_bundled_libs gopt)
+else()
+ set(LIBGOPT_FIND_REQUIRED ON)
+ find_package(LibGOPT)
+endif()
#
# MsgPuck
@@ -377,11 +388,14 @@
# zstd
#
-# Debian: missing zstd_static.h in libzstd-dev
-# Fedora: not found
-# => always use bundled version
-include(BuildZSTD)
-zstd_build()
+option(ENABLE_BUNDLED_ZSTD "Enable building of the bundled zstd" ON)
+if (ENABLE_BUNDLED_ZSTD)
+ include(BuildZSTD)
+ zstd_build()
+else()
+ set(LIBZSTD_FIND_REQUIRED ON)
+ find_package(ZSTD)
+endif()
#
# OpenSSL
--- /dev/null
+++ b/cmake/FindLibCORO.cmake
@@ -0,0 +1,24 @@
+find_path(LIBCORO_INCLUDE_DIR
+ NAMES coro.h
+)
+
+find_library(LIBCORO_LIBRARY
+ NAMES libcoro.a coro
+)
+
+set(LIBCORO_INCLUDE_DIRS "${LIBCORO_INCLUDE_DIR}")
+set(LIBCORO_LIBRARIES "${LIBCORO_LIBRARY}")
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LIBCORO REQUIRED_VARS
+ LIBCORO_LIBRARIES LIBCORO_INCLUDE_DIRS)
+
+mark_as_advanced(LIBCORO_LIBRARY LIBCORO_LIBRARIES
+ LIBCORO_INCLUDE_DIR LIBCORO_INCLUDE_DIRS)
+
+if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "86" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "amd64"
+ OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
+ add_definitions("-DCORO_ASM")
+else()
+ add_definitions("-DCORO_SJLJ")
+endif()
--- /dev/null
+++ b/cmake/FindLibGOPT.cmake
@@ -0,0 +1,17 @@
+find_path(LIBGOPT_INCLUDE_DIR
+ NAMES gopt.h
+)
+
+find_library(LIBGOPT_LIBRARY
+ NAMES libgopt.a gopt
+)
+
+set(LIBGOPT_INCLUDE_DIRS "${LIBGOPT_INCLUDE_DIR}")
+set(LIBGOPT_LIBRARIES "${LIBGOPT_LIBRARY}")
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LIBGOPT REQUIRED_VARS
+ LIBGOPT_LIBRARIES LIBGOPT_INCLUDE_DIRS)
+
+mark_as_advanced(LIBGOPT_LIBRARY LIBGOPT_LIBRARIES
+ LIBGOPT_INCLUDE_DIR LIBGOPT_INCLUDE_DIRS)
--- /dev/null
+++ b/cmake/FindZSTD.cmake
@@ -0,0 +1,17 @@
+find_path(ZSTD_INCLUDE_DIR
+ NAMES zstd.h
+)
+
+find_library(ZSTD_LIBRARY
+ NAMES zstd
+)
+
+set(ZSTD_INCLUDE_DIRS "${ZSTD_INCLUDE_DIR}")
+set(ZSTD_LIBRARIES "${ZSTD_LIBRARY}")
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(ZSTD REQUIRED_VARS
+ ZSTD_LIBRARIES ZSTD_INCLUDE_DIRS)
+
+mark_as_advanced(ZSTD_LIBRARY ZSTD_LIBRARIES
+ ZSTD_INCLUDE_DIR ZSTD_INCLUDE_DIRS)
--- a/src/main.cc
+++ b/src/main.cc
@@ -67,7 +67,7 @@
#include "random.h"
#include "tt_uuid.h"
#include "iobuf.h"
-#include <third_party/gopt/gopt.h>
+#include <gopt.h>
#include "cfg.h"
#include "version.h"
#include <readline/readline.h>
--- a/src/fiber.h
+++ b/src/fiber.h
@@ -44,7 +44,7 @@
#include "small/rlist.h"
#include "salad/stailq.h"
-#include <third_party/coro/coro.h>
+#include <coro.h>
#if defined(__cplusplus)
extern "C" {
--- a/src/opts.c
+++ b/src/opts.c
@@ -31,7 +31,7 @@
#include "trivia/config.h"
#include <stddef.h>
-#include <third_party/gopt/gopt.h>
+#include <gopt.h>
const void *opt_def =
gopt_start(
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -47,15 +47,15 @@
lua_source(lua_sources lua/httpc.lua)
lua_source(lua_sources lua/iconv.lua)
# LuaJIT jit.* library
-lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/bc.lua")
-lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/bcsave.lua")
-lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/dis_x86.lua")
-lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/dis_x64.lua")
-lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/dump.lua")
-lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/vmdef.lua")
-lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/v.lua")
-lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/p.lua")
-lua_source(lua_sources "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit/zone.lua")
+lua_source(lua_sources "${LUAJIT_JITLIB_DIR}/bc.lua")
+lua_source(lua_sources "${LUAJIT_JITLIB_DIR}/bcsave.lua")
+lua_source(lua_sources "${LUAJIT_JITLIB_DIR}/dis_x86.lua")
+lua_source(lua_sources "${LUAJIT_JITLIB_DIR}/dis_x64.lua")
+lua_source(lua_sources "${LUAJIT_JITLIB_DIR}/dump.lua")
+lua_source(lua_sources "${LUAJIT_JITLIB_DIR}/vmdef.lua")
+lua_source(lua_sources "${LUAJIT_JITLIB_DIR}/v.lua")
+lua_source(lua_sources "${LUAJIT_JITLIB_DIR}/p.lua")
+lua_source(lua_sources "${LUAJIT_JITLIB_DIR}/zone.lua")
add_custom_target(generate_lua_sources
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src/box
@@ -197,10 +197,11 @@
# Rule of thumb: if exporting a symbol from a static library, list the
# library here.
set (reexport_libraries server core misc bitset csv
- ${LUAJIT_LIBRARIES} ${MSGPUCK_LIBRARIES})
+ ${MSGPUCK_LIBRARIES})
set (common_libraries
${reexport_libraries}
+ ${LUAJIT_LIBRARIES}
${LIBEIO_LIBRARIES}
${LIBGOPT_LIBRARIES}
${LIBYAML_LIBRARIES}
--- a/cmake/luajit.cmake
+++ b/cmake/luajit.cmake
@@ -38,6 +38,7 @@
set (LUAJIT_PREFIX "${LUAJIT_BUNDLED_PREFIX}")
set (LUAJIT_INCLUDE "${PROJECT_SOURCE_DIR}/third_party/luajit/src")
set (LUAJIT_LIB "${LUAJIT_BUNDLED_LIB}")
+ set (LUAJIT_JITLIB_DIR "${CMAKE_BINARY_DIR}/third_party/luajit/src/jit")
set (ENABLE_BUNDLED_LUAJIT True)
endmacro()
@@ -63,10 +64,12 @@
# usable with the server (determined by a compiled test).
#
macro (luajit_try_system)
- find_path (LUAJIT_INCLUDE lj_obj.h PATH_SUFFIXES luajit-2.0 luajit)
+ find_path (LUAJIT_INCLUDE lj_obj.h PATH_SUFFIXES luajit-2.1 luajit)
find_library (LUAJIT_LIB NAMES luajit luajit-5.1 PATH_SUFFIXES x86_64-linux-gnu)
- if (LUAJIT_INCLUDE AND LUAJIT_LIB)
- message (STATUS "include: ${LUAJIT_INCLUDE}, lib: ${LUAJIT_LIB}")
+ file (GLOB LUAJIT_JITLIB_SEARCH_PATHS "/usr/local/share/luajit-2.1*/jit" "/usr/share/luajit-2.1*/jit" "/share/luajit-2.1*/jit")
+ find_path (LUAJIT_JITLIB_DIR vmdef.lua PATHS ${LUAJIT_JITLIB_SEARCH_PATHS})
+ if (LUAJIT_INCLUDE AND LUAJIT_LIB AND LUAJIT_JITLIB_DIR)
+ message (STATUS "include: ${LUAJIT_INCLUDE}, lib: ${LUAJIT_LIB}, jitlib_dir: ${LUAJIT_JITLIB_DIR}")
message (STATUS "Found a system-wide LuaJIT.")
luajit_test()
if ("${LUAJIT_RUNS}" STREQUAL "1")
@@ -79,6 +82,7 @@
message (FATAL_ERROR "Not found a system LuaJIT")
#luajit_use_bundled()
endif()
+ unset(LUAJIT_JITLIB_SEARCH_PATHS)
endmacro()
#
@@ -87,7 +91,8 @@
macro (luajit_try_prefix)
find_path (LUAJIT_INCLUDE "lua.h" ${LUAJIT_PREFIX} NO_DEFAULT_PATH)
find_library (LUAJIT_LIB "luajit" ${LUAJIT_PREFIX} NO_DEFAULT_PATH)
- if (LUAJIT_INCLUDE AND LUAJIT_LIB)
+ find_path (LUAJIT_JITLIB_DIR "vmdef.lua" ${LUAJIT_PREFIX}/jit NO_DEFAULT_PATH)
+ if (LUAJIT_INCLUDE AND LUAJIT_LIB AND LUAJIT_JITLIB_DIR)
include_directories("${LUAJIT_INCLUDE}")
luajit_test()
if (LUAJIT_RUNS)
--- a/cmake/utils.cmake
+++ b/cmake/utils.cmake
@@ -41,8 +41,8 @@
function(lua_source varname filename)
if (IS_ABSOLUTE "${filename}")
set (srcfile "${filename}")
- set (tmpfile "${filename}.new.c")
- set (dstfile "${filename}.c")
+ set (tmpfile "${CMAKE_CURRENT_BINARY_DIR}${filename}.new.c")
+ set (dstfile "${CMAKE_CURRENT_BINARY_DIR}${filename}.c")
else(IS_ABSOLUTE "${filename}")
set (srcfile "${CMAKE_CURRENT_SOURCE_DIR}/${filename}")
set (tmpfile "${CMAKE_CURRENT_BINARY_DIR}/${filename}.new.c")
@@ -62,7 +62,7 @@
COMMAND ${ECHO} '\;' >> ${tmpfile}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmpfile} ${dstfile}
COMMAND ${CMAKE_COMMAND} -E remove ${tmpfile}
- DEPENDS ${srcfile} txt2c libluajit)
+ DEPENDS ${srcfile} txt2c)
set(var ${${varname}})
set(${varname} ${var} ${dstfile} PARENT_SCOPE)
|