configure.ac 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. dnl Process this file with autoconf to produce a configure script.
  2. dnl
  3. dnl Copyright (C) 2021 Free Software Foundation, Inc.
  4. dnl
  5. dnl This file is free software; you can redistribute it and/or modify
  6. dnl it under the terms of the GNU General Public License as published by
  7. dnl the Free Software Foundation; either version 3 of the License, or
  8. dnl (at your option) any later version.
  9. dnl
  10. dnl This program is distributed in the hope that it will be useful,
  11. dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. dnl GNU General Public License for more details.
  14. dnl
  15. dnl You should have received a copy of the GNU General Public License
  16. dnl along with this program; see the file COPYING3. If not see
  17. dnl <http://www.gnu.org/licenses/>.
  18. m4_include([../bfd/version.m4])
  19. m4_include([../config/zlib.m4])
  20. AC_INIT([gprofng], BFD_VERSION)
  21. AC_CANONICAL_TARGET
  22. AM_INIT_AUTOMAKE([subdir-objects])
  23. AM_MAINTAINER_MODE
  24. AC_USE_SYSTEM_EXTENSIONS
  25. AC_PROG_CC
  26. AC_PROG_CXX
  27. AC_PROG_INSTALL
  28. AC_PROG_RANLIB
  29. AM_PROG_AR
  30. AC_DISABLE_SHARED
  31. LT_INIT
  32. GPROFNG_LIBADD="-L../../libiberty -liberty"
  33. if test "$enable_shared" = "yes"; then
  34. GPROFNG_LIBADD="-L../../libiberty/pic -liberty"
  35. fi
  36. AC_SUBST(GPROFNG_LIBADD)
  37. # Figure out what compiler warnings we can enable.
  38. # See config/warnings.m4 for details.
  39. ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
  40. ACX_PROG_CC_WARNING_OPTS([-Wall], [gprofng_cflags])
  41. ACX_PROG_CC_WARNING_OPTS([-Wno-format-truncation], [GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS])
  42. ACX_PROG_CC_WARNING_OPTS([-Wno-switch], [GPROFNG_NO_SWITCH_CFLAGS])
  43. gprofng_cppflags="-U_ASM"
  44. build_collector=
  45. build_src=
  46. # This is annoying: it means we have to pass --enable-shared explicitly to
  47. # get gprofng, while the configure default is supposed to be that shared libs
  48. # are on by default. But as long as libiberty has code like this, so must
  49. # we...
  50. case "${target}" in
  51. x86_64-*-linux*)
  52. build_src=true
  53. build_collector=true
  54. ;;
  55. i?86-*-linux*)
  56. build_collector=true
  57. build_collector=true
  58. ;;
  59. aarch64-*-linux*)
  60. build_src=true
  61. build_collector=true
  62. ;;
  63. esac
  64. AC_ARG_ENABLE(gprofng-tools,
  65. AS_HELP_STRING([--disable-gprofng-tools], [do not build gprofng/src directory]),
  66. build_src=$enableval)
  67. AM_CONDITIONAL([BUILD_COLLECTOR], [test x$build_collector = xtrue])
  68. AM_CONDITIONAL([BUILD_SRC], [test x$build_src = xtrue])
  69. run_tests=false
  70. if test x$build_collector = xtrue; then
  71. AC_CONFIG_SUBDIRS([libcollector])
  72. if test x${host} = x${target}; then
  73. run_tests=true
  74. fi
  75. fi
  76. AM_CONDITIONAL([RUN_TESTS], [test x$run_tests = xtrue])
  77. AX_PTHREAD
  78. # Specify a location for JDK
  79. enable_gprofng_jp=
  80. jdk_inc=
  81. AC_ARG_WITH(jdk,
  82. [AS_HELP_STRING([--with-jdk=PATH],
  83. [specify prefix directory for installed JDK.])])
  84. if test "x$with_jdk" != x; then
  85. jdk_inc="-I$with_jdk/include -I$with_jdk/include/linux"
  86. enable_gprofng_jp=yes
  87. else
  88. AC_PATH_PROG([JAVAC], [javac], [javac])
  89. if test -f $JAVAC; then
  90. x=`readlink -f $JAVAC`
  91. x=`dirname $x`
  92. x=`dirname $x`
  93. if ! test -f $x/include/jni.h; then
  94. x=`dirname $x`
  95. fi
  96. if test -f $x/include/jni.h; then
  97. jdk_inc="-I$x/include -I$x/include/linux"
  98. enable_gprofng_jp=yes
  99. fi
  100. fi
  101. fi
  102. if test "x$enable_gprofng_jp" = x; then
  103. AC_PATH_PROG([JAVA], [java], [java])
  104. if test -f $JAVA; then
  105. x=`readlink -f $JAVA`
  106. x=`dirname $x`
  107. x=`dirname $x`
  108. if ! test -f $x/include/jni.h; then
  109. x=`dirname $x`
  110. fi
  111. if test -f $x/include/jni.h; then
  112. jdk_inc="-I$x/include -I$x/include/linux"
  113. enable_gprofng_jp=yes
  114. fi
  115. fi
  116. fi
  117. if test "x$enable_gprofng_jp" = x; then
  118. AC_CHECK_HEADER([jni.h], [ enable_gprofng_jp=yes ], [], [] )
  119. fi
  120. GPROFNG_BROKEN_JAVAC=no
  121. if test "x$enable_gprofng_jp" = x; then
  122. AC_MSG_WARN([ Cannot find the JDK include directory.
  123. gprofng will be build without support for profiling Java applications.
  124. Use --with-jdk=PATH to specify directory for the installed JDK])
  125. else
  126. AC_DEFINE(GPROFNG_JAVA_PROFILING, 1, [Enable java profiling])
  127. if test "x$JAVAC" != x; then
  128. cat > configtest.java << EOF
  129. class Simple{
  130. public static void main(String args[]){
  131. System.out.println("Hello Java");
  132. }
  133. }
  134. EOF
  135. if AC_TRY_COMMAND($JAVAC conftest.java &AS_MESSAGE_LOG_FD 2>&1); then
  136. GPROFNG_BROKEN_JAVAC=no
  137. else
  138. GPROFNG_BROKEN_JAVAC=yes
  139. fi
  140. rm -f configtest.*
  141. fi
  142. fi
  143. AC_SUBST(GPROFNG_BROKEN_JAVAC)
  144. AC_SUBST(jdk_inc)
  145. DEBUG=
  146. GCC_ENABLE([gprofng-debug], [no], [], [Enable debugging output])
  147. if test "${enable_gprofng_debug}" = yes; then
  148. AC_DEFINE(DEBUG, 1, [Enable debugging output.])
  149. fi
  150. # Check if linker supports --as-needed and --no-as-needed options.
  151. AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
  152. [bfd_cv_ld_as_needed=no
  153. if $LD --help 2>/dev/null | grep as-needed > /dev/null; then
  154. bfd_cv_ld_as_needed=yes
  155. fi
  156. ])
  157. no_as_needed=
  158. if test x"$bfd_cv_ld_as_needed" = xyes; then
  159. no_as_needed='-Wl,--no-as-needed'
  160. fi
  161. AC_PATH_PROG([EXPECT], [expect])
  162. AC_CACHE_CHECK([for Tcl supporting try/catch], [ac_cv_libctf_tcl_try],
  163. [ac_cv_libctf_tcl_try=`if test -z $EXPECT; then echo no; else $EXPECT << EOF
  164. if @<:@llength @<:@info commands try@:>@@:>@ then { puts yes } else { puts no }
  165. EOF
  166. fi`
  167. ])
  168. AM_CONDITIONAL(TCL_TRY, test "${ac_cv_libctf_tcl_try}" = yes)
  169. AM_ZLIB
  170. # Generate manpages, if possible.
  171. if test $cross_compiling = no; then
  172. AM_MISSING_PROG(HELP2MAN, help2man)
  173. build_man=true
  174. else
  175. build_man=false
  176. fi
  177. AM_CONDITIONAL([BUILD_MAN], [test x$build_man = xtrue])
  178. AC_SUBST(LD_NO_AS_NEEDED, [${no_as_needed}])
  179. AC_SUBST(GPROFNG_CFLAGS, [${gprofng_cflags}])
  180. AC_SUBST(GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS)
  181. AC_SUBST(GPROFNG_NO_SWITCH_CFLAGS)
  182. AC_SUBST(GPROFNG_CPPFLAGS, [${gprofng_cppflags}])
  183. AC_CHECK_DECLS([basename])
  184. AC_CHECK_FUNCS(clock_gettime strsignal)
  185. clock_gettime_link=
  186. # At least for glibc, clock_gettime is in librt. But don't
  187. # pull that in if it still doesn't give us the function we want. This
  188. # test is copied from libgomp, and modified to not link in -lrt as
  189. # we're using this for test timing only.
  190. if test "$ac_cv_func_clock_gettime" = no; then
  191. AC_CHECK_LIB(rt, clock_gettime,
  192. [CLOCK_GETTIME_LINK=-lrt
  193. AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
  194. [Define to 1 if you have the `clock_gettime' function.])])
  195. fi
  196. AC_SUBST(CLOCK_GETTIME_LINK)
  197. AC_SUBST(BUILD_SUBDIRS)
  198. AC_CONFIG_FILES([Makefile src/Makefile gp-display-html/Makefile doc/Makefile])
  199. AC_CONFIG_HEADERS([config.h:common/config.h.in])
  200. AC_OUTPUT