aboutsummaryrefslogtreecommitdiff
path: root/gprofng/configure.ac
blob: 550dd80d3315668db4552892b8f5f1e4d549ed45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
dnl Process this file with autoconf to produce a configure script.
dnl
dnl   Copyright (C) 2021 Free Software Foundation, Inc.
dnl
dnl This file is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 3 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; see the file COPYING3.  If not see
dnl <http://www.gnu.org/licenses/>.

m4_include([../bfd/version.m4])
m4_include([../config/zlib.m4])
AC_INIT([gprofng], BFD_VERSION)
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([subdir-objects])
AM_MAINTAINER_MODE

AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_RANLIB
AM_PROG_AR

AC_DISABLE_SHARED
LT_INIT

GPROFNG_LIBADD="-L../../libiberty -liberty"
if test "$enable_shared" = "yes"; then
  GPROFNG_LIBADD="-L../../libiberty/pic -liberty"
fi
AC_SUBST(GPROFNG_LIBADD)

# Figure out what compiler warnings we can enable.
# See config/warnings.m4 for details.

ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
ACX_PROG_CC_WARNING_OPTS([-Wall], [gprofng_cflags])
ACX_PROG_CC_WARNING_OPTS([-Wno-format-truncation], [GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS])
ACX_PROG_CC_WARNING_OPTS([-Wno-switch], [GPROFNG_NO_SWITCH_CFLAGS])
gprofng_cppflags="-U_ASM"
build_collector=
build_src=

# This is annoying: it means we have to pass --enable-shared explicitly to
# get gprofng, while the configure default is supposed to be that shared libs
# are on by default.  But as long as libiberty has code like this, so must
# we...

  case "${target}" in
    x86_64-*-linux*)
      build_src=true
      build_collector=true
      ;;
    i?86-*-linux*)
      build_collector=true
      build_collector=true
      ;;
    aarch64-*-linux*)
      build_src=true
      build_collector=true
      ;;
  esac
  AC_ARG_ENABLE(gprofng-tools,
    AS_HELP_STRING([--disable-gprofng-tools], [do not build gprofng/src directory]),
    build_src=$enableval)

AM_CONDITIONAL([BUILD_COLLECTOR], [test x$build_collector = xtrue])
AM_CONDITIONAL([BUILD_SRC], [test x$build_src = xtrue])

run_tests=false
if test x$build_collector = xtrue; then
  AC_CONFIG_SUBDIRS([libcollector])
  if test x${host} = x${target}; then
    run_tests=true
  fi
fi
AM_CONDITIONAL([RUN_TESTS], [test x$run_tests = xtrue])
AX_PTHREAD

# Specify a location for JDK
enable_gprofng_jp=
jdk_inc=
AC_ARG_WITH(jdk,
[AS_HELP_STRING([--with-jdk=PATH],
		[specify prefix directory for installed JDK.])])

if test "x$with_jdk" != x; then
  jdk_inc="-I$with_jdk/include -I$with_jdk/include/linux"
  enable_gprofng_jp=yes
else
  AC_PATH_PROG([JAVAC], [javac], [javac])
  if test -f $JAVAC; then
    x=`readlink -f $JAVAC`
    x=`dirname $x`
    x=`dirname $x`
    if ! test -f $x/include/jni.h; then
      x=`dirname $x`
    fi
    if test -f $x/include/jni.h; then
      jdk_inc="-I$x/include -I$x/include/linux"
      enable_gprofng_jp=yes
    fi
  fi
fi
if test "x$enable_gprofng_jp" = x; then
  AC_PATH_PROG([JAVA], [java], [java])
  if test -f $JAVA; then
    x=`readlink -f $JAVA`
    x=`dirname $x`
    x=`dirname $x`
    if ! test -f $x/include/jni.h; then
      x=`dirname $x`
    fi
    if test -f $x/include/jni.h; then
      jdk_inc="-I$x/include -I$x/include/linux"
      enable_gprofng_jp=yes
    fi
  fi
