Improve Sun Studio support. Patch from Monty Taylor.

pull/3335/head
kenton@google.com 16 years ago
parent 6c9f0020e2
commit 6be265a826
  1. 43
      configure.ac
  2. 66
      m4/acx_check_suncc.m4

@ -14,15 +14,20 @@ AC_PREREQ(2.59)
# the size of one file name in the dist tarfile over the 99-char limit.) # the size of one file name in the dist tarfile over the 99-char limit.)
AC_INIT([Protocol Buffers],[2.1.1-pre],[protobuf@googlegroups.com],[protobuf]) AC_INIT([Protocol Buffers],[2.1.1-pre],[protobuf@googlegroups.com],[protobuf])
# Detect whether the user specified their own compilation flags. If so then
# we want to respect their decision, otherwise we will twiddle them later.
AS_IF([test "$CXXFLAGS" = ""],[
protobuf_default_cxxflags=yes
])
AC_CONFIG_SRCDIR(src/google/protobuf/message.cc) AC_CONFIG_SRCDIR(src/google/protobuf/message.cc)
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
# autoconf's default CXXFLAGS are usually "-g -O2". These aren't necessarily
# the best choice for libprotobuf.
AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
[CFLAGS=""])
AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
[CXXFLAGS=""])
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE AM_INIT_AUTOMAKE
AC_ARG_WITH([zlib], AC_ARG_WITH([zlib],
@ -40,26 +45,15 @@ AC_PROG_CC
AC_PROG_CXX AC_PROG_CXX
AC_LANG([C++]) AC_LANG([C++])
ACX_USE_SYSTEM_EXTENSIONS ACX_USE_SYSTEM_EXTENSIONS
AC_PROG_LIBTOOL
AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
# autoconf's default CXXFLAGS are usually "-g -O2". These aren't necessarily # test_util.cc takes forever to compile with GCC and optimization turned on.
# the best choice for libprotobuf.
AC_MSG_CHECKING([C++ compiler flags...]) AC_MSG_CHECKING([C++ compiler flags...])
AS_IF([test "$protobuf_default_cxxflags" = "yes"],[ AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],[
AS_IF([test "$GCC" = "yes"],[
# test_util.cc takes forever to compile with GCC and optimization turned on. PROTOBUF_OPT_FLAG="-O2"
# But we cannot override anything that is part of CXXFLAGS since it is the CXXFLAGS="${CXXFLAGS} -g"
# last thing added to the command line. The automake docs insist that you ])
# should never want to override CXXFLAGS because they represent the intent of
# the user, and the user knows best. But if the user actually did not set
# any CXXFLAGS, then AC_PROG_CXX sets them to a rather arbitrary default.
# That's not user intent at all, but automake still treats it like it is.
# Grr. Anyway, getting back to the point, this hack here strips out the -O
# flag from autoconf's defaults and puts it into another variable so that
# we can override it. BTW, m4 escaping sucks.
PROTOBUF_OPT_FLAG=`echo "$CXXFLAGS" | grep -o '\-O@<:@0-9@:>@\?'`
CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/ \?-O@<:@0-9@:>@\?//g'`
# Protocol Buffers contains several checks that are intended to be used only # Protocol Buffers contains several checks that are intended to be used only
# for debugging and which might hurt performance. Most users are probably # for debugging and which might hurt performance. Most users are probably
@ -68,7 +62,6 @@ AS_IF([test "$protobuf_default_cxxflags" = "yes"],[
AC_MSG_RESULT([use default: $PROTOBUF_OPT_FLAG $CXXFLAGS]) AC_MSG_RESULT([use default: $PROTOBUF_OPT_FLAG $CXXFLAGS])
],[ ],[
PROTOBUF_OPT_FLAG=
AC_MSG_RESULT([use user-supplied: $CXXFLAGS]) AC_MSG_RESULT([use user-supplied: $CXXFLAGS])
]) ])
@ -76,6 +69,10 @@ AC_SUBST(PROTOBUF_OPT_FLAG)
ACX_CHECK_SUNCC ACX_CHECK_SUNCC
# Have to do libtool after SUNCC, other wise it "helpfully" adds Crun Cstd
# to the link
AC_PROG_LIBTOOL
# Checks for header files. # Checks for header files.
AC_HEADER_STDC AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h]) AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h])

