2018-03-22 08:14:13 +00:00
|
|
|
# Preamble
|
2014-04-29 14:11:27 +00:00
|
|
|
project( Lsyncd )
|
|
|
|
cmake_minimum_required( VERSION 2.8 )
|
2018-03-12 10:50:08 +00:00
|
|
|
set( LSYNCD_VERSION 3.0.0-devel )
|
2014-04-29 14:11:27 +00:00
|
|
|
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/" )
|
|
|
|
|
|
|
|
|
2018-03-22 08:14:13 +00:00
|
|
|
# Finding Lua
|
2016-12-13 13:53:01 +00:00
|
|
|
find_package( Lua REQUIRED )
|
2014-04-29 14:11:27 +00:00
|
|
|
include_directories ( ${LUA_INCLUDE_DIR} )
|
|
|
|
|
2018-03-22 08:14:13 +00:00
|
|
|
# Setting Lsyncd sources.
|
2018-04-22 15:52:35 +00:00
|
|
|
# Order doesn't matter here.
|
2018-03-22 08:14:13 +00:00
|
|
|
set( LSYNCD_SRC
|
2018-03-23 08:34:33 +00:00
|
|
|
core/log.c
|
2018-03-28 06:59:10 +00:00
|
|
|
core/observe.c
|
2018-03-26 17:05:00 +00:00
|
|
|
core/pipe.c
|
2018-04-13 20:55:04 +00:00
|
|
|
core/main.c
|
2018-04-11 07:03:53 +00:00
|
|
|
core/mci.c
|
2018-03-27 07:09:07 +00:00
|
|
|
core/mem.c
|
2018-04-03 06:54:07 +00:00
|
|
|
core/signal.c
|
2018-03-30 07:36:26 +00:00
|
|
|
core/time.c
|
2018-04-03 06:54:07 +00:00
|
|
|
core/userobs.c
|
2018-03-27 07:09:07 +00:00
|
|
|
core/util.c
|
2018-03-23 16:36:51 +00:00
|
|
|
mantle.c
|
|
|
|
default.c
|
2018-03-22 08:14:13 +00:00
|
|
|
)
|
2014-04-29 14:11:27 +00:00
|
|
|
|
2018-03-22 08:14:13 +00:00
|
|
|
# Tell systemd via the sd-daemon library about the status of Lsyncd.
|
2018-03-12 11:51:52 +00:00
|
|
|
option( WITH_SYSTEMD "Communicate Lsyncd status to systemd" ON )
|
2014-04-29 14:11:27 +00:00
|
|
|
|
2018-03-22 08:14:13 +00:00
|
|
|
# Selecting the file notification mechanisms to compile against.
|
2014-04-29 14:11:27 +00:00
|
|
|
option( WITH_INOTIFY "Compile with inotify file notifications (Linux)" ON )
|
|
|
|
|
|
|
|
if( WITH_INOTIFY )
|
2018-03-13 15:09:41 +00:00
|
|
|
set( LSYNCD_SRC ${LSYNCD_SRC} core/inotify.c )
|
2014-04-29 14:11:27 +00:00
|
|
|
endif( WITH_INOTIFY )
|
|
|
|
|
2018-03-13 15:09:41 +00:00
|
|
|
|
2018-03-22 08:14:13 +00:00
|
|
|
# Generating the config.h file.
|
2014-04-29 14:11:27 +00:00
|
|
|
configure_file (
|
|
|
|
"${PROJECT_SOURCE_DIR}/config.h.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/config.h"
|
|
|
|
)
|
2018-04-22 15:52:35 +00:00
|
|
|
include_directories( "${PROJECT_BINARY_DIR}" )
|
2014-04-29 14:11:27 +00:00
|
|
|
|
|
|
|
|
2018-03-23 16:36:51 +00:00
|
|
|
# The mantle written in Lua
|
2018-03-22 08:14:13 +00:00
|
|
|
#
|
|
|
|
# Order here matters as the scripts lua will be executed in this order
|
|
|
|
# on initialization of Lsyncd.
|
|
|
|
#
|
2018-03-23 16:36:51 +00:00
|
|
|
set( MANTLE_CODE
|
2018-04-22 15:52:35 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/signames.lua
|
2018-03-14 16:50:51 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/mantle/array.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/mantle/counter.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/mantle/queue.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/mantle/lock.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/mantle/delay.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/mantle/inotify.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/mantle/combiner.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/mantle/inlet.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/mantle/filter.lua
|
2018-03-15 16:11:45 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/mantle/sync.lua
|
2018-03-15 16:49:12 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/mantle/syncmaster.lua
|
2018-03-16 08:36:32 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/mantle/monitor.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/mantle/fwriter.lua
|
2018-03-19 07:50:29 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/mantle/statusfile.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/mantle/useralarm.lua
|
2018-03-19 08:02:30 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/mantle/mci.lua
|
2018-05-06 20:46:00 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/mantle/signal.lua
|
2018-03-19 07:50:29 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/mantle/user.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/mantle/string.lua
|
2018-03-19 08:22:11 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/mantle/version.lua
|
2018-03-23 16:36:51 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/mantle/userenv.lua
|
|
|
|
)
|
|
|
|
|
2018-04-22 15:52:35 +00:00
|
|
|
# Generates the signal list for this system
|
|
|
|
add_custom_command( OUTPUT signames.lua
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Generating signal name list"
|
|
|
|
COMMAND ${PROJECT_SOURCE_DIR}/signames.sh signames.lua
|
|
|
|
DEPENDS signames.sh
|
|
|
|
)
|
|
|
|
|
2018-03-23 16:36:51 +00:00
|
|
|
# The default sync implementations.
|
|
|
|
#
|
|
|
|
# Order here matters as the scripts lua will be executed in this order
|
|
|
|
# on initialization of Lsyncd.
|
|
|
|
#
|
|
|
|
set( DEFAULT_CODE
|
2018-03-13 15:09:41 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/default/default.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/default/rsync.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/default/rsyncssh.lua
|
|
|
|
${PROJECT_SOURCE_DIR}/default/direct.lua
|
2014-04-29 14:11:27 +00:00
|
|
|
)
|
|
|
|
|
2018-03-23 16:36:51 +00:00
|
|
|
# Compiling the mantle to Lua bytecode
|
|
|
|
add_custom_command( OUTPUT mantle.out
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Compiling mantle"
|
|
|
|
COMMAND ${LUA_COMPILER} -o mantle.out ${MANTLE_CODE}
|
|
|
|
DEPENDS ${MANTLE_CODE}
|
|
|
|
)
|
|
|
|
|
|
|
|
# Compiling the default sync implementations to Lua bytecode
|
|
|
|
add_custom_command( OUTPUT default.out
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Compiling default"
|
|
|
|
COMMAND ${LUA_COMPILER} -o default.out ${DEFAULT_CODE}
|
|
|
|
DEPENDS ${DEFAULT_CODE}
|
2016-11-25 14:09:27 +00:00
|
|
|
)
|
2014-04-29 14:11:27 +00:00
|
|
|
|
2018-03-23 16:36:51 +00:00
|
|
|
# Transforms the Lua bytecode into C constants
|
2018-03-22 08:14:13 +00:00
|
|
|
# It may be possible to use the linker directly to link binary
|
|
|
|
# Code into the resulting ELF-file, but this proofed to be more
|
|
|
|
# portable and easier.
|
2018-03-23 16:36:51 +00:00
|
|
|
add_custom_command( OUTPUT mantle.c
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Generating mantle linkable"
|
|
|
|
COMMAND ${LUA_EXECUTABLE} ${PROJECT_SOURCE_DIR}/bin2carray.lua mantle.out mantle mantle.c
|
|
|
|
DEPENDS mantle.out
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_command( OUTPUT default.c
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Generating default linkable"
|
|
|
|
COMMAND ${LUA_EXECUTABLE} ${PROJECT_SOURCE_DIR}/bin2carray.lua default.out default default.c
|
|
|
|
DEPENDS default.out
|
2018-03-22 08:14:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# The manpage
|
2017-01-04 09:59:01 +00:00
|
|
|
add_custom_target( manpage
|
2016-11-25 14:09:27 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Updating the manpage"
|
2016-05-30 14:23:14 +00:00
|
|
|
COMMAND a2x --format=manpage doc/manpage/lsyncd.1.txt
|
2016-11-25 14:09:27 +00:00
|
|
|
DEPENDS doc/manpage/lsyncd.1.txt
|
2014-04-29 14:38:25 +00:00
|
|
|
)
|
2014-04-29 14:11:27 +00:00
|
|
|
|
2018-03-22 08:14:13 +00:00
|
|
|
# The test suite.
|
2017-01-05 09:37:43 +00:00
|
|
|
add_custom_target( tests
|
|
|
|
COMMAND echo "Running the tests"
|
|
|
|
COMMAND echo "Note you are expected to:"
|
|
|
|
COMMAND echo " * have lua-posix installed"
|
|
|
|
COMMAND echo " * have a passwordless ssh access to localhost"
|
2018-03-22 08:14:13 +00:00
|
|
|
COMMAND echo "/tmp will be used as testbase"
|
2018-03-09 10:07:53 +00:00
|
|
|
COMMAND ${LUA_EXECUTABLE} tests/schedule.lua
|
|
|
|
COMMAND ${LUA_EXECUTABLE} tests/l4rsyncdata.lua
|
2018-03-09 12:05:45 +00:00
|
|
|
COMMAND ${LUA_EXECUTABLE} tests/filter-rsync.lua
|
2018-03-09 10:07:53 +00:00
|
|
|
COMMAND ${LUA_EXECUTABLE} tests/exclude-rsync.lua
|
|
|
|
COMMAND ${LUA_EXECUTABLE} tests/exclude-rsyncssh.lua
|
|
|
|
COMMAND ${LUA_EXECUTABLE} tests/churn-rsync.lua
|
|
|
|
COMMAND ${LUA_EXECUTABLE} tests/churn-rsyncssh.lua
|
|
|
|
COMMAND ${LUA_EXECUTABLE} tests/churn-direct.lua
|
2018-03-22 08:14:13 +00:00
|
|
|
COMMAND echo "Finished all successfully!"
|
2017-01-05 09:37:43 +00:00
|
|
|
)
|
|
|
|
|
2018-03-22 08:14:13 +00:00
|
|
|
# Compiling and linking it all together.
|
2014-04-29 14:11:27 +00:00
|
|
|
add_executable( lsyncd ${LSYNCD_SRC} )
|
|
|
|
target_link_libraries( lsyncd ${LUA_LIBRARIES} )
|
2014-04-29 14:38:25 +00:00
|
|
|
|
2018-03-22 08:14:13 +00:00
|
|
|
# Installing.
|
2014-04-29 14:38:25 +00:00
|
|
|
install( TARGETS lsyncd RUNTIME DESTINATION bin )
|
2016-12-13 13:53:01 +00:00
|
|
|
install( FILES doc/manpage/lsyncd.1 DESTINATION man )
|
2018-03-09 09:27:41 +00:00
|
|
|
|