Added autodetection of libpthread. Defaults to USE_PTHREADS if libpthread is detected. Can be overridden via --enable-user-pthread, --with-native-threads or --with-bthreads depending upon the platform. unlabeled-1.1.2
authorcls%seawood.org
Thu, 05 Aug 1999 01:09:54 +0000
branchunlabeled-1.1.2
changeset 743 949926dd0156a8c4d49be9f3c10b8c159aa600ac
parent 729 15f052f8fec75392f33fafbdda7894e1488db37c
child 750 42d90fbfd0664b158158ad2c969c4580c0f2f1ee
push idunknown
push userunknown
push dateunknown
Added autodetection of libpthread. Defaults to USE_PTHREADS if libpthread is detected. Can be overridden via --enable-user-pthread, --with-native-threads or --with-bthreads depending upon the platform. Sets MOD_VERSION & MOD_NAME to get the nspr version suffix. Gcc under win32 uses standard gcc extensions for OBJ_SUFFIX, DLL_SUFFIX & LIB_SUFFIX. Requires pr/src/md/platform/objs.mk to set md object files. Added objs.mk for windows.
configure.in
pr/src/md/beos/Makefile.in
pr/src/md/windows/objs.mk
--- a/configure.in
+++ b/configure.in
@@ -14,71 +14,55 @@ AC_VALIDATE_CACHED_SYSTEM_TUPLE
 
 dnl Set this define to make fixes w/o breaking anything else.
 AC_DEFINE(USE_AUTOCONF)
 
 dnl Always set this for mozilla.
 AC_DEFINE(MOZILLA_CLIENT)
 
 dnl ========================================================
+dnl = Version defaults
+dnl ========================================================
+NSPR_VERSION=3
+NSPR_MODNAME=nspr20
+_HAVE_PTHREADS=
+USE_PTHREADS=
+USE_USER_PTHREADS=1
+
+dnl ========================================================
 dnl =
 dnl = Dont change the following lines.  Doing so breaks:
 dnl =
 dnl = CFLAGS="-foo" ./configure
 dnl =
 dnl ========================================================
 CFLAGS="${CFLAGS=}"
 CXXFLAGS="${CXXFLAGS=}"
 LDFLAGS="${LDFLAGS=}"
 HOST_CFLAGS="${HOST_CFLAGS=}"
 HOST_LDFLAGS="${HOST_LDFLAGS=}"
 
 dnl ========================================================
 dnl =
-dnl = Check --enable options that may affect the compiler
+dnl = Check options that may affect the compiler
 dnl =
 dnl ========================================================
-AC_ARG_ENABLE(pthreads,
-    [  --enable-pthreads           Use system pthreads library as thread subsystem],
-    [ USE_PTHREADS=1 CLASSIC_NSPR=],
-    [ USE_PTHREADS= CLASSIC_NSPR=1])
-
-AC_ARG_ENABLE(bthreads,
-    [  --enable-bthreads           Use system bthreads library as thread subsystem],
-    USE_BTHREADS=1,
-    USE_BTHREADS=)
-
-AC_ARG_ENABLE(cplus,
-    [  --enable-cplus              Use cplus for whatever reason],
-    USE_CPLUS=1,
-    USE_CPLUS=)
-
-AC_ARG_ENABLE(ipv6,
-    [  --enable-ipv6               Compile ipv6 support],
-    USE_IPV6=1,
-    USE_IPV6=)
-
-if test "$CLASSIC_NSPR" = 1 ; then
-AC_ARG_ENABLE(pthreads-user,
-    [  --enable-pthreads-user      Build pthreads-user version],
-    PTHREADS_USER=1,
-    PTHREADS_USER=)
-fi
-
+MOZ_DEBUG=1
 AC_ARG_ENABLE(debug,
     [  --disable-debug             Do not compile in debugging symbols],
-    MOZ_DEBUG=,
-    MOZ_DEBUG=1)
+    [	if test "$enableval" = "no"; then
+    	    MOZ_DEBUG=
+	fi])
 
 AC_ARG_ENABLE(target,
     [  --enable-target=\$t         Turn on features for target \$t when build has multiple targets],
-    MOZ_TARGET=`echo $enableval | tr A-Z a-z`,
+    MOZ_TARGET=`echo $enableval | tr a-z A-Z`,
     MOZ_TARGET=)
 
