summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcls%seawood.org <devnull@localhost>1999-08-05 01:09:54 +0000
committercls%seawood.org <devnull@localhost>1999-08-05 01:09:54 +0000
commita105b16c49c9c814b5e80d6ddcb43e881fd3bc6c (patch)
treef6eae336c1d26b55557cfb326bac0f7ec0512e5c
parentfdb52dcbef64a86dd9f69e5666c4d8e5f771ab68 (diff)
downloadnspr-hg-a105b16c49c9c814b5e80d6ddcb43e881fd3bc6c.tar.gz
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.
-rw-r--r--configure.in269
-rw-r--r--pr/src/md/beos/Makefile.in2
-rw-r--r--pr/src/md/windows/objs.mk64
3 files changed, 268 insertions, 67 deletions
diff --git a/configure.in b/configure.in
index 5f41e704..5f0b19c7 100644
--- a/configure.in
+++ b/configure.in
@@ -19,6 +19,15 @@ 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 =
@@ -33,47 +42,22 @@ 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
@@ -157,6 +141,10 @@ else
fi
fi
+if test "$GCC" = "yes"; then
+ GNU_CC=1
+fi
+
dnl ========================================================
dnl Checks for programs.
dnl ========================================================
@@ -171,6 +159,8 @@ 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
@@ -185,56 +175,48 @@ dnl ========================================================
dnl Override of system specific target options
dnl ========================================================
case "$target" in
-i?86-*-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"
+*-beos*)
+ AC_DEFINE(XP_BEOS)
+ AC_DEFINE(BeOS)
+ AC_DEFINE(BEOS)
;;
-alpha-*-linux*)
+*-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 -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.])
@@ -243,16 +225,16 @@ alpha-*-linux*)
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
;;
@@ -324,6 +306,156 @@ 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)
@@ -332,12 +464,17 @@ 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)
diff --git a/pr/src/md/beos/Makefile.in b/pr/src/md/beos/Makefile.in
index 86cfa0ac..28ab0e97 100644
--- a/pr/src/md/beos/Makefile.in
+++ b/pr/src/md/beos/Makefile.in
@@ -24,7 +24,7 @@ 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
diff --git a/pr/src/md/windows/objs.mk b/pr/src/md/windows/objs.mk
new file mode 100644
index 00000000..eff0e2b1
--- /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)))
+
+