#
# Top level makefile for me2/mc2
# invokes make in each of the sub-directories to make everything
# passing flags down to each sub-directory make.
#
# Before invoking make you must configure the following:
#    util/os.h
#    mc2/mm.h
#    me2/config.h
#    me2/Makefile
#    mutt2/Makefile
#    ./Makefile (this file!)
#
# Caution: assumes you are using GNUmake. If you are not you should be!
#
#	++jrb  bammi@cadence.com
#

##########################################################################
##		     start of user configuration			##
##########################################################################

MAKE=f:\gnubin\make.ttp
SHELL=c:\gulam\msh.prg

# Choose your compiler
#   For most systems just cc
#   You may prefer to use gcc
#   For the atariST specify your cross or native gcc
#

#CC=cc		# normal cc (how boring!)
CC=gcc
#CC=gcc		# gcc unix/atariST
#CC=cgcc	# gcc atariST TOS/MiNT

# Choose the base compile flags for your C compiler. These flags
# are used for everything that is compiled. K&R or ANSI C ok.
# For HP-UX and ANSI C, use "-O -Aa", else "-O"
# For Apollo and ANSI C, use "-O -Aansi", else "-O"
# For everybody else, "-O" should be OK
# For the atariST use -O2 -fstrength-reduce
# On a  Sun-sparc with gcc-2.1 i have tested "-O2 -g"
#
#BASECFLAGS = -g
BASECFLAGS = -O2 -fomit-frame-pointer -DNDEBUG
#BASECFLAGS = -O			# normal 
#BASECFLAGS = -O -Aa +Obb2000		# hp snake
#BASECFLAGS = -O2 -g			# gcc unix
#BASECFLAGS = -O2 -fomit-frame-pointer	# gcc atariST-TOS
#BASECFLAGS = -O -mint			# gcc atariST-MiNT

# Choose the flags for the linker. These are not applied when compiling.
# For most unixen use nothing
# On a HP-Snake +O3 does improve things
# On the atariST nothing is fine
# LDFLAGS = +O3		# hp-snake
# LDFLAGS = -g		# gcc unix
# LDFLAGS = -v		# cc unixen / gcc atariST-TOS
# LDFLAGS = -mint	# gcc atariST-MiNT

# Name of your archiver and ranlib
# On unixen "ar" and "ranlib"
# On the atariST car (or gcc-ar on native) and "car s"
#AR=ar		# unixen
#RANLIB=ranlib	# unixen
#AR = gar	# atariST
#RANLIB = gar s	# atariST
AR = gar
RANLIB = gar s

# The subdirectories in which we are going to make stuff
# unixen: util ed mc2 comserver me2 mutt2
# atariST: util ed mc2 me2 mutt2 
#
# SUBDIRS = util ed mc2 comserver me2 mutt2 	# unixen
# SUBDIRS = util ed mc2 me2 			# atariST -cross
SUBDIRS = util ed mc2 me2 mutt2 		# atariST -native


# The following should only be defined if you are compiling for the atariST
# (these variables are tested in subdir/Makefiles to test conditions)
# For unixen dont define them.
#
# ATARI=		# unixen
# ATARIOS=		# unixen
# ATARI=atariST		# define this if atariST, MiNT or TOS
# ATARIOS=TOS		# define this only if atariST-TOS
# ATARIOS=MiNT		# define this only if atariST-MiNT
ATARI=atariST
ATARIOS=TOS

# Installation directories
#
# BIN = /util/bin
BIN = /net/acae127/home/bammi/bin
LIB = /net/acae127/home/bammi/lib/me2

##########################################################################
##			end of user configuration			##
##########################################################################

all: announce subdirs

announce:
	@echo ">>>>>>>>>>>>>>>>Building the Mutt World<<<<<<<<<<<<<<<<<<<<<"

subdirs:
	cd util;  $(MAKE) CC="$(CC)" BASECFLAGS="$(BASECFLAGS)" LDFLAGS="$(LDFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" ATARI="$(ATARI)" ATARIOS="$(ATARIOS)"
	cd ed;    $(MAKE) CC="$(CC)" BASECFLAGS="$(BASECFLAGS)" LDFLAGS="$(LDFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" ATARI="$(ATARI)" ATARIOS="$(ATARIOS)"
	cd mc2;   $(MAKE) CC="$(CC)" BASECFLAGS="$(BASECFLAGS)" LDFLAGS="$(LDFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" ATARI="$(ATARI)" ATARIOS="$(ATARIOS)"
	cd me2;   $(MAKE) CC="$(CC)" BASECFLAGS="$(BASECFLAGS)" LDFLAGS="$(LDFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" ATARI="$(ATARI)" ATARIOS="$(ATARIOS)"
	cd mutt2; $(MAKE) CC="$(CC)" BASECFLAGS="$(BASECFLAGS)" LDFLAGS="$(LDFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" ATARI="$(ATARI)" ATARIOS="$(ATARIOS)"
#	for dir in $(SUBDIRS); do \
#	(cd $$dir; \
#	$(MAKE) CC="$(CC)" BASECFLAGS="$(BASECFLAGS)" LDFLAGS="$(LDFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" ATARI="$(ATARI)" ATARIOS="$(ATARIOS)"; \
#	) \
#	done

# clean just cleans up objects
clean:
	cd util;  $(MAKE) clean
	cd ed;    $(MAKE) clean
	cd mc2;   $(MAKE) clean
	cd me2;   $(MAKE) clean
#	cd mutt2; $(MAKE) clean
#	for dir in $(SUBDIRS); do \
#	(cd $$dir; \
#	$(MAKE) clean; \
#	) \
#	done

# realclean cleanup objects, libraries, executables and .mco's
realclean: clean
	for dir in $(SUBDIRS); do \
	( cd $$dir; \
	$(MAKE) realclean; \
	) \
	done

install:
	cp me2/me2 mc2/mc2 $(BIN)
	cp mutt2/*.mco $(LIB)
