[BACK]Return to bsd.lua.mk CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / share / mk

File: [cvs.NetBSD.org] / src / share / mk / bsd.lua.mk (download)

Revision 1.8, Thu Apr 20 09:29:11 2017 UTC (7 years ago) by ozaki-r
Branch: MAIN
CVS Tags: prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, phil-wifi, pgoyette-localcount-20170426, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-9-base, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-10-base, matt-nb8-mediatek-base, matt-nb8-mediatek, is-mlppp-base, is-mlppp, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x, bouyer-socketcan-base1
Branch point for: netbsd-10
Changes since 1.7: +9 -3 lines

Introduce MKSTRIPSYM build option

If it's yes, all local symbols of shared libraries are stripped
(default). If it's no, only temporary local symbols are stripped;
for example, symbols of static functions are kept. Keeping such
symbols is useful on using DTrace for userland libraries and
getting a backtrace from a rump server loading modules (shared
libraries).

Proposed and discussed on tech-kern and tech-toolchain

#	$NetBSD: bsd.lua.mk,v 1.8 2017/04/20 09:29:11 ozaki-r Exp $
#
# 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 to build/installi
# LUA_DPLIBS	shared library dependencies as per LIBDPLIBS
#
# LUA_SRCS.mod	sources for each module (by default: "${mod:S/./_/g}.lua")
#
# DPADD		additional dependencies for building modules
# DPADD.mod	additional dependencies for a specific module
#
#
# HAVE_LUAC	if defined, .lua source files will be compiled with ${LUAC}
#		and installed as precompiled chunks for faster loading. Note
#		that the luac file format is not yet standardised and may be
#		subject to change.
#
# LUAC		the luac compiler (by default: /usr/bin/luac)
#
#
# Notes:
#
# currently make(depend) and make(tags) do not support .lua sources; We
# add Lua sources to DPSRCS when HAVE_LUAC is defined and other language
# sources to SRCS for <bsd.dep.mk>.
#
# other language support for other than C is incomplete
#
# C language sources are passed though lint, when MKLINT != "no"
#
# The Lua binary searches /usr/share/lua/5.1/ at this time and we could
# install .lua modules there which would mean slightly less duplication
# in compat builds. However, MKSHARE=no would prevent such modules from
# being installed so we just install everything under /usr/lib/lua/5.1/
#

.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
lint:		.PHONY lua-lint

lua-install:	.PHONY

lua-all:	.PHONY

lua-lint:	.PHONY

CLEANFILES+= a.out [Ee]rrs mklog core *.core

##
##### Global variables
LUA_VERSION?=	5.3
LUA_LIBDIR?=	${LIBDIR}/lua/${LUA_VERSION}
LUAC?=		/usr/bin/luac

##
##### Build rules

# XX should these always be on?
CFLAGS+=	-fPIC

.SUFFIXES:	.lua .luac
.lua.luac:
	${_MKTARGET_COMPILE}
	${LUAC} -o ${.TARGET} ${.IMPSRC}

##
##### Libraries that modules may depend upon.
.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

##
##### Lua Modules
.for _M in ${LUA_MODULES}
LUA_SRCS.${_M}?=${_M:S/./_/g}.lua
LUA_DEST.${_M}=${LUA_LIBDIR}${_M:S/./\//g:S/^/\//:H}

.if !empty(LUA_SRCS.${_M}:M*.lua)
.if ${LUA_SRCS.${_M}:[\#]} > 1
.error Module "${_M}" has too many source files
.endif
.if defined(HAVE_LUAC)
##
## The module has Lua source and needs to be compiled
LUA_TARG.${_M}=${_M:S/./_/g}.luac
LUA_NAME.${_M}=${_M:S/./\//g:T}.luac
CLEANFILES+=${LUA_TARG.${_M}}
DPSRCS+=${LUA_SRCS.${_M}}

.NOPATH:		${LUA_TARG.${_M}}
lua-all:		${LUA_TARG.${_M}}
${LUA_TARG.${_M}}:	${LUA_SRCS.${_M}} ${DPADD} ${DPADD.${_M}}
.else
##
## The module has Lua source and can be installed directly
LUA_TARG.${_M}=${LUA_SRCS.${_M}}
LUA_NAME.${_M}=${_M:S/./\//g:T}.lua
.endif
.else
##
## The module has other language source and we must build ${_M}.so
LUA_OBJS.${_M}=${LUA_SRCS.${_M}:N*.lua:R:S/$/.o/g}
LUA_LOBJ.${_M}=${LUA_SRCS.${_M}:M*.c:.c=.ln}
LUA_TARG.${_M}=${_M:S/./_/g}.so
LUA_NAME.${_M}=${_M:S/./\//g:T}.so
CLEANFILES+=${LUA_OBJS.${_M}} ${LUA_LOBJ.${_M}} ${LUA_TARG.${_M}}
DPSRCS+=${LUA_SRCS.${_M}}
SRCS+=${LUA_SRCS.${_M}}

LUA_LDOPTS=	-Wl,--warn-shared-textrel
.if ${MKSTRIPSYM:Uyes} == "yes"
LUA_LDOPTS+=	-Wl,-x
.else
LUA_LDOPTS+=	-Wl,-X
.endif

.NOPATH:		${LUA_OBJS.${_M}} ${LUA_LOBJ.${_M}} ${LUA_TARG.${_M}}
.if ${MKLINT} != "no"
${LUA_TARG.${_M}}:	${LUA_LOBJ.${_M}}
.endif
lua-lint:		${LUA_LOBJ.${_M}}
lua-all:		${LUA_TARG.${_M}}
${LUA_TARG.${_M}}:	${LUA_OBJS.${_M}} ${DPADD} ${DPADD.${_M}}
	${_MKTARGET_BUILD}
	rm -f ${.TARGET}
	${CC} ${LUA_LDOPTS} -shared ${LUA_OBJS.${_M}} \
	    -Wl,-soname,${LUA_NAME.${_M}} -o ${.TARGET} \
	    ${LDADD} ${LDADD.${_M}} ${LDFLAGS} ${LDFLAGS.${_M}}

.endif

DPADD+=	${LIBLUA}
LDADD+=	-llua

##
## module install rules
lua-install:		${DESTDIR}${LUA_DEST.${_M}}/${LUA_NAME.${_M}}
${DESTDIR}${LUA_DEST.${_M}}/${LUA_NAME.${_M}}! ${LUA_TARG.${_M}}
	${_MKTARGET_INSTALL}
	${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE}	\
	    ${.ALLSRC} ${.TARGET}

.endfor
##
##### end of modules

.include <bsd.clean.mk>
.include <bsd.dep.mk>
.include <bsd.inc.mk>
.include <bsd.obj.mk>
.include <bsd.sys.mk>
.endif	# ! defined(_BSD_LUA_MK_)