• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
12AC_PREREQ(2.13)
13
14AC_INIT(libop/op_config.h)
15AM_INIT_AUTOMAKE(oprofile, 0.9.7cvs)
16AM_CONFIG_HEADER(config.h)
17
18AC_CHECK_DECLS([basename], [], [], [[#include <libgen.h>]])
19AC_PROG_RANLIB
20AC_PROG_LIBTOOL
21
22dnl for the man page
23DATE="`date '+%a %d %B %Y'`"
24AC_SUBST(DATE)
25
26dnl needed for module build
27OPROFILE_DIR=`pwd`
28AC_SUBST(OPROFILE_DIR)
29
30# this needs to come before --with-gcc so we link with binutil's version
31# of libiberty ... sigh
32AC_ARG_WITH(binutils,
33[  --with-binutils=dir		Path to binutils installation to use], BINUTILSDIR=$withval)
34
35if 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"
52fi
53
54AC_ARG_WITH(gcc,
55[  --with-gcc=dir		Path to GCC installation to use], GCCDIR=$withval)
56
57if test "$GCCDIR" != ""; then
58	CC="$GCCDIR/bin/gcc"
59	CXX="$GCCDIR/bin/g++"
60	LDFLAGS="$LDFLAGS -L$GCCDIR/lib -Xlinker -R -Xlinker $GCCDIR/lib"
61fi
62
63AC_PROG_CC
64AC_PROG_CPP
65AC_PROG_CXX
66AC_CHECK_PROG(LD,ld,ld,)
67test "$LD" || AC_ERROR(ld not found)
68
69AX_FIND_KERNEL
70
71if test "$OPROFILE_26" = "no"; then
72	AX_CONFIG_MODULE
73fi
74
75AC_ARG_WITH(module-dir,
76[  --with-module-dir=dir        Path to module installation directory], MODINSTALLDIR=$withval)
77AC_SUBST(MODINSTALLDIR)
78
79AC_ARG_WITH(java,
80[  --with-java=java-home        Path to Java home directory], JAVA_HOMEDIR=$withval)
81AC_SUBST(JAVA_HOMEDIR)
82
83if 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",)
86fi
87
88AM_CONDITIONAL(BUILD_JVMTI_AGENT, test -n "$JVMTI_H_EXISTS")
89AM_CONDITIONAL(BUILD_JVMPI_AGENT, test -n "$JVMPI_H_EXISTS")
90
91AX_MALLOC_ATTRIBUTE
92AX_BUILTIN_EXPECT
93
94AC_SUBST(EXTRA_CFLAGS_MODULE)
95
96topdir=`pwd`
97AC_SUBST(topdir)
98
99AX_EXTRA_DIRS
100
101ORIG_SAVE_LIBS="$LIBS"
102
103dnl advanced glibc features which we need but may not be present
104AC_CHECK_FUNCS(sched_setaffinity perfmonctl)
105
106AC_CHECK_LIB(popt, poptGetContext,, AC_MSG_ERROR([popt library not found]))
107AX_BINUTILS
108AX_CELL_SPU
109
110# C++ tests
111
112AC_LANG_CPLUSPLUS
113
114AX_POPT_CONST
115AX_CHECK_SSTREAM
116
117dnl bfd.h pre 1998 check only for gnu 2.xx series, so gcc 3.0 can't compile it
118AC_MSG_CHECKING([whether bfd defines bool])
119AC_TRY_COMPILE([#include <bfd.h>], [],
120AC_MSG_RESULT([no]);,
121AC_MSG_RESULT([yes]); AC_DEFINE(TRUE_FALSE_ALREADY_DEFINED, 1, [whether bfd.h defines bool values]))
122
123dnl smart demangler need to know what are the underlined type for some typedef
124AX_TYPEDEFED_NAME(size_t, "unsigned" "unsigned long", SIZE_T_TYPE)
125AC_SUBST(SIZE_T_TYPE)
126AX_TYPEDEFED_NAME(ptrdiff_t, "int" "long", PTRDIFF_T_TYPE)
127AC_SUBST(PTRDIFF_T_TYPE)
128
129AC_PATH_XTRA
130ORIG_X_SAVE_LIBS="$LIBS"
131LIBS="$X_PRE_LIBS $LIBS $X_LIBS -lX11 $X_EXTRA_LIBS"
132X_LIBS="$LIBS"
133AC_SUBST(X_LIBS)
134QT_DO_IT_ALL
135LIBS="$ORIG_X_SAVE_LIBS"
136
137dnl enable pch for c++
138AC_ARG_ENABLE(pch,
139	[  --enable-pch                 enable precompiled header (default is disabled)],
140	enable_pch=$enableval, enable_pch=no)
141if test "$enable_pch" = yes; then
142	AX_CHECK_PRECOMPILED_HEADER(OP_CXXFLAGS)
143fi
144
145AX_CHECK_DOCBOOK
146
147dnl finally restore the original libs setting
148LIBS="$ORIG_SAVE_LIBS"
149LIBERTY_LIBS="-liberty $DL_LIB $INTL_LIB"
150BFD_LIBS="-lbfd -liberty $DL_LIB $INTL_LIB $Z_LIB"
151POPT_LIBS="-lpopt"
152AC_SUBST(LIBERTY_LIBS)
153AC_SUBST(BFD_LIBS)
154AC_SUBST(POPT_LIBS)
155
156# do NOT put tests here, they will fail in the case X is not installed !
157
158AM_CONDITIONAL(have_qt, test -n "$QT_LIB")
159
160AX_CFLAGS_OPTION(OP_CFLAGS,[-W])
161AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-W])
162AX_CFLAGS_OPTION(OP_CFLAGS,[-Wall])
163AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-Wall])
164AX_CFLAGS_OPTION(OP_CFLAGS,[-fno-common])
165AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-fno-common])
166AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-ftemplate-depth-50])
167AX_CFLAGS_OPTION(OP_CFLAGS,[-Wdeclaration-after-statement])
168
169dnl enable option to use GCC test coverage
170AC_ARG_ENABLE(gcov,
171	[  --enable-gcov                enable option for gcov coverage testing (default is disabled)],
172	enable_gcov=$enableval, enable_gcov=no)
173if 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])
178fi
179
180AC_ARG_ENABLE(werror,
181	[  --disable-werror            disable -Werror flag (default is enabled for non-release)],
182        enable_werror=$enableval, enable_werror=yes)
183if 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
189fi
190
191AC_ARG_ENABLE(optimization,
192	[  --disable-optimization      disable optimization flags (default is enabled)],
193	enable_optimization=$enableval, enable_optimisation=yes)
194if test "$enable_optimization" = "no"; then
195	CFLAGS=`echo $CFLAGS | sed 's/-O2//g'`
196	CXXFLAGS=`echo $CXXFLAGS | sed 's/-O2//g'`
197fi
198
199AC_ARG_ENABLE(account-check,
200	[  --disable-account-check     disable account check (default is enabled)],
201	enable_account_check=$enableval, enable_account_check=yes)
202
203AM_CONDITIONAL(CHECK_ACCOUNT, test "x$enable_account_check" = "xyes")
204
205AC_SUBST(OP_CFLAGS)
206AC_SUBST(OP_CXXFLAGS)
207
208# fixups for config.h
209if test "$prefix" = "NONE"; then
210	my_op_prefix="$ac_default_prefix"
211else
212	my_op_prefix="$prefix"
213fi
214my_op_datadir="$my_op_prefix/share"
215
216if test "$exec_prefix" = "NONE"; then
217	my_op_exec_prefix="$my_op_prefix"
218else
219	my_op_exec_prefix="$exec_prefix"
220fi
221my_op_bindir="$my_op_exec_prefix/bin"
222
223OP_DATADIR=`eval echo "$my_op_datadir/$PACKAGE/"`
224AC_DEFINE_UNQUOTED(OP_DATADIR, "$OP_DATADIR", [package data directory])
225OP_BINDIR=`eval echo "$my_op_bindir/"`
226AC_DEFINE_UNQUOTED(OP_BINDIR, "$OP_BINDIR", [package binary directory])
227OP_DOCDIR=`eval echo "${my_op_prefix}/share/doc/$PACKAGE/"`
228AC_SUBST(OP_DOCDIR)
229
230AC_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
275AX_COPY_IF_CHANGE(doc/xsl/catalog-1.xml, doc/xsl/catalog.xml)
276
277if test -z "$QT_LIB"; then
278	echo "Warning: a working Qt not found; no GUI will be built"
279fi
280
281if ! test "x$enable_account_check" = "xyes"; then
282	:
283elif 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
300fi
301
302