Mike Dodd | 8cfa702 | 2010-11-17 11:12:26 -0800 | [diff] [blame] | 1 | # Autoconf script for oprofile |
| 2 | # |
| 3 | # Copyright 1999 Olaf Titz <olaf@bigred.inka.de> |
| 4 | # Adapted for oprofile |
| 5 | # |
| 6 | # This program is free software; you can redistribute it and/or |
| 7 | # modify it under the terms of the GNU General Public License |
| 8 | # as published by the Free Software Foundation; either version |
| 9 | # 2 of the License, or (at your option) any later version. |
| 10 | # |
| 11 | |
| 12 | AC_PREREQ(2.13) |
| 13 | |
| 14 | AC_INIT(libop/op_config.h) |
| 15 | AM_INIT_AUTOMAKE(oprofile, 0.9.6) |
| 16 | AM_CONFIG_HEADER(config.h) |
| 17 | |
| 18 | AC_CHECK_DECLS([basename], [], [], [[#include <libgen.h>]]) |
| 19 | AC_PROG_RANLIB |
| 20 | AC_PROG_LIBTOOL |
| 21 | |
| 22 | dnl for the man page |
| 23 | DATE="`date '+%a %d %B %Y'`" |
| 24 | AC_SUBST(DATE) |
| 25 | |
| 26 | dnl needed for module build |
| 27 | OPROFILE_DIR=`pwd` |
| 28 | AC_SUBST(OPROFILE_DIR) |
| 29 | |
| 30 | # this needs to come before --with-gcc so we link with binutil's version |
| 31 | # of libiberty ... sigh |
| 32 | AC_ARG_WITH(binutils, |
| 33 | [ --with-binutils=dir Path to binutils installation to use], BINUTILSDIR=$withval) |
| 34 | |
| 35 | if test "$BINUTILSDIR" != ""; then |
| 36 | LD="$BINUTILSDIR/ld" |
| 37 | if test "$CFLAGS" = ""; then |
| 38 | CFLAGS="-g -O2" |
| 39 | fi |
| 40 | if test "$CXXFLAGS" = ""; then |
| 41 | CXXFLAGS="-g -O2" |
| 42 | fi |
| 43 | CFLAGS="$CFLAGS -I$BINUTILSDIR/include" |
| 44 | CXXFLAGS="$CXXFLAGS -I$BINUTILSDIR/include" |
| 45 | AC_ARG_WITH(binutils-libname, |
| 46 | [ --with-binutils-libname Lib dir name under binutils installation; @<:@lib@:>@]], |
| 47 | BINUTILSLIB=$withval) |
| 48 | if test "$BINUTILSLIB" = ""; then |
| 49 | BINUTILSLIB="lib" |
| 50 | fi |
| 51 | LDFLAGS="$LDFLAGS -L$BINUTILSDIR/$BINUTILSLIB -Xlinker -R -Xlinker $BINUTILSDIR/$BINUTILSLIB" |
| 52 | fi |
| 53 | |
| 54 | AC_ARG_WITH(gcc, |
| 55 | [ --with-gcc=dir Path to GCC installation to use], GCCDIR=$withval) |
| 56 | |
| 57 | if test "$GCCDIR" != ""; then |
| 58 | CC="$GCCDIR/bin/gcc" |
| 59 | CXX="$GCCDIR/bin/g++" |
| 60 | LDFLAGS="$LDFLAGS -L$GCCDIR/lib -Xlinker -R -Xlinker $GCCDIR/lib" |
| 61 | fi |
| 62 | |
| 63 | AC_PROG_CC |
| 64 | AC_PROG_CPP |
| 65 | AC_PROG_CXX |
| 66 | AC_CHECK_PROG(LD,ld,ld,) |
| 67 | test "$LD" || AC_ERROR(ld not found) |
| 68 | |
| 69 | AX_FIND_KERNEL |
| 70 | |
| 71 | if test "$OPROFILE_26" = "no"; then |
| 72 | AX_CONFIG_MODULE |
| 73 | fi |
| 74 | |
| 75 | AC_ARG_WITH(module-dir, |
| 76 | [ --with-module-dir=dir Path to module installation directory], MODINSTALLDIR=$withval) |
| 77 | AC_SUBST(MODINSTALLDIR) |
| 78 | |
| 79 | AC_ARG_WITH(java, |
| 80 | [ --with-java=java-home Path to Java home directory], JAVA_HOMEDIR=$withval) |
| 81 | AC_SUBST(JAVA_HOMEDIR) |
| 82 | |
| 83 | if test -n "$JAVA_HOMEDIR"; then |
| 84 | AC_CHECK_FILE("$JAVA_HOMEDIR/include/jvmti.h",JVMTI_H_EXISTS="yes",) |
| 85 | AC_CHECK_FILE("$JAVA_HOMEDIR/include/jvmpi.h",JVMPI_H_EXISTS="yes",) |
| 86 | fi |
| 87 | |
| 88 | AM_CONDITIONAL(BUILD_JVMTI_AGENT, test -n "$JVMTI_H_EXISTS") |
| 89 | AM_CONDITIONAL(BUILD_JVMPI_AGENT, test -n "$JVMPI_H_EXISTS") |
| 90 | |
| 91 | AX_MALLOC_ATTRIBUTE |
| 92 | AX_BUILTIN_EXPECT |
| 93 | |
| 94 | AC_SUBST(EXTRA_CFLAGS_MODULE) |
| 95 | |
| 96 | topdir=`pwd` |
| 97 | AC_SUBST(topdir) |
| 98 | |
| 99 | AX_EXTRA_DIRS |
| 100 | |
| 101 | ORIG_SAVE_LIBS="$LIBS" |
| 102 | |
| 103 | dnl advanced glibc features which we need but may not be present |
| 104 | AC_CHECK_FUNCS(sched_setaffinity perfmonctl) |
| 105 | |
| 106 | AC_CHECK_LIB(popt, poptGetContext,, AC_MSG_ERROR([popt library not found])) |
| 107 | AX_BINUTILS |
| 108 | AX_CELL_SPU |
| 109 | |
| 110 | # C++ tests |
| 111 | |
| 112 | AC_LANG_CPLUSPLUS |
| 113 | |
| 114 | AX_POPT_CONST |
| 115 | AX_CHECK_SSTREAM |
| 116 | |
| 117 | dnl bfd.h pre 1998 check only for gnu 2.xx series, so gcc 3.0 can't compile it |
| 118 | AC_MSG_CHECKING([whether bfd defines bool]) |
| 119 | AC_TRY_COMPILE([#include <bfd.h>], [], |
| 120 | AC_MSG_RESULT([no]);, |
| 121 | AC_MSG_RESULT([yes]); AC_DEFINE(TRUE_FALSE_ALREADY_DEFINED, 1, [whether bfd.h defines bool values])) |
| 122 | |
| 123 | dnl smart demangler need to know what are the underlined type for some typedef |
| 124 | AX_TYPEDEFED_NAME(size_t, "unsigned" "unsigned long", SIZE_T_TYPE) |
| 125 | AC_SUBST(SIZE_T_TYPE) |
| 126 | AX_TYPEDEFED_NAME(ptrdiff_t, "int" "long", PTRDIFF_T_TYPE) |
| 127 | AC_SUBST(PTRDIFF_T_TYPE) |
| 128 | |
| 129 | AC_PATH_XTRA |
| 130 | ORIG_X_SAVE_LIBS="$LIBS" |
| 131 | LIBS="$X_PRE_LIBS $LIBS $X_LIBS -lX11 $X_EXTRA_LIBS" |
| 132 | X_LIBS="$LIBS" |
| 133 | AC_SUBST(X_LIBS) |
| 134 | QT_DO_IT_ALL |
| 135 | LIBS="$ORIG_X_SAVE_LIBS" |
| 136 | |
| 137 | dnl enable pch for c++ |
| 138 | AC_ARG_ENABLE(pch, |
| 139 | [ --enable-pch enable precompiled header (default is disabled)], |
| 140 | enable_pch=$enableval, enable_pch=no) |
| 141 | if test "$enable_pch" = yes; then |
| 142 | AX_CHECK_PRECOMPILED_HEADER(OP_CXXFLAGS) |
| 143 | fi |
| 144 | |
| 145 | AX_CHECK_DOCBOOK |
| 146 | |
| 147 | dnl finally restore the original libs setting |
| 148 | LIBS="$ORIG_SAVE_LIBS" |
| 149 | LIBERTY_LIBS="-liberty $DL_LIB $INTL_LIB" |
| 150 | BFD_LIBS="-lbfd -liberty $DL_LIB $INTL_LIB $Z_LIB" |
| 151 | POPT_LIBS="-lpopt" |
| 152 | AC_SUBST(LIBERTY_LIBS) |
| 153 | AC_SUBST(BFD_LIBS) |
| 154 | AC_SUBST(POPT_LIBS) |
| 155 | |
| 156 | # do NOT put tests here, they will fail in the case X is not installed ! |
| 157 | |
| 158 | AM_CONDITIONAL(have_qt, test -n "$QT_LIB") |
| 159 | |
| 160 | AX_CFLAGS_OPTION(OP_CFLAGS,[-W]) |
| 161 | AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-W]) |
| 162 | AX_CFLAGS_OPTION(OP_CFLAGS,[-Wall]) |
| 163 | AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-Wall]) |
| 164 | AX_CFLAGS_OPTION(OP_CFLAGS,[-fno-common]) |
| 165 | AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-fno-common]) |
| 166 | AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-ftemplate-depth-50]) |
| 167 | AX_CFLAGS_OPTION(OP_CFLAGS,[-Wdeclaration-after-statement]) |
| 168 | |
| 169 | dnl enable option to use GCC test coverage |
| 170 | AC_ARG_ENABLE(gcov, |
| 171 | [ --enable-gcov enable option for gcov coverage testing (default is disabled)], |
| 172 | enable_gcov=$enableval, enable_gcov=no) |
| 173 | if test "$enable_gcov" = yes; then |
| 174 | AX_CFLAGS_OPTION(OP_CFLAGS,[-fprofile-arcs]) |
| 175 | AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-fprofile-arcs]) |
| 176 | AX_CFLAGS_OPTION(OP_CFLAGS,[-ftest-coverage]) |
| 177 | AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-ftest-coverage]) |
| 178 | fi |
| 179 | |
| 180 | AC_ARG_ENABLE(werror, |
| 181 | [ --disable-werror disable -Werror flag (default is enabled for non-release)], |
| 182 | enable_werror=$enableval, enable_werror=yes) |
| 183 | if test "$enable_werror" = yes; then |
| 184 | # enable -Werror for non-release versions. |
| 185 | if echo "$VERSION" | grep cvs >/dev/null; then |
| 186 | AX_CFLAGS_OPTION(OP_CFLAGS,[-Werror]) |
| 187 | AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-Werror]) |
| 188 | fi |
| 189 | fi |
| 190 | |
| 191 | AC_ARG_ENABLE(optimization, |
| 192 | [ --disable-optimization disable optimization flags (default is enabled)], |
| 193 | enable_optimization=$enableval, enable_optimisation=yes) |
| 194 | if test "$enable_optimization" = "no"; then |
| 195 | CFLAGS=`echo $CFLAGS | sed 's/-O2//g'` |
| 196 | CXXFLAGS=`echo $CXXFLAGS | sed 's/-O2//g'` |
| 197 | fi |
| 198 | |
| 199 | AC_SUBST(OP_CFLAGS) |
| 200 | AC_SUBST(OP_CXXFLAGS) |
| 201 | |
| 202 | # fixups for config.h |
| 203 | if test "$prefix" = "NONE"; then |
| 204 | my_op_prefix="$ac_default_prefix" |
| 205 | else |
| 206 | my_op_prefix="$prefix" |
| 207 | fi |
| 208 | my_op_datadir="$my_op_prefix/share" |
| 209 | |
| 210 | if test "$exec_prefix" = "NONE"; then |
| 211 | my_op_exec_prefix="$my_op_prefix" |
| 212 | else |
| 213 | my_op_exec_prefix="$exec_prefix" |
| 214 | fi |
| 215 | my_op_bindir="$my_op_exec_prefix/bin" |
| 216 | |
| 217 | OP_DATADIR=`eval echo "$my_op_datadir/$PACKAGE/"` |
| 218 | AC_DEFINE_UNQUOTED(OP_DATADIR, "$OP_DATADIR", [package data directory]) |
| 219 | OP_BINDIR=`eval echo "$my_op_bindir/"` |
| 220 | AC_DEFINE_UNQUOTED(OP_BINDIR, "$OP_BINDIR", [package binary directory]) |
| 221 | OP_DOCDIR=`eval echo "${my_op_prefix}/share/doc/$PACKAGE/"` |
| 222 | AC_SUBST(OP_DOCDIR) |
| 223 | |
| 224 | AC_OUTPUT(Makefile \ |
| 225 | m4/Makefile \ |
| 226 | libutil/Makefile \ |
| 227 | libutil/tests/Makefile \ |
| 228 | libutil++/Makefile \ |
| 229 | libutil++/tests/Makefile \ |
| 230 | libop/Makefile \ |
| 231 | libop/tests/Makefile \ |
| 232 | libopagent/Makefile \ |
| 233 | libopt++/Makefile \ |
| 234 | libdb/Makefile \ |
| 235 | libdb/tests/Makefile \ |
| 236 | libabi/Makefile \ |
| 237 | libabi/tests/Makefile \ |
| 238 | libregex/Makefile \ |
| 239 | libregex/tests/Makefile \ |
| 240 | libregex/stl.pat \ |
| 241 | libregex/tests/mangled-name \ |
| 242 | daemon/Makefile \ |
| 243 | daemon/liblegacy/Makefile \ |
| 244 | events/Makefile \ |
| 245 | utils/Makefile \ |
| 246 | doc/Makefile \ |
| 247 | doc/xsl/catalog-1.xml \ |
| 248 | doc/oprofile.1 \ |
| 249 | doc/opcontrol.1 \ |
| 250 | doc/ophelp.1 \ |
| 251 | doc/opreport.1 \ |
| 252 | doc/opannotate.1 \ |
| 253 | doc/opgprof.1 \ |
| 254 | doc/oparchive.1 \ |
| 255 | doc/opimport.1 \ |
| 256 | doc/srcdoc/Doxyfile \ |
| 257 | libpp/Makefile \ |
| 258 | opjitconv/Makefile \ |
| 259 | pp/Makefile \ |
| 260 | gui/Makefile \ |
| 261 | gui/ui/Makefile \ |
| 262 | module/Makefile \ |
| 263 | module/x86/Makefile \ |
| 264 | module/ia64/Makefile \ |
| 265 | agents/Makefile \ |
| 266 | agents/jvmti/Makefile \ |
| 267 | agents/jvmpi/Makefile) |
| 268 | |
| 269 | AX_COPY_IF_CHANGE(doc/xsl/catalog-1.xml, doc/xsl/catalog.xml) |
| 270 | |
| 271 | if test -z "$QT_LIB"; then |
| 272 | echo "Warning: a working Qt not found; no GUI will be built" |
| 273 | fi |
| 274 | |
| 275 | if test "`getent passwd oprofile 2>/dev/null`" == "" || \ |
| 276 | test "`getent group oprofile 2>/dev/null`" == ""; then |
| 277 | if test `id -u` != "0"; then |
| 278 | echo "Warning: The user account 'oprofile:oprofile' does not exist on the system." |
| 279 | echo " To profile JITed code, this special user account must exist." |
| 280 | echo " Please ask your system administrator to add the following user and group:" |
| 281 | echo " user name : 'oprofile'" |
| 282 | echo " group name: 'oprofile'" |
| 283 | echo " The 'oprofile' group must be the default group for the 'oprofile' user." |
| 284 | else |
| 285 | echo "Warning: The user account 'oprofile:oprofile' does not exist on the system." |
| 286 | echo " To profile JITed code, this special user account must exist." |
| 287 | echo " Please add the following user and group:" |
| 288 | echo " user name : 'oprofile'" |
| 289 | echo " group name: 'oprofile'" |
| 290 | echo " The 'oprofile' group must be the default group for the 'oprofile' user." |
| 291 | fi |
| 292 | fi |
| 293 | |