Commits

Anton Afanasyev committed 534f42b

initial commit of the port. compiles and installs just fine. only the default options tested, but all permutations should work

Comments (0)

Files changed (7)

+# Ports collection makefile for:	spidermonkey-185
+# Date created:			Sat Aug 18, 2012
+# Whom:					Anton Afanasyev <aasoft@gmail.com>
+#
+# $FreeBSD:$
+
+PORTNAME=		spidermonkey-185
+DISTVERSION=	1.8.5
+PORTVERSION=	${DISTVERSION}
+CATEGORIES=		lang
+
+JS_VERSION=		${DISTVERSION:S/.//g}
+MASTER_SITES=	${MASTER_SITE_MOZILLA}
+MASTER_SITE_SUBDIR=	js
+DISTNAME=		js${JS_VERSION}-1.0.0
+
+MAINTAINER=		aasoft@gmail.com
+COMMENT=		A standalone JavaScript interpreter from the Mozilla project, version 1.8.5
+
+BUILD_DEPENDS=	zip:${PORTSDIR}/archivers/zip
+LIB_DEPENDS=	nspr4.1:${PORTSDIR}/devel/nspr
+
+CONFLICTS=		njs-[0-9]*
+
+USE_AUTOTOOLS=	autoconf213:env libtool:env
+USE_LDCONFIG=	yes
+GNU_CONFIGURE=	yes
+USE_GMAKE=		yes
+
+
+CONFIGURE_ENV=	CC="${CC}"
+
+CONFIGURE_ARGS=		--with-nspr --with-system-nspr --with-pthreads
+
+.ifndef(WITHOUT_X11)
+CONFIGURE_ARGS+=	--with-x
+.else
+CONFIGURE_ARGS+=	--without-x
+.endif
+
+
+SRC_DIR=	js-${DISTVERSION}/js/src
+WRKSRC=		${WRKDIR}/${SRC_DIR}
+
+# we build in a separate directory, so must change config path, location, and build location
+CONFIGURE_SCRIPT=	../configure
+CONFIGURE_WRKSRC=	${WRKSRC}/${OPSYS}`${UNAME} -r`_DBG.OBJ
+BUILD_WRKSRC=		${CONFIGURE_WRKSRC}
+
+OPTIONS_DEFINE=		TSAFE DEBUG TRACEJIT METHODJIT
+
+OPTIONS_SINGLE=		OPTIM
+
+
+# can specify only one of these, and it is require only of the
+OPTIONS_SINGLE_OPTIM=		OPTIMIZE_DISABLE OPTIMIZE_O OPTIMIZE_O1 OPTIMIZE_O2 OPTIMIZE_O3
+OPTIMIZE_DISABLE_DESC=		Disable compiler optimization
+OPTIMIZE_O_DESC=			-O compiler optimization flags
+OPTIMIZE_O1_DESC=			-O1 compiler optimization flags
+OPTIMIZE_O2_DESC=			-O2 compiler optimization flags
+OPTIMIZE_O3_DESC=			-O3 compiler optimization flags
+
+
+TSAFE_DESC=			Enable support for multiple threads
+DEBUG_DESC=			Enable building with developer debug info
+TRACEJIT_DESC=		Enable tracing JIT support
+METHODJIT_DESC=		Enable method JIT support
+
+# threads because they will become mandatory (i.e. wont be able to disable) in future releases 
+# method and trace jit because theyre enable by default, but you might want to turn them off
+# default optimization level also selected to be the default for SpiderMonkey's configure script
+OPTIONS_DEFAULT=	TSAFE TRACEJIT METHODJIT OPTIMIZE_O
+
+.include <bsd.port.options.mk>
+
+
+
+OPTIM_FLAG_=
+.if ${PORT_OPTIONS:MOPTIMIZE_DISABLE}
+OPTIM_FLAG_=
+.elif ${PORT_OPTIONS:MOPTIMIZE_O}
+OPTIM_FLAG_=	--enable-optimize=-O
+.elif ${PORT_OPTIONS:MOPTIMIZE_O1}
+OPTIM_FLAG_=	--enable-optimize=-O1
+.elif ${PORT_OPTIONS:MOPTIMIZE_O2}
+OPTIM_FLAG_=	--enable-optimize=-O2
+.elif ${PORT_OPTIONS:MOPTIMIZE_O3}
+OPTIM_FLAG_=	--enable-optimize=-O3
+.endif
+CONFIGURE_ARGS+=	${OPTIM_FLAG_}
+
+
+.if ${PORT_OPTIONS:MTRACEJIT}
+#nada
+.else
+CONFIGURE_ARGS+=	--disable-tracejit
+.endif
+
+.if ${PORT_OPTIONS:MMETHODJIT}
+#nada
+.else
+CONFIGURE_ARGS+=	--disable-methodjit
+.endif
+
+.if ${PORT_OPTIONS:MDEBUG}
+CONFIGURE_ARGS+=	--enable-debug
+.else
+#nada
+.endif
+
+
+.if ${PORT_OPTIONS:MTSAFE}
+CONFIGURE_ARGS+=	--enable-threadsafe
+.endif
+
+
+
+# these includes are found in different locations, but must end up in the same
+# ${PREFIX}/include/, so split them into separate defines first
+# 	* please also note that mozilla's install system doesnt guarantee the
+#	  locations as written here - they're merely as I found them. Their system
+#	  looks for them across the source automatically.
+
+# the headers will end up here
+JSH_DESTINATION=	${PREFIX}/include/js/
+
+JSH_BUILD_DIR=		js-config.h jsautocfg.h jsautokw.h
+
+JSH_SRC_DIR=		js.msg jsanalyze.h jsapi.h jsarray.h jsarena.h jsatom.h \
+					jsbit.h jsbool.h jsclist.h jsclone.h jscntxt.h jscompat.h \
+					jsdate.h jsdbgapi.h jsdhash.h jsdtoa.h jsemit.h jsfun.h \
+					jsfriendapi.h jsgc.h jscell.h jsgcchunk.h jsgcstats.h \
+					jscompartment.h jshash.h jsinterp.h jsinttypes.h jsiter.h \
+					jslock.h jslong.h jsmath.h jsobj.h jsobjinlines.h json.h \
+					jsopcode.tbl jsopcode.h jsopcodeinlines.h jsotypes.h \
+					jsparse.h jsproxy.h jsprf.h jsprobes.h jspropertycache.h \
+					jspropertycacheinlines.h jspropertytree.h jsproto.tbl \
+					jsprvtd.h jspubtd.h jsreflect.h jsregexp.h jsscan.h \
+					jsscope.h jsscript.h jsscriptinlines.h jsstaticcheck.h \
+					jsstdint.h jsstr.h jstracer.h jshotloop.h jstypedarray.h \
+					jstypes.h jsutil.h jsvector.h jstl.h jshashtable.h \
+					jsversion.h jswrapper.h jsxdrapi.h jsxml.h jsval.h \
+					jsvalue.h prmjtime.h jsbuiltins.h
+
+.if ${PORT_OPTIONS:MTRACEJIT}
+# following logic for nanojit arch taken from ${WRKSRC}/ref-config/Linux_All.mk
+# update as necessary when that changes.
+CPU_ARCH!=	uname -m
+
+.	if ${CPU_ARCH} != x86_64
+.		if ${CPU_ARCH:M*86}
+NANOJIT_ARCH_ = i386
+.		endif # 86
+.	endif # !x86_64
+
+# no jitter on x64 yet present in sources
+#
+
+.	if ${CPU_ARCH} == arm
+NANOJIT_ARCH_ = ARM
+.	endif
+
+
+
+JSH_NANOJIT_DIR=	Assembler.h Allocator.h CodeAlloc.h Containers.h LIR.h \
+					LIRopcode.tbl avmplus.h Fragmento.h Native.h \
+					NativeCommon.h \
+					Native$(NANOJIT_ARCH_).h \
+					njconfig.h njcpudetect.h RegAlloc.h nanojit.h VMPI.h
+
+JSH_TRACEJIT_DIR=	Writer.h
+.endif
+
+JSH_PERF_DIR=		jsperf.h
+
+# get list of all the headers to be installed, without regard of where they are to be found
+JSH:=	${JSH_BUILD_DIR} ${JSH_SRC_DIR} ${JSH_NANOJIT_DIR} ${JSH_TRACEJIT_DIR} ${JSH_PERF_DIR}
+
+PLIST_FILES=	bin/js-config \
+				lib/libmozjs185-1.0.a \
+				lib/libmozjs185.so.1.0.0 lib/libmozjs185.so.1.0 lib/libmozjs185.so \
+				${JSH:S,^,include/js/,}
+PLIST_DIRS=		include/js
+
+EXTRACT_AFTER_ARGS=| ${TAR} -xf - --exclude js/jsd
+
+post-patch: system-headers-fix make-target-extract
+
+# somehow, gcc (or whatever) does not find this header. this tells it that its a system header and does indeed exist. see bsd.gecko.mk gecko-post-patch target
+system-headers-fix:
+	@if [ -f ${WRKSRC}/config/system-headers ] ; then \
+		${ECHO_CMD} "pthread_np.h" >> ${WRKSRC}/config/system-headers ; \
+	fi
+
+make-target-extract:
+	${CP} ${WRKSRC}/ref-config/Linux_All.mk ${WRKSRC}/ref-config/${OPSYS}`${UNAME} -r`.mk
+
+
+pre-configure:
+	${MKDIR} -p ${CONFIGURE_WRKSRC}
+
+
+# the install plan is, as gathered from the nsinstall app in the sources:
+# - copy all headers (as in JSH_* defines) to ${PREFIX}/include/js/
+#	* because we have headers found in different dirs, will have a couple separate INSTALL_DATA statements
+# - copy js-config to ${PREFIX}/bin/
+# - copy libjs_static.a to ${PREFIX}/lib/libmozjs185-1.0.a
+# - copy libmozjs185.so to ${PREFIX}/lib/libmozjs185.so.1.0.0
+# 	- and then link to it from ${PREFIX}/lib/libmozjs185.so.1.0
+#		- and then link to it from ${PREFIX}/lib/libmozjs185.so
+do-install:
+	@${MKDIR} ${JSH_DESTINATION}
+	${INSTALL_DATA} ${JSH_BUILD_DIR:S,^,${BUILD_WRKSRC}/,} ${JSH_DESTINATION}
+	${INSTALL_DATA} ${JSH_SRC_DIR:S,^,${WRKSRC}/,} ${JSH_DESTINATION}
+.if ${PORT_OPTIONS:MTRACEJIT}
+		${INSTALL_DATA} ${JSH_NANOJIT_DIR:S,^,${WRKSRC}/nanojit/,} ${JSH_DESTINATION}
+		${INSTALL_DATA} ${JSH_TRACEJIT_DIR:S,^,${WRKSRC}/tracejit/,} ${JSH_DESTINATION}
+.endif
+	${INSTALL_DATA} ${JSH_PERF_DIR:S,^,${WRKSRC}/perf/,} ${JSH_DESTINATION}
+
+	${INSTALL_SCRIPT} ${BUILD_WRKSRC}/js-config ${PREFIX}/bin
+
+	${INSTALL_LIB} ${BUILD_WRKSRC}/libjs_static.a ${PREFIX}/lib
+	${MV} -f ${PREFIX}/lib/libjs_static.a ${PREFIX}/lib/libmozjs185-1.0.a
+
+	${INSTALL_LIB} ${BUILD_WRKSRC}/libmozjs185.so ${PREFIX}/lib
+	${MV} -f ${PREFIX}/lib/libmozjs185.so ${PREFIX}/lib/libmozjs185.so.1.0.0
+	${LN} -sf ${PREFIX}/lib/libmozjs185.so.1.0.0 ${PREFIX}/lib/libmozjs185.so.1.0
+	${LN} -sf ${PREFIX}/lib/libmozjs185.so.1.0 ${PREFIX}/lib/libmozjs185.so
+
+
+
+.include <bsd.port.mk>
+SHA256 (js185-1.0.0.tar.gz) = 5d12f7e1f5b4a99436685d97b9b7b75f094d33580227aa998c406bbae6f2a687
+SIZE (js185-1.0.0.tar.gz) = 6164605

files/patch-Makefile

+--- Makefile.ref.orig	2011-03-31 14:08:36.000000000 -0500
++++ Makefile.ref	2011-08-11 19:46:02.000000000 -0500
+@@ -420,7 +420,7 @@
+ 	link.exe -out:"$@" $(EXE_LINK_FLAGS) $^
+ else
+ $(PROGRAM): $(PROG_OBJS) $(LIBRARY)
+-	$(CXX) -o $@ $(CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS) $(OTHER_LIBS) \
++	$(CXX) -o $@ $(CFLAGS) $(PROG_OBJS) -L$(OBJDIR) -ljs $(LDFLAGS) $(OTHER_LIBS) \
+ 	    $(PROG_LIBS)
+ endif
+ 

files/patch-config

+--- ref-config/Linux_All.mk	2011-03-31 12:08:36.000000000 -0700
++++ ref-config/Linux_All.mk	2012-08-01 20:55:43.000000000 -0700
+@@ -41,7 +41,7 @@
+ # Config for all versions of Linux
+ #
+ 
+-CC = gcc
++CC ?= g++
+ CCC = g++
+ LD = g++
+ CFLAGS +=  -Wall -Wno-format -MMD
+@@ -76,7 +76,7 @@
+ 
+ GFX_ARCH = x
+ 
+-OS_LIBS = -lm -lc
++OS_LIBS = -lm
+ 
+ ASFLAGS += -x assembler-with-cpp
+ 
+@@ -90,16 +90,16 @@
+ endif
+ 
+ # Use the editline library to provide line-editing support.
+-JS_EDITLINE = 1
++JS_READLINE = 1
+ 
+-ifeq ($(CPU_ARCH),x86_64)
+-# Use VA_COPY() standard macro on x86-64
+-# FIXME: better use it everywhere
+-OS_CFLAGS += -DHAVE_VA_COPY -DVA_COPY=va_copy
+-endif
++#ifeq ($(CPU_ARCH),x86_64)
++## Use VA_COPY() standard macro on x86-64
++## FIXME: better use it everywhere
++#OS_CFLAGS += -DHAVE_VA_COPY -DVA_COPY=va_copy
++#endif
+ 
+-ifeq ($(CPU_ARCH),x86_64)
+-# We need PIC code for shared libraries
+-# FIXME: better patch rules.mk & fdlibm/Makefile*
++ifeq ($(CPU_ARCH),sparc64)
+ OS_CFLAGS += -DPIC -fPIC
++else
++OS_CFLAGS += -DPIC -fpic
+ endif

files/patch-jslock.cpp

+--- jslock.cpp.orig	2011-03-31 14:08:36.000000000 -0500
++++ jslock.cpp	2011-08-11 19:55:57.000000000 -0500
+@@ -311,8 +311,10 @@
+ 
+ #define GLOBAL_LOCK_INDEX(id)   (((uint32)(jsuword)(id)>>2) & global_locks_mask)
+ 
++#ifndef NSPR_LOCK
+ static void
+ js_Dequeue(JSThinLock *);
++#endif
+ 
+ static PRLock **global_locks;
+ static uint32 global_lock_count = 1;

files/patch-jsopcode.cpp

+--- jsopcode.cpp.orig	2011-08-11 19:58:41.000000000 -0500
++++ jsopcode.cpp	2011-08-11 19:59:16.000000000 -0500
+@@ -498,7 +498,7 @@
+         pc2 += jmplen;
+         npairs = GET_UINT16(pc2);
+         pc2 += UINT16_LEN;
+-        fprintf(fp, " offset %d npairs %u", (intN) off, (uintN) npairs);
++        fprintf(fp, " offset %td npairs %u", (intN) off, (uintN) npairs);
+         while (npairs) {
+             uint16 constIndex = GET_INDEX(pc2);
+             pc2 += INDEX_LEN;
+Spidermonkey is the JavaScript interpreter from the Mozilla project.
+This is version 1.8.5.
+
+WWW: http://www.mozilla.org/js/spidermonkey/