From b9245b3fe425823138d7388cb0ef8e0846de6642 Mon Sep 17 00:00:00 2001 From: Brian West Date: Mon, 18 Dec 2006 18:10:31 +0000 Subject: [PATCH] wip git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3696 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/js/src/jsautocfg.h | 26 +++---- src/mod/languages/mod_spidermonkey/Makefile | 10 ++- .../mod_spidermonkey/mod_spidermonkey.c | 29 -------- .../mod_spidermonkey/mod_spidermonkey.h | 30 +++++++- src/mod/languages/mod_spidermonkey/sm.mak | 69 +------------------ .../mod_spidermonkey_core_db/Makefile | 6 +- .../languages/mod_spidermonkey_odbc/Makefile | 5 +- .../mod_spidermonkey_teletone/Makefile | 7 +- 8 files changed, 52 insertions(+), 130 deletions(-) diff --git a/libs/js/src/jsautocfg.h b/libs/js/src/jsautocfg.h index 78ed4bda8b..7dccf19bb9 100644 --- a/libs/js/src/jsautocfg.h +++ b/libs/js/src/jsautocfg.h @@ -10,42 +10,42 @@ #define JS_BYTES_PER_SHORT 2L #define JS_BYTES_PER_INT 4L #define JS_BYTES_PER_INT64 8L -#define JS_BYTES_PER_LONG 8L +#define JS_BYTES_PER_LONG 4L #define JS_BYTES_PER_FLOAT 4L #define JS_BYTES_PER_DOUBLE 8L -#define JS_BYTES_PER_WORD 8L +#define JS_BYTES_PER_WORD 4L #define JS_BYTES_PER_DWORD 8L #define JS_BITS_PER_BYTE 8L #define JS_BITS_PER_SHORT 16L #define JS_BITS_PER_INT 32L #define JS_BITS_PER_INT64 64L -#define JS_BITS_PER_LONG 64L +#define JS_BITS_PER_LONG 32L #define JS_BITS_PER_FLOAT 32L #define JS_BITS_PER_DOUBLE 64L -#define JS_BITS_PER_WORD 64L +#define JS_BITS_PER_WORD 32L #define JS_BITS_PER_BYTE_LOG2 3L #define JS_BITS_PER_SHORT_LOG2 4L #define JS_BITS_PER_INT_LOG2 5L #define JS_BITS_PER_INT64_LOG2 6L -#define JS_BITS_PER_LONG_LOG2 6L +#define JS_BITS_PER_LONG_LOG2 5L #define JS_BITS_PER_FLOAT_LOG2 5L #define JS_BITS_PER_DOUBLE_LOG2 6L -#define JS_BITS_PER_WORD_LOG2 6L +#define JS_BITS_PER_WORD_LOG2 5L #define JS_ALIGN_OF_SHORT 2L #define JS_ALIGN_OF_INT 4L -#define JS_ALIGN_OF_LONG 8L -#define JS_ALIGN_OF_INT64 8L +#define JS_ALIGN_OF_LONG 4L +#define JS_ALIGN_OF_INT64 4L #define JS_ALIGN_OF_FLOAT 4L -#define JS_ALIGN_OF_DOUBLE 8L -#define JS_ALIGN_OF_POINTER 8L -#define JS_ALIGN_OF_WORD 8L +#define JS_ALIGN_OF_DOUBLE 4L +#define JS_ALIGN_OF_POINTER 4L +#define JS_ALIGN_OF_WORD 4L -#define JS_BYTES_PER_WORD_LOG2 3L +#define JS_BYTES_PER_WORD_LOG2 2L #define JS_BYTES_PER_DWORD_LOG2 3L -#define JS_WORDS_PER_DWORD_LOG2 0L +#define JS_WORDS_PER_DWORD_LOG2 1L #define JS_STACK_GROWTH_DIRECTION (-1) diff --git a/src/mod/languages/mod_spidermonkey/Makefile b/src/mod/languages/mod_spidermonkey/Makefile index cfbc9afcad..df7406310a 100644 --- a/src/mod/languages/mod_spidermonkey/Makefile +++ b/src/mod/languages/mod_spidermonkey/Makefile @@ -1,17 +1,15 @@ include sm.mak -OBJS=$(BASE)/libs/mozilla/js/src/$(OS_CONFIG)_$(VER).OBJ/libjs.a $(BASE)/libs/mozilla/nsprpub/dist/lib/libnspr4.a -lcurl -LINKER=$(CC) - all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN) depends: - BUILD_OPT=$(BO) MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) mozilla.tar.gz --prefix=$(PREFIX) + MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install js/nsprpub --prefix=$(PREFIX) --with-pic + MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install js --prefix=$(PREFIX) --with-pic --with-nspr=yes MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install curl-7.15.2.tar.gz --prefix=$(PREFIX) --without-libidn $(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c - $(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o - $(LINKER) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(OBJS) $(LDFLAGS) + $(CC) $(CFLAGS) -c $(MODNAME).c -o $(MODNAME).o + $(CC) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(OBJS) $(LDFLAGS) clean: rm -fr *.$(DYNAMIC_LIB_EXTEN) *.o *~ diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index dc19f1ca0e..ba5efc4b35 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -2248,35 +2248,6 @@ static JSFunctionSpec fs_functions[] = { }; -SWITCH_SM_DECLARE(int) eval_some_js(char *code, JSContext *cx, JSObject *obj, jsval *rval) -{ - JSScript *script = NULL; - char *cptr; - char *path = NULL; - int res = 0; - - JS_ClearPendingException(cx); - - if (code[0] == '~') { - cptr = code + 1; - script = JS_CompileScript(cx, obj, cptr, strlen(cptr), "inline", 1); - } else { - if (*code == '/') { - script = JS_CompileFile(cx, obj, code); - } else if ((path = switch_mprintf("%s%s%s", SWITCH_GLOBAL_dirs.script_dir, SWITCH_PATH_SEPARATOR, code))) { - script = JS_CompileFile(cx, obj, path); - switch_safe_free(path); - } - } - - if (script) { - res = JS_ExecuteScript(cx, obj, script, rval) == JS_TRUE ? 1 : 0; - JS_DestroyScript(cx, script); - } - - return res; -} - static int env_init(JSContext *cx, JSObject *javascript_object) { diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h index 846853a6c9..258dd4f524 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h @@ -76,7 +76,35 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_SM_DECLARE(type) type #endif -SWITCH_SM_DECLARE(int) eval_some_js(char *code, JSContext *cx, JSObject *obj, jsval *rval); +static int eval_some_js(char *code, JSContext *cx, JSObject *obj, jsval *rval) +{ + JSScript *script = NULL; + char *cptr; + char *path = NULL; + int res = 0; + + JS_ClearPendingException(cx); + + if (code[0] == '~') { + cptr = code + 1; + script = JS_CompileScript(cx, obj, cptr, strlen(cptr), "inline", 1); + } else { + if (*code == '/') { + script = JS_CompileFile(cx, obj, code); + } else if ((path = switch_mprintf("%s%s%s", SWITCH_GLOBAL_dirs.script_dir, SWITCH_PATH_SEPARATOR, code))) { + script = JS_CompileFile(cx, obj, path); + switch_safe_free(path); + } + } + + if (script) { + res = JS_ExecuteScript(cx, obj, script, rval) == JS_TRUE ? 1 : 0; + JS_DestroyScript(cx, script); + } + + return res; +} + typedef switch_status_t(*spidermonkey_load_t)(JSContext *cx, JSObject *obj); diff --git a/src/mod/languages/mod_spidermonkey/sm.mak b/src/mod/languages/mod_spidermonkey/sm.mak index bb351f3d4a..ef56bb615f 100644 --- a/src/mod/languages/mod_spidermonkey/sm.mak +++ b/src/mod/languages/mod_spidermonkey/sm.mak @@ -1,67 +1,2 @@ -# This is all used to make sure we use the right options during build and link. - -OS_ARCH := $(subst /,_,$(shell uname -s | sed /\ /s//_/)) -#VER=DBG -#BO=0 -VER=OPT -BO=1 - -# Attempt to differentiate between SunOS 5.4 and x86 5.4 -OS_CPUARCH := $(shell uname -m) -ifeq ($(OS_CPUARCH),i86pc) -OS_RELEASE := $(shell uname -r)_$(OS_CPUARCH) -else -ifeq ($(OS_ARCH),AIX) -OS_RELEASE := $(shell uname -v).$(shell uname -r) -else -OS_RELEASE := $(shell uname -r) -endif -endif -ifeq ($(OS_ARCH),IRIX64) -OS_ARCH := IRIX -endif - -# Handle output from win32 unames other than Netscape's version -ifeq (,$(filter-out Windows_95 Windows_98 CYGWIN_95-4.0 CYGWIN_98-4.10, $(OS_ARCH))) - OS_ARCH := WIN95 -endif -ifeq ($(OS_ARCH),WIN95) - OS_ARCH := WINNT - OS_RELEASE := 4.0 -endif -ifeq ($(OS_ARCH), Windows_NT) - OS_ARCH := WINNT - OS_MINOR_RELEASE := $(shell uname -v) - ifeq ($(OS_MINOR_RELEASE),00) - OS_MINOR_RELEASE = 0 - endif - OS_RELEASE := $(OS_RELEASE).$(OS_MINOR_RELEASE) -endif -ifeq (CYGWIN_NT,$(findstring CYGWIN_NT,$(OS_ARCH))) - OS_RELEASE := $(patsubst CYGWIN_NT-%,%,$(OS_ARCH)) - OS_ARCH := WINNT -endif -ifeq ($(OS_ARCH), CYGWIN32_NT) - OS_ARCH := WINNT -endif -ifeq (MINGW32_NT,$(findstring MINGW32_NT,$(OS_ARCH))) - OS_RELEASE := $(patsubst MINGW32_NT-%,%,$(OS_ARCH)) - OS_ARCH := WINNT -endif - -ifeq ($(OS_ARCH),Linux) -OS_CONFIG := Linux_All -else -ifeq ($(OS_ARCH),dgux) -OS_CONFIG := dgux -else -ifeq ($(OS_ARCH),Darwin) -OS_CONFIG := Darwin -else -OS_CONFIG := $(OS_ARCH)$(OS_OBJTYPE)$(OS_RELEASE) -endif -endif -endif - -CFLAGS += -I../mod_spidermonkey -I$(BASE)/libs/mozilla/js/src -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/js/src -I$(BASE)/libs/mozilla/js/src/$(OS_CONFIG)_$(VER).OBJ -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr -I$(OS_CONFIG)_$(VER).OBJ -LDFLAGS +=-DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr +CFLAGS += -I$(PREFIX)/include/js -I$(PREFIX)/include/nspr -DXP_UNIX -I../mod_spidermonkey +LDFLAGS += -lnspr4 -ljs -lcurl diff --git a/src/mod/languages/mod_spidermonkey_core_db/Makefile b/src/mod/languages/mod_spidermonkey_core_db/Makefile index 2d000943d7..749b218e76 100644 --- a/src/mod/languages/mod_spidermonkey_core_db/Makefile +++ b/src/mod/languages/mod_spidermonkey_core_db/Makefile @@ -1,16 +1,12 @@ include ../mod_spidermonkey/sm.mak -OBJS=#$(BASE)/libs/mozilla/js/src/$(OS_CONFIG)_$(VER).OBJ/libjs.a $(BASE)/libs/mozilla/nsprpub/dist/lib/libnspr4.a -LINKER=$(CC) - - all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN) depends: $(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c $(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o - $(LINKER) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(OBJS) $(LDFLAGS) + $(CC) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(OBJS) $(LDFLAGS) clean: rm -fr *.$(DYNAMIC_LIB_EXTEN) *.o *~ diff --git a/src/mod/languages/mod_spidermonkey_odbc/Makefile b/src/mod/languages/mod_spidermonkey_odbc/Makefile index e7bf062294..1e9d99ecd8 100644 --- a/src/mod/languages/mod_spidermonkey_odbc/Makefile +++ b/src/mod/languages/mod_spidermonkey_odbc/Makefile @@ -1,7 +1,4 @@ include ../mod_spidermonkey/sm.mak - -OBJS=#$(BASE)/libs/mozilla/js/src/$(OS_CONFIG)_$(VER).OBJ/libjs.a $(BASE)/libs/mozilla/nsprpub/dist/lib/libnspr4.a -LINKER=$(CC) LDFLAGS+=-lodbc all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN) @@ -11,7 +8,7 @@ depends: $(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c $(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o - $(LINKER) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(OBJS) $(LDFLAGS) + $(CC) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(OBJS) $(LDFLAGS) clean: rm -fr *.$(DYNAMIC_LIB_EXTEN) *.o *~ diff --git a/src/mod/languages/mod_spidermonkey_teletone/Makefile b/src/mod/languages/mod_spidermonkey_teletone/Makefile index 2d000943d7..86bb0ae620 100644 --- a/src/mod/languages/mod_spidermonkey_teletone/Makefile +++ b/src/mod/languages/mod_spidermonkey_teletone/Makefile @@ -1,8 +1,5 @@ include ../mod_spidermonkey/sm.mak - -OBJS=#$(BASE)/libs/mozilla/js/src/$(OS_CONFIG)_$(VER).OBJ/libjs.a $(BASE)/libs/mozilla/nsprpub/dist/lib/libnspr4.a -LINKER=$(CC) - +LDFLAGS+=-lteletone all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN) @@ -10,7 +7,7 @@ depends: $(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c $(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o - $(LINKER) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(OBJS) $(LDFLAGS) + $(CC) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(OBJS) $(LDFLAGS) clean: rm -fr *.$(DYNAMIC_LIB_EXTEN) *.o *~