#
# Copyright 2003-2020 Intel Corporation.
#
# This software and the related documents are Intel copyrighted materials, and your use of
# them is governed by the express license under which they were provided to you (License).
# Unless the License provides otherwise, you may not use, modify, copy, publish, distribute,
# disclose or transmit this software or the related documents without Intel's prior written
# permission.
#
# This software and the related documents are provided as is, with no express or implied
# warranties, other than those that are expressly stated in the License.
#
# This software and the related documents are provided as is, with no express or implied
# warranties, other than those that are expressly stated in the License.#
# This makefile builds config.h (which is expected by VT_sample.c)
# and produces VT_frame.o. Linking with this object file enables
# automatic recording of Operating System and hardware counters.
# libVTsample.a is a symbolic link that simplifies linking
# against the object file because one can use the linkers
# directory search rules.
#

# compile with all flags
CC=cc

# include paths
VTINC=$(VT_ROOT)/include
PAPI_ROOT=/usr/local
PAPI_INC=$(PAPI_ROOT)/include

all: libVTsample.so

# config.h is expected by VT_sample.c with the following content:
config.h : Makefile
	rm -f $@
	echo >>$@ "#define HAVE_PAPI" # optional, remove to compile without PAPI
	echo >>$@ "#define INT32 int"
	echo >>$@ "#define UINT32 unsigned INT32"
	echo >>$@ "#define INT64 long"
	echo >>$@ "#define UINT64 unsigned INT64"
	echo >>$@ "#define FLOAT64 double"

# needs VT.h and (optionally) papi.h to compile
libVTsample.so : VT_sample.c config.h
	$(CC) -shared -fPIC -I$(VTINC) -I$(PAPI_INC) -o libVTsample.so $<

clean:
	rm -f VT_sample.so config.h
