Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra steps needed to compile on Termux #687

Open
evanbattaglia opened this issue Nov 3, 2022 · 1 comment
Open

Extra steps needed to compile on Termux #687

evanbattaglia opened this issue Nov 3, 2022 · 1 comment

Comments

@evanbattaglia
Copy link

Great tool! I think this will work well for remote development from my Android phone. I had to do the following to get it compiled with Termux. Not sure if these can be worked into the build process but at least here it is for documentation purposes if anyone else has issues.

  1. After installing lua with pkg install lua52, I had to remove the reference to LUA_MATH_LIBRARY in FindLua.cmake, similar to the Apple path. I just did this.
diff --git a/cmake/FindLua.cmake b/cmake/FindLua.cmake
index 6628209..8d2c1ae 100644
--- a/cmake/FindLua.cmake
+++ b/cmake/FindLua.cmake
@@ -94,7 +94,7 @@ IF(LUA_LIBRARY)
   # include the math library for Unix
   IF(UNIX AND NOT APPLE)
     FIND_LIBRARY(LUA_MATH_LIBRARY m)
-    SET( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
+    SET( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
  1. Using liblua54 failed with the following message, no idea why, so I used lua 5.2 as mentioned above.
[ 22%] Generating defaults.out
Compiling built-in default configs
make[2]: *** [CMakeFiles/lsyncd.dir/build.make:93: defaults.out] Aborted
make[2]: *** Deleting file 'defaults.out'
make[1]: *** [CMakeFiles/Makefile2:191: CMakeFiles/lsyncd.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
  1. When running make I got the following error:
/data/data/com.termux/files/home/programs/lsyncd/lsyncd.c:1817:16: error: use of undeclared identifier 'facilitynames'
                        for( i = 0; facilitynames[ i ].c_name; i++ )

I don't see it defined anywhere in the code, maybe it is in some external library that doesn't exist on Termux or in a newer version of lua or something. To fix this I looked in the git history and resurrected the old definition of facilitynames:

diff --git a/lsyncd.c b/lsyncd.c
index 461c287..9a8aee3 100644
--- a/lsyncd.c
+++ b/lsyncd.c
@@ -53,6 +53,38 @@
 #endif


+/**
+ * configurable names for logging facility
+ * to be translated to integer value.
+ */
+struct {
+     const char * c_name;
+     int c_val;
+} facilitynames[] = {
+     { "auth",      LOG_AUTH     },
+     { "authprive", LOG_AUTHPRIV },
+     { "cron",      LOG_CRON     },
+     { "daemon",    LOG_DAEMON   },
+     { "ftp",       LOG_FTP      },
+     { "kern",      LOG_KERN     },
+     { "lpr",       LOG_LPR      },
+     { "mail",      LOG_MAIL     },
+     { "news",      LOG_NEWS     },
+     { "syslog",    LOG_SYSLOG   },
+     { "user",      LOG_USER     },
+     { "uucp",      LOG_UUCP     },
+     { "local0",    LOG_LOCAL0   },
+     { "local1",    LOG_LOCAL1   },
+     { "local2",    LOG_LOCAL2   },
+     { "local3",    LOG_LOCAL3   },
+     { "local4",    LOG_LOCAL4   },
+     { "local5",    LOG_LOCAL5   },
+     { "local6",    LOG_LOCAL6   },
+     { "local7",    LOG_LOCAL7   },
+     { NULL,       -1            },
+};
+
+
 /*
 | The Lua part of Lsyncd
 */
@poelzi
Copy link
Member

poelzi commented Nov 11, 2022

There is i bug in lua 5.4.4 that causes a segfault when building the lua object code. I just reported the bug to the lua mailing list.
lua 5.3, 5.1 should work.
I will look into the facility names bug. This array is defined in syslog.c, but might be protected in some way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants