1 # $NetBSD: bsd.lua.mk,v 1.6 2013/09/12 15:36:16 joerg Exp $
3 # Build rules and definitions for Lua modules
8 # LUA_VERSION currently installed version of Lua
9 # LUA_LIBDIR ${LIBDIR}/lua/${LUA_VERSION}
11 # LUA_MODULES list of Lua modules to build/installi
12 # LUA_DPLIBS shared library dependencies as per LIBDPLIBS
14 # LUA_SRCS.mod sources for each module (by default: "${mod:S/./_/g}.lua")
16 # DPADD additional dependencies for building modules
17 # DPADD.mod additional dependencies for a specific module
20 # HAVE_LUAC if defined, .lua source files will be compiled with ${LUAC}
21 # and installed as precompiled chunks for faster loading. Note
22 # that the luac file format is not yet standardised and may be
25 # LUAC the luac compiler (by default: /usr/bin/luac)
30 # currently make(depend) and make(tags) do not support .lua sources; We
31 # add Lua sources to DPSRCS when HAVE_LUAC is defined and other language
32 # sources to SRCS for <bsd.dep.mk>.
34 # other language support for other than C is incomplete
36 # C language sources are passed though lint, when MKLINT != "no"
38 # The Lua binary searches /usr/share/lua/5.1/ at this time and we could
39 # install .lua modules there which would mean slightly less duplication
40 # in compat builds. However, MKSHARE=no would prevent such modules from
41 # being installed so we just install everything under /usr/lib/lua/5.1/
44 .if
!defined
(_BSD_LUA_MK_
)
47 .
include <bsd.init.mk
>
48 .
include <bsd.shlib.mk
>
51 .if defined
(__MINIX
) && ${USE_BITCODE
:Uno
} == "yes"
52 LDFLAGS
+= -L
${DESTDIR}/usr
/lib
53 .
endif # defined(__MINIX) && ${USE_BITCODE:Uno} == "yes"
57 realinstall
: .PHONY lua-install
58 realall
: .PHONY lua-all
67 CLEANFILES
+= a.out
[Ee
]rrs mklog core
*.core
70 ##### Global variables
72 LUA_LIBDIR?
= ${LIBDIR}/lua
/${LUA_VERSION}
78 # XX should these always be on?
84 ${LUAC} -o
${.TARGET
} ${.IMPSRC
}
87 ##### Libraries that modules may depend upon.
88 .for _lib _dir in
${LUA_DPLIBS}
89 .if
!defined
(LIBDO.
${_lib})
90 LIBDO.
${_lib}!= cd
"${_dir}" && ${PRINTOBJDIR}
91 .MAKEOVERRIDES
+=LIBDO.
${_lib}
93 LDADD
+=-L
${LIBDO.
${_lib}} -l
${_lib}
94 DPADD
+=${LIBDO.
${_lib}}/lib
${_lib}.so
99 .for _M in
${LUA_MODULES}
100 LUA_SRCS.
${_M}?
=${_M
:S
/.
/_
/g
}.lua
101 LUA_DEST.
${_M}=${LUA_LIBDIR}${_M
:S
/.
/\
//g
:S
/^
/\
//:H
}
103 .if
!empty
(LUA_SRCS.
${_M}:M
*.lua
)
104 .if
${LUA_SRCS.
${_M}:[\
#]} > 1
105 .error Module
"${_M}" has too many source files
107 .if defined
(HAVE_LUAC
)
109 ## The module has Lua source and needs to be compiled
110 LUA_TARG.
${_M}=${_M
:S
/.
/_
/g
}.luac
111 LUA_NAME.
${_M}=${_M
:S
/.
/\
//g
:T
}.luac
112 CLEANFILES
+=${LUA_TARG.
${_M}}
113 DPSRCS
+=${LUA_SRCS.
${_M}}
115 .NOPATH
: ${LUA_TARG.
${_M}}
116 lua-all
: ${LUA_TARG.
${_M}}
117 ${LUA_TARG.
${_M}}: ${LUA_SRCS.
${_M}} ${DPADD} ${DPADD.
${_M}}
120 ## The module has Lua source and can be installed directly
121 LUA_TARG.
${_M}=${LUA_SRCS.
${_M}}
122 LUA_NAME.
${_M}=${_M
:S
/.
/\
//g
:T
}.lua
126 ## The module has other language source and we must build ${_M}.so
127 LUA_OBJS.
${_M}=${LUA_SRCS.
${_M}:N
*.lua
:R
:S
/$/.o
/g
}
128 LUA_LOBJ.
${_M}=${LUA_SRCS.
${_M}:M
*.c
:.c
=.ln
}
129 LUA_TARG.
${_M}=${_M
:S
/.
/_
/g
}.so
130 LUA_NAME.
${_M}=${_M
:S
/.
/\
//g
:T
}.so
131 CLEANFILES
+=${LUA_OBJS.
${_M}} ${LUA_LOBJ.
${_M}} ${LUA_TARG.
${_M}}
132 DPSRCS
+=${LUA_SRCS.
${_M}}
133 SRCS
+=${LUA_SRCS.
${_M}}
135 .NOPATH
: ${LUA_OBJS.
${_M}} ${LUA_LOBJ.
${_M}} ${LUA_TARG.
${_M}}
136 .if
${MKLINT} != "no"
137 ${LUA_TARG.
${_M}}: ${LUA_LOBJ.
${_M}}
139 lua-lint
: ${LUA_LOBJ.
${_M}}
140 lua-all
: ${LUA_TARG.
${_M}}
141 ${LUA_TARG.
${_M}}: ${LUA_OBJS.
${_M}} ${DPADD} ${DPADD.
${_M}}
144 ${CC} -Wl
,--warn-shared-textrel \
145 -Wl
,-x
-shared
${LUA_OBJS.
${_M}} \
146 -Wl
,-soname
,${LUA_NAME.
${_M}} -o
${.TARGET
} \
147 ${LDADD} ${LDADD.
${_M}} ${LDFLAGS} ${LDFLAGS.
${_M}}
155 ## module install rules
156 lua-install
: ${DESTDIR}${LUA_DEST.
${_M}}/${LUA_NAME.
${_M}}
157 ${DESTDIR}${LUA_DEST.
${_M}}/${LUA_NAME.
${_M}}! ${LUA_TARG.
${_M}}
159 ${INSTALL_FILE} -o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
160 ${.ALLSRC
} ${.TARGET
}
166 .
include <bsd.
clean.mk
>
167 .
include <bsd.dep.mk
>
168 .
include <bsd.inc.mk
>
169 .
include <bsd.obj.mk
>
170 .
include <bsd.sys.mk
>
171 .
endif # ! defined(_BSD_LUA_MK_)