lighttpd: fix reading from block devices, enable mmap
[opendreambox.git] / meta-opendreambox / recipes-extended / lighttpd / lighttpd / 0003-build-use-CC_FOR_BUILD-for-lemon-when-cross-compilin.patch
1 From 8218bea0ca5eff1fb50d268faf076450fab1e9ea Mon Sep 17 00:00:00 2001
2 From: Andreas Oberritter <obi@saftware.de>
3 Date: Mon, 19 Sep 2016 20:21:57 +0200
4 Subject: [PATCH] build: use CC_FOR_BUILD for lemon when cross-compiling
5
6 Also don't use config.h for build tools.
7 ---
8  configure.ac               |   4 +-
9  m4/ax_prog_cc_for_build.m4 | 125 +++++++++++++++++++++++++++++++++++++++++++++
10  src/Makefile.am            |  20 +++-----
11  src/lemon.c                |  12 +----
12  4 files changed, 134 insertions(+), 27 deletions(-)
13  create mode 100644 m4/ax_prog_cc_for_build.m4
14
15 diff --git a/configure.ac b/configure.ac
16 index 34f42f4..148804a 100644
17 --- a/configure.ac
18 +++ b/configure.ac
19 @@ -63,6 +63,7 @@ AC_DEFUN([TRY_LDFLAGS],
20  dnl Checks for programs.
21  AC_PROG_CC
22  AM_PROG_CC_C_O
23 +AX_PROG_CC_FOR_BUILD
24  AC_PROG_LD
25  AC_PROG_INSTALL
26  AC_PROG_AWK
27 @@ -672,9 +673,6 @@ if test x$mmap = xtrue; then
28    AC_DEFINE(ENABLE_MMAP, [1], [Use mmap if available])
29  fi
30  
31 -
32 -AM_CONDITIONAL(CROSS_COMPILING, test "x$cross_compiling" = xyes)
33 -
34  dnl check for fastcgi lib, for the tests only
35  fastcgi_found=no
36  AC_CHECK_LIB(fcgi, FCGI_Accept, [
37 diff --git a/m4/ax_prog_cc_for_build.m4 b/m4/ax_prog_cc_for_build.m4
38 new file mode 100644
39 index 0000000..77fd346
40 --- /dev/null
41 +++ b/m4/ax_prog_cc_for_build.m4
42 @@ -0,0 +1,125 @@
43 +# ===========================================================================
44 +#   http://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html
45 +# ===========================================================================
46 +#
47 +# SYNOPSIS
48 +#
49 +#   AX_PROG_CC_FOR_BUILD
50 +#
51 +# DESCRIPTION
52 +#
53 +#   This macro searches for a C compiler that generates native executables,
54 +#   that is a C compiler that surely is not a cross-compiler. This can be
55 +#   useful if you have to generate source code at compile-time like for
56 +#   example GCC does.
57 +#
58 +#   The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything
59 +#   needed to compile or link (CC_FOR_BUILD) and preprocess (CPP_FOR_BUILD).
60 +#   The value of these variables can be overridden by the user by specifying
61 +#   a compiler with an environment variable (like you do for standard CC).
62 +#
63 +#   It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and object
64 +#   file extensions for the build platform, and GCC_FOR_BUILD to `yes' if
65 +#   the compiler we found is GCC. All these variables but GCC_FOR_BUILD are
66 +#   substituted in the Makefile.
67 +#
68 +# LICENSE
69 +#
70 +#   Copyright (c) 2008 Paolo Bonzini <bonzini@gnu.org>
71 +#
72 +#   Copying and distribution of this file, with or without modification, are
73 +#   permitted in any medium without royalty provided the copyright notice
74 +#   and this notice are preserved. This file is offered as-is, without any
75 +#   warranty.
76 +
77 +#serial 8
78 +
79 +AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD])
80 +AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl
81 +AC_REQUIRE([AC_PROG_CC])dnl
82 +AC_REQUIRE([AC_PROG_CPP])dnl
83 +AC_REQUIRE([AC_EXEEXT])dnl
84 +AC_REQUIRE([AC_CANONICAL_HOST])dnl
85 +
86 +dnl Use the standard macros, but make them use other variable names
87 +dnl
88 +pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl
89 +pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl
90 +pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl
91 +pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl
92 +pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl
93 +pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl
94 +pushdef([ac_cv_objext], ac_cv_build_objext)dnl
95 +pushdef([ac_exeext], ac_build_exeext)dnl
96 +pushdef([ac_objext], ac_build_objext)dnl
97 +pushdef([CC], CC_FOR_BUILD)dnl
98 +pushdef([CPP], CPP_FOR_BUILD)dnl
99 +pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl
100 +pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
101 +pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl
102 +pushdef([host], build)dnl
103 +pushdef([host_alias], build_alias)dnl
104 +pushdef([host_cpu], build_cpu)dnl
105 +pushdef([host_vendor], build_vendor)dnl
106 +pushdef([host_os], build_os)dnl
107 +pushdef([ac_cv_host], ac_cv_build)dnl
108 +pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl
109 +pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl
110 +pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl
111 +pushdef([ac_cv_host_os], ac_cv_build_os)dnl
112 +pushdef([ac_cpp], ac_build_cpp)dnl
113 +pushdef([ac_compile], ac_build_compile)dnl
114 +pushdef([ac_link], ac_build_link)dnl
115 +
116 +save_cross_compiling=$cross_compiling
117 +save_ac_tool_prefix=$ac_tool_prefix
118 +cross_compiling=no
119 +ac_tool_prefix=
120 +
121 +AC_PROG_CC
122 +AC_PROG_CPP
123 +AC_EXEEXT
124 +
125 +ac_tool_prefix=$save_ac_tool_prefix
126 +cross_compiling=$save_cross_compiling
127 +
128 +dnl Restore the old definitions
129 +dnl
130 +popdef([ac_link])dnl
131 +popdef([ac_compile])dnl
132 +popdef([ac_cpp])dnl
133 +popdef([ac_cv_host_os])dnl
134 +popdef([ac_cv_host_vendor])dnl
135 +popdef([ac_cv_host_cpu])dnl
136 +popdef([ac_cv_host_alias])dnl
137 +popdef([ac_cv_host])dnl
138 +popdef([host_os])dnl
139 +popdef([host_vendor])dnl
140 +popdef([host_cpu])dnl
141 +popdef([host_alias])dnl
142 +popdef([host])dnl
143 +popdef([LDFLAGS])dnl
144 +popdef([CPPFLAGS])dnl
145 +popdef([CFLAGS])dnl
146 +popdef([CPP])dnl
147 +popdef([CC])dnl
148 +popdef([ac_objext])dnl
149 +popdef([ac_exeext])dnl
150 +popdef([ac_cv_objext])dnl
151 +popdef([ac_cv_exeext])dnl
152 +popdef([ac_cv_prog_cc_g])dnl
153 +popdef([ac_cv_prog_cc_cross])dnl
154 +popdef([ac_cv_prog_cc_works])dnl
155 +popdef([ac_cv_prog_gcc])dnl
156 +popdef([ac_cv_prog_CPP])dnl
157 +
158 +dnl Finally, set Makefile variables
159 +dnl
160 +BUILD_EXEEXT=$ac_build_exeext
161 +BUILD_OBJEXT=$ac_build_objext
162 +AC_SUBST(BUILD_EXEEXT)dnl
163 +AC_SUBST(BUILD_OBJEXT)dnl
164 +AC_SUBST([CFLAGS_FOR_BUILD])dnl
165 +AC_SUBST([CPPFLAGS_FOR_BUILD])dnl
166 +AC_SUBST([LDFLAGS_FOR_BUILD])dnl
167 +])
168 diff --git a/src/Makefile.am b/src/Makefile.am
169 index 906823e..d51efb6 100644
170 --- a/src/Makefile.am
171 +++ b/src/Makefile.am
172 @@ -1,10 +1,11 @@
173  AM_CFLAGS = $(FAM_CFLAGS) $(LIBUNWIND_CFLAGS)
174  
175 -noinst_PROGRAMS=proc_open lemon # simple-fcgi #graphic evalo bench ajp ssl error_test adserver gen-license
176 +noinst_PROGRAMS=proc_open # simple-fcgi #graphic evalo bench ajp ssl error_test adserver gen-license
177  sbin_PROGRAMS=lighttpd lighttpd-angel
178 -LEMON=$(top_builddir)/src/lemon$(EXEEXT)
179 +LEMON=$(top_builddir)/src/lemon$(BUILD_EXEEXT)
180  
181 -lemon_SOURCES=lemon.c
182 +lemon$(BUILD_EXEEXT): lemon.c
183 +       $(AM_V_CC)$(CC_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ $^
184  
185  lighttpd_angel_SOURCES=lighttpd-angel.c
186  
187 @@ -33,28 +34,21 @@ versionstamp:
188                 rm versionstamp.h.tmp; \
189         fi
190  
191 -if CROSS_COMPILING
192 -configparser.c configparser.h:
193 -mod_ssi_exprparser.c mod_ssi_exprparser.h:
194 -
195 -parsers:
196 -else
197  configparser.h: configparser.c
198 -configparser.c: $(srcdir)/configparser.y $(srcdir)/lempar.c lemon$(EXEEXT)
199 +configparser.c: $(srcdir)/configparser.y $(srcdir)/lempar.c lemon$(BUILD_EXEEXT)
200         rm -f configparser.h
201         $(LEMON) -q $(srcdir)/configparser.y $(srcdir)/lempar.c
202  
203  mod_ssi_exprparser.h: mod_ssi_exprparser.c
204 -mod_ssi_exprparser.c: $(srcdir)/mod_ssi_exprparser.y $(srcdir)/lempar.c lemon$(EXEEXT)
205 +mod_ssi_exprparser.c: $(srcdir)/mod_ssi_exprparser.y $(srcdir)/lempar.c lemon$(BUILD_EXEEXT)
206         rm -f mod_ssi_exprparser.h
207         $(LEMON) -q $(srcdir)/mod_ssi_exprparser.y $(srcdir)/lempar.c
208  
209  parsers: configparser.c mod_ssi_exprparser.c
210 -endif
211  
212  BUILT_SOURCES = parsers versionstamp
213  MAINTAINERCLEANFILES = configparser.c configparser.h mod_ssi_exprparser.c mod_ssi_exprparser.h
214 -CLEANFILES = versionstamp.h versionstamp.h.tmp
215 +CLEANFILES = versionstamp.h versionstamp.h.tmp lemon$(BUILD_EXEEXT)
216  
217  common_src=base64.c buffer.c log.c \
218         keyvalue.c chunk.c  \
219 diff --git a/src/lemon.c b/src/lemon.c
220 index 2f72ef4..286ecd5 100644
221 --- a/src/lemon.c
222 +++ b/src/lemon.c
223 @@ -11,17 +11,7 @@
224  #include <string.h>
225  #include <ctype.h>
226  #include <stdlib.h>
227 -
228 -#ifdef HAVE_CONFIG_H
229 -#include "config.h"
230 -#endif
231 -
232 -#ifdef HAVE_STDINT_H
233 -# include <stdint.h>
234 -#endif
235 -#ifdef HAVE_INTTYPES_H
236 -# include <inttypes.h>
237 -#endif
238 +#include <inttypes.h>
239  
240  #define UNUSED(x) ( (void)(x) )
241