1 # Autoconf script for oprofile 2 # 3 # Copyright 1999 Olaf Titz <olaf (a] 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.7cvs) 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_ARG_ENABLE(account-check, 200 [ --disable-account-check disable account check (default is enabled)], 201 enable_account_check=$enableval, enable_account_check=yes) 202 203 AM_CONDITIONAL(CHECK_ACCOUNT, test "x$enable_account_check" = "xyes") 204 205 AC_SUBST(OP_CFLAGS) 206 AC_SUBST(OP_CXXFLAGS) 207 208 # fixups for config.h 209 if test "$prefix" = "NONE"; then 210 my_op_prefix="$ac_default_prefix" 211 else 212 my_op_prefix="$prefix" 213 fi 214 my_op_datadir="$my_op_prefix/share" 215 216 if test "$exec_prefix" = "NONE"; then 217 my_op_exec_prefix="$my_op_prefix" 218 else 219 my_op_exec_prefix="$exec_prefix" 220 fi 221 my_op_bindir="$my_op_exec_prefix/bin" 222 223 OP_DATADIR=`eval echo "$my_op_datadir/$PACKAGE/"` 224 AC_DEFINE_UNQUOTED(OP_DATADIR, "$OP_DATADIR", [package data directory]) 225 OP_BINDIR=`eval echo "$my_op_bindir/"` 226 AC_DEFINE_UNQUOTED(OP_BINDIR, "$OP_BINDIR", [package binary directory]) 227 OP_DOCDIR=`eval echo "${my_op_prefix}/share/doc/$PACKAGE/"` 228 AC_SUBST(OP_DOCDIR) 229 230 AC_OUTPUT(Makefile \ 231 m4/Makefile \ 232 libutil/Makefile \ 233 libutil/tests/Makefile \ 234 libutil++/Makefile \ 235 libutil++/tests/Makefile \ 236 libop/Makefile \ 237 libop/tests/Makefile \ 238 libopagent/Makefile \ 239 libopt++/Makefile \ 240 libdb/Makefile \ 241 libdb/tests/Makefile \ 242 libabi/Makefile \ 243 libabi/tests/Makefile \ 244 libregex/Makefile \ 245 libregex/tests/Makefile \ 246 libregex/stl.pat \ 247 libregex/tests/mangled-name \ 248 daemon/Makefile \ 249 daemon/liblegacy/Makefile \ 250 events/Makefile \ 251 utils/Makefile \ 252 doc/Makefile \ 253 doc/xsl/catalog-1.xml \ 254 doc/oprofile.1 \ 255 doc/opcontrol.1 \ 256 doc/ophelp.1 \ 257 doc/opreport.1 \ 258 doc/opannotate.1 \ 259 doc/opgprof.1 \ 260 doc/oparchive.1 \ 261 doc/opimport.1 \ 262 doc/srcdoc/Doxyfile \ 263 libpp/Makefile \ 264 opjitconv/Makefile \ 265 pp/Makefile \ 266 gui/Makefile \ 267 gui/ui/Makefile \ 268 module/Makefile \ 269 module/x86/Makefile \ 270 module/ia64/Makefile \ 271 agents/Makefile \ 272 agents/jvmti/Makefile \ 273 agents/jvmpi/Makefile) 274 275 AX_COPY_IF_CHANGE(doc/xsl/catalog-1.xml, doc/xsl/catalog.xml) 276 277 if test -z "$QT_LIB"; then 278 echo "Warning: a working Qt not found; no GUI will be built" 279 fi 280 281 if ! test "x$enable_account_check" = "xyes"; then 282 : 283 elif test "`getent passwd oprofile 2>/dev/null`" == "" || \ 284 test "`getent group oprofile 2>/dev/null`" == ""; then 285 if test `id -u` != "0"; then 286 echo "Warning: The user account 'oprofile:oprofile' does not exist on the system." 287 echo " To profile JITed code, this special user account must exist." 288 echo " Please ask your system administrator to add the following user and group:" 289 echo " user name : 'oprofile'" 290 echo " group name: 'oprofile'" 291 echo " The 'oprofile' group must be the default group for the 'oprofile' user." 292 else 293 echo "Warning: The user account 'oprofile:oprofile' does not exist on the system." 294 echo " To profile JITed code, this special user account must exist." 295 echo " Please add the following user and group:" 296 echo " user name : 'oprofile'" 297 echo " group name: 'oprofile'" 298 echo " The 'oprofile' group must be the default group for the 'oprofile' user." 299 fi 300 fi 301 302