#-----------------------------------------------------------------------------#
# This source file is hereby placed in the public domain.  -fjh (the author).
#-----------------------------------------------------------------------------#
MAIN_TARGET=all

depend: mercury_main.depend mercury_lib.depend
all: mercury_main

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

.SUFFIXES: .cc
.cc.o:
	$(CXX) $(HACK) $(CXXFLAGS) -c $<

CXX=mgnuc

# Due to a bug in g++ 2.7, global register variables don't work in C++.
# Hence we need to ensure that we don't include the global register
# variable declarations.  The following hack seems to do the trick.

HACK=		-DALPHA_REGS_H \
		-DMIPS_REGS_H \
		-DSPARC_REGS_H \
		-DI386_REGS_H \
		-DPA_REGS_H \
		-DRS6000_REGS_H

# pass `-g' to the C compiler and linker, so we can use a debugger (e.g. gdb)
CXXFLAGS=-g
MGNUCFLAGS=-g
MLFLAGS=-g

# tell Mmake not to remove the `.c' files, so we can look at them (e.g. in gdb)
RM_C=:

# tell the Mercury linker to link in cpp_main.o and mercury_lib.o
MLLIBS=cpp_main.o mercury_lib.o

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

# tell mmake that it needs to make cpp_main.o and mercury_lib.o
# before it can make mercury_main
mercury_main: cpp_main.o mercury_lib.o

# we also need to add header file dependencies
cpp_main.o: cpp_main.h mercury_lib.h
cpp_main_int.o: cpp_main.h

# to make mercury_lib.h, just compile mercury_lib.m;
# the Mercury compiler will create mercury_lib.h as a side-effect.
mercury_lib.h: mercury_lib.o

# make sure that `mmake clean' removes cpp_main.o and mercury_lib.h
clean_local:
	rm -f cpp_main.o mercury_lib.h

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