-if test "$MOZ_DEBUG"; then
+if test -n "$MOZ_DEBUG"; then
     CFLAGS="$CFLAGS -g"
     CXXFLAGS="$CXXFLAGS -g"
 fi
 
 dnl ========================================================
 dnl Checks for compilers.
 dnl ========================================================
 if test "$target" != "$host"; then
@@ -152,112 +136,110 @@ else
     if test -z "$HOST_CC"; then
 	HOST_CC="$CC"
     fi
     if test -z "$HOST_CFLAGS"; then
 	HOST_CFLAGS="$CFLAGS"
     fi
 fi
 
+if test "$GCC" = "yes"; then
+    GNU_CC=1
+fi
+
 dnl ========================================================
 dnl Checks for programs.
 dnl ========================================================
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PATH_PROGS(PERL, perl5 perl, :)
 
 dnl ========================================================
 dnl Default platform specific options
 dnl ========================================================
 OBJ_SUFFIX=o
 LIB_SUFFIX=a
 DLL_SUFFIX=so
 MKSHLIB='$(CCC) -shared -o $@'
+PR_MD_ASFILES=
+PR_MD_CSRCS=
 
 dnl ========================================================
 dnl Override of system specific host options
 dnl ========================================================
 case "$host" in
 *-linux*)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
     ;;
 esac
 
 dnl ========================================================
 dnl Override of system specific target options
 dnl ========================================================
 case "$target" in
-i?86-*-linux*)
+*-beos*)
+    AC_DEFINE(XP_BEOS)
+    AC_DEFINE(BeOS)
+    AC_DEFINE(BEOS)
+    ;;
+
+*-linux*)
+    AC_DEFINE(XP_UNIX)
     MDCPUCFG_H=_linux.cfg
     PR_MD_CSRCS=linux.c
-    PR_MD_ASFILES=
     PR_MD_ARCH_DIR=unix
-    if test "$USE_PTHREADS" = 1 ; then
-	DEFINES="$DEFINES -D_REENTRANT"
-    else
-	DEFINES="$DEFINES -D_PR_LOCAL_THREADS_ONLY"
-    fi
-    DEFINES="$DEFINES -DXP_UNIX"
-    ;;
-
-alpha-*-linux*)
-    MDCPUCFG_H=_linux.cfg
-    PR_MD_CSRCS=linux.c
-    PR_MD_ASFILES=
-    PR_MD_ARCH_DIR=unix
-    if test "$USE_PTHREADS" = 1 ; then
-	DEFINES="$DEFINES -D_REENTRANT"
-    else
-	DEFINES="$DEFINES -D_PR_LOCAL_THREADS_ONLY"
-    fi
-    DEFINES="$DEFINES -DXP_UNIX -D_POSIX_SOURCE -D_BSD_SOURCE -DHAVE_STRERROR"
+    case "${target_cpu}" in
+    alpha*)
+	AC_DEFINE(XP_UNIX)
+	AC_DEFINE(_POSIX_SOURCE)
+	AC_DEFINE(_BSD_SOURCE)
+	;;
+    esac
     ;;
 
 *-mingw*)
-    DEFINES="$DEFINES -DXP_PC"
-    PR_MD_ASFILES=
+    AC_DEFINE(XP_PC)
     PR_MD_ARCH_DIR=windows
