tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bsd.lua.mk (was Re: A place for Lua module sources)
On Mon, 17 Jan 2011, Marc Balmer wrote:
> Maybe you could committ your Makefile stubs, so we can work on them (and
> use them...)
sorry here it is (I did intend to attach it to the original mail)
still work in progres as I have some considerations with the
compiler/linker args but have been busy for a few days hope to get back to
it this weekend
regards,
iain
# $NetBSD$
#
# Build rules and definitions for Lua modules
#
# Variables used
#
# LUA_VERSION currently installed version of Lua
# LUA_LIBDIR ${LIBDIR}/lua/${LUA_VERSION}
#
# LUA_MODULES list of Lua modules provided
# LUA_DPLIBS shared library dependencies as per LIBDPLIBS
#
# LUA_SRC.mod sources for each module (by default: "${mod:S/./_/g}.lua")
#
.if !defined(_BSD_LUA_MK_)
_BSD_LUA_MK_=1
.include <bsd.init.mk>
.include <bsd.shlib.mk>
.include <bsd.gcc.mk>
##### Basic targets
realinstall: .PHONY lua-install
realall: .PHONY lua-all
clean: .PHONY lua-clean
lua-install: .PHONY
lua-all: .PHONY
lua-clean: .PHONY
rm -f ${LUA_CLEAN}
##### Global variables
LUA_VERSION?= 5.1
LUA_LIBDIR?= ${LIBDIR}/lua/${LUA_VERSION}
##### Build rules
.if empty(CPPFLAGS:M-nostdinc)
CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
.endif
.if empty(CXXFLAGS:M-nostdinc++)
CXXFLAGS+= ${DESTDIR:D-nostdinc++ ${CXXFLAG_ISYSTEM}
${DESTDIR}/usr/include/g++}
.endif
.SUFFIXES: .lua .luac
.lua.luac:
${_MKTARGET_COMPILE}
luac -o ${.TARGET} ${.IMPSRC}
##### Libraries that modules may depend upon.
.if defined(LUA_DPLIBS)
.for _lib _dir in ${LUA_DPLIBS}
.if !defined(LIBDO.${_lib})
LIBDO.${_lib}!= cd "${_dir}" && ${PRINTOBJDIR}
.MAKEOVERRIDES+=LIBDO.${_lib}
.endif
LDADD+=-L${LIBDO.${_lib}} -l${_lib}
DPADD+=${LIBDO.${_lib}}/lib${_lib}.so
.endfor
.endif
##### Lua Modules
.for _M in ${LUA_MODULES}
LUA_SRC.${_M}?=${_M:S/./_/g}.lua
LUA_DIR.${_M}=${LUA_LIBDIR}/${_M:S/./\//g:H}
.if !empty(LUA_SRC.${_M}:M*.lua)
.if ${LUA_SRC.${_M}:[\#]} > 1
.error Too many source files for Lua module "${_M}"
.endif
.if defined(HAVE_LUAC)
##
## The module has Lua source and needs to be compiled
LUA_TGT.${_M}=${_M:S/./_/g}.luac
LUA_DST.${_M}=${_M:S/./\//g:T}.luac
LUA_CLEAN+=${LUA_TGT.${_M}}
DPSRCS+=${LUA_SRC.${_M}}
.NOPATH: ${LUA_TGT.${_M}}
lua-all: ${LUA_TGT.${_M}}
${LUA_TGT.${_M}}: ${LUA_SRC.${_M}}
.else
##
## The module has Lua source and can be installed directly
LUA_TGT.${_M}=${LUA_SRC.${_M}}
LUA_DST.${_M}=${_M:S/./\//g:T}.lua
.endif
.else
##
## The module has other language source and we must build ${_M}.so
LUA_OBJ.${_M}=${LUA_SRC.${_M}:N*.lua:R:S/$/.o/g}
LUA_TGT.${_M}=${_M:S/./_/g}.so
LUA_DST.${_M}=${_M:S/./\//g:T}.so
LUA_CLEAN+=${LUA_OBJ.${_M}} ${LUA_TGT.${_M}}
DPSRCS+=${LUA_SRC.${_M}}
# XX should we provide a lint rule?
# XX using CC might not be right (could be CXX)
# XX do we care about --whole-archive since we didn't actually use ranlib?
# XX is using -llua proper here, do we need to specify -L too?
# XX what about the -nostdlib/-L${_GCC_LIBGCCDIR}
# XX should we make .pico files instead, as per bsd.lib.mk?
# XX (and use -Wl,--warn-shared-textrel)
.NOPATH: ${LUA_TGT.${_M}} ${LUA_OBJ.${_M}}
lua-all: ${LUA_TGT.${_M}}
${LUA_TGT.${_M}}: ${LUA_OBJ.${_M}} ${DPADD} ${DPADD.${_M}}
${_MKTARGET_BUILD}
rm -f ${.TARGET}
${CC} \
-Wl,-nostdlib -B${_GCC_CRTDIR}/ -B${DESTDIR}${SHLIBDIR}/ \
-Wl,-x -shared \
-Wl,-soname,${LUA_DST.${_M}} \
-Wl,--whole-archive ${LUA_OBJ.${_M}} \
-Wl,--no-whole-archive -llua \
${LDADD} \
${LDADD.${_M}} \
${LDFLAGS} \
${LDFLAGS.${_M}} \
-o ${.TARGET} \
-L${_GCC_LIBGCCDIR}
.endif
##
## module install rules
lua-install: ${DESTDIR}${LUA_DIR.${_M}}/${LUA_DST.${_M}}
${DESTDIR}${LUA_DIR.${_M}}/${LUA_DST.${_M}}! ${LUA_TGT.${_M}}
${_MKTARGET_INSTALL}
${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${.ALLSRC} ${.TARGET}
.endfor
##### end of modules
.if !empty(DPSRCS)
# XX make(depend) needs SRCS defined
# XX also make(tags) does not work without it
SRCS?=
.include <bsd.dep.mk>
.endif
.include <bsd.obj.mk>
.include <bsd.sys.mk>
.endif # ! defined(_BSD_LUA_MK_)
Home |
Main Index |
Thread Index |
Old Index