fi
if test "x$enable_gprofng_jp" = x; then
  AC_CHECK_HEADER([jni.h], [ enable_gprofng_jp=yes ], [], [] )
fi
GPROFNG_BROKEN_JAVAC=no
if test "x$enable_gprofng_jp" = x; then
    AC_MSG_WARN([ Cannot find the JDK include directory.
      gprofng will be build without support for profiling Java applications.
      Use --with-jdk=PATH to specify directory for the installed JDK])
else
    AC_DEFINE(GPROFNG_JAVA_PROFILING, 1, [Enable java profiling])
    if test "x$JAVAC" != x; then
      cat > configtest.java << EOF
class Simple{
  public static void main(String args[]){
    System.out.println("Hello Java");
  }
}
EOF
      if AC_TRY_COMMAND($JAVAC conftest.java &AS_MESSAGE_LOG_FD 2>&1); then
	GPROFNG_BROKEN_JAVAC=no
      else
	GPROFNG_BROKEN_JAVAC=yes
      fi
      rm -f configtest.*
    fi
fi
AC_SUBST(GPROFNG_BROKEN_JAVAC)
AC_SUBST(jdk_inc)

DEBUG=
GCC_ENABLE([gprofng-debug], [no], [], [Enable debugging output])
if test "${enable_gprofng_debug}" = yes; then
    AC_DEFINE(DEBUG, 1, [Enable debugging output.])
fi

# Check if linker supports --as-needed and --no-as-needed options.
AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
	[bfd_cv_ld_as_needed=no
	if $LD --help 2>/dev/null | grep as-needed > /dev/null; then
		bfd_cv_ld_as_needed=yes
	fi
	])

no_as_needed=
if test x"$bfd_cv_ld_as_needed" = xyes; then
    no_as_needed='-Wl,--no-as-needed'
fi

AC_PATH_PROG([EXPECT], [expect])
AC_CACHE_CHECK([for Tcl supporting try/catch], [ac_cv_libctf_tcl_try],
  [ac_cv_libctf_tcl_try=`if test -z $EXPECT; then echo no; else $EXPECT << EOF
if @<:@llength @<:@info commands try@:>@@:>@ then { puts yes } else { puts no }
EOF
fi`
])
AM_CONDITIONAL(TCL_TRY, test "${ac_cv_libctf_tcl_try}" = yes)

AM_ZLIB

# Generate manpages, if possible.
if test $cross_compiling = no; then
  AM_MISSING_PROG(HELP2MAN, help2man)
  build_man=true
else
  build_man=false
fi
AM_CONDITIONAL([BUILD_MAN], [test x$build_man = xtrue])

AC_SUBST(LD_NO_AS_NEEDED, [${no_as_needed}])
AC_SUBST(GPROFNG_CFLAGS, [${gprofng_cflags}])
AC_SUBST(GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS)
AC_SUBST(GPROFNG_NO_SWITCH_CFLAGS)
AC_SUBST(GPROFNG_CPPFLAGS, [${gprofng_cppflags}])

AC_CHECK_DECLS([basename])
AC_CHECK_FUNCS(clock_gettime strsignal)

clock_gettime_link=
# At least for glibc, clock_gettime is in librt.  But don't
# pull that in if it still doesn't give us the function we want.  This
# test is copied from libgomp, and modified to not link in -lrt as
# we're using this for test timing only.
if test "$ac_cv_func_clock_gettime" = no; then
  AC_CHECK_LIB(rt, clock_gettime,
    [CLOCK_GETTIME_LINK=-lrt
     AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
	       [Define to 1 if you have the `clock_gettime' function.])])
fi
AC_SUBST(CLOCK_GETTIME_LINK)

AC_SUBST(BUILD_SUBDIRS)

AC_CONFIG_FILES([Makefile src/Makefile gp-display-html/Makefile doc/Makefile])
AC_CONFIG_HEADERS([config.h:common/config.h.in])

AC_OUTPUT