philanc / luanacha

"NaCl with Chacha in Lua" - a wrapper around the Monocypher crypto library
5 stars 4 forks source link

Actually make the build work. #1

Open Habbie opened 7 years ago

Habbie commented 7 years ago

With these changes, make LUA=$(which lua-5.2) LUADIR=/usr/local/opt/lua clean luanacha.so test works on macOS for me (after brew install lua which installs 5.2).

I am unsure how your Makefile can work on any system as it does not link in liblua at all. How did you make make test work for you?

philanc commented 7 years ago

Hi Habbie, sorry for the long wait, I somehow missed your pull request.

As far as I know, at least on Linux, Lua extension modules (when built as a dynamic library, eg. luanacha.so) do not need to be linked with liblua.a. All the liblua symbols are defined within the lua executable, and are resolved when the extension is dynamically loaded.

I don't know about Lua build and modules on MacOS or OS X. You may find useful information at http://lua-users.org/wiki/BuildingModules (see section Mac OS X shared libraries)

It looks like the " -shared " link option should be replaced with " -bundle -undefined dynamic_lookup "

See also for example the well-known LFS (LuaFileSystem) Makefile https://github.com/keplerproject/luafilesystem

Hope it helps,

Phil

Habbie commented 7 years ago

Hello Phil,

and I somehow missed your comment 🙈

Indeed -bundle -undefined dynamic_lookup does the trick. Would you accept a PR fixing that for OSX? Do you have a preferred approach to making this conditional? How about libtool?

philanc commented 7 years ago

Thanks to confirm it works (I have no way to test on a Mac).

For the moment, I will at least add a comment in the Makefile with a LDFLAGS definition for OSX.

What would you suggest to improve this? would a distinct 'Makefile.OSX' be better?

Re libtools: I really dislike libtooI and autotools, maybe because I don't know them well enough! ;-) I also want to keep the build as minimal as possible.