8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 12:43:02 +01:00

Use GNU autoconf macros to determine switches required to generate threaded binaries properly

This commit is contained in:
skidder 2004-10-04 05:23:56 +00:00
parent f1b30f408b
commit 6c85fc2f27
8 changed files with 229 additions and 40 deletions

199
acx_pthread.m4 Normal file
View File

@ -0,0 +1,199 @@
dnl Available from the GNU Autoconf Macro Archive at:
dnl http://www.gnu.org/software/ac-archive/htmldoc/acx_pthread.html
dnl
AC_DEFUN([ACX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_LANG_SAVE
AC_LANG_C
acx_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on True64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using
# them:
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
AC_MSG_RESULT($acx_pthread_ok)
if test x"$acx_pthread_ok" = xno; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
fi
# We must check for the threads library under a number of different
# names; the ordering is very important because some systems
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
# libraries is broken (non-POSIX).
# Create a list of thread flags to try. Items starting with a "-" are
# C compiler flags, and other items are library names, except for "none"
# which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library.
acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# pthreads: AIX (must check this before -lpthread)
# none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
# -pthreads: Solaris/gcc
# -mthreads: Mingw32/gcc, Lynx/gcc
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads too;
# also defines -D_REENTRANT)
# pthread: Linux, etcetera
# --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library)
case "${host_cpu}-${host_os}" in
*solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (We need to link with -pthread or
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
# a function called by this macro, so we could check for that, but
# who knows whether they'll stub that too in a future libc.) So,
# we'll just look for -pthreads and -lpthread first:
acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
;;
esac
if test x"$acx_pthread_ok" = xno; then
for flag in $acx_pthread_flags; do
case $flag in
none)
AC_MSG_CHECKING([whether pthreads work without any flags])
;;
-*)
AC_MSG_CHECKING([whether pthreads work with $flag])
PTHREAD_CFLAGS="$flag"
;;
pthread-config)
AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
if test x"$acx_pthread_config" = xno; then continue; fi
PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;;
*)
AC_MSG_CHECKING([for the pthreads library -l$flag])
PTHREAD_LIBS="-l$flag"
;;
esac
save_LIBS="$LIBS"
save_CFLAGS="$CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we
# need a special flag -Kthread to make this header compile.)
# We check for pthread_join because it is in -lpthread on IRIX
# while pthread_create is in libc. We check for pthread_attr_init
# due to DEC craziness with -lpthreads. We check for
# pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles.
AC_TRY_LINK([#include <pthread.h>],
[pthread_t th; pthread_join(th, 0);
pthread_attr_init(0); pthread_cleanup_push(0, 0);
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
[acx_pthread_ok=yes])
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
AC_MSG_RESULT($acx_pthread_ok)
if test "x$acx_pthread_ok" = xyes; then
break;
fi
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
done
fi
# Various other checks:
if test "x$acx_pthread_ok" = xyes; then
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Detect AIX lossage: threads are created detached by default
# and the JOINABLE attribute has a nonstandard name (UNDETACHED).
AC_MSG_CHECKING([for joinable pthread attribute])
AC_TRY_LINK([#include <pthread.h>],
[int attr=PTHREAD_CREATE_JOINABLE;],
ok=PTHREAD_CREATE_JOINABLE, ok=unknown)
if test x"$ok" = xunknown; then
AC_TRY_LINK([#include <pthread.h>],
[int attr=PTHREAD_CREATE_UNDETACHED;],
ok=PTHREAD_CREATE_UNDETACHED, ok=unknown)
fi
if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then
AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok,
[Define to the necessary symbol if this constant
uses a non-standard name on your system.])
fi
AC_MSG_RESULT(${ok})
if test x"$ok" = xunknown; then
AC_MSG_WARN([we do not know how to create joinable pthreads])
fi
AC_MSG_CHECKING([if more special flags are required for pthreads])
flag=no
case "${host_cpu}-${host_os}" in
*-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
*solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
esac
AC_MSG_RESULT(${flag})
if test "x$flag" != xno; then
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
fi
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
# More AIX lossage: must compile with cc_r
AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC})
else
PTHREAD_CC="$CC"
fi
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_CC)
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x"$acx_pthread_ok" = xyes; then
ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
:
else
acx_pthread_ok=no
$2
fi
AC_LANG_RESTORE
])dnl ACX_PTHREAD

View File

