#-----------------------------------------------------------------------------#
# Copyright (C) 1995-2000,2002-2003 The University of Melbourne. 
# This file may only be copied under the terms of the GNU General
# Public Licence - see the file COPYING in the Mercury distribution.
#-----------------------------------------------------------------------------#

# Mmake - this is Mmake file for building the Mercury profiler

MERCURY_DIR=..
LINK_STATIC=yes
include $(MERCURY_DIR)/Mmake.common

# Module-specific options should go in Mercury.options so they
# can be found by `mmc --make'.
include Mercury.options

MAIN_TARGET=mercury_profile
MERCURY_MAIN_MODULES=mercury_profile

#-----------------------------------------------------------------------------#

MLFLAGS += --shared
MCFLAGS += --linkage shared

#-----------------------------------------------------------------------------#

.PHONY: depend
depend : mercury_profile.depend

.PHONY: all
all : mercury_profile

#-----------------------------------------------------------------------------#

# Add some additional dependencies, so that Mmake knows to remake the
# profiler if one of the libraries changes.

ifeq ("$(filter il% java%,$(GRADE))","")        
mercury_profile: $(RUNTIME_DIR)/lib$(RT_LIB_NAME).$A
mercury_profile: $(LIBRARY_DIR)/lib$(STD_LIB_NAME).$A
# XXX Should also depend on $(BOEHM_GC_DIR)/libgc(_prof).$A, but only
# if in .gc(.prof) grade.
endif

$(cs_subdir)mercury_profile_init.c: $(UTIL_DIR)/mkinit

#-----------------------------------------------------------------------------#

.PHONY: check
check		: mercury_profile.check

.PHONY: ints 
ints		: mercury_profile.ints

#-----------------------------------------------------------------------------#

tags		: $(MTAGS) $(mercury_profile.ms) $(LIBRARY_DIR)/*.m
	$(MTAGS) $(mercury_profile.ms) $(LIBRARY_DIR)/*.m

#-----------------------------------------------------------------------------#

.PHONY: dates
dates		:
	touch $(mercury_profile.dates)

#-----------------------------------------------------------------------------#

.PHONY: os cs ss ils
os: $(mercury_profile.os) $(os_subdir)mercury_profile_init.o
cs: $(mercury_profile.cs) $(cs_subdir)mercury_profile_init.c
ss: $(mercury_profile.ss)
ils: $(mercury_profile.ils)

#-----------------------------------------------------------------------------#

realclean_local:
	rm -f tags

#-----------------------------------------------------------------------------#

# Installation targets

.PHONY: install
install: install_profiler

.PHONY: install_profiler
install_profiler: mercury_profile
	-[ -d $(INSTALL_MERC_BIN_DIR) ] || mkdir -p $(INSTALL_MERC_BIN_DIR)
	cp `vpath_find mercury_profile$(EXT_FOR_EXE)` $(INSTALL_MERC_BIN_DIR)

#-----------------------------------------------------------------------------#
