#-----------------------------------------------------------------------------#
# Copyright (C) 1997-2000 The University of Melbourne.
# This file may only be copied under the terms of the GNU Library General
# Public License - see the file COPYING.LIB in the Mercury distribution.
#-----------------------------------------------------------------------------#

-include ../Mmake.params

GRADEFLAGS += --use-trail

# Install in an "extras" subdirectory of the main installation tree
INSTALL_PREFIX := $(INSTALL_PREFIX)/extras
LIBGRADES = asm_fast.tr asm_fast.gc.tr.debug

MAIN_TARGET = libglobal

# In case the user of the library wants to do intermodule optimisation
MCFLAGS += --intermodule-optimisation
MCFLAGS += --transitive-intermodule-optimisation

.PHONY: depend
depend: global.depend
	cd samples && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" depend
	cd tests && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" depend

.PHONY: check
check: libglobal
	cd tests && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" check

.PHONY: install
install: libglobal.install

.PHONY: install_check
install_check:
	cd samples && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" \
		EXTRA_LIB_DIRS="$(INSTALL_PREFIX)/lib/mercury" check

.PHONY: clean
clean: clean_subdirs

.PHONY: clean_subdirs
clean_subdirs:
	cd samples && mmake $(MMAKEFLAGS) clean
	cd tests && mmake $(MMAKEFLAGS) clean

.PHONY: realclean
realclean: realclean_subdirs

.PHONY: realclean_subdirs
realclean_subdirs:
	cd samples && mmake $(MMAKEFLAGS) realclean
	cd tests && mmake $(MMAKEFLAGS) realclean

# We need this to use shared libraries on Linux
ML = ml --mercury-libs shared

