#
# Top-Level RTcmix Makefile
#
#
MAKE = make
#
# ARCHFLAGS should be the only macro that needs to change based on your
# IRIX release and your machine type
#
# Use this for IRIX 6.2 Indys and Indigos
ARCHFLAGS = -O2 
#
# Use this for IRIX 6.3+ O2s
# ARCHFLAGS = -n32 -mips4 -O3 -r5000
#
# Use this for Octanes and other R10K machines
#ARCHFLAGS = -n32 -mips4 -O3 -r10000
#
RANLIB = true
CC = cc $(ARCHFLAGS)
CXX = CC $(ARCHFLAGS)
# Adjust this to match compiler (i.e., -n32 for -n32 and -o32 for -o32)
# LD = ld -n32
# Use this for IRIX 6.2 Indys and Indigos
LD = ld
#
# Set these based on where you put the source tree and where you wish to install
#
TOPDIR = /musr/cmix
LIBDIR = $(TOPDIR)/lib
DESTDIR = /musr/bin
# This is where it will install all the dynamic shared libraries
LIBDESTDIR = /musr/lib
#
# Don't fiddle with these!
#
ARCH = SGI
# INCLUDES = -I$(TOPDIR)/H -I/usr/local/include
INCLUDES = -I$(TOPDIR)/H
FLAGS = $(INCLUDES) -signed -DNEXT -Dsgi
SYSLIBS = -laudio -laudiofile -lm
LDFLAGS = $(ARCHFLAGS) $(SYSLIBS)
SHARED_LDFLAGS = $(ARCHFLAGS) -shared -update_registry $(LIBDESTDIR)/so_locations

# MFLAGS gets passed down to subdirs to allow all the flags to be transferred
# down to the lower-level 'make's.

MFLAGS = 'CC=$(CC)' 'CXX=$(CXX)' 'LD=$(LD)' 'ARCH=$(ARCH)' 'FLAGS=$(FLAGS)' \
'CFLAGS=$(FLAGS)' 'CXXFLAGS=$(FLAGS)' 'INCLUDES=$(INCLUDES)' \
'LDFLAGS=$(LDFLAGS)' 'SHARED_LDFLAGS=$(SHARED_LDFLAGS)' 'DESTDIR=$(DESTDIR)' \
'LIBDIR=$(LIBDIR)' 'LIBDESTDIR=$(LIBDESTDIR)' 'INCLUDEDIR=$(INCLUDEDIR)' \
'FORTLIBS=$(FORTLIBS)' 'RANLIB=$(RANLIB)' 'SYSLIBS=$(SYSLIBS)'

DIRS = H rtstuff/heap rtstuff Minc sys lib head cmd insts

all: H heap rtstuff Minc sys lib head cmd insts

install:
	@echo "making install..."
	@cd insts; $(MAKE) -k $(MFLAGS) install;
	@echo "install done."; echo ""

H::
	@echo "making H..."
	@cd H; $(MAKE) $(MFLAGS) all;
	@echo "done.";echo""

heap::
	@echo "making heap ..."
	@cd rtstuff/heap; $(MAKE) $(MFLAGS) all
	@echo "done."; echo""

Minc::
	@echo "making Minc..."
	@cd Minc; $(MAKE) $(MFLAGS) all
	@echo "done.";echo""

sys::
	@echo "making sys..."
	@cd sys; $(MAKE) $(MFLAGS) all
	@echo "done.";echo""

lib::
	@echo "making lib..."
	@cd lib; $(MAKE) $(MFLAGS) all
	@echo "done.";echo""

rtstuff::
	@echo "making rtstuff..."
	@cd rtstuff; $(MAKE) $(MFLAGS) all
	@echo "done.";echo""

insts::
	@echo "making insts..."
	@cd insts; $(MAKE) -k $(MFLAGS) all
	@echo "done.";echo""

head::
	@echo "making head..."
	@cd head; $(MAKE) $(MFLAGS) all
	@echo "done.";echo""

cmd::
	@echo "making cmd..."
	@cd cmd; $(MAKE) $(MFLAGS) all
	@echo "done.";echo""

clean:
	@for DIR in $(DIRS); \
	do \
	    ( cd $$DIR; echo "making clean in $$DIR..."; \
	    $(MAKE) $(MFLAGS) clean ); \
	done


