bug 442706 - build NSPR for Symbian targets with autoconf and make. Patch by Harry Li <harry.li@pagefreedom.org>, r=wtc,ted
authorted.mielczarek%gmail.com
Tue, 03 Mar 2009 22:04:24 +0000
changeset 4062 deb781bfbe2e03e46a9a5bc76ae03db0b3ac44e9
parent 4061 88ec4e301bb266a95168e32bd2f239f284c5bb34
child 4063 b9f2ead6ccda40ca1da1b014883ea21e735d90cf
push idunknown
push userunknown
push dateunknown
reviewerswtc, ted
bugs442706
bug 442706 - build NSPR for Symbian targets with autoconf and make. Patch by Harry Li <harry.li@pagefreedom.org>, r=wtc,ted
config/Makefile.in
config/autoconf.mk.in
configure.in
pr/src/pthreads/ptthread.c
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -108,17 +108,17 @@ endif
 
 include $(topsrcdir)/config/rules.mk
 
 PROGS	= $(OBJDIR)/now$(PROG_SUFFIX)
 
 ifeq (,$(CROSS_COMPILE)$(filter-out OS2 WINNT,$(OS_ARCH)))
 TARGETS = $(PROGS)
 else
-ifeq ($(OS_ARCH),WINCE)
+ifeq (,$(filter-out SYMBIAN WINCE,$(OS_ARCH)))
 TARGETS = $(PROGS)
 else
 PROGS	+= $(OBJDIR)/nsinstall$(PROG_SUFFIX)
 TARGETS = $(PROGS) $(PLSRCS:.pl=)
 endif
 endif
 
 OUTOPTION = -o # end of the line
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -119,12 +119,14 @@ WRAP_SYSTEM_INCLUDES = @WRAP_SYSTEM_INCL
 
 MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@
 ifdef MACOSX_DEPLOYMENT_TARGET
 export MACOSX_DEPLOYMENT_TARGET
 endif
 
 MACOS_SDK_DIR	= @MACOS_SDK_DIR@
 
+SYMBIAN_SDK_DIR = @SYMBIAN_SDK_DIR@
+
 NEXT_ROOT	= @NEXT_ROOT@
 ifdef NEXT_ROOT
 export NEXT_ROOT
 endif
--- a/configure.in
+++ b/configure.in
@@ -206,16 +206,22 @@ AC_ARG_ENABLE(debug,
         fi])
 
 AC_ARG_ENABLE(win32-target,
     [  --enable-win32-target=\$t
                           Specify win32 flavor. (WIN95 or WINNT)],
     OS_TARGET=`echo $enableval | tr a-z A-Z`,
     OS_TARGET=)
 
+AC_ARG_ENABLE(symbian-target,
+    [  --enable-symbian-target=\$t
+                          Specify symbian flavor. (WINSCW or GCCE)],
+    OS_TARGET=`echo $enableval | tr a-z A-Z`,
+    OS_TARGET=GCCE)
+
 AC_ARG_ENABLE(debug-rtl,
     [  --enable-debug-rtl      Use the MSVC debug runtime library],
     [ if test "$enableval" = "yes"; then
 	    USE_DEBUG_RTL=1
       fi ])
 
 AC_ARG_ENABLE(n32,
     [  --enable-n32            Enable n32 ABI support (IRIX only)],
@@ -2152,16 +2158,86 @@ mips-sony-newsos*)
         AC_DEFINE(_PR_HAVE_SOCKADDR_LEN)
         MDCPUCFG_H=_unixware7.cfg
     fi
     PR_MD_CSRCS=unixware.c
     DSO_LDOPTS=-G
     CPU_ARCH=x86
     ;;
 