-    OBJ_SUFFIX=obj
-    LIB_SUFFIX=lib
-    DLL_SUFFIX=dll
+    if test -z "$GNU_CC"; then
+	OBJ_SUFFIX=obj
+	LIB_SUFFIX=lib
+	DLL_SUFFIX=dll
+    fi
     MKSHLIB='$(DLLTOOL) --as=$(AS) -k --dllname $*.dll --output-lib $@'
 
     case "$MOZ_TARGET" in
-    winnt)
+    WINNT)
 	DEFINES="$DEFINES -DWIN32 -DWINNT -DWin32_Winsock"
 	MDCPUCFG_H=_winnt.cfg
-	PR_MD_CSRCS="ntmisc.c ntsem.c ntinrval.c ntgc.c ntio.c ntthread.c ntdllmn.c win32_errors.c w32poll.c"
 	;;
-    win95)
+    WIN95)
 	DEFINES="$DEFINES -UWINNT -DWIN32 -DWIN95 -DWin32_Winsock -D_PR_GLOBAL_THREADS_ONLY"
 	MDCPUCFG_H=_win95.cfg
-	PR_MD_CSRCS="ntmisc.c ntsem.c ntinrval.c ntgc.c w95thred.c w95io.c w95cv.c w95sock.c win32_errors.c w32poll.c w95dllmain.c"
 	;;
-    win16)
+    WIN16)
 	DEFINES="$DEFINES -UWINNT"
 	MDCPUCFG_H=_win16.cfg
-	PR_MD_CSRCS="w16null.c w16thred.c w16proc.c w16fmem.c w16sock.c w16mem.c w16io.c w16gc.c w16error.c w16stdio.c w16callb.c ntinrval.c"
 	;;
     *)
 	AC_MSG_ERROR([Missing MOZ_TARGET for ${target}.  Use --enable-target to set.])
    	;;
     esac
 
     case "$target" in
     i?86-*)
-	DEFINES="$DEFINES -D_X86_"
+	AC_DEFINE(_X86_)
         ;;
     alpha-*)
-	DEFINES="$DEFINES -D_ALPHA_=1"
+	AC_DEFINE(_ALPHA_)
    	;;
     mips-*)
-	DEFINES="$DEFINES -D_MIPS_"
+	AC_DEFINE(_MIPS_)
 	;;
     *)
-	DEFINES="$DEFINES -D_CPU_ARCH_NOT_DEFINED"
+	AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
 	;;
     esac
     ;;
 esac
 
 dnl ========================================================
 dnl Check for system libraries
 dnl ========================================================
@@ -319,30 +301,185 @@ dnl AC_FUNC_MMAP
 dnl AC_FUNC_SETVBUF_REVERSED
 dnl AC_FUNC_STRCOLL
 dnl AC_FUNC_STRFTIME
 dnl AC_FUNC_UTIME_NULL
 dnl AC_FUNC_VPRINTF
 dnl AC_CHECK_FUNCS(ftime getcwd gethostname gettimeofday getwd mkdir mktime putenv rmdir select socket strdup strerror strstr strtol strtoul uname)
 
 dnl ========================================================