@ -27,10 +27,11 @@
# Contributor(s): # Contributor(s):
# #
# #
# $Id: Makefile.in.extlib,v 1.16 2004-04-30 23:02:07 brodsom Exp $ # $Id: Makefile.in.extlib,v 1.17 2004-10-04 05:23:56 skidder Exp $
# #
ROOT=.. ROOT=..
ObjModuleType=std ObjModuleType=std
CFLAGS:=@PTHREAD_CFLAGS@
include $(ROOT)/gen/make.defaults include $(ROOT)/gen/make.defaults
include $(ROOT)/gen/make.platform include $(ROOT)/gen/make.platform
@ -77,14 +78,16 @@ all: lib_ib_udf lib_ib_util
lib_ib_udf: $(UDF)/ib_udf.$(SHRLIB_EXT) lib_ib_udf: $(UDF)/ib_udf.$(SHRLIB_EXT)
$(UDF)/ib_udf.$(SHRLIB_EXT): $(UDF_Objects) $(UTIL_Objects) $(UDF)/ib_udf.$(SHRLIB_EXT): $(UDF_Objects) $(UTIL_Objects)
$(LIB_LINK) $(LIB_LINK_OPTIONS) $(LIB_LINK_SONAME)ib_udf.$(SHRLIB_EXT) $(LIB_LINK_RPATH)$(FirebirdInstallPrefix)/lib -o $@ $^ $(LIB_LINK) $(LIB_LINK_OPTIONS) $(LIB_LINK_SONAME)ib_udf.$(SHRLIB_EXT) \
$(LIB_LINK_RPATH)$(FirebirdInstallPrefix)/lib -o $@ $^ @PTHREAD_CFLAGS@ @PTHREAD_LIBS@
# ib_util # ib_util
lib_ib_util: $(LIBIBUTIL_SO) lib_ib_util: $(LIBIBUTIL_SO)
$(LIBIBUTIL_SO): $(UTIL_Objects) $(LIBIBUTIL_SO): $(UTIL_Objects)
$(LIB_LINK) $(LIB_LINK_OPTIONS) $(LIB_LINK_SONAME)$(IbUtilLibraryName) $(LIB_LINK_RPATH)$(FirebirdInstallPrefix)/lib -o $@ $^ $(LIB_LINK) $(LIB_LINK_OPTIONS) $(LIB_LINK_SONAME)$(IbUtilLibraryName) \
$(LIB_LINK_RPATH)$(FirebirdInstallPrefix)/lib -o $@ $^ @PTHREAD_CFLAGS@ @PTHREAD_LIBS@
include $(ROOT)/gen/make.shared.targets include $(ROOT)/gen/make.shared.targets

View File