@ -14,22 +14,58 @@ AC_DEFUN([ACX_CHECK_SUNCC],[
AC_LANG_PUSH([C++]) AC_LANG_PUSH([C++])
AC_CHECK_DECL([__SUNPRO_CC], [SUNCC="yes"], [SUNCC="no"]) AC_CHECK_DECL([__SUNPRO_CC], [SUNCC="yes"], [SUNCC="no"])
AC_LANG_POP()
AS_IF([test "$SUNCC" = "yes"],[
isainfo_k=`isainfo -k`
AS_IF([test "$target_cpu" = "sparc"],[
MEMALIGN_FLAGS="-xmemalign=8s"
IS_64="-m64"
LDFLAGS="${LDFLAGS} -L/usr/lib/${isainfo_k} -L/usr/local/lib/${isainfo_k}"
],[
AS_IF([test "$isainfo_k" = "amd64"],[
IS_64="-m64"
LDFLAGS="${LDFLAGS} -L/usr/lib/${isainfo_k} -L/usr/local/lib/${isainfo_k}"
])
])
CFLAGS="-g -xO4 -xlibmil -xdepend -Xa -mt -xstrconst ${IS_64} ${MEMALIGN_FLAGS} $CFLAGS" AC_ARG_ENABLE([64bit-solaris],
CXXFLAGS="-g -xO4 -xlibmil -mt ${IS_64} ${MEMALIGN_FLAGS} -xlang=c99 -compat=5 -library=stlport4 -template=no%extdef $CXXFLAGS" [AS_HELP_STRING([--disable-64bit-solaris],
[Build 64 bit binary on Solaris @<:@default=on@:>@])],
[ac_enable_64bit="$enableval"],
[ac_enable_64bit="yes"])
AS_IF([test "$SUNCC" = "yes" -a "x${ac_cv_env_CXXFLAGS_set}" = "x"],[
dnl Sun Studio has a crashing bug with -xO4 in some cases. Keep this
dnl at -xO3 until a proper test to detect those crashes can be done.
CXXFLAGS="-g0 -xO3 -xlibmil -xdepend -xbuiltin -mt -compat=5 -library=stlport4 -template=no%extdef ${CXXFLAGS}"
]) ])
AC_LANG_POP()
case $host_os in
*solaris*)
AC_CHECK_PROGS(ISAINFO, [isainfo], [no])
AS_IF([test "x$ISAINFO" != "xno"],
[isainfo_b=`${ISAINFO} -b`],
[isainfo_b="x"])
AS_IF([test "$isainfo_b" != "x"],[
isainfo_k=`${ISAINFO} -k`
AS_IF([test "x$ac_enable_64bit" = "xyes"],[
AS_IF([test "x${ac_cv_env_LDFLAGS_set}" = "x"],[
LDFLAGS="-L/usr/local/lib/${isainfo_k} ${LDFLAGS}"
])
AS_IF([test "x$libdir" = "x\${exec_prefix}/lib"],[
dnl The user hasn't overridden the default libdir, so we'll
dnl the dir suffix to match solaris 32/64-bit policy
libdir="${libdir}/${isainfo_k}"
])
dnl This should just be set in CPPFLAGS and in LDFLAGS, but libtool
dnl does the wrong thing if you don't put it into CXXFLAGS. sigh.
AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],[
CXXFLAGS="${CXXFLAGS} -m64"
ac_cv_env_CXXFLAGS_set=set
ac_cv_env_CXXFLAGS_value='-m64'
])
AS_IF([test "$target_cpu" = "sparc" -a "x$SUNCC" = "xyes" ],[
CXXFLAGS="-xmemalign=8s ${CXXFLAGS}"
])
])
])
;;
esac
]) ])

Loading…
Cancel
Save