Merge lp:~cjwatson/frame/cross into lp:frame

Proposed by Colin Watson
Status: Merged
Approved by: Daniel d'Andrada
Approved revision: 110
Merged at revision: 110
Proposed branch: lp:~cjwatson/frame/cross
Merge into: lp:frame
Diff against target: 81 lines (+14/-35)
2 files modified
m4/gtest.m4 (+12/-4)
m4/xorg-gtest.m4 (+2/-31)
To merge this branch: bzr merge lp:~cjwatson/frame/cross
Reviewer Review Type Date Requested Status
Daniel d'Andrada (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+137457@code.launchpad.net

Commit message

Remove _CHECK_GTEST macro, and fix CHECK_GTEST to work correctly when cross-compiling.

Description of the change

Fix cross-building.

Firstly, the _CHECK_GTEST macro appears to be a cloned-and-hacked copy of CHECK_GTEST, and furthermore it's broken: observe that $have_gtest_source is tested but never set. It seems better to delete it in favour of the one that looks more likely to work.

Secondly, AC_CHECK_FILES doesn't work when cross-compiling, and fails hard, exiting the configure script. I chose to replace it with a compiler test: this is slower, but it avoids this problem. Of course, tests can't generally actually be run when cross-building unless you have qemu-user-static support or similar, but it still ought to be possible to perform the build. I've tested that this permits cross-building frame from amd64 to armhf.

From the looks of things, I suspect that these Autoconf macros exist in multiple Canonical projects. If there's an upstream source for them, or if I should submit matching MPs to other projects, please let me know.

To post a comment you must log in.
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Looks ok.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'm4/gtest.m4'
2--- m4/gtest.m4 2012-07-18 12:28:56 +0000
3+++ m4/gtest.m4 2012-12-02 23:33:20 +0000
4@@ -38,10 +38,18 @@
5
6 GTEST_CPPFLAGS="$GTEST_CPPFLAGS -I$GTEST_SOURCE"
7
8- AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc]
9- [$GTEST_SOURCE/src/gtest_main.cc],
10- [have_gtest=yes],
11- [have_gtest=no])
12+ AC_LANG_PUSH(C++)
13+ gtest_save_CPPFLAGS=$CPPFLAGS
14+ CPPFLAGS="$CPPFLAGS $GTEST_CPPFLAGS"
15+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "src/gtest-all.cc"]])],
16+ [have_gtest=yes],
17+ [have_gtest=no])
18+ AS_IF([test "x$have_gtest" = xyes],
19+ [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include "src/gtest_main.cc"]])],
20+ [],
21+ [have_gtest=no])])
22+ CPPFLAGS=$gtest_save_CPPFLAGS
23+ AC_LANG_POP(C++)
24
25 AS_IF([test "x$have_gtest" = xyes],
26 [GTEST_LIBS=-lpthread
27
28=== modified file 'm4/xorg-gtest.m4'
29--- m4/xorg-gtest.m4 2012-06-21 19:41:40 +0000
30+++ m4/xorg-gtest.m4 2012-12-02 23:33:20 +0000
31@@ -1,4 +1,4 @@
32-# serial 2
33+# serial 3
34
35 # Copyright (C) 2012 Canonical, Ltd.
36 #
37@@ -21,35 +21,6 @@
38 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39 # SOFTWARE.
40
41-# Checks whether the gtest source is available on the system. Allows for
42-# adjusting the include and source path. Sets have_gtest=yes if the source is
43-# present. Sets GTEST_CPPFLAGS and GTEST_SOURCE to the preprocessor flags and
44-# source location respectively.
45-AC_DEFUN([_CHECK_GTEST],
46-[
47- AC_ARG_WITH([gtest-source-path],
48- [AS_HELP_STRING([--with-gtest-source-path],
49- [location of the Google test sources, defaults to /usr/src/gtest])],
50- [GTEST_SOURCE="$withval"; GTEST_CPPFLAGS="-I$withval/include"],
51- [GTEST_SOURCE="/usr/src/gtest"])
52-
53- AC_ARG_WITH([gtest-include-path],
54- [AS_HELP_STRING([--with-gtest-include-path],
55- [location of the Google test headers])],
56- [GTEST_CPPFLAGS="-I$withval"])
57-
58- GTEST_CPPFLAGS="$GTEST_CPPFLAGS -I$GTEST_SOURCE"
59-
60- AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc]
61- [$GTEST_SOURCE/src/gtest_main.cc],
62- [have_gtest=yes],
63- [have_gtest=no])
64-
65- AS_IF([test "x$have_gtest_source" = xyes],
66- [AC_SUBST(GTEST_CPPFLAGS)]
67- [AC_SUBST(GTEST_SOURCE)])
68-]) # _CHECK_GTEST
69-
70 # CHECK_XORG_GTEST([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
71 #
72 # Checks whether the xorg-gtest source is available on the system. Allows for
73@@ -61,7 +32,7 @@
74 # Both default actions are no-ops.
75 AC_DEFUN([CHECK_XORG_GTEST],
76 [
77- AC_REQUIRE([_CHECK_GTEST])
78+ AC_REQUIRE([CHECK_GTEST])
79
80 PKG_CHECK_EXISTS([xorg-gtest],
81 [have_xorg_gtest=yes],

Subscribers

People subscribed via source and target branches