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

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

MERCURY_DIR=..
include ../Mmake.common

MAIN_TARGET=mercury_profile

VPATH=../library

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

# Specify which compilers to use to compile the compiler.
# Don't change these without good reason - if you want to
# do a temporary change, change ../Mmake.params

MCD	=	MERCURY_INT_DIR=. $(MC) --generate-dependencies
MCI	=	MERCURY_INT_DIR=$(LIBRARY_DIR) $(MC) --make-interface
MCG	=	MERCURY_C_INCL_DIR=$(RUNTIME_DIR) \
		MERCURY_INT_DIR=$(LIBRARY_DIR) $(MC) --compile-to-c
MGNUC	=	MERCURY_C_INCL_DIR=$(RUNTIME_DIR) mgnuc
MGNUCFLAGS =	-I $(BOEHM_GC_DIR) $(PROFFLAGS)
C2INIT =	\
MERCURY_MOD_LIB_MODS="../runtime/runtime.init ../library/library.init" \
		MERCURY_MKINIT=../util/mkinit c2init
ML	=	MERCURY_C_LIB_DIR=. ml
MLFLAGS =	-- -static -L$(RUNTIME_DIR) -L$(LIBRARY_DIR) -L$(BOEHM_GC_DIR)
MSL	=	MERCURY_SP_LIB_DIR=../library msl
MNLFLAGS =	-u 6000

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

.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.

mercury_profile: $(RUNTIME_DIR)/libmer.a $(LIBRARY_DIR)/libmercury.a \
	$(BOEHM_GC_DIR)/libgc.a

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

.PHONY: check
check		: mercury_profile.check

.PHONY: ints 
ints		: mercury_profile.ints

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

tags		: $(mercury_profile.ms)
	mtags $(mercury_profile.ms) ../library/*.m

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

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

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

.PHONY: os cs
os: $(mercury_profile.os) mercury_profile_init.o
cs: $(mercury_profile.cs) mercury_profile_init.c

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

# 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` $(INSTALL_MERC_BIN_DIR)

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