1 | dnl |
---|
2 | dnl Copyright 2005-2006 Intel Corporation |
---|
3 | dnl |
---|
4 | dnl Licensed under the Apache License, Version 2.0 (the "License"); |
---|
5 | dnl you may not use this file except in compliance with the License. |
---|
6 | dnl You may obtain a copy of the License at |
---|
7 | dnl |
---|
8 | dnl http://www.apache.org/licenses/LICENSE-2.0 |
---|
9 | dnl |
---|
10 | dnl Unless required by applicable law or agreed to in writing, software |
---|
11 | dnl distributed under the License is distributed on an "AS IS" BASIS, |
---|
12 | dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
13 | dnl See the License for the specific language governing permissions and |
---|
14 | dnl limitations under the License. |
---|
15 | dnl |
---|
16 | |
---|
17 | dnl |
---|
18 | dnl Autoconf support for linking with google's performace code |
---|
19 | dnl |
---|
20 | |
---|
21 | AC_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 | |
---|
84 | AC_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 | ]) |
---|