# Oracle Linux DTrace.
# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.

TEST_UTILS = baddof badioctl showUSDT

define test-util-template
CMDS += $(1)
$(1)_DIR := $(current-dir)
$(1)_TARGET = $(1)
$(1)_SOURCES = $(1).c
$(1)_POST := link-test-util
$(1)_CFLAGS := -Ilibdtrace
$(1)_NOCFLAGS := --coverage
$(1)_NOLDFLAGS := --coverage
$(1)_DEPS = libdtrace.so
$(1)_LIBS = -L$(objdir) -ldtrace

clean::
	rm -f test/utils/$(1)
endef

define link-test-util
	rm -f test/utils/$(notdir $(1))
	ln -s $(1) test/utils/$(notdir $(1))
endef

$(foreach util,$(TEST_UTILS),$(eval $(call test-util-template,$(util))))

# The showUSDT utility needs to be linked against libelf, and should not be
# linked against libdtrace.
showUSDT_DEPS =
showUSDT_LIBS = -lelf

# Install the showUSDT utility in $(DOCDIR); do not count on this utility to
# always be present --- it is only included there to assist in early debugging of
# the (semi-new) USDT feature.
install::
	mkdir -p $(INSTDOCDIR)
	$(call describe-install-target,$(INSTDOCDIR),showUSDT)
	install -m 755 test/utils/showUSDT $(INSTDOCDIR)