+*-symbian*)
+    AC_ARG_WITH(symbian-sdk,
+    [  --with-symbian-sdk=SYMBIAN_SDK_DIR
+                          The path to the Symbian SDK],
+    SYMBIAN_SDK_DIR=$withval)
+
+    echo -----------------------------------------------------------------------------
+    echo Building with Symbian SDK in: $SYMBIAN_SDK_DIR
+    echo -----------------------------------------------------------------------------
+
+    AC_DEFINE(XP_UNIX)
+    AC_DEFINE(SYMBIAN)
+    AC_DEFINE(__arm__)
+    AC_DEFINE(__SYMBIAN32__)
+    AC_DEFINE(_UNICODE)
+    AC_DEFINE(NDEBUG)
+    AC_DEFINE(__SUPPORT_CPP_EXCEPTIONS__)
+    AC_DEFINE(MOZ_STDERR_TO_STDOUT)
+    AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
+    AC_DEFINE(HAVE_SOCKLEN_T)
+    USE_PTHREADS=1
+    LIB_SUFFIX=lib
+    DLL_SUFFIX=dll
+    MKSHLIB=
+    DSO_LDOPTS=
+    DSO_CFLAGS=
+    VISIBILITY_FLAGS=
+    MDCPUCFG_H=_symbian.cfg
+    PR_MD_CSRCS=symbian.c
+    NSINSTALL=nsinstall
+    RANLIB='echo no ranlib '
+    CPU_ARCH=ARM
+    OS_ARCH=SYMBIAN
+    OS_EXE_CFLAGS="$OS_EXE_CFLAGS -D__EXE__"
+    CFLAGS="$CFLAGS -MD -nostdinc"
+    SYMBIAN_SYS_INCLUDE="-I$SYMBIAN_SDK_DIR/Epoc32/include/variant -I$SYMBIAN_SDK_DIR/Epoc32/include -I$SYMBIAN_SDK_DIR/Epoc32/include/stdapis"
+    echo -------------------------------------------------------
+    echo SYMBIAN_SYS_INCLUDE is: $SYMBIAN_SYS_INCLUDE
+    echo -------------------------------------------------------
+    case "$OS_TARGET" in
+    WINSCW)
+        CC=mwccsym2.exe
+        CXX=mwccsym2.exe
+        LD=mwldsym2.exe
+        AR=mwldsym2.exe
+        WINSCW_LD_DIR="\$(SYMBIAN_SDK_DIR)/EPOC32/RELEASE/WINSCW/UDEB"
+        CFLAGS="$CFLAGS -O0 -inline off -wchar_t off -align 4 -warnings on -w nohidevirtual,nounusedexpr -msgstyle gcc -enum int -str pool -exc ms -trigraphs on -nostderr -gccdep -cwd source -i- -I\$(VPATH)"
+        SYMBIAN_SYS_INCLUDE="$SYMBIAN_SYS_INCLUDE -include Symbian_OS_v9.2.hrh"
+        AR_FLAGS="-library -msgstyle gcc -stdlib -subsystem windows -noimplib -o \$@"
+        AC_DEFINE(_DEBUG)
+        AC_DEFINE(__CW32__)
+        AC_DEFINE(__WINS__)
+        AC_DEFINE(__WINSCW__)
+        DEFINES="$DEFINES -U_WIN32"
+	    ;;
+    GCCE)
+        CFLAGS="$CFLAGS -Wall -Wno-unknown-pragmas -fexceptions -march=armv5t -mapcs -pipe -x c -msoft-float"
+        CXXFLAGS="$CXXFLAGS $CFLAGS -Wno-ctor-dtor-privacy"
+        SYMBIAN_SYS_INCLUDE="$SYMBIAN_SYS_INCLUDE -include $SYMBIAN_SDK_DIR/EPOC32/INCLUDE/GCCE/GCCE.h"
+        AC_DEFINE(__GCCE__)
+        AC_DEFINE(__EABI__)
+        DEFINES="$DEFINES -D__PRODUCT_INCLUDE__=$SYMBIAN_SDK_DIR/Epoc32/include/variant/Symbian_OS_v9.2.hrh"
+	    ;;
+    *)
+	    AC_MSG_ERROR([Missing OS_TARGET for ${target}. Set --enable-symbian-target to with 'WINSCW' or 'GCCE'.])
+   	;;
+    esac
+    CFLAGS="$CFLAGS ${SYMBIAN_SYS_INCLUDE}"
+    ;;
+
 *-os2*)
     AC_DEFINE(XP_OS2)
     AC_DEFINE(XP_PC)
     AC_DEFINE(BSD_SELECT)
     AC_DEFINE(TCPV40HDRS)
     LIB_SUFFIX=lib
     DLL_SUFFIX=dll
     RC=rc.exe
@@ -2809,16 +2885,17 @@ AC_SUBST(RC)
 AC_SUBST(RCFLAGS)
 AC_SUBST(DLLFLAGS)
 AC_SUBST(EXEFLAGS)
 AC_SUBST(OS_DLLFLAGS)
 AC_SUBST(CYGWIN_WRAPPER)
 AC_SUBST(VISIBILITY_FLAGS)
 AC_SUBST(WRAP_SYSTEM_INCLUDES)
 AC_SUBST(MACOS_SDK_DIR)
+AC_SUBST(SYMBIAN_SDK_DIR)
 AC_SUBST(NEXT_ROOT)
 AC_SUBST(MT)
 
 dnl ========================================================
 dnl Generate output files.
 dnl ========================================================
 MAKEFILES="
 Makefile 
--- a/pr/src/pthreads/ptthread.c
+++ b/pr/src/pthreads/ptthread.c
@@ -47,16 +47,23 @@
 #include "primpl.h"
 #include "prpdce.h"
 
 #include <pthread.h>
 #include <unistd.h>
 #include <string.h>
 #include <signal.h>
 
+#ifdef SYMBIAN
+/* In Open C sched_get_priority_min/max do not work properly, then we undef
+ * _POSIX_THREAD_PRIORITY_SCHEDULING here.
+ */
+#undef _POSIX_THREAD_PRIORITY_SCHEDULING
+#endif
+
 /*
  * Record whether or not we have the privilege to set the scheduling
  * policy and priority of threads.  0 means that privilege is available.
  * EPERM means that privilege is not available.
  */
 
 static PRIntn pt_schedpriv = 0;
 extern PRLock *_pr_sleeplock;