@ -27,11 +27,11 @@
# Contributor(s): # Contributor(s):
# #
# #
# $Id: Makefile.in.fbserver,v 1.15 2004-08-17 22:34:26 skidder Exp $ # $Id: Makefile.in.fbserver,v 1.16 2004-10-04 05:23:56 skidder Exp $
# #
ROOT=.. ROOT=..
ObjModuleType=superserver ObjModuleType=superserver
CFLAGS:=-DSUPERSERVER CFLAGS:=-DSUPERSERVER @PTHREAD_CFLAGS@
ArchType=super ArchType=super
include $(ROOT)/gen/make.defaults include $(ROOT)/gen/make.defaults
@ -51,7 +51,7 @@ SERVER_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(SERVER_Source
fbserver : $(FB_SUPER_SERVER) fbserver : $(FB_SUPER_SERVER)
$(FB_SUPER_SERVER): $(SERVER_Objects) $(FB_SUPER_SERVER): $(SERVER_Objects)
$(LD) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(LIB_GUI) $(LINK_LIBS) $(LD) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(LIB_GUI) $(LINK_LIBS) @PTHREAD_CFLAGS@ @PTHREAD_LIBS@
AllObjects = $(SERVER_Objects) AllObjects = $(SERVER_Objects)

View File

@ -27,11 +27,11 @@
# Contributor(s): # Contributor(s):
# #
# #
# $Id: Makefile.in.intl,v 1.18 2004-04-30 23:02:06 brodsom Exp $ # $Id: Makefile.in.intl,v 1.19 2004-10-04 05:23:56 skidder Exp $
# #
ROOT=.. ROOT=..
ObjModuleType=superclient ObjModuleType=superclient
CFLAGS:=-DSUPERCLIENT CFLAGS:=-DSUPERCLIENT @PTHREAD_CFLAGS@
include $(ROOT)/gen/make.defaults include $(ROOT)/gen/make.defaults
include $(ROOT)/gen/make.platform include $(ROOT)/gen/make.platform
@ -78,7 +78,7 @@ libfbintl : $(LIBFBINTL_SO)
$(LIBFBINTL_SO): $(INTL_Objects) $(LIBFBINTL_SO): $(INTL_Objects)
$(LIB_LINK) $(LINK_FBINTL_SYMBOLS) $(LIB_LINK_OPTIONS) $(LIB_LINK_SONAME)libintl.$(SHRLIB_EXT).1 \ $(LIB_LINK) $(LINK_FBINTL_SYMBOLS) $(LIB_LINK_OPTIONS) $(LIB_LINK_SONAME)libintl.$(SHRLIB_EXT).1 \
$(LIB_LINK_RPATH)$(FirebirdInstallPrefix)/lib -o $@ $^ $(SO_LINK_LIBS) $(LIB_LINK_RPATH)$(FirebirdInstallPrefix)/lib -o $@ $^ $(SO_LINK_LIBS) @PTHREAD_CFLAGS@ @PTHREAD_LIBS@
include $(ROOT)/gen/make.shared.targets include $(ROOT)/gen/make.shared.targets

View File

@ -27,11 +27,11 @@
# Contributor(s): # Contributor(s):
# #
# #
# $Id: Makefile.in.libfbclient,v 1.24 2004-09-16 22:32:30 skidder Exp $ # $Id: Makefile.in.libfbclient,v 1.25 2004-10-04 05:23:56 skidder Exp $
# #
ROOT=.. ROOT=..
ObjModuleType=superclient ObjModuleType=superclient
CFLAGS:=-DSUPERCLIENT CFLAGS:=-DSUPERCLIENT @PTHREAD_CFLAGS@
include $(ROOT)/gen/make.defaults include $(ROOT)/gen/make.defaults
include $(ROOT)/gen/make.platform include $(ROOT)/gen/make.platform
@ -115,7 +115,8 @@ endif
$(LIBFBCLIENT_SO): $(FBCLIENT_Objects) $(LIBFBCLIENT_SO): $(FBCLIENT_Objects)
$(LIB_LINK) $(LINK_FIREBIRD_SYMBOLS) $(LIB_LINK_OPTIONS) $(LIB_LINK_IMPLIB) \ $(LIB_LINK) $(LINK_FIREBIRD_SYMBOLS) $(LIB_LINK_OPTIONS) $(LIB_LINK_IMPLIB) \
$(LIB_LINK_SONAME)$(ClientLibraryNameMajor) $(LIB_LINK_RPATH)$(FirebirdInstallPrefix)/lib -o $@ $^ $(SO_LINK_LIBS) $(LIB_LINK_SONAME)$(ClientLibraryNameMajor) $(LIB_LINK_RPATH)$(FirebirdInstallPrefix)/lib \
-o $@ $^ $(SO_LINK_LIBS) @PTHREAD_CFLAGS@ @PTHREAD_LIBS@
AllObjects = $(FBCLIENT_Objects) AllObjects = $(FBCLIENT_Objects)

View File

@ -26,7 +26,7 @@
# Contributor(s): # Contributor(s):
# #
# #
# $Id: make.rules,v 1.23 2004-07-30 22:37:44 skidder Exp $ # $Id: make.rules,v 1.24 2004-10-04 05:23:56 skidder Exp $
# #
#____________________________________________________________________________ #____________________________________________________________________________
@ -43,9 +43,9 @@ IsProdTypeBuild = @PROD_BUILD_FLG@
CFLAGS:= $(CFLAGS) -I$(SRC_ROOT)/include/gen -I$(SRC_ROOT)/include CFLAGS:= $(CFLAGS) -I$(SRC_ROOT)/include/gen -I$(SRC_ROOT)/include
ifeq ($(IsProdTypeBuild),Y) ifeq ($(IsProdTypeBuild),Y)
CFLAGS:= $(CFLAGS) $(PROD_FLAGS) $(SUPER_FLAG) -DPROD_BUILD CFLAGS:= $(CFLAGS) $(PROD_FLAGS) -DPROD_BUILD
else else
CFLAGS:= $(CFLAGS) $(DEV_FLAGS) $(SUPER_FLAG) -DDEV_BUILD CFLAGS:= $(CFLAGS) $(DEV_FLAGS) -DDEV_BUILD
endif endif
CXXFLAGS:= $(CXXFLAGS) $(CFLAGS) CXXFLAGS:= $(CXXFLAGS) $(CFLAGS)

View File

@ -20,8 +20,8 @@
# #
# -Wno-unused-variable is used due to unused gpre generated variables # -Wno-unused-variable is used due to unused gpre generated variables
PROD_FLAGS=-O2 -march=i586 -mcpu=i686 -DMINGW -mno-cygwin -mthreads -Wall -Wshadow -Wundef -pedantic -Wno-long-long -Wno-unused-variable -Wno-unknown-pragmas -Wno-parentheses -Wno-switch -fmessage-length=0 -Dlint -DWIN32_LEAN_AND_MEAN -MMD PROD_FLAGS=-O2 -march=i586 -mcpu=i686 -DMINGW -mno-cygwin -Wall -Wshadow -Wundef -pedantic -Wno-long-long -Wno-unused-variable -Wno-unknown-pragmas -Wno-parentheses -Wno-switch -fmessage-length=0 -Dlint -DWIN32_LEAN_AND_MEAN -MMD
DEV_FLAGS=-ggdb -march=i586 -mcpu=i686 -DMINGW -mno-cygwin -mthreads -Wall -Wshadow -Wundef -pedantic -Wno-long-long -Wno-unused-variable -Wno-unknown-pragmas -Wno-parentheses -Wno-switch -fmessage-length=0 -Dlint -DWIN32_LEAN_AND_MEAN -MMD DEV_FLAGS=-ggdb -march=i586 -mcpu=i686 -DMINGW -mno-cygwin -Wall -Wshadow -Wundef -pedantic -Wno-long-long -Wno-unused-variable -Wno-unknown-pragmas -Wno-parentheses -Wno-switch -fmessage-length=0 -Dlint -DWIN32_LEAN_AND_MEAN -MMD
PLATFORM_PATH=jrd/os/win32 PLATFORM_PATH=jrd/os/win32

View File

@ -1,4 +1,4 @@
dnl $Id: configure.in,v 1.204 2004-09-30 16:30:05 skidder Exp $ dnl $Id: configure.in,v 1.205 2004-10-04 05:23:54 skidder Exp $
dnl ############################# INITIALISATION ############################### dnl ############################# INITIALISATION ###############################
@ -16,6 +16,8 @@ define([XE_APPEND],[[$2]="$[$2] [$1]"])
dnl XE_PREPEND(value, varname) dnl XE_PREPEND(value, varname)
define([XE_PREPEND],[[$2]="[$1] $[$2]"]) define([XE_PREPEND],[[$2]="[$1] $[$2]"])
sinclude(acx_pthread.m4)
dnl ############################# ADD TESTS BELOW ############################## dnl ############################# ADD TESTS BELOW ##############################
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
@ -180,18 +182,13 @@ AC_ARG_ENABLE(debug,
esac]) esac])
AC_SUBST(PROD_BUILD_FLG) AC_SUBST(PROD_BUILD_FLG)
HAVE_MULTI_THREAD_FLG=Y dnl Find out how to use threads on this platform
AC_ARG_ENABLE(threads, ACX_PTHREAD([
[ --enable-threads build threads version (default=yes)],
[case "$enableval" in
yes) HAVE_MULTI_THREAD_FLG=Y;;
no) HAVE_MULTI_THREAD_FLG=N;;
*) AC_MSG_ERROR(bad value '${enableval}' for --enable-threads);;
esac])
if test "$HAVE_MULTI_THREAD_FLG" = "Y"; then
AC_DEFINE(HAVE_MULTI_THREAD, 1, AC_DEFINE(HAVE_MULTI_THREAD, 1,
[Define this if multi-threading should be supported]) [Define this if multi-threading should be supported])])
fi
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(PTHREAD_CFLAGS)
AC_ARG_ENABLE(raw-devices, AC_ARG_ENABLE(raw-devices,
[ --enable-raw-devices enable databases on raw devices (default on POSIX)], [ --enable-raw-devices enable databases on raw devices (default on POSIX)],
@ -384,17 +381,6 @@ dnl Check for libraries
AC_CHECK_LIB(dl, main) AC_CHECK_LIB(dl, main)
AC_CHECK_LIB(c, main) AC_CHECK_LIB(c, main)
AC_CHECK_LIB(m, main) AC_CHECK_LIB(m, main)
if test "$FIREBIRD_ARCH_TYPE" = "super"; then
case "$PLATFORM" in
SOLARIS|solx86)
dnl #Solaris always check for lthread not only SuperServer
;;
*)
AC_CHECK_LIB(pthread, main)
;;
esac
fi
AC_CHECK_LIB(crypt, main) AC_CHECK_LIB(crypt, main)
AC_CHECK_LIB(curses, main) AC_CHECK_LIB(curses, main)
dnl AC_CHECK_LIB(termcap, main) dnl AC_CHECK_LIB(termcap, main)