TOP = ../../
include $(TOP)/util/include/make.preamble

# - -  L i n u x  - - 
ifeq ($(OSTYPE), Linux)
LCCFLAGS	+= -g $(PROFILEFLAGS)
LLDOPTS  	+= $(PROFILEFLAGS)
JUNK		+= gmon.out
JUNKCLOBBER	+= bb.out
endif

# - -  I R I X  - - 
ifeq ($(OSTYPE), Irix)
JUNK		+= *pixn32 *pixie
endif

# - -  A l l  - -
JUNK		+= *bbg bb.out *bb *da
JUNKCLOBBER	+= *results *gcov

BIN             = go.exe

OBJECTS         = \
                  main.o \
                  $(NULL)

EXTRA_LIBS	= \
		timeit \
		$(NULL)

# this example does not build or run under windows
ifeq ($(OSTYPE), Windows)
clobber clean default:
	@echo "this example does not currently work under windows"
endif

# this example does not build or run under cygnus gnuwin
ifeq ($(OSTYPE), Cygnus)
clobber clean default:
	@echo "this example does not currently work under cygnus gnuwin"
else
#all other platforms
include $(TOP)/util/include/make.tmpl
endif

#  - -  I R I X  - - 
ifeq ($(OSTYPE), Irix)
profile: go.exe
	ssrun -ideal go.exe; \
	ssrun -usertime go.exe; \
	prof *ideal* > go.exe_ideal_results; \
	prof *usertime* > go.exe_usertime_results; \
	$(DELETE) go.exe*[0-9]
endif

#  - -  L i n u x  - - 
ifeq ($(OSTYPE), Linux)
profile_ideal:
	$(DELETE) main.o; \
	env PROFILEFLAGS="-fprofile-arcs -ftest-coverage" $(MAKE) go.exe -e; \
	./go.exe; \
	gcov main.cxx; \
	$(NULL)

profile_usertime:
	$(DELETE) main.o; \
	env PROFILEFLAGS="-a -pg" $(MAKE) go.exe -e; \
	./go.exe; \
	gprof go.exe > go.exe_usertime_results; \
	$(NULL)

profile: profile_ideal profile_usertime

endif