source: git/m4/google-perftools.m4 @ 69185ce

fieker-DuValspielwiese
Last change on this file since 69185ce was 69185ce, checked in by Hans Schoenemann <hannes@…>, 3 years ago
update configure stuff
  • Property mode set to 100644
File size: 5.2 KB
Line 
1dnl
2dnl    Copyright 2005-2006 Intel Corporation
3dnl
4dnl    Licensed under the Apache License, Version 2.0 (the "License");
5dnl    you may not use this file except in compliance with the License.
6dnl    You may obtain a copy of the License at
7dnl
8dnl        http://www.apache.org/licenses/LICENSE-2.0
9dnl
10dnl    Unless required by applicable law or agreed to in writing, software
11dnl    distributed under the License is distributed on an "AS IS" BASIS,
12dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13dnl    See the License for the specific language governing permissions and
14dnl    limitations under the License.
15dnl
16
17dnl
18dnl Autoconf support for linking with google's performace code
19dnl
20
21AC_DEFUN([AC_CONFIG_GOOGLE_PERFTOOLS], [
22
23    ac_google_perfdir='no'
24    AC_ARG_WITH(google-perftools,
25        AS_HELP_STRING([--with-google-perftools=DIR],[location of a google perftools installation (default none)]),
26        ac_google_perfdir=$withval)
27
28    AC_ARG_ENABLE(google-profiling,
29                  AS_HELP_STRING([--enable-google-profiling],[compile with google profiling]),
30                  [google_profile=$enableval],
31                  [google_profile=no])
32
33    AC_MSG_CHECKING([whether to compile with google profiling])
34    AC_MSG_RESULT($google_profile)
35
36    GOOGLE_PROFILE_ENABLED=0
37    if test $google_profile = yes ; then
38        if test $ac_google_perfdir = no ; then
39           AC_MSG_ERROR([must specify --with-google-perftools to use google profiling])
40        fi
41        GOOGLE_PROFILE_ENABLED=1
42    fi
43
44    AC_DEFINE_UNQUOTED(GOOGLE_PROFILE_ENABLED, $GOOGLE_PROFILE_ENABLED,
45         [whether google profiling support is enabled])
46
47    dnl
48    dnl First make sure we even want it
49    dnl
50    if test "$ac_google_perfdir" = no; then
51    GOOGLE_PERFTOOLS_ENABLED=0
52    else
53
54    GOOGLE_PERFTOOLS_ENABLED=1
55    AC_DEFINE_UNQUOTED(GOOGLE_PERFTOOLS_ENABLED, 1,
56         [whether google perftools support is enabled])
57
58    dnl
59    dnl Now check if we have a cached value, unless the user specified
60    dnl something explicit with the --with-google-perf= argument, in
61    dnl which case we force it to redo the checks (i.e. ignore the
62    dnl cached values)
63    dnl
64    if test "$ac_google_perfdir" = yes -a \
65            ! "$oasys_cv_path_google_perf_h" = "" ; then
66        echo "checking for google_perf installation... (cached)"
67    else
68        AC_OASYS_FIND_GOOGLE_PERFTOOLS
69    fi
70
71    if test ! $oasys_cv_path_google_perf_h = /usr/include ; then
72        GOOGLE_PERFTOOLS_CFLAGS="-I$oasys_cv_path_google_perf_h"
73    fi
74
75    if test ! $oasys_cv_path_google_perf_lib = /usr/lib ; then
76        GOOGLE_PERFTOOLS_LDFLAGS="-L$oasys_cv_path_google_perf_lib"
77    fi
78
79    GOOGLE_PERFTOOL_LDFLAGS="$GOOGLE_PERFTOOLS_LDFLAGS -Wl,-Bstatic -lprofiler -Wl,-Bdynamic"
80
81    fi # GOOGLE_PERF_ENABLED
82])
83
84AC_DEFUN([AC_OASYS_FIND_GOOGLE_PERFTOOLS], [
85    oasys_cv_path_google_perf_h=
86    oasys_cv_path_google_perf_lib=
87
88    ac_save_CPPFLAGS="$CPPFLAGS"
89    ac_save_LDFLAGS="$LDFLAGS"
90    ac_save_LIBS="$LIBS"
91
92    AC_LANG_PUSH(C++)
93
94    if test "$ac_google_perfdir" = system -o \
95            "$ac_google_perfdir" = yes -o \
96            "$ac_google_perfdir" = "" ;
97    then
98        ac_google_perfincdirs="/usr/local/include \
99                               /usr/local/google-perftools/include"
100        ac_google_perflibdirs="/usr/local/lib \
101                               /usr/local/google-perftools/lib"
102    else
103        ac_google_perfincdirs="$ac_google_perfdir/include"
104        ac_google_perflibdirs="$ac_google_perfdir/lib"
105    fi
106
107    for ac_google_perfincdir in $ac_google_perfincdirs; do
108
109        CPPFLAGS="$ac_save_CPPFLAGS -I$ac_google_perfincdir"
110        LDFLAGS="$ac_save_LDFLAGS"
111        LIBS="$ac_save_LIBS"
112
113        dnl
114        dnl First check the version in the header file. If there's a match,
115        dnl fall through to the other check to make sure it links.
116        dnl If not, then we can break out of the two inner loops.
117        dnl
118        AC_MSG_CHECKING([for google perftools header profiler.h in $ac_google_perfincdir])
119        AC_LINK_IFELSE(
120          [AC_LANG_PROGRAM(
121            [
122                #include <google/profiler.h>
123            ],
124
125            [
126            ])],
127          [
128              AC_MSG_RESULT([yes])
129              oasys_cv_path_google_perf_h=$ac_google_perfincdir
130              break
131          ],
132          [
133              AC_MSG_RESULT([no])
134              continue
135          ])
136    done
137
138    AC_LANG_POP(C++)
139
140    if test x$oasys_cv_path_google_perf_h = x ; then
141        AC_MSG_ERROR([can't find usable google perftools installation])
142    fi
143
144    AC_LANG_PUSH(C++)
145
146    for ac_google_perflibdir in $ac_google_perflibdirs; do
147
148        LDFLAGS="$ac_save_LDFLAGS -L$ac_google_perflibdir"
149        LIBS="$ac_save_LIBS -lprofiler"
150
151        AC_MSG_CHECKING([for google perftolos library libprofiler in $ac_google_perflibdir])
152        AC_LINK_IFELSE(
153          [AC_LANG_PROGRAM(
154            [
155                #include <google/profiler.h>
156            ],
157
158            [
159                ProfilerStart("test");
160            ])],
161
162          [
163              AC_MSG_RESULT([yes])
164              oasys_cv_path_google_perf_lib=$ac_google_perflibdir
165              break
166          ],
167          [
168              AC_MSG_RESULT([no])
169          ])
170    done
171
172    CPPFLAGS="$ac_save_CPPFLAGS"
173    LDFLAGS="$ac_save_LDFLAGS"
174    LIBS="$ac_save_LIBS"
175
176    AC_LANG_POP(C++)
177
178    if test x$oasys_cv_path_google_perf_lib = x ; then
179        AC_MSG_ERROR([can't find usable google perftools library])
180    fi
181])
Note: See TracBrowser for help on using the repository browser.