Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
# This file: # http://anggtwu.net/LuaC/Makefile.html # http://anggtwu.net/LuaC/Makefile # (find-angg "LuaC/Makefile") # Author: Eduardo Ochs <eduardoochs@gmail.com> # # (defun e () (interactive) (find-angg "LuaC/Makefile")) # (find-es "lua5" "binary_module") # (find-luabm0file "Makefile") # (find-node "(make)Automatic Variables" "$@" "target of the rule") # (find-node "(make)Automatic Variables" "$*" "stem") #LIBTOOL = libtool --silent --tag=CC LIBTOOL = libtool --tag=CC LUA_CFLAGS := $(shell pkg-config lua5.1 --cflags) LUA_LDFLAGS := $(shell pkg-config lua5.1 --libs) LUA_LDSFLAGS := $(shell pkg-config lua5.1 --static --libs) # this is the path where you'll eventually install the module RPATH=$(shell pkg-config lua5.1 --define-variable=prefix=/usr/local \ --variable=INSTALL_CMOD) # Following is a build and use example for a binary Lua module "foo". The # implementation is in "lua-foo.c". To support dynamic loading conventions # it will need to have an open function named "luaopen_foo" which registers # the global module "foo". test: test-dynamic # compile source to make objects for static and dynamic link lua-%.lo: lua-%.c $(LIBTOOL) --mode=compile $(CC) -c -Wall -O2 $(LUA_CFLAGS) lua-$*.c # link objects to make static and dynamic libraries. The .so will be # left in "./.libs/". Note that the Lua library and its dependencies are # not called out on the link line since they are assumed to be part of # whatever our library is linked to. We want to avoid duplicate library # copies, which is a waste of space and can cause run-time problems. liblua-%.la %.so: lua-%.lo $(LIBTOOL) --mode=link $(CC) \ -rpath $(RPATH) \ $(LUA_LDSFLAGS) \ -o liblua-$*.la lua-$*.lo ln -sf ./.libs/liblua-$*.so $*.so # If all went well, we can dynamically load the module into Lua. The # following will load the library into the interpreter and call a function. test-dynamic: foo.so lua5.1 -l foo -e 'print(foo.get_greeting())' clean: $(RM) *.o *.lo *.la *.so app $(RM) -r ./.libs/ # See: (find-eepitch-intro "3.3. `eepitch-preprocess-line'") # (setq eepitch-preprocess-regexp "^") # (setq eepitch-preprocess-regexp "^#T ?") # #T * (eepitch-shell) #T * (eepitch-kill) #T * (eepitch-shell) #T make clean #T make test-dynamic #T laf -R #T #T make test-dynamic #T make -n test-dynamic