0001-Use-the-native-compiler-to-build-generate_cookbook.patch 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. From c7c769990bca3049bc389dcbd9985adaec134946 Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Sat, 29 Aug 2015 11:59:18 +0200
  4. Subject: [PATCH] Use the native compiler to build generate_cookbook
  5. The generate_cookbook binary needs to be executed at build time. When
  6. cross-compiling, this means that it should be built with the native
  7. compiler rather than the cross-compiler.
  8. To achieve this, this commit imports the AX_CC_FOR_BUILD autoconf
  9. macro from the GNU Autoconf Archive project, and adjusts
  10. src/Makefile.am to use CC_FOR_BUILD to build generate_cookbook.
  11. Based on initial work by Bernd Kuhls.
  12. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  13. ---
  14. Makefile.am | 1 +
  15. configure.ac | 2 ++
  16. m4/ax_cc_for_build.m4 | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++
  17. src/Makefile.am | 3 ++
  18. 4 files changed, 83 insertions(+)
  19. create mode 100644 m4/ax_cc_for_build.m4
  20. diff --git a/Makefile.am b/Makefile.am
  21. index 4468bca..bd3ce01 100644
  22. --- a/Makefile.am
  23. +++ b/Makefile.am
  24. @@ -2,6 +2,7 @@ AM_CFLAGS = -Isrc -fPIC -Wall -O3 -lm
  25. AUTOMAKE_OPTIONS = gnu
  26. NAME = codec2
  27. AM_CPPFLAGS = $(AM_CFLAGS)
  28. +ACLOCAL_AMFLAGS = -I m4
  29. pkgconfigdir = $(libdir)/pkgconfig
  30. pkgconfig_DATA = codec2.pc
  31. diff --git a/configure.ac b/configure.ac
  32. index 493c517..7520af6 100644
  33. --- a/configure.ac
  34. +++ b/configure.ac
  35. @@ -4,10 +4,12 @@
  36. AC_PREREQ([2.59])
  37. AC_INIT(codec2, 0.2, david@rowetel.com)
  38. AM_INIT_AUTOMAKE
  39. +AC_CONFIG_MACRO_DIR([m4])
  40. # Checks for programs.
  41. AC_PROG_CC
  42. AC_PROG_LIBTOOL
  43. +AX_CC_FOR_BUILD
  44. # Checks for libraries.
  45. # FIXME: Replace `main' with a function in `-lm':
  46. diff --git a/m4/ax_cc_for_build.m4 b/m4/ax_cc_for_build.m4
  47. new file mode 100644
  48. index 0000000..c880fd0
  49. --- /dev/null
  50. +++ b/m4/ax_cc_for_build.m4
  51. @@ -0,0 +1,77 @@
  52. +# ===========================================================================
  53. +# http://www.gnu.org/software/autoconf-archive/ax_cc_for_build.html
  54. +# ===========================================================================
  55. +#
  56. +# SYNOPSIS
  57. +#
  58. +# AX_CC_FOR_BUILD
  59. +#
  60. +# DESCRIPTION
  61. +#
  62. +# Find a build-time compiler. Sets CC_FOR_BUILD and EXEEXT_FOR_BUILD.
  63. +#
  64. +# LICENSE
  65. +#
  66. +# Copyright (c) 2010 Reuben Thomas <rrt@sc3d.org>
  67. +# Copyright (c) 1999 Richard Henderson <rth@redhat.com>
  68. +#
  69. +# This program is free software: you can redistribute it and/or modify it
  70. +# under the terms of the GNU General Public License as published by the
  71. +# Free Software Foundation, either version 3 of the License, or (at your
  72. +# option) any later version.
  73. +#
  74. +# This program is distributed in the hope that it will be useful, but
  75. +# WITHOUT ANY WARRANTY; without even the implied warranty of
  76. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  77. +# Public License for more details.
  78. +#
  79. +# You should have received a copy of the GNU General Public License along
  80. +# with this program. If not, see <http://www.gnu.org/licenses/>.
  81. +#
  82. +# As a special exception, the respective Autoconf Macro's copyright owner
  83. +# gives unlimited permission to copy, distribute and modify the configure
  84. +# scripts that are the output of Autoconf when processing the Macro. You
  85. +# need not follow the terms of the GNU General Public License when using
  86. +# or distributing such scripts, even though portions of the text of the
  87. +# Macro appear in them. The GNU General Public License (GPL) does govern
  88. +# all other use of the material that constitutes the Autoconf Macro.
  89. +#
  90. +# This special exception to the GPL applies to versions of the Autoconf
  91. +# Macro released by the Autoconf Archive. When you make and distribute a
  92. +# modified version of the Autoconf Macro, you may extend this special
  93. +# exception to the GPL to apply to your modified version as well.
  94. +
  95. +#serial 2
  96. +
  97. +dnl Get a default for CC_FOR_BUILD to put into Makefile.
  98. +AC_DEFUN([AX_CC_FOR_BUILD],
  99. +[# Put a plausible default for CC_FOR_BUILD in Makefile.
  100. +if test -z "$CC_FOR_BUILD"; then
  101. + if test "x$cross_compiling" = "xno"; then
  102. + CC_FOR_BUILD='$(CC)'
  103. + else
  104. + CC_FOR_BUILD=gcc
  105. + fi
  106. +fi
  107. +AC_SUBST(CC_FOR_BUILD)
  108. +# Also set EXEEXT_FOR_BUILD.
  109. +if test "x$cross_compiling" = "xno"; then
  110. + EXEEXT_FOR_BUILD='$(EXEEXT)'
  111. +else
  112. + AC_CACHE_CHECK([for build system executable suffix], bfd_cv_build_exeext,
  113. + [rm -f conftest*
  114. + echo 'int main () { return 0; }' > conftest.c
  115. + bfd_cv_build_exeext=
  116. + ${CC_FOR_BUILD} -o conftest conftest.c 1>&5 2>&5
  117. + for file in conftest.*; do
  118. + case $file in
  119. + *.c | *.o | *.obj | *.ilk | *.pdb) ;;
  120. + *) bfd_cv_build_exeext=`echo $file | sed -e s/conftest//` ;;
  121. + esac
  122. + done
  123. + rm -f conftest*
  124. + test x"${bfd_cv_build_exeext}" = x && bfd_cv_build_exeext=no])
  125. + EXEEXT_FOR_BUILD=""
  126. + test x"${bfd_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${bfd_cv_build_exeext}
  127. +fi
  128. +AC_SUBST(EXEEXT_FOR_BUILD)])dnl
  129. diff --git a/src/Makefile.am b/src/Makefile.am
  130. index 1153b3c..719088d 100644
  131. --- a/src/Makefile.am
  132. +++ b/src/Makefile.am
  133. @@ -77,6 +77,9 @@ CODEBOOKSGE= \
  134. noinst_PROGRAMS = generate_codebook genlspdtcb
  135. +generate_codebook$(EXEEXT_FOR_BUILD): generate_codebook.c
  136. + $(CC_FOR_BUILD) -o $@ generate_codebook.c -lm
  137. +
  138. codebook.$(OBJEXT): codebook.c
  139. codebookd.$(OBJEXT): codebookd.c
  140. codebookdt.$(OBJEXT): codebookdt.c
  141. --
  142. 2.5.0