[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Generating makefile for C library.
- From: "Heesob Park" <phasis@...>
- Date: Tue, 28 Oct 2008 11:13:11 +0900
2008/10/28 Sam Roberts <email@example.com>:
> On Mon, Oct 27, 2008 at 11:42 AM, Asko Kauppi <firstname.lastname@example.org> wrote:
>> Sam Roberts kirjoitti 27.10.2008 kello 18:26:
>>> On Mon, Oct 27, 2008 at 1:27 AM, Heesob Park <email@example.com> wrote:
>>>> Is there any module for automating makefile generation?
>>> Check on luaforge, but I've never seen one used. Its kindof clunky,
>>> but lua projects just seem to come with simple makefiles. The
>>> philosophy seems to be, agree with it or not, that lua is mostly used
>>> as a script core embedded into larger projects - and that you will use
>>> that larger projects build system.
>> Well, he was asking about a C library, a Lua module that is.
> I know. My justification for the (relative) crudity of makefiles in
> the Lua world was instended to forestall a "Lua doesn't have X that
> some other language has? Wow, Lua sucks" remark.
>> I would suggest taking some existing one, s.a. Lua Lanes or maybe LuaSocket,
>> and seeing how that is being built.
> His question assumed the members of the lua list are conversant with
> how ruby modules are built. Clearly, not such a good assumption! :-)
> LuaSocket's makefile, like all the lua C modules I've seen, and Lua's
> itself, has hardcoded paths in it. In order to build for your system,
> you have to modify the makefile. If you are lucky, its just
> uncommenting the section relevant to your OS.
> extconf.rb is a ruby program which you run, examines your system,
> figures out where ruby is installed, the local policies, what your
> compiler is, etc.
> Its basically autoconf for ruby "C" modules, though probably more
> inspired by Perl's make wrappers.
> Anyhow, no such thing exists for lua, as far as I can tell.
> Btw, I'm no great extconf.rb fan. When it works, its great, but the
> only thing I hate more than the autotools is learning yet another
> autotools replacement system specific to some language, and extconf.rb
> is pretty light on documentation.
>> Depends on your system, which you did not name to us.
> Because extconf.rb figures that out, and does the right thing on
> common OSes (X, windows, linux, BSDs, ... ).
Here is the draft version of make.lua works on Linux and Windows:
source = arg
module = string.match(source,"^([^.]+)")
if package.config:sub(1,1)=="\\" then -- Windows
lua_root = package.path:match("^[^;]+;([^;]+)\\lua")
version = _VERSION:match("[%d\.]+$")
lua_lib = "\"" .. lua_root .. "\\lib\\lua" .. version .. ".lib\""
lua_inc = "-I\"" .. lua_root .. "\\include\""
cc = "cl.exe /LD"
ext = "/link /export:luaopen_"..module
lua_root = package.path:match("^[^;]+;([^;]+)/share")
lua_lib = "-L" .. lua_root .. "/lib"
lua_inc = "-I" .. lua_root .. "/include"
cc = "cc -shared -o " .. module .. ".so"
ext = ""
f = io.open("Makefile","w")
f:write(string.format("\t%s %s %s %s %s\n",cc,lua_inc,lua_lib,source,ext))
Usage: lua make.lua module.c