GNOME Bugzilla – Bug 721346
non-standard CFLAGS_FOR_BUILD, CPPFLAGS_FOR_BUILD, LDFLAGS_FOR_BUILD cause problems
Last modified: 2014-01-03 01:32:14 UTC
Most people are trying to build gtk+ in a non-cross-compiled world. In this case, the CFLAGS_FOR_BUILD (and friends) are problematic because they need to explicitly be set to the same thing as CFLAGS. This is unlike every other module where settings CFLAGS, LDFLAGS, etc. is sufficient. In the case that we are not doing a cross-compile, we should set the default value for these variables from the corresponding host variables (CFLAGS, CPPFLAGS, LDFLAGS) so that the person trying to build gtk+ doesn't have to set both variants.
I've sent an email to the autoconf-archive maintainers list (since this is clearly a problem with the AX_PROG_CC_FOR_BUILD macro that we simply downloaded from there). The two solutions I've proposed are as follows: if test "$cross_compiling" = "no"; then if test -n "$CFLAGS"; then CFLAGS_FOR_BUILD=$CFLAGS fi if test -n "$CPPFLAGS"; then CPPFLAGS_FOR_BUILD=$CPPFLAGS fi if test -n "$LDFLAGS"; then LDFLAGS_FOR_BUILD=$LDFLAGS fi fi -- or -- if test -z "$CFLAGS_FOR_BUILD" -a -n "$CFLAGS"; then CFLAGS_FOR_BUILD="$CFLAGS" fi if test -z "$CPPFLAGS_FOR_BUILD" -a -n "$CPPFLAGS"; then CPPFLAGS_FOR_BUILD="$CPPFLAGS" fi if test -z "$LDFLAGS_FOR_BUILD" -a -n "$LDFLAGS"; then LDFLAGS_FOR_BUILD="$LDFLAGS" fi with preference for the first one. Meanwhile, we can add a local workaround. I'll do a patch based on the first one.
Created attachment 265163 [details] [review] configure: use CFLAGS, etc. _FOR_BUILD as well When not doing cross-builds, use the values of CFLAGS, CPPFLAGS and LDFLAGS as the default value for CFLAGS_FOR_BUILD, CPPFLAGS_FOR_BUILD and LDFLAGS_FOR_BUILD, respectively. This avoids having to manually specify these variables in order to get extract-strings to build properly. This should really be handled by ax_prog_cc_for_build.m4. That has been reported upstream. This is a workaround for now.
I tested this as follows: - normal build no CFLAGS set - normal build with CFLAGS in environment variable - normal build with CFLAGS given to ./configure commandline - cross build via mingw32-configure in all cases, this code functions as I expect: - in normal builds CFLAGS == CFLAGS_FOR_BUILD - in cross builds, CFLAGS_FOR_BUILD are the default ones (-O2 -g) and CFLAGS are the ones that mingw32-configure sets up
Created attachment 265166 [details] [review] configure: use CFLAGS, etc. _FOR_BUILD as well When not doing cross-builds, use the values of CFLAGS, CPPFLAGS and LDFLAGS as the default value for CFLAGS_FOR_BUILD, CPPFLAGS_FOR_BUILD and LDFLAGS_FOR_BUILD, respectively. This avoids having to manually specify these variables in order to get extract-strings to build properly. This should really be handled by ax_prog_cc_for_build.m4. That has been reported upstream. This is a workaround for now.
Comment on attachment 265163 [details] [review] configure: use CFLAGS, etc. _FOR_BUILD as well Accidentally uploaded some unrelated bits (one of which was caused by having to pin back our required glib version to test a cross-build under mingw32).
Review of attachment 265166 [details] [review]: ok
Attachment 265166 [details] pushed as 14c7b26 - configure: use CFLAGS, etc. _FOR_BUILD as well