aboutsummaryrefslogtreecommitdiffstats
path: root/lang/lua52/Makefile
blob: 8349a4b7f151a409313c6b15b936b6bafd2b7549 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Created by: GreenDog <fiziologus@gmail.com>
# $FreeBSD$

PORTNAME=   lua
PORTVERSION=    5.2.4
CATEGORIES= lang
MASTER_SITES=   http://www.lua.org/ftp/
PKGNAMESUFFIX=  52

MAINTAINER= john@essenz.com
COMMENT=    Small, compilable scripting language providing easy access to C code

LICENSE=    MIT

USES=       libedit
LUA_VER=    5.2
USE_LDCONFIG=   yes

# Overriding __MAKE_CONF makes sure that we don't re-parse
# /etc/make.conf during do-build, which would jeopardize the build
# if, for instance, the user set CFLAGS=mumble
# NOTE: /etc/make.conf is read BEFORE Makefile, so we already
# have its settings when we get here.
# See http://wiki.freebsd.org/MatthiasAndree/LuaLessonsLearnt
MAKE_ARGS=  __MAKE_CONF=${NONEXISTENT}
# liblua.so requires libm, so make sure it has an explicit dependency
# so that applications need not second-guess lua's dependencies.
CPPFLAGS+=  -I${LOCALBASE}/include
LDFLAGS+=   -lm -pthread
BUILD_WRKSRC=   ${WRKSRC}/src
MAKE_ARGS+= MYCFLAGS="${CFLAGS} ${CPPFLAGS} -DLUA_USE_LINUX" \
        MYLDFLAGS="${LDFLAGS}" \
        MYLIBS="-Wl,-E -L${LOCALBASE}/lib -ledit" \
        CC="${CC}" \
        LUA_T=lua52 \
        LUAC_T=luac52 \
        LUA_A=liblua-${LUA_VER}.a \
        LUA_SO=liblua-${LUA_VER}.so \
        LUA_SONAME=liblua-${LUA_VER}.so \
        TO_BIN="lua52 luac52" \
        TO_LIB="liblua-${LUA_VER}.a liblua-${LUA_VER}.so" \
        INSTALL_TOP=${STAGEDIR}${PREFIX} \
        INSTALL_INC=${STAGEDIR}${PREFIX}/include/lua52 \
        INSTALL_EXEC="${INSTALL_PROGRAM}"

# Cope with the lack of support for Lua 5.2 in bsd.lua.mk.  These
# overrides, which are required below, should be removed once bsd.lua.mk
# understands this lua version.
LUA_PREFIX?=    ${PREFIX}
LUA_SUBDIR?=    lua${PKGNAMESUFFIX}
LUA_INCDIR?=    ${LUA_PREFIX}/include/${LUA_SUBDIR}
LUA_LIBDIR?=    ${LUA_PREFIX}/lib

SUB_FILES=  lua-${LUA_VER}.pc
SUB_LIST=   version=${PORTVERSION} \
        includedir=${LUA_INCDIR} \
        libdir=${LUA_LIBDIR} \
        soname=lua-${LUA_VER}

CFLAGS+=    -fPIC

post-patch:
    @${REINPLACE_CMD} -e 's,rand *(,random(,g' \
        ${WRKSRC}/src/lmathlib.c
    @${REINPLACE_CMD} -e "/LUA_ROOT/s|/usr/local|${LUA_PREFIX}| ; \
        s,readline/,editline/,g ; \
        /history\.h/d" \
        ${WRKSRC}/src/luaconf.h ${WRKSRC}/src/lua.c

post-install:
    @${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/liblua-${LUA_VER}.so
    @${MV} ${STAGEDIR}${PREFIX}/man/man1/lua.1 \
        ${STAGEDIR}${PREFIX}/man/man1/lua52.1
    @${MV} ${STAGEDIR}${PREFIX}/man/man1/luac.1 \
        ${STAGEDIR}${PREFIX}/man/man1/luac52.1
    ${INSTALL_DATA} ${WRKDIR}/lua-${LUA_VER}.pc \
        ${STAGEDIR}${PREFIX}/libdata/pkgconfig

.include <bsd.port.mk>