diff --git a/.gitignore b/.gitignore index 396f30b1e..9235361b8 100644 --- a/.gitignore +++ b/.gitignore @@ -33,7 +33,7 @@ Makefile Makefile.in # Generated by dtrace(1) when doing an in-tree build. -/src/unix/uv-dtrace.h +/include/uv-dtrace.h /out/ /build/gyp diff --git a/Makefile.am b/Makefile.am index df911d006..97552e3c4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,6 +20,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/include \ include_HEADERS=include/uv.h include/uv-unix.h +CLEANFILES = + lib_LTLIBRARIES = libuv.la libuv_la_CFLAGS = @CFLAGS@ libuv_la_LDFLAGS = -no-undefined -version-info 11:0:0 @@ -189,3 +191,33 @@ include_HEADERS += include/uv-sunos.h libuv_la_CFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500 libuv_la_SOURCES += src/unix/sunos.c endif + +if HAVE_DTRACE +BUILT_SOURCES = include/uv-dtrace.h +CLEANFILES += include/uv-dtrace.h +endif + +if DTRACE_NEEDS_OBJECTS +libuv_la_SOURCES += src/unix/uv-dtrace.d +libuv_la_DEPENDENCIES = src/unix/uv-dtrace.o +libuv_la_LIBADD = src/unix/uv-dtrace.lo +CLEANFILES += src/unix/uv-dtrace.o src/unix/uv-dtrace.lo +endif + +SUFFIXES = .d + +include/uv-dtrace.h: src/unix/uv-dtrace.d + $(AM_V_GEN)$(DTRACE) $(DTRACEFLAGS) -h -xnolibs -s $< -o $@ + +src/unix/uv-dtrace.o: src/unix/uv-dtrace.d ${libuv_la_OBJECTS} + +.d.o: + $(AM_V_GEN)$(DTRACE) $(DTRACEFLAGS) -G -o $@ -s $< \ + `grep '^pic_object' ${top_builddir}/*.lo | cut -f 2 -d\'` + $(AM_V_GEN)printf %s\\n \ + '# $(patsubst %.o, %.lo, $@) - a libtool object file' \ + '# Generated by libtool (GNU libtool) 2.4' \ + '# libtool wants a .lo not a .o' \ + "pic_object='uv-dtrace.o'" \ + "non_pic_object='uv-dtrace.o'" \ + > $(patsubst %.o, %.lo, $@) diff --git a/autogen.sh b/autogen.sh index c8791e395..ed07953e7 100755 --- a/autogen.sh +++ b/autogen.sh @@ -20,6 +20,6 @@ fi set -ex ${LIBTOOLIZE:-libtoolize} -${ACLOCAL:-aclocal} +${ACLOCAL:-aclocal -I m4} ${AUTOCONF:-autoconf} ${AUTOMAKE:-automake} --add-missing diff --git a/configure.ac b/configure.ac index baaaaa615..9da911cff 100644 --- a/configure.ac +++ b/configure.ac @@ -42,5 +42,6 @@ AM_CONDITIONAL([LINUX], [AS_CASE([$host_os], [linux*], [true], [false])]) AM_CONDITIONAL([NETBSD], [AS_CASE([$host_os], [netbsd*], [true], [false])]) AM_CONDITIONAL([OPENBSD], [AS_CASE([$host_os], [openbsd*], [true], [false])]) AM_CONDITIONAL([SUNOS], [AS_CASE([$host_os], [solaris*], [true], [false])]) +PANDORA_ENABLE_DTRACE AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/m4/dtrace.m4 b/m4/dtrace.m4 new file mode 100644 index 000000000..4060af318 --- /dev/null +++ b/m4/dtrace.m4 @@ -0,0 +1,58 @@ +dnl Copyright (C) 2009 Sun Microsystems +dnl This file is free software; Sun Microsystems +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl --------------------------------------------------------------------------- +dnl Macro: PANDORA_ENABLE_DTRACE +dnl --------------------------------------------------------------------------- +AC_DEFUN([PANDORA_ENABLE_DTRACE],[ + AC_ARG_ENABLE([dtrace], + [AS_HELP_STRING([--disable-dtrace], + [enable DTrace USDT probes. @<:@default=yes@:>@])], + [ac_cv_enable_dtrace="$enableval"], + [ac_cv_enable_dtrace="yes"]) + + AS_IF([test "$ac_cv_enable_dtrace" = "yes"],[ + AC_CHECK_PROGS([DTRACE], [dtrace]) + AS_IF([test "x$ac_cv_prog_DTRACE" = "xdtrace"],[ + + AC_CACHE_CHECK([if dtrace works],[ac_cv_dtrace_works],[ + cat >conftest.d <<_ACEOF +provider Example { + probe increment(int); +}; +_ACEOF + $DTRACE -h -o conftest.h -s conftest.d 2>/dev/zero + AS_IF([test $? -eq 0],[ac_cv_dtrace_works=yes], + [ac_cv_dtrace_works=no]) + rm -f conftest.h conftest.d + ]) + AS_IF([test "x$ac_cv_dtrace_works" = "xyes"],[ + AC_DEFINE([HAVE_DTRACE], [1], [Enables DTRACE Support]) + ]) + AC_CACHE_CHECK([if dtrace should instrument object files], + [ac_cv_dtrace_needs_objects],[ + dnl DTrace on MacOSX does not use -G option + cat >conftest.d <<_ACEOF +provider Example { + probe increment(int); +}; +_ACEOF + $DTRACE -G -o conftest.d.o -s conftest.d 2>/dev/zero + AS_IF([test $? -eq 0],[ac_cv_dtrace_needs_objects=yes], + [ac_cv_dtrace_needs_objects=no]) + rm -f conftest.d.o conftest.d + ]) + AC_SUBST(DTRACEFLAGS) dnl TODO: test for -G on OSX + ac_cv_have_dtrace=yes + ])]) + +AM_CONDITIONAL([HAVE_DTRACE], [test "x$ac_cv_dtrace_works" = "xyes"]) +AM_CONDITIONAL([DTRACE_NEEDS_OBJECTS], + [test "x$ac_cv_dtrace_needs_objects" = "xyes"]) + +]) +dnl --------------------------------------------------------------------------- +dnl End Macro: PANDORA_ENABLE_DTRACE +dnl ---------------------------------------------------------------------------