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
diff --git a/configure.ac b/configure.ac
index 9960731..2290889 100755
--- a/configure.ac
+++ b/configure.ac
@@ -89,6 +89,13 @@
                            Default = "/usr/local/bin"])
 AS_IF([test "x$GOBIN" = x], [GOBIN="/usr/local/bin"])
 
+AC_ARG_VAR([D_IMPORT_PREFIX], [Prefix for installing D modules.
+                           [INCLUDEDIR/d2]])
+AS_IF([test "x$D_IMPORT_PREFIX" = x], [D_IMPORT_PREFIX="${includedir}/d2"])
+
+AC_ARG_VAR([DMD_LIBEVENT_FLAGS], [DMD flags for linking libevent (auto-detected if not set).])
+AC_ARG_VAR([DMD_OPENSSL_FLAGS], [DMD flags for linking OpenSSL (auto-detected if not set).])
+
 AC_PROG_CC
 AC_PROG_CPP
 AC_PROG_CXX
@@ -287,6 +294,94 @@
 fi
 AM_CONDITIONAL(WITH_GO, [test "$have_go" = "yes"])
 
+
+AX_THRIFT_LIB(d, [D], yes)
+if test "$with_d" = "yes";  then
+  AX_DMD
+  AC_SUBST(DMD)
+  if test "x$DMD" != "x"; then
+    have_d="yes"
+  fi
+fi
+
+# Determine actual name of the generated D library for use in the command line
+# when compiling tests. This is needed because the -l<lib> syntax doesn't work
+# with OPTLINK (Windows).
+lib_prefix=lib
+lib_suffix=a
+case "$host_os" in
+  cygwin* | mingw* | pw32* | cegcc*)
+    lib_prefix=""
+    lib_suffix=lib
+    ;;
+esac
+D_LIB_NAME="${lib_prefix}thriftd.${lib_suffix}"
+AC_SUBST(D_LIB_NAME)
+D_EVENT_LIB_NAME="${lib_prefix}thriftd-event.${lib_suffix}"
+AC_SUBST(D_EVENT_LIB_NAME)
+D_SSL_LIB_NAME="${lib_prefix}thriftd-ssl.${lib_suffix}"
+AC_SUBST(D_SSL_LIB_NAME)
+
+if test "$have_d" = "yes"; then
+  AX_CHECK_D_MODULE(deimos.event2.event)
+  have_deimos_event2=$success
+
+  with_d_event_tests="no"
+  if test "$have_deimos_event2" = "yes"; then
+    if test "x$DMD_LIBEVENT_FLAGS" = "x"; then
+      if test "$dmd_optlink" = "yes"; then
+        AC_MSG_WARN([D libevent interface found, but cannot auto-detect \
+linker flags for OPTLINK. Please set DMD_LIBEVENT_FLAGS manually.])
+      else
+        AX_LIB_EVENT([2.0])
+        if test "$success" = "yes"; then
+          DMD_LIBEVENT_FLAGS=$(echo "$LIBEVENT_LDFLAGS $LIBEVENT_LIBS" | \
+            sed -e 's/^ *//g;s/ *$//g;s/^\(.\)/-L\1/g;s/  */ -L/g')
+          with_d_event_tests="yes"
+        else
+          AC_MSG_WARN([D libevent interface present, but libevent library not found.])
+        fi
+      fi
+    else
+      with_d_event_tests="yes"
+    fi
+  fi
+
+  AX_CHECK_D_MODULE(deimos.openssl.ssl)
+  have_deimos_openssl=$success
+
+  with_d_ssl_tests="no"
+  if test "$have_deimos_openssl" = "yes"; then
+    if test "x$DMD_OPENSSL_FLAGS" = "x"; then
+      if test "$dmd_optlink" = "yes"; then
+        AC_MSG_WARN([D OpenSSL interface found, but cannot auto-detect \
+linker flags for OPTLINK. Please set DMD_OPENSSL_FLAGS manually.])
+      else
+        AX_CHECK_OPENSSL([with_d_ssl_tests="yes"])
+        if test "$with_d_ssl_tests" = "yes"; then
+          DMD_OPENSSL_FLAGS=$(echo "$OPENSSL_LDFLAGS $OPENSSL_LIBS" | \
+            sed -e 's/^ *//g;s/ *$//g;s/^\(.\)/-L\1/g;s/  */ -L/g')
+        else
+          AC_MSG_WARN([D OpenSSL interface present, but OpenSSL library not found.])
+        fi
+      fi
+    else
+      with_d_ssl_tests="yes"
+    fi
+  fi
+fi
+
+AM_CONDITIONAL(WITH_D, [test "$have_d" = "yes"])
+AM_CONDITIONAL(DMD_OPTLINK, [test "$dmd_optlink" = "yes"])
+AC_SUBST(DMD_OF_DIRSEP, "$dmd_of_dirsep")
+AM_CONDITIONAL(HAVE_DEIMOS_EVENT2, [test "$have_deimos_event2" = "yes"])
+AM_CONDITIONAL(WITH_D_EVENT_TESTS, [test "$with_d_event_tests" = "yes"])
+AC_SUBST(DMD_LIBEVENT_FLAGS)
+AM_CONDITIONAL(HAVE_DEIMOS_OPENSSL, [test "$have_deimos_openssl" = "yes"])
+AM_CONDITIONAL(WITH_D_SSL_TESTS, [test "$with_d_ssl_tests" = "yes"])
+AC_SUBST(DMD_OPENSSL_FLAGS)
+
+
 have_tests=yes
 if test "$with_tests" = "no"; then
   have_tests="no"
@@ -490,6 +585,8 @@
   lib/c_glib/thrift_c_glib.pc
   lib/c_glib/test/Makefile
   lib/csharp/Makefile
+  lib/d/Makefile
+  lib/d/test/Makefile
   lib/erl/Makefile
   lib/hs/Makefile
   lib/java/Makefile
@@ -530,6 +627,7 @@
 echo "Building PHP Library ......... : $have_php"
 echo "Building Erlang Library ...... : $have_erlang"
 echo "Building Go Library .......... : $have_go"
+echo "Building D Library ........... : $have_d"
 if test "$have_cpp" = "yes" ; then
   echo
   echo "C++ Library:"
@@ -589,6 +687,12 @@
   echo "   Using GO Compiler.......... : $GO_C"
   echo "   Using GO Linker............ : $GO_L"
 fi
+if test "$have_d" = "yes" ; then
+  echo
+  echo "Using D Compiler ............. : $DMD"
+  echo "Building D libevent tests .... : $with_d_event_tests"
+  echo "Building D SSL tests ......... : $with_d_ssl_tests"
+fi
 echo
 echo "If something is missing that you think should be present,"
 echo "please skim the output of configure to find the missing"