lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Jun 19, 2010, at 1:38 PM, Wesley Smith wrote:

> Anyone know how to write a Makefile.am in order to generate a .so Lua
> module?  Here's what I've got so far:
> 
> INCLUDES = -I$(srcdir)/include -I/usr/include/lua5.1
> LIBS = -shared
> 
> lib_LTLIBRARIES = libtest.la
> libtest_la_SOURCES = src/test.cpp
> 
> 
> While it does produces the shared library, it's less than desirable.
> It builds a libtest.la and a libtest.so.0.0.0 with libtest.so as a
> symlink.  Ideally, I'd actually have just test.so, but autotools
> complains bitterly since such a name doesn't have "lib" or ".la" in
> the name.  I'm wondering if anyone else has tried this.
You might also try CMake[1] as alternative to autotools. 
This works for most OSes, compilers and architectures.

// Find Lua and set up LUA_ variables
FIND_PACKAGE(Lua51 REQUIRED)
INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR})

// Build module
ADD_LIBRARY(myModule MODULE mySource.c myOtherSource.c)
TARGET_LINK_LIBRARIES(myModule ${LUA_LIBRARY})

// Remove any prefix from the module such as "lib" or "cyg" depending on platform
SET_TARGET_PROPERTIES(myModule PROPERTIES PREFIX "")

pd

[1] http://www.cmake.org