configure.ac, Makefile.am: introduce THRIFT variable to support cross-compilation
The thrift build system currently assumes that the thrift compiler is
always available in $(top_builddir)/compiler/cpp/thrift. However, in a
cross-compilation context, this location contains the thrift compiler
built for the target... which obviously will not run on the build
machine.
In order to support such cross-compilation situation, we introduce the
THRIFT variable as a an argument for the configure script (using
AC_ARG_VAR). If not specified, it defaults to the existing value of
using compiler/cpp/thrift from the build directory, but it can be
overridden when calling ./configure.
Note that $(top_builddir) cannot be used within the configure script,
so we simply use `pwd`, which is the same as the top_builddir.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This closes #1336
This closes #1350
diff --git a/configure.ac b/configure.ac
index df716bd..17d4060 100755
--- a/configure.ac
+++ b/configure.ac
@@ -83,6 +83,9 @@
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_ARG_VAR([THRIFT], [Path to the thrift tool (needed for cross-compilation).])
+AS_IF([test "x$THRIFT" = x], [THRIFT=`pwd`/compiler/cpp/thrift])
+
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
diff --git a/lib/c_glib/test/Makefile.am b/lib/c_glib/test/Makefile.am
index 8c6c48d..5e9d2ea 100755
--- a/lib/c_glib/test/Makefile.am
+++ b/lib/c_glib/test/Makefile.am
@@ -237,8 +237,6 @@
gen-cpp/ThriftTest_types.h
libtestgencpp_la_CPPFLAGS = -I../../cpp/src $(BOOST_CPPFLAGS) -I./gen-cpp
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
gen-c_glib/t_test_container_test_types.c gen-c_glib/t_test_container_test_types.h gen-c_glib/t_test_container_service.c gen-c_glib/t_test_container_service.h: ContainerTest.thrift $(THRIFT)
$(THRIFT) --gen c_glib $<
diff --git a/lib/cpp/Makefile.am b/lib/cpp/Makefile.am
index 4441fba..cd1d923 100755
--- a/lib/cpp/Makefile.am
+++ b/lib/cpp/Makefile.am
@@ -265,8 +265,6 @@
src/thrift/qt/TQIODeviceTransport.h \
src/thrift/qt/TQTcpServer.h
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
WINDOWS_DIST = \
src/thrift/windows \
thrift.sln \
diff --git a/lib/cpp/test/Makefile.am b/lib/cpp/test/Makefile.am
index 95d9889..c298e26 100755
--- a/lib/cpp/test/Makefile.am
+++ b/lib/cpp/test/Makefile.am
@@ -360,7 +360,6 @@
#
# Common thrift code generation rules
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
gen-cpp/AnnotationTest_constants.cpp gen-cpp/AnnotationTest_constants.h gen-cpp/AnnotationTest_types.cpp gen-cpp/AnnotationTest_types.h: $(top_srcdir)/test/AnnotationTest.thrift
$(THRIFT) --gen cpp $<
diff --git a/lib/d/test/Makefile.am b/lib/d/test/Makefile.am
index c510471..3b6a6f1 100755
--- a/lib/d/test/Makefile.am
+++ b/lib/d/test/Makefile.am
@@ -24,8 +24,6 @@
# Thrift compiler rules
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
debug_proto_gen = $(addprefix gen-d/, DebugProtoTest_types.d)
$(debug_proto_gen): $(top_srcdir)/test/DebugProtoTest.thrift
diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am
index a3bc9e0..5531e07 100644
--- a/lib/go/test/Makefile.am
+++ b/lib/go/test/Makefile.am
@@ -21,7 +21,6 @@
COMPILER_EXTRAFLAG=",legacy_context"
endif
-THRIFT = $(top_builddir)/compiler/cpp/thrift
THRIFTARGS = -out gopath/src/ --gen go:thrift_import=thrift$(COMPILER_EXTRAFLAG)
THRIFTTEST = $(top_srcdir)/test/ThriftTest.thrift
diff --git a/lib/haxe/test/Makefile.am b/lib/haxe/test/Makefile.am
index 5c638d4..2b8b245 100644
--- a/lib/haxe/test/Makefile.am
+++ b/lib/haxe/test/Makefile.am
@@ -17,7 +17,6 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
THRIFTCMD = $(THRIFT) --gen haxe -r
THRIFTTEST = $(top_srcdir)/test/ThriftTest.thrift
AGGR = $(top_srcdir)/contrib/async-test/aggr.thrift
diff --git a/lib/java/Makefile.am b/lib/java/Makefile.am
index ab130f5..1c867ae 100644
--- a/lib/java/Makefile.am
+++ b/lib/java/Makefile.am
@@ -19,8 +19,6 @@
export CLASSPATH
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
all-local:
$(ANT) $(ANT_FLAGS)
diff --git a/lib/nodejs/Makefile.am b/lib/nodejs/Makefile.am
index 6d785be..a3424d0 100755
--- a/lib/nodejs/Makefile.am
+++ b/lib/nodejs/Makefile.am
@@ -16,8 +16,6 @@
# under the License.
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
stubs: $(top_srcdir)/test/ThriftTest.thrift
$(THRIFT) --gen js:node -o test/ $(top_srcdir)/test/ThriftTest.thrift
diff --git a/lib/php/test/Makefile.am b/lib/php/test/Makefile.am
index d966246..c872b1a 100755
--- a/lib/php/test/Makefile.am
+++ b/lib/php/test/Makefile.am
@@ -17,8 +17,6 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
stubs: ../../../test/ThriftTest.thrift TestValidators.thrift
mkdir -p ./packages
$(THRIFT) --gen php -r --out ./packages ../../../test/ThriftTest.thrift
diff --git a/test/c_glib/Makefile.am b/test/c_glib/Makefile.am
index 4f9a119..0c478f9 100755
--- a/test/c_glib/Makefile.am
+++ b/test/c_glib/Makefile.am
@@ -54,8 +54,6 @@
#
# Common thrift code generation rules
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
gen-c_glib/t_test_second_service.c gen-c_glib/t_test_second_service.h gen-c_glib/t_test_thrift_test.c gen-c_glib/t_test_thrift_test.h gen-c_glib/t_test_thrift_test_types.c gen-c_glib/t_test_thrift_test_types.h: $(top_srcdir)/test/ThriftTest.thrift $(THRIFT)
$(THRIFT) --gen c_glib -r $<
diff --git a/test/cpp/Makefile.am b/test/cpp/Makefile.am
index e2c21f5..359e7e6 100755
--- a/test/cpp/Makefile.am
+++ b/test/cpp/Makefile.am
@@ -98,8 +98,6 @@
#
# Common thrift code generation rules
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_constants.cpp: $(top_srcdir)/test/ThriftTest.thrift $(THRIFT)
$(THRIFT) --gen cpp:templates,cob_style -r $<
diff --git a/test/dart/Makefile.am b/test/dart/Makefile.am
index e274771..9750ec2 100644
--- a/test/dart/Makefile.am
+++ b/test/dart/Makefile.am
@@ -17,8 +17,6 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
gen-dart/thrift_test/lib/thrift_test.dart: ../ThriftTest.thrift
$(THRIFT) --gen dart ../ThriftTest.thrift
diff --git a/test/erl/Makefile.am b/test/erl/Makefile.am
index be8b4f5..ff25e89 100644
--- a/test/erl/Makefile.am
+++ b/test/erl/Makefile.am
@@ -17,8 +17,6 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
THRIFT_FILES = $(wildcard ../*.thrift)
if ERLANG_OTP16
diff --git a/test/go/Makefile.am b/test/go/Makefile.am
index ce711f6..1438d44 100644
--- a/test/go/Makefile.am
+++ b/test/go/Makefile.am
@@ -22,7 +22,6 @@
COMPILER_EXTRAFLAG=",legacy_context"
endif
-THRIFT = $(top_builddir)/compiler/cpp/thrift
THRIFTCMD = $(THRIFT) -out src/gen --gen go:thrift_import=thrift$(COMPILER_EXTRAFLAG)
THRIFTTEST = $(top_srcdir)/test/ThriftTest.thrift
diff --git a/test/haxe/Makefile.am b/test/haxe/Makefile.am
index 1a32185..4edaa30 100644
--- a/test/haxe/Makefile.am
+++ b/test/haxe/Makefile.am
@@ -17,7 +17,6 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
THRIFTCMD = $(THRIFT) --gen haxe -r
THRIFTTEST = $(top_srcdir)/test/ThriftTest.thrift
diff --git a/test/hs/Makefile.am b/test/hs/Makefile.am
index 3f35396..1748906 100644
--- a/test/hs/Makefile.am
+++ b/test/hs/Makefile.am
@@ -17,8 +17,6 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
stubs: $(THRIFT) ../ConstantsDemo.thrift ../DebugProtoTest.thrift ../ThriftTest.thrift ../Include.thrift
$(THRIFT) --gen hs ../ConstantsDemo.thrift
$(THRIFT) --gen hs ../DebugProtoTest.thrift
diff --git a/test/perl/Makefile.am b/test/perl/Makefile.am
index d975f69..165b9a7 100644
--- a/test/perl/Makefile.am
+++ b/test/perl/Makefile.am
@@ -17,8 +17,6 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
stubs: ../ThriftTest.thrift
$(THRIFT) --gen perl ../ThriftTest.thrift
diff --git a/test/php/Makefile.am b/test/php/Makefile.am
index 7c4347f..ea6eaf3 100755
--- a/test/php/Makefile.am
+++ b/test/php/Makefile.am
@@ -17,8 +17,6 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
stubs: ../ThriftTest.thrift
$(THRIFT) --gen php ../ThriftTest.thrift
$(THRIFT) --gen php:inlined ../ThriftTest.thrift
diff --git a/test/py.twisted/Makefile.am b/test/py.twisted/Makefile.am
index 78cde22..d11908c 100644
--- a/test/py.twisted/Makefile.am
+++ b/test/py.twisted/Makefile.am
@@ -17,7 +17,6 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
TRIAL ?= trial
stubs: ../ThriftTest.thrift ../SmallTest.thrift
diff --git a/test/py/Makefile.am b/test/py/Makefile.am
index 53c1e63..b3513dd 100644
--- a/test/py/Makefile.am
+++ b/test/py/Makefile.am
@@ -18,8 +18,6 @@
#
AUTOMAKE_OPTIONS = serial-tests
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
py_unit_tests = RunClientServer.py
thrift_gen = \
diff --git a/test/rb/Makefile.am b/test/rb/Makefile.am
index 7b74c6c..4bd4704 100644
--- a/test/rb/Makefile.am
+++ b/test/rb/Makefile.am
@@ -17,8 +17,6 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
stubs: $(THRIFT) ../ThriftTest.thrift ../SmallTest.thrift
$(THRIFT) --gen rb ../ThriftTest.thrift
$(THRIFT) --gen rb ../SmallTest.thrift
diff --git a/test/rs/Makefile.am b/test/rs/Makefile.am
index 1a409b8..54905b4 100644
--- a/test/rs/Makefile.am
+++ b/test/rs/Makefile.am
@@ -17,8 +17,6 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
stubs: ../ThriftTest.thrift
$(THRIFT) -I ./thrifts -out src --gen rs ../ThriftTest.thrift
diff --git a/tutorial/c_glib/Makefile.am b/tutorial/c_glib/Makefile.am
index 15a9995..4dbe655 100755
--- a/tutorial/c_glib/Makefile.am
+++ b/tutorial/c_glib/Makefile.am
@@ -28,8 +28,6 @@
AM_CPPFLAGS = -I$(top_srcdir)/lib/c_glib/src -Igen-c_glib
AM_LDFLAGS = $(GLIB_LIBS) $(GOBJECT_LIBS) $(OPENSSL_LDFLAGS) $(OPENSSL_LIBS) @GCOV_LDFLAGS@
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
noinst_LTLIBRARIES = \
libtutorialgencglib.la
diff --git a/tutorial/cpp/Makefile.am b/tutorial/cpp/Makefile.am
index 184a69d..49cf3be 100755
--- a/tutorial/cpp/Makefile.am
+++ b/tutorial/cpp/Makefile.am
@@ -61,8 +61,6 @@
#
# Common thrift code generation rules
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
gen-cpp/Calculator.cpp gen-cpp/SharedService.cpp gen-cpp/shared_constants.cpp gen-cpp/shared_types.cpp gen-cpp/tutorial_constants.cpp gen-cpp/tutorial_types.cpp: $(top_srcdir)/tutorial/tutorial.thrift
$(THRIFT) --gen cpp -r $<
diff --git a/tutorial/dart/Makefile.am b/tutorial/dart/Makefile.am
index 438e457..2e8cd34 100644
--- a/tutorial/dart/Makefile.am
+++ b/tutorial/dart/Makefile.am
@@ -19,8 +19,6 @@
BUILT_SOURCES = gen-dart/tutorial/lib/tutorial.dart gen-dart/shared/lib/shared.dart
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
gen-dart/tutorial/lib/tutorial.dart gen-dart/shared/lib/shared.dart: $(top_srcdir)/tutorial/tutorial.thrift
$(THRIFT) --gen dart -r $<
diff --git a/tutorial/go/Makefile.am b/tutorial/go/Makefile.am
index b6ad9a5..30662f5 100644
--- a/tutorial/go/Makefile.am
+++ b/tutorial/go/Makefile.am
@@ -21,8 +21,6 @@
COMPILER_EXTRAFLAG=":legacy_context"
endif
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
gen-go/tutorial/calculator.go gen-go/shared/shared_service.go: $(top_srcdir)/tutorial/tutorial.thrift
$(THRIFT) --gen go$(COMPILER_EXTRAFLAG) -r $<
diff --git a/tutorial/haxe/Makefile.am b/tutorial/haxe/Makefile.am
index e9c8820..13ac48d 100644
--- a/tutorial/haxe/Makefile.am
+++ b/tutorial/haxe/Makefile.am
@@ -17,13 +17,10 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
BIN_CPP = bin/Main-debug
BIN_PHP = bin/php/Main-debug.php
BIN_PHP_WEB = bin/php-web-server/Main-debug.php
-
gen-haxe/tutorial/calculator.hx gen-haxe/shared/shared_service.hx: $(top_srcdir)/tutorial/tutorial.thrift
$(THRIFT) --gen haxe -r $<
diff --git a/tutorial/nodejs/Makefile.am b/tutorial/nodejs/Makefile.am
index ecf3b2b..1516fec 100644
--- a/tutorial/nodejs/Makefile.am
+++ b/tutorial/nodejs/Makefile.am
@@ -17,8 +17,6 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
gen-nodejs/Calculator.js gen-nodejs/SharedService.js: $(top_srcdir)/tutorial/tutorial.thrift
$(THRIFT) --gen js:node -r $<
diff --git a/tutorial/py.tornado/Makefile.am b/tutorial/py.tornado/Makefile.am
index 6ac6023..4b73c1e 100755
--- a/tutorial/py.tornado/Makefile.am
+++ b/tutorial/py.tornado/Makefile.am
@@ -17,8 +17,6 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
gen-py.tornado/tutorial/Calculator.py gen-py.tornado/shared/SharedService.py: $(top_srcdir)/tutorial/tutorial.thrift
$(THRIFT) --gen py:tornado -r $<
diff --git a/tutorial/py.twisted/Makefile.am b/tutorial/py.twisted/Makefile.am
index c6cbd45..50cd342 100755
--- a/tutorial/py.twisted/Makefile.am
+++ b/tutorial/py.twisted/Makefile.am
@@ -17,8 +17,6 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
gen-py/tutorial/Calculator.py gen-py/shared/SharedService.py: $(top_srcdir)/tutorial/tutorial.thrift
$(THRIFT) --gen py:twisted -r $<
diff --git a/tutorial/py/Makefile.am b/tutorial/py/Makefile.am
index d891640..7db816d 100755
--- a/tutorial/py/Makefile.am
+++ b/tutorial/py/Makefile.am
@@ -17,8 +17,6 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
gen-py/tutorial/Calculator.py gen-py/shared/SharedService.py: $(top_srcdir)/tutorial/tutorial.thrift
$(THRIFT) --gen py -r $<
diff --git a/tutorial/rb/Makefile.am b/tutorial/rb/Makefile.am
index 369e903..9372413 100755
--- a/tutorial/rb/Makefile.am
+++ b/tutorial/rb/Makefile.am
@@ -17,8 +17,6 @@
# under the License.
#
-THRIFT = $(top_builddir)/compiler/cpp/thrift
-
gen-py/calculator.rb gen-py/shared_service.rb: $(top_srcdir)/tutorial/tutorial.thrift
$(THRIFT) --gen rb -r $<