aboutsummaryrefslogtreecommitdiff
path: root/lang/mujs/Makefile
blob: df024e4ab89bc15f8e8c38bb78c9509a2818d027 (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
PORTNAME=	mujs
DISTVERSION=	1.3.3
CATEGORIES=	lang devel

MAINTAINER=	yuri@FreeBSD.org
COMMENT=	Embeddable Javascript interpreter in C
WWW=		https://mujs.com/

LICENSE=	ISCL
LICENSE_FILE=	${WRKSRC}/COPYING

TEST_DEPENDS=	git:devel/git

USES=		compiler:c11 cpe gmake readline # c11 is induced by the FreeBSD headers via isnan(3), etc, otherwise the project is all c99 code
CPE_VENDOR=	artifex
USE_LDCONFIG=	yes

USE_GITHUB=	yes
GH_ACCOUNT=	ccxvii

ALL_TARGET=	build/release/mujs \
		build/release/libmujs.so \
		build/release/libmujs.a
INSTALL_TARGET=	install-shared install-static

.if defined(WITH_DEBUG) # this project manages its build options itself
MAKE_ARGS=	build=debug
.endif

PLIST_FILES=	bin/mujs \
		bin/mujs-pp \
		include/mujs.h \
		lib/libmujs.so \
		lib/libmujs.a \
		libdata/pkgconfig/mujs.pc

OPTIONS_DEFINE=		32BIT SANITIZED
OPTIONS_DEFAULT=	32BIT

32BIT_DESC=		32-bit address space to allow for larger programs
32BIT_MAKE_ARGS=	XCFLAGS="-DJS_INSTRUCTION=int"

SANITIZED_DESC=		Sanitized build (only for debugging)
SANITIZED_MAKE_ARGS=	build=sanitize

post-install:
	@${STRIP_CMD} \
		${STAGEDIR}${PREFIX}/bin/mujs \
		${STAGEDIR}${PREFIX}/bin/mujs-pp \
		${STAGEDIR}${PREFIX}/lib/libmujs.so

do-test: # Test-262 JavaScript testsuite is downloaded and run.
	# Something is off with the test harness so too many tests fail: https://github.com/ccxvii/mujs/issues/147
	${RM} -r ${WRKDIR}/testing && \
	${MKDIR} -p ${WRKDIR}/testing && \
	cd ${WRKDIR}/testing && \
	git clone https://github.com/tc39/test262.git && \
	fetch https://github.com/ccxvii/mujs/files/2332077/mujs-test262-harness-and-output.zip && \
	unzip mujs-test262-harness-and-output.zip && \
	(${TAIL} -3 mujs-harness-out.txt > mujs-harness-out-3.txt) && \
	cd test262 && \
	git checkout es5-tests && \
	${ECHO} "Running MuJS tests ..." && \
	(${FIND} test/suite -name '*.js' | ${STAGEDIR}${PREFIX}/bin/mujs ../mujs-harness.js > mujs-harness-out-our.txt) && \
	${ECHO} "MuJS tests finished: " && \
	(${TAIL} -3 mujs-harness-out-our.txt | tee mujs-harness-out-our-3.txt) && \
	${ECHO} "" && \
	${ECHO} "Compare with reference results:" && \
	${DIFF} ../mujs-harness-out-3.txt mujs-harness-out-our-3.txt

.include <bsd.port.mk>