aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt2
-rw-r--r--README.txt23
-rw-r--r--configure.ac24
-rw-r--r--src/Makefile.am10
4 files changed, 59 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 8fa7a536..3ffad2a4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -29,6 +29,8 @@
optional int32 foo = 1 [deprecated = true];
Currently this does not have any actual effect, but in the future the code
generators may generate deprecation annotations in each language.
+ * Cross-compiling should now be possible using the --with-protoc option to
+ configure. See README.txt for more info.
protoc
* --error_format=msvs option causes errors to be printed in Visual Studio
diff --git a/README.txt b/README.txt
index 8b7c8531..daacfb26 100644
--- a/README.txt
+++ b/README.txt
@@ -33,6 +33,29 @@ For advanced usage information on configure and make, see INSTALL.txt.
If you already built the package with a different prefix, make sure
to run "make clean" before building again.
+** Note for cross-compiling **
+
+ The makefiles normally invoke the protoc executable that they just
+ built in order to build tests. When cross-compiling, the protoc
+ executable may not be executable on the host machine. In this case,
+ you must build a copy of protoc for the host machine first, then use
+ the --with-protoc option to tell configure to use it instead. For
+ example:
+
+ ./configure --with-protoc=protoc
+
+ This will use the installed protoc (found in your $PATH) instead of
+ trying to execute the one built during the build process. You can
+ also use an executable that hasn't been installed. For example, if
+ you built the protobuf package for your host machine in ../host,
+ you might do:
+
+ ./configure --with-protoc=../host/src/protoc
+
+ Either way, you must make sure that the protoc executable you use
+ has the same version as the protobuf source code you are trying to
+ use it with.
+
** Note for Solaris users **
Solaris 10 x86 has a bug that will make linking fail, complaining
diff --git a/configure.ac b/configure.ac
index 7f068c31..b10473e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,6 +30,11 @@ AC_ARG_WITH([zlib],
[include classes for streaming compressed data in and out @<:@default=check@:>@])],
[],[with_zlib=check])
+AC_ARG_WITH([protoc],
+ [AS_HELP_STRING([--with-protoc=COMMAND],
+ [use the given protoc command instead of building a new one when building tests (useful for cross-compiling)])],
+ [],[with_protoc=no])
+
# Checks for programs.
AC_PROG_CC
AC_PROG_CXX
@@ -90,6 +95,25 @@ AS_IF([test "$with_zlib" != no],
fi])])
AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1])
+AS_IF([test "$with_protoc" != "no"], [
+ PROTOC=$with_protoc
+ AS_IF([test "$with_protoc" == "yes"], [
+ # No argument given. Use system protoc.
+ PROTOC=protoc
+ ])
+ AS_IF([echo "$PROTOC" | grep -q '^@<:@^/@:>@.*/'], [
+ # Does not start with a slash, but contains a slash. So, it's a relative
+ # path (as opposed to an absolute path or an executable in $PATH).
+ # Since it will actually be executed from the src directory, prefix with
+ # the current directory. We also insert $ac_top_build_prefix in case this
+ # is a nested package and --with-protoc was actually given on the outer
+ # package's configure script.
+ PROTOC=`pwd`/${ac_top_build_prefix}$PROTOC
+ ])
+ AC_SUBST([PROTOC])
+])
+AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"])
+
ACX_PTHREAD
AC_CXX_STL_HASH
diff --git a/src/Makefile.am b/src/Makefile.am
index 260834de..3e32c25e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -206,6 +206,14 @@ protoc_outputs = \
BUILT_SOURCES = $(protoc_outputs)
+if USE_EXTERNAL_PROTOC
+
+unittest_proto_middleman: $(protoc_inputs)
+ $(PROTOC) -I$(srcdir) --cpp_out=. $(protoc_inputs)
+ touch unittest_proto_middleman
+
+else
+
# This rule is a little weird. The first prereq is the protoc executable
# and the rest are its inputs. Therefore, $^ -- which expands to the
# list of prereqs -- is actually a valid command. We have to place "./" in
@@ -220,6 +228,8 @@ unittest_proto_middleman: protoc$(EXEEXT) $(protoc_inputs)
./$^ -I$(srcdir) --cpp_out=.
touch unittest_proto_middleman
+endif
+
$(protoc_outputs): unittest_proto_middleman
COMMON_TEST_SOURCES = \