1
# Copyright (c) 2009 Sun Microsystems, Inc.
2
# Use is subject to license terms.
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; version 2 of the License.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
# Generates an ELF object file with dtrace entry points.
18
# This object that must to be linked with together with
19
# the target. This script needs to run on Solaris only
21
# Do not follow symlinks in GLOB_RECURSE
22
CMAKE_POLICY(SET CMP0009 NEW)
23
FILE(REMOVE ${OUTFILE})
25
MACRO(CONVERT_TO_RELATIVE_PATHS files rel_paths)
26
GET_FILENAME_COMPONENT(abs_dir . ABSOLUTE)
28
FOREACH(file ${files})
29
FILE(RELATIVE_PATH rel ${abs_dir} ${file})
30
LIST(APPEND ${rel_paths} ${rel})
34
IF(TYPE STREQUAL "MERGE")
35
# Rerun dtrace on objects that are already in static libraries.
36
# Object paths are stored in text files named 'dtrace_objects'
37
# in the input directores. We have to copy the objects into temp.
38
# directory, as running dtrace -G on original files will change
39
# timestamps and cause rebuilds or the libraries / excessive
41
FILE(REMOVE_RECURSE dtrace_objects_merge)
42
MAKE_DIRECTORY(dtrace_objects_merge)
45
FILE(STRINGS ${dir}/dtrace_objects OBJS)
48
EXECUTE_PROCESS(COMMAND cp ${obj} dtrace_objects_merge)
52
FILE(GLOB_RECURSE OBJECTS dtrace_objects_merge/*.o)
53
CONVERT_TO_RELATIVE_PATHS("${OBJECTS}" REL_OBJECTS)
55
COMMAND ${DTRACE} ${DTRACE_FLAGS} -o ${OUTFILE} -G -s ${DFILE} ${REL_OBJECTS}
61
FILE(GLOB_RECURSE OBJECTS ${dir}/*.o)
62
CONVERT_TO_RELATIVE_PATHS("${OBJECTS}" REL)
63
LIST(APPEND REL_OBJECTS ${REL})
66
FILE(WRITE dtrace_timestamp "")
68
COMMAND ${DTRACE} ${DTRACE_FLAGS} -o ${OUTFILE} -G -s ${DFILE} ${REL_OBJECTS}
71
# Save objects that contain dtrace probes in a file.
72
# This file is used when script is called with -DTYPE=MERGE
73
# to dtrace from static libs.
74
# To find objects with probes, look at the timestamp, it was updated
76
IF(TYPE MATCHES "STATIC")
77
FILE(WRITE dtrace_objects "")
78
FOREACH(obj ${REL_OBJECTS})
79
IF(${obj} IS_NEWER_THAN dtrace_timestamp)
80
GET_FILENAME_COMPONENT(obj_absolute_path ${obj} ABSOLUTE)
81
FILE(APPEND dtrace_objects "${obj_absolute_path}\n" )