From b95b0ffa720ffdebd829861ed420d10deab6c852 Mon Sep 17 00:00:00 2001 From: Jake Farrell Date: Thu, 22 Mar 2012 21:49:10 +0000 Subject: THRIFT-1500: d programming language support Client: D Patch: David Nadlinger D program language library and additions git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1304085 13f79535-47bb-0310-9956-ffa450edef68 --- aclocal/ax_check_openssl.m4 | 124 ++++++++++++++++++++++++++++++++++++++++++++ aclocal/ax_dmd.m4 | 107 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 231 insertions(+) create mode 100644 aclocal/ax_check_openssl.m4 create mode 100644 aclocal/ax_dmd.m4 (limited to 'aclocal') diff --git a/aclocal/ax_check_openssl.m4 b/aclocal/ax_check_openssl.m4 new file mode 100644 index 000000000..a87c5a6b6 --- /dev/null +++ b/aclocal/ax_check_openssl.m4 @@ -0,0 +1,124 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_openssl.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_OPENSSL([action-if-found[, action-if-not-found]]) +# +# DESCRIPTION +# +# Look for OpenSSL in a number of default spots, or in a user-selected +# spot (via --with-openssl). Sets +# +# OPENSSL_INCLUDES to the include directives required +# OPENSSL_LIBS to the -l directives required +# OPENSSL_LDFLAGS to the -L or -R flags required +# +# and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately +# +# This macro sets OPENSSL_INCLUDES such that source files should use the +# openssl/ directory in include directives: +# +# #include +# +# LICENSE +# +# Copyright (c) 2009,2010 Zmanda Inc. +# Copyright (c) 2009,2010 Dustin J. Mitchell +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +AU_ALIAS([CHECK_SSL], [AX_CHECK_OPENSSL]) +AC_DEFUN([AX_CHECK_OPENSSL], [ + found=false + AC_ARG_WITH([openssl], + [AS_HELP_STRING([--with-openssl=DIR], + [root of the OpenSSL directory])], + [ + case "$withval" in + "" | y | ye | yes | n | no) + AC_MSG_ERROR([Invalid --with-openssl value]) + ;; + *) ssldirs="$withval" + ;; + esac + ], [ + # if pkg-config is installed and openssl has installed a .pc file, + # then use that information and don't search ssldirs + AC_PATH_PROG([PKG_CONFIG], [pkg-config]) + if test x"$PKG_CONFIG" != x""; then + OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null` + if test $? = 0; then + OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null` + OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null` + found=true + fi + fi + + # no such luck; use some default ssldirs + if ! $found; then + ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr" + fi + ] + ) + + + # note that we #include , so the OpenSSL headers have to be in + # an 'openssl' subdirectory + + if ! $found; then + OPENSSL_INCLUDES= + for ssldir in $ssldirs; do + AC_MSG_CHECKING([for openssl/ssl.h in $ssldir]) + if test -f "$ssldir/include/openssl/ssl.h"; then + OPENSSL_INCLUDES="-I$ssldir/include" + OPENSSL_LDFLAGS="-L$ssldir/lib" + OPENSSL_LIBS="-lssl -lcrypto" + found=true + AC_MSG_RESULT([yes]) + break + else + AC_MSG_RESULT([no]) + fi + done + + # if the file wasn't found, well, go ahead and try the link anyway -- maybe + # it will just work! + fi + + # try the preprocessor and linker with our new flags, + # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS + + AC_MSG_CHECKING([whether compiling and linking against OpenSSL works]) + echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \ + "OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&AS_MESSAGE_LOG_FD + + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + save_CPPFLAGS="$CPPFLAGS" + LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" + LIBS="$OPENSSL_LIBS $LIBS" + CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([#include ], [SSL_new(NULL)])], + [ + AC_MSG_RESULT([yes]) + $1 + ], [ + AC_MSG_RESULT([no]) + $2 + ]) + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + + AC_SUBST([OPENSSL_INCLUDES]) + AC_SUBST([OPENSSL_LIBS]) + AC_SUBST([OPENSSL_LDFLAGS]) +]) diff --git a/aclocal/ax_dmd.m4 b/aclocal/ax_dmd.m4 new file mode 100644 index 000000000..13b84b021 --- /dev/null +++ b/aclocal/ax_dmd.m4 @@ -0,0 +1,107 @@ +dnl @synopsis AX_DMD +dnl +dnl Test for the presence of a DMD-compatible D2 compiler, and (optionally) +dnl specified modules on the import path. +dnl +dnl If "DMD" is defined in the environment, that will be the only +dnl dmd command tested. Otherwise, a hard-coded list will be used. +dnl +dnl After AX_DMD runs, the shell variables "success" and "ax_dmd" are set to +dnl "yes" or "no", and "DMD" is set to the appropriate command. Furthermore, +dnl "dmd_optlink" will be set to "yes" or "no" depending on whether OPTLINK is +dnl used as the linker (DMD/Windows), and "dmd_of_dirsep" will be set to the +dnl directory separator to use when passing -of to DMD (OPTLINK requires a +dnl backslash). +dnl +dnl AX_CHECK_D_MODULE must be run after AX_DMD. It tests for the presence of a +dnl module in the import path of the chosen compiler, and sets the shell +dnl variable "success" to "yes" or "no". +dnl +dnl @category D +dnl @version 2011-05-31 +dnl @license AllPermissive +dnl +dnl Copyright (C) 2009 David Reiss +dnl Copyright (C) 2011 David Nadlinger +dnl Copying and distribution of this file, with or without modification, +dnl are permitted in any medium without royalty provided the copyright +dnl notice and this notice are preserved. + + +AC_DEFUN([AX_DMD], + [ + dnl Hard-coded default commands to test. + DMD_PROGS="dmd,gdmd,ldmd" + + dnl Allow the user to specify an alternative. + if test -n "$DMD" ; then + DMD_PROGS="$DMD" + fi + + AC_MSG_CHECKING(for DMD) + + # std.algorithm as a quick way to check for D2/Phobos. + echo "import std.algorithm; void main() {}" > configtest_ax_dmd.d + success=no + oIFS="$IFS" + + IFS="," + for DMD in $DMD_PROGS ; do + IFS="$oIFS" + + echo "Running \"$DMD configtest_ax_dmd.d\"" >&AS_MESSAGE_LOG_FD + if $DMD configtest_ax_dmd.d >&AS_MESSAGE_LOG_FD 2>&1 ; then + success=yes + break + fi + done + + if test "$success" != "yes" ; then + AC_MSG_RESULT(no) + DMD="" + else + AC_MSG_RESULT(yes) + fi + + ax_dmd="$success" + + # Test whether OPTLINK is used by trying if DMD accepts -L/? without + # erroring out. + if test "$success" == "yes" ; then + AC_MSG_CHECKING(whether DMD uses OPTLINK) + echo "Running \”$DMD -L/? configtest_ax_dmd.d\"" >&AS_MESSAGE_LOG_FD + if $DMD -L/? configtest_ax_dmd.d >&AS_MESSAGE_LOG_FD 2>&1 ; then + AC_MSG_RESULT(yes) + dmd_optlink="yes" + + # This actually produces double slashes in the final configure + # output, but at least it works. + dmd_of_dirsep="\\\\" + else + AC_MSG_RESULT(no) + dmd_optlink="no" + dmd_of_dirsep="/" + fi + fi + + rm -f configtest_ax_dmd* + ]) + + +AC_DEFUN([AX_CHECK_D_MODULE], + [ + AC_MSG_CHECKING(for D module [$1]) + + echo "import $1; void main() {}" > configtest_ax_dmd.d + + echo "Running \"$DMD configtest_ax_dmd.d\"" >&AS_MESSAGE_LOG_FD + if $DMD -c configtest_ax_dmd.d >&AS_MESSAGE_LOG_FD 2>&1 ; then + AC_MSG_RESULT(yes) + success=yes + else + AC_MSG_RESULT(no) + success=no + fi + + rm -f configtest_ax_dmd* + ]) -- cgit v1.2.1