+dnl Check options
+dnl ========================================================
+AC_CHECK_LIB(pthread, pthread_attr_init, 
+             _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread")
+
+dnl 
+dnl If the above test failed, try lib c_r
+dnl 
+if test "x$ac_cv_lib_pthread_pthread_attr_init" = "xno" -a \
+"x$ac_cv_lib_c_r_gethostbyname_r" = "xno"
+then
+  AC_CHECK_LIB(c_r, pthread_attr_init,
+               _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r")
+fi
+
+AC_ARG_WITH(pthreads,
+    [  --with-pthreads           Use system pthreads library as thread subsystem],
+    [	if test "$withval" = "yes"; then
+	    if test -n "$_HAVE_PTHREADS"; then
+		USE_PTHREADS=1 
+		USE_USER_PTHREADS=
+	    else
+		AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
+	    fi
+	else
+	    USE_PTHREADS=
+	    _PTHREAD_LDFLAGS=
+	    USE_USER_PTHREADS=1
+	fi],
+	[ if test -n "$_HAVE_PTHREADS"; then
+	    USE_PTHREADS=1
+	    USE_USER_PTHREADS=
+	  fi])
+
+AC_ARG_ENABLE(user-pthreads,
+    [  --enable-user-pthreads      Build using userland pthreads],
+    [	if test "$enableval" = "yes"; then
+	    USE_USER_PTHREADS=1
+	    USE_PTHREADS=
+	fi])
+
+case "$target" in
+*-beos*)
+    AC_ARG_WITH(bthreads,
+    [  --with-bthreads           Use system bthreads library as thread subsystem],
+    [	if test "$withval" = "yes"; then
+    	    USE_BTHREADS=1
+	    USE_USER_PTHREADS=
+	    USE_PTHREADS=
+	fi])
+    ;;
+
+*-solaris*)
+    AC_ARG_WITH(native-threads,
+    [  --with-native-threads     Use native system threads as thread subsystem],
+    [	if test "$withval" = "yes"; then
+	    USE_NATIVE_THREADS=1
+	    USE_USER_PTHREADS=
+	    USE_PTHREADS=
+	fi])
+    ;;
+esac
+
+USE_CPLUS=
+AC_ARG_ENABLE(cplus,
+    [  --enable-cplus              Use cplus for whatever reason],
+    [ if test "$enableval" = "yes"; then
+	USE_CPLUS=1
+      fi]) 
+
+USE_IPV6=
+AC_ARG_ENABLE(ipv6,
+    [  --enable-ipv6               Compile ipv6 support],
+    [ if test "$enableval" = "yes"; then
+	USE_IPV6=1
+      fi])
+
+if test -n "$USE_PTHREADS"; then
+   dnl See if -pthread is supported.
+   rm -f conftest*
+   ac_cv_have_dash_pthread=no
+   AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
+   echo 'int main() { return 0; }' | cat > conftest.c
+   ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
+   if test $? -eq 0; then
+	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
+	    ac_cv_have_dash_pthread=yes
+	    CFLAGS="$CFLAGS -pthread"
+	    CXXFLAGS="$CXXFLAGS -pthread"
+	fi
+    fi
+    rm -f conftest*
+    AC_MSG_RESULT($ac_cv_have_dash_pthread)
+
+    case "$target" in
+    *-mingw*|*-cygwin*|*-uwin*)
+	# win32 does not use pthreads
+	USE_PTHREADS=
+	PTHREAD_LDFLAGS=
+	USE_USER_PTHREADS=
+	;;
+    *-linux*)
+	AC_DEFINE(_REENTRANT)
+	;;
+    *-solaris*)
+	AC_DEFINE(_REENTRANT)
+	if test -n "$GNU_CC"; then
+	    CFLAGS="$CFLAGS -mt"
+	    CXXFLAGS="$CXXFLAGS -mt"
+	fi
+	;;
+    alpha*-osf*)
+	AC_DEFINE(_REENTRANT)
+	;;
+    *-freebsd*)
+	AC_DEFINE(_REENTRANT)
+	AC_DEFINE(_THREAD_SAFE)
+	 dnl -pthread links in -lc_r, so don't specify it explicitly.
+	if test "$ac_cv_have_dash_pthread" = "yes"; then
+	    PTHREAD_LDFLAGS=
+	fi
+	;;
+    *)
+	AC_DEFINE(_REENTRANT)
+	;;
+    esac
+
+else
+    case "$target" in
+    *-mingw*|*-cygwin*|*-uwin*)
+	# win32 does not use pthreads
+	USE_PTHREADS=
+	PTHREAD_LDFLAGS=
+	USE_USER_PTHREADS=
+	;;
+    *-solaris*)
+	if test -n "$USE_NATIVE_THREADS"; then
+	    AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
+	else
+	    AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
+	fi
+	;;
+    *)
+	AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
+	;;
+    esac
+ 
+fi
+
+dnl ========================================================
 dnl Substitution of found variables.
 dnl ========================================================
 AC_SUBST(CC)
 AC_SUBST(CXX)
 AC_SUBST(CFLAGS)
 AC_SUBST(CXXFLAGS)
 AC_SUBST(HOST_CC)
 AC_SUBST(HOST_CFLAGS)
+AC_SUBST(GNU_CC)
 
 AC_SUBST(USE_PTHREADS)
 AC_SUBST(USE_BTHREADS)
 AC_SUBST(USE_CPLUS)
 AC_SUBST(USE_IPV6)
+AC_SUBST(USE_USER_PTHREADS)
+AC_SUBST(USE_NATIVE_THREADS)
 
+AC_SUBST(NSPR_VERSION)
+AC_SUBST(NSPR_MODNAME)
 AC_SUBST(MDCPUCFG_H)
 AC_SUBST(MOZ_TARGET)
 AC_SUBST(PR_MD_CSRCS)
 AC_SUBST(PR_MD_ASFILES)
 AC_SUBST(PR_MD_ARCH_DIR)
 
 AC_SUBST(OBJ_SUFFIX)
 AC_SUBST(LIB_SUFFIX)
--- a/pr/src/md/beos/Makefile.in
+++ b/pr/src/md/beos/Makefile.in
@@ -19,15 +19,15 @@ include $(MOD_DEPTH)/config/autoconf.mk
 
 include $(topsrcdir)/config/config.mk
 
 include bsrcs.mk
 CSRCS += $(MDCSRCS)
 
 TARGETS		= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
new file mode 100644
--- /dev/null
+++ b/pr/src/md/windows/objs.mk
@@ -0,0 +1,64 @@
+#
+# The contents of this file are subject to the Mozilla Public License
+# Version 1.1 (the "MPL"); you may not use this file except in
+# compliance with the MPL.  You may obtain a copy of the MPL at
+# http://www.mozilla.org/MPL/
+# 
+# Software distributed under the MPL is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL
+# for the specific language governing rights and limitations under the
+# MPL.
+# 
+# The Initial Developer of this code under the MPL is Christopher
+# Seawood <cls@seawood.org>.  Portions created by Christopher Seawood are
+# Copyright (C) 1999 Christopher Seawood. All Rights Reserved.
+#
+
+ifeq (WINNT,$(MOZ_TARGET))
+CSRCS = ntmisc.c \
+	ntsem.c \
+	ntinrval.c \
+	ntgc.c \
+	ntio.c \
+	ntthread.c \
+	ntdllmn.c \
+	win32_errors.c \
+	w32poll.c
+else
+ifeq (WIN95,$(MOZ_TARGET))
+CSRCS =	ntmisc.c \
+	ntsem.c \
+	ntinrval.c \
+	ntgc.c \
+	w95thred.c \
+	w95io.c \
+	w95cv.c \
+	w95sock.c \
+	win32_errors.c \
+	w32poll.c \
+	w95dllmain.c
+else
+ifeq (WIN16,$(MOZ_TARGET))
+CSRCS =	w16null.c \
+	w16thred.c \
+	w16proc.c \
+	w16fmem.c \
+	w16sock.c \
+	w16mem.c \
+	w16io.c \
+	w16gc.c \
+	w16error.c \
+	w16stdio.c \
+	w16callb.c \
+	ntinrval.c
+endif # win16
+endif # win95
+endif # winnt
+
+CSRCS	+= $(PR_MD_CSRCS)
+ASFILES += $(PR_MD_ASFILES)
+
+OBJS += $(addprefix md/windows/$(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX)))  \
+	$(addprefix md/windows/$(OBJDIR)/,$(ASFILES:.s=.$(OBJ_SUFFIX)))
+
+