Will, could you please review this patch?
Thanks.
-Maynard
On 07/06/2012 09:12 AM, Maynard Johnson wrote:
> Gergely,
> This patch was made against the master branch. It will apply with fuzz
> against the perf-events branch, but then the pe_profiling/Makefile.am
> file would need to be changed to use the @OP_CPPFLAGS@ and @OP_LDFLAGS@
> similar to the other Makefile.am files altered by this patch (for example,
> see daemon/Makefile.am).
>
> Can you please give it a test? Thanks.
>
> -Maynard
>
> -----------------------------------------------------------------------
> [PATCH] Fix configure to not alter user variables
>
> The configure script for oprofile had a few places
> where user variables were being altered in contradiction
> to the GNU Automake manual. See the following URL for details:
>
> http://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html
>
> In brief, user variables are those listed under "Some influential
> environment variables" section of the output from 'configure --help'.
> These are variables which the user may set prior to invoking configure,
> and thus, the configure script should not alter them. This patch
> makes use of new internal variables (e.g., OP_LDFLAGS and OP_CPPFLAGS),
> which did unfortunately create quite a ripple effect with the Makefile.am
> files. But this was unavoidable in order to correct this error.
>
> Signed-off-by: Maynard Johnson <maynardj@...>
> ---
> configure.in | 34 +++++++++++++++++++++++++---------
> daemon/Makefile.am | 4 +++-
> daemon/liblegacy/Makefile.am | 3 ++-
> gui/Makefile.am | 3 ++-
> gui/ui/Makefile.am | 2 +-
> libabi/Makefile.am | 5 +++--
> libabi/tests/Makefile.am | 3 ++-
> libdb/Makefile.am | 3 ++-
> libdb/tests/Makefile.am | 3 ++-
> libop/Makefile.am | 2 +-
> libop/tests/Makefile.am | 3 ++-
> libopagent/Makefile.am | 9 +++++++--
> libopt++/Makefile.am | 2 +-
> libpp/Makefile.am | 3 ++-
> libregex/Makefile.am | 2 +-
> libutil++/Makefile.am | 3 ++-
> libutil++/tests/Makefile.am | 2 +-
> libutil/Makefile.am | 2 +-
> libutil/tests/Makefile.am | 2 +-
> opjitconv/Makefile.am | 7 ++++++-
> pp/Makefile.am | 4 +++-
> utils/Makefile.am | 6 +++++-
> 22 files changed, 75 insertions(+), 32 deletions(-)
>
> diff --git a/configure.in b/configure.in
> index 24912cc..d387148 100644
> --- a/configure.in
> +++ b/configure.in
> @@ -26,19 +26,18 @@ AC_SUBST(DATE)
>
> # this needs to come before --with-gcc so we link with binutil's version
> # of libiberty ... sigh
> +
> +# Since we should not permanently alter user environment variables, we'll
> +# save the contents of the original flags in case the user has set them
> +# prior to running this configue script.
> +CPPFLAGS_SAVE="$CPP_FLAGS"
> +LDFLAGS_SAVE="$LDFLAGS"
> AC_ARG_WITH(binutils,
> [ --with-binutils=dir Path to binutils installation to use], BINUTILSDIR=$withval)
>
> if test "$BINUTILSDIR" != ""; then
> LD="$BINUTILSDIR/ld"
> - if test "$CFLAGS" = ""; then
> - CFLAGS="-g -O2"
> - fi
> - if test "$CXXFLAGS" = ""; then
> - CXXFLAGS="-g -O2"
> - fi
> - CFLAGS="$CFLAGS -I$BINUTILSDIR/include"
> - CXXFLAGS="$CXXFLAGS -I$BINUTILSDIR/include"
> + CPPFLAGS="$CFLAGS -I$BINUTILSDIR/include"
> AC_ARG_WITH(binutils-libname,
> [ --with-binutils-libname Lib dir name under binutils installation; @<:@lib@:>@]],
> BINUTILSLIB=$withval)
> @@ -46,17 +45,27 @@ if test "$BINUTILSDIR" != ""; then
> BINUTILSLIB="lib"
> fi
> LDFLAGS="$LDFLAGS -L$BINUTILSDIR/$BINUTILSLIB -Xlinker -R -Xlinker $BINUTILSDIR/$BINUTILSLIB"
> + OP_LDFLAGS="$LDFLAGS"
> + OP_CPPFLAGS="$CPPFLAGS"
> +else
> + OP_LDFLAGS=
> + OP_CPPFLAGS=
> fi
>
> AC_ARG_WITH(gcc,
> [ --with-gcc=dir Path to GCC installation to use], GCCDIR=$withval)
>
> +# It's correct to alter the user environment variables CC and CXX here because it wouldn't
> +# make much sense to NOT honor the --with-gcc option.
> if test "$GCCDIR" != ""; then
> CC="$GCCDIR/bin/gcc"
> CXX="$GCCDIR/bin/g++"
> - LDFLAGS="$LDFLAGS -L$GCCDIR/lib -Xlinker -R -Xlinker $GCCDIR/lib"
> + OP_LDFLAGS="$LDFLAGS -L$GCCDIR/lib -Xlinker -R -Xlinker $GCCDIR/lib"
> fi
>
> +# We can't restore original flag values for CPPFLAGS and LDFLAGS until we're don
> +# checking for bfd.h and libiberty.h (in AX_BINUTILS).
> +
> AC_PROG_CC
> AC_PROG_CPP
> AC_PROG_CXX
> @@ -100,6 +109,13 @@ AC_CHECK_FUNCS(sched_setaffinity perfmonctl)
>
> AC_CHECK_LIB(popt, poptGetContext,, AC_MSG_ERROR([popt library not found]))
> AX_BINUTILS
> +# Now we can restore original flag values, and may as well do the
> +# AC_SUBST, too.
> +CPPFLAGS="$CPPFLAGS_SAVE"
> +LDFLAGS="$LDFLAGS_SAVE"
> +AC_SUBST(OP_CPPFLAGS)
> +AC_SUBST(OP_LDFLAGS)
> +
> AX_CELL_SPU
>
> # C++ tests
> diff --git a/daemon/Makefile.am b/daemon/Makefile.am
> index 043cfd6..ce6f5e2 100644
> --- a/daemon/Makefile.am
> +++ b/daemon/Makefile.am
> @@ -41,10 +41,12 @@ AM_CPPFLAGS = \
> -I ${top_srcdir}/libabi \
> -I ${top_srcdir}/libutil \
> -I ${top_srcdir}/libop \
> - -I ${top_srcdir}/libdb
> + -I ${top_srcdir}/libdb \
> + @OP_CPPFLAGS@
>
> # -fno-omit-frame-pointer needed for daemon build: see ChangeLog-2004 02-23
> AM_CFLAGS = @OP_CFLAGS@ -fno-omit-frame-pointer
> +AM_LDFLAGS = @OP_LDFLAGS@
>
> bin_PROGRAMS = oprofiled
>
> diff --git a/daemon/liblegacy/Makefile.am b/daemon/liblegacy/Makefile.am
> index 51078a6..5c71dd8 100644
> --- a/daemon/liblegacy/Makefile.am
> +++ b/daemon/liblegacy/Makefile.am
> @@ -7,7 +7,8 @@ AM_CPPFLAGS = \
> -I ${top_srcdir}/libutil \
> -I ${top_srcdir}/libop \
> -I ${top_srcdir}/libdb \
> - -I ${top_srcdir}/daemon
> + -I ${top_srcdir}/daemon \
> + @OP_CPPFLAGS@
>
> liblegacy_a_SOURCES = \
> opd_24_stats.c \
> diff --git a/gui/Makefile.am b/gui/Makefile.am
> index eb62ef6..c079e9b 100644
> --- a/gui/Makefile.am
> +++ b/gui/Makefile.am
> @@ -17,7 +17,8 @@ AM_CPPFLAGS = \
> @QT_CFLAGS@ \
> -I ${top_srcdir}/libop \
> -I ${top_srcdir}/libutil++ \
> - -I ${top_srcdir}/libutil
> + -I ${top_srcdir}/libutil \
> + @OP_CPPFLAGS@
>
> AM_CXXFLAGS = @OP_CXXFLAGS@
>
> diff --git a/gui/ui/Makefile.am b/gui/ui/Makefile.am
> index 7b4edbe..235d370 100644
> --- a/gui/ui/Makefile.am
> +++ b/gui/ui/Makefile.am
> @@ -2,7 +2,7 @@ EXTRA_DIST = oprof_start.base.ui
>
> if have_qt
>
> -AM_CPPFLAGS = @QT_CFLAGS@
> +AM_CPPFLAGS = @QT_CFLAGS@ @OP_CPPFLAGS@
>
> AM_CXXFLAGS = @OP_CXXFLAGS@
>
> diff --git a/libabi/Makefile.am b/libabi/Makefile.am
> index 95c0c8c..f72357d 100644
> --- a/libabi/Makefile.am
> +++ b/libabi/Makefile.am
> @@ -6,10 +6,11 @@ AM_CPPFLAGS = \
> -I ${top_srcdir}/libop \
> -I ${top_srcdir}/libutil \
> -I ${top_srcdir}/libdb \
> - -I ${top_srcdir}/libopt++
> + -I ${top_srcdir}/libopt++ \
> + @OP_CPPFLAGS@
>
> AM_CXXFLAGS = @OP_CXXFLAGS@
> -
> +AM_LDFLAGS = @OP_LDFLAGS@
> noinst_LIBRARIES = libabi.a
> libabi_a_SOURCES = abi.cpp abi.h op_abi.c op_abi.h
>
> diff --git a/libabi/tests/Makefile.am b/libabi/tests/Makefile.am
> index 3eb7e1a..c15f0d0 100644
> --- a/libabi/tests/Makefile.am
> +++ b/libabi/tests/Makefile.am
> @@ -5,7 +5,8 @@ AM_CPPFLAGS = \
> -I ${top_srcdir}/libop \
> -I ${top_srcdir}/libdb \
> -I ${top_srcdir}/libopt++ \
> - -I ${top_srcdir}/libutil
> + -I ${top_srcdir}/libutil \
> + @OP_CPPFLAGS@
>
> AM_CXXFLAGS = @OP_CXXFLAGS@
>
> diff --git a/libdb/Makefile.am b/libdb/Makefile.am
> index 61658f9..2da22ba 100644
> --- a/libdb/Makefile.am
> +++ b/libdb/Makefile.am
> @@ -2,7 +2,8 @@ SUBDIRS=. tests
>
> AM_CPPFLAGS = \
> -I ${top_srcdir}/libop \
> - -I ${top_srcdir}/libutil
> + -I ${top_srcdir}/libutil \
> + @OP_CPPFLAGS@
>
> AM_CFLAGS = @OP_CFLAGS@
>
> diff --git a/libdb/tests/Makefile.am b/libdb/tests/Makefile.am
> index 6932088..8a69003 100644
> --- a/libdb/tests/Makefile.am
> +++ b/libdb/tests/Makefile.am
> @@ -1,7 +1,8 @@
> AM_CPPFLAGS = \
> -I ${top_srcdir}/libop \
> -I ${top_srcdir}/libutil \
> - -I ${top_srcdir}/libdb
> + -I ${top_srcdir}/libdb \
> + @OP_CPPFLAGS@
>
> AM_CFLAGS = @OP_CFLAGS@
>
> diff --git a/libop/Makefile.am b/libop/Makefile.am
> index 22f8578..f893118 100644
> --- a/libop/Makefile.am
> +++ b/libop/Makefile.am
> @@ -1,6 +1,6 @@
> SUBDIRS = . tests
>
> -AM_CPPFLAGS=-I${top_srcdir}/libutil
> +AM_CPPFLAGS=-I${top_srcdir}/libutil @OP_CPPFLAGS@
> AM_CFLAGS = @OP_CFLAGS@
>
> noinst_LIBRARIES = libop.a
> diff --git a/libop/tests/Makefile.am b/libop/tests/Makefile.am
> index d4160c3..8a79eb5 100644
> --- a/libop/tests/Makefile.am
> +++ b/libop/tests/Makefile.am
> @@ -1,6 +1,7 @@
> AM_CPPFLAGS = \
> -I ${top_srcdir}/libutil \
> - -I ${top_srcdir}/libop
> + -I ${top_srcdir}/libop \
> + @OP_CPPFLAGS@
>
> AM_CFLAGS = @OP_CFLAGS@ -DOPROFILE_SRCDIR=\"@top_srcdir@\"
>
> diff --git a/libopagent/Makefile.am b/libopagent/Makefile.am
> index 7b891a3..caea70e 100644
> --- a/libopagent/Makefile.am
> +++ b/libopagent/Makefile.am
> @@ -10,7 +10,11 @@ libopagent_la_SOURCES = opagent.c \
> EXTRA_DIST = opagent_symbols.ver
>
>
> -libopagent_la_CFLAGS = -fPIC -I ${top_srcdir}/libop -I ${top_srcdir}/libutil
> +libopagent_la_CFLAGS = -fPIC
> +libopagent_la_CPPFLAGS = -I ${top_srcdir}/libop \
> + -I ${top_srcdir}/libutil \
> + @OP_CPPFLAGS@
> +
> libopagent_la_LIBADD = $(BFD_LIBS)
>
> # Do not increment the major version for this library except to
> @@ -20,6 +24,7 @@ libopagent_la_LIBADD = $(BFD_LIBS)
> # See http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_node/ld_25.html
> # for details about the --version-script option.
> libopagent_la_LDFLAGS = -version-info 1:0:0 \
> - -Wl,--version-script=${top_srcdir}/libopagent/opagent_symbols.ver
> + -Wl,--version-script=${top_srcdir}/libopagent/opagent_symbols.ver \
> + @OP_LDFLAGS@
>
>
> diff --git a/libopt++/Makefile.am b/libopt++/Makefile.am
> index f175ce7..3e0b492 100644
> --- a/libopt++/Makefile.am
> +++ b/libopt++/Makefile.am
> @@ -1,4 +1,4 @@
> -AM_CPPFLAGS=-I ${top_srcdir}/libutil++ -I ${top_srcdir}/libutil
> +AM_CPPFLAGS=-I ${top_srcdir}/libutil++ -I ${top_srcdir}/libutil @OP_CPPFLAGS@
> AM_CXXFLAGS = @OP_CXXFLAGS@
>
> noinst_LIBRARIES = libopt++.a
> diff --git a/libpp/Makefile.am b/libpp/Makefile.am
> index 3244d98..d3fcbdd 100644
> --- a/libpp/Makefile.am
> +++ b/libpp/Makefile.am
> @@ -5,7 +5,8 @@ AM_CPPFLAGS = \
> -I ${top_srcdir}/libopt++ \
> -I ${top_srcdir}/libutil++ \
> -I ${top_srcdir}/libop++ \
> - -I ${top_srcdir}/libregex
> + -I ${top_srcdir}/libregex \
> + @OP_CPPFLAGS@
>
> AM_CXXFLAGS = @OP_CXXFLAGS@
>
> diff --git a/libregex/Makefile.am b/libregex/Makefile.am
> index 012d307..e29aae3 100644
> --- a/libregex/Makefile.am
> +++ b/libregex/Makefile.am
> @@ -1,6 +1,6 @@
> SUBDIRS = . tests
>
> -AM_CPPFLAGS = -I ${top_srcdir}/libutil++
> +AM_CPPFLAGS = -I ${top_srcdir}/libutil++ @OP_CPPFLAGS@
> AM_CXXFLAGS = @OP_CXXFLAGS@
>
> noinst_LIBRARIES = libop_regex.a
> diff --git a/libutil++/Makefile.am b/libutil++/Makefile.am
> index 66fab2c..cfd8551 100644
> --- a/libutil++/Makefile.am
> +++ b/libutil++/Makefile.am
> @@ -3,7 +3,8 @@ SUBDIRS = . tests
> AM_CPPFLAGS= \
> -I ${top_srcdir}/libutil \
> -I ${top_srcdir}/libop \
> - -I ${top_srcdir}/libpp
> + -I ${top_srcdir}/libpp \
> + @OP_CPPFLAGS@
>
> AM_CXXFLAGS = @OP_CXXFLAGS@
>
> diff --git a/libutil++/tests/Makefile.am b/libutil++/tests/Makefile.am
> index fcc9a7d..51af031 100644
> --- a/libutil++/tests/Makefile.am
> +++ b/libutil++/tests/Makefile.am
> @@ -4,7 +4,7 @@ REALPATH= readlink -f
> SRCDIR := $(shell $(REALPATH) $(topdir)/libutil++/tests/ )
>
> AM_CPPFLAGS = \
> - -I ${top_srcdir}/libutil++ -D SRCDIR="\"$(SRCDIR)/\""
> + -I ${top_srcdir}/libutil++ -D SRCDIR="\"$(SRCDIR)/\"" @OP_CPPFLAGS@
>
> COMMON_LIBS = ../libutil++.a ../../libutil/libutil.a
>
> diff --git a/libutil/Makefile.am b/libutil/Makefile.am
> index cf19f12..87346c8 100644
> --- a/libutil/Makefile.am
> +++ b/libutil/Makefile.am
> @@ -1,6 +1,6 @@
> SUBDIRS = . tests
>
> -AM_CPPFLAGS=-I ${top_srcdir}/libop
> +AM_CPPFLAGS=-I ${top_srcdir}/libop @OP_CPPFLAGS@
> AM_CFLAGS = @OP_CFLAGS@
>
> noinst_LIBRARIES = libutil.a
> diff --git a/libutil/tests/Makefile.am b/libutil/tests/Makefile.am
> index 6fa360e..dfcd6ec 100644
> --- a/libutil/tests/Makefile.am
> +++ b/libutil/tests/Makefile.am
> @@ -1,5 +1,5 @@
> AM_CPPFLAGS = \
> - -I ${top_srcdir}/libutil
> + -I ${top_srcdir}/libutil @OP_CPPFLAGS@
>
> AM_CFLAGS = @OP_CFLAGS@
>
> diff --git a/opjitconv/Makefile.am b/opjitconv/Makefile.am
> index b253507..fe5c00d 100644
> --- a/opjitconv/Makefile.am
> +++ b/opjitconv/Makefile.am
> @@ -1,5 +1,10 @@
> -AM_CPPFLAGS = -I ${top_srcdir}/libopagent -I ${top_srcdir}/libutil -I ${top_srcdir}/daemon
> +AM_CPPFLAGS = -I ${top_srcdir}/libopagent \
> + -I ${top_srcdir}/libutil \
> + -I ${top_srcdir}/daemon \
> + @OP_CPPFLAGS@
> +
> AM_CFLAGS = @OP_CFLAGS@
> +AM_LDFLAGS = @OP_LDFLAGS@
>
> bin_PROGRAMS = opjitconv
>
> diff --git a/pp/Makefile.am b/pp/Makefile.am
> index 1436473..759f2b6 100644
> --- a/pp/Makefile.am
> +++ b/pp/Makefile.am
> @@ -5,9 +5,11 @@ AM_CPPFLAGS = \
> -I ${top_srcdir}/libopt++ \
> -I ${top_srcdir}/libutil++ \
> -I ${top_srcdir}/libregex \
> - -I ${top_srcdir}/libpp
> + -I ${top_srcdir}/libpp \
> + @OP_CPPFLAGS@
>
> AM_CXXFLAGS = @OP_CXXFLAGS@
> +AM_LDFLAGS = @OP_LDFLAGS@
>
> bin_PROGRAMS = opreport opannotate opgprof oparchive
>
> diff --git a/utils/Makefile.am b/utils/Makefile.am
> index 45136e0..1c16b18 100644
> --- a/utils/Makefile.am
> +++ b/utils/Makefile.am
> @@ -1,5 +1,9 @@
> -AM_CPPFLAGS=-I ${top_srcdir}/libop -I ${top_srcdir}/libutil
> +AM_CPPFLAGS=-I ${top_srcdir}/libop \
> + -I ${top_srcdir}/libutil \
> + @OP_CPPFLAGS@
> +
> AM_CFLAGS = @OP_CFLAGS@
> +AM_LDFLAGS = @OP_LDFLAGS@
>
> LIBS=@POPT_LIBS@ @LIBERTY_LIBS@
>
|