#--------------------------
# MultiMail Makefile (top)
#--------------------------

# General options (passed to mmail/Makefile and interfac/Makefile):

# With debug:
#OPTS = -g -Wall -pedantic

# Optimized, no debug:
OPTS = -O2 -Wall -pedantic

#--------------------------------------------------------------
# Defaults are for Linux, with ncurses:

# CURS_INC specifies the location of your ncurses header file. Broken
# brackets (<, >) should be preceded by backslashes. Quotes (") should
# be preceded by *three* backslashes:

CURS_INC = \<ncurses/curses.h\>

# CURS_DIR may also be necessary in some cases:

# Default:
CURS_DIR = .

# Some ncurses installations:
#CURS_DIR = /usr/include/ncurses

# CURS_LIB specifies the directory where the ncurses libraries can be found,
# if they're not in the standard search path. "." (the current directory) is
# used here as a placeholder:

# No extras:
CURS_LIB = .

# LIBS lists any "extra" libraries that need to be linked in:

LIBS = -lncurses

# PREFIX is the base directory under which to install the binary and man 
# page; generally either /usr/local or /usr (or perhaps /opt...):

PREFIX = /usr/local

# Ranlib command (e.g., "ranlib" or "ar -s"):

RANLIB = ranlib

# Delete command ("rm" or "del", as appropriate):

RM = rm -f

# The separator for multi-statement lines... some systems require ";",
# while others need "&&":

SEP = ;

# Any post-processing that needs doing:

POST =

#--------------------------------------------------------------
# NetBSD, with ncurses -- same as Linux, except for CURS_LIB:

#CURS_INC = \<ncurses/curses.h\>
#CURS_DIR = .
#CURS_LIB = /usr/local/lib
#LIBS = -lncurses
#PREFIX = /usr/local
#RANLIB = ranlib
#RM = rm -f
#SEP = ;
#POST =

#--------------------------------------------------------------
# Solaris, with standard curses:

#CURS_INC = \<curses.h\>
#CURS_DIR = .
#CURS_LIB = .
#LIBS = -lcurses
#PREFIX = /usr/local
#RANLIB = ranlib
#RM = rm -f
#SEP = ;
#POST =

#--------------------------------------------------------------
# Solaris, with ncurses installed in the user's home directory:

# Example with quotes (relative pathnames start from ./interfac):
#CURS_INC = \\\"../../ncurses-4.2/include/curses.h\\\"
#CURS_DIR = .
#CURS_LIB = ../ncurses-4.2/lib
#LIBS = -lncurses
#PREFIX = /usr/local
#RANLIB = ranlib
#RM = rm -f
#SEP = ;
#POST =

#--------------------------------------------------------------
# DJGPP (MSDOS), with PDCurses 2.2:

#CURS_INC = \<curses.h\>
#CURS_DIR = /djgpp/contrib/pdcurs22/include
#CURS_LIB = ../contrib/pdcurs22/lib
#LIBS = -lcurso
#PREFIX =
#RANLIB = ranlib
#RM = del
#SEP = ;
#POST =
# Optional; attach pmode stub:
#POST = $(RM) mm.exe $(SEP) strip mm $(SEP) copy /b \
#	..\pmode\pmodstub.exe+mm mm.exe $(SEP) $(RM) mm

#--------------------------------------------------------------
# EMX (OS/2), with GNU make, and PDCurses 2.3:
# Note: If you get "g++: Command not found", then type "set cxx=gcc"
# before running make.

# For some reason, it wants twice as many slashes:
#CURS_INC = \\\\\\"../../PDCurses-2.3/curses.h\\\\\\"
#CURS_DIR = /emx/PDCurses-2.3
#CURS_LIB = .
#LIBS = /emx/PDCurses-2.3/os2/pdcurses.a
#PREFIX =
#RANLIB = ar -s
#RM = del /n
#SEP = &&
# Remove "emxbind -s" for a debug executable:
#POST = emxbind mm $(SEP) $(RM) mm $(SEP) emxbind -s mm

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

HELPDIR = $(PREFIX)/man/man1

all:
	cd mmail $(SEP) $(MAKE) RANLIB="$(RANLIB)" \
		OPTS="$(OPTS)" mm.a $(SEP) cd ..
	cd interfac $(SEP) $(MAKE) RANLIB="$(RANLIB)" \
		OPTS="$(OPTS) -I$(CURS_DIR)" \
		CURS_INC="$(CURS_INC)" interfac.a $(SEP) cd ..
	$(MAKE) mm

mm:	interfac/interfac.a mmail/mm.a
	$(CXX) -o mm interfac/interfac.a mmail/mm.a -L$(CURS_LIB) $(LIBS)
	$(POST)

dep:
	cd interfac $(SEP) $(MAKE) CURS_INC="$(CURS_INC)" dep $(SEP) cd ..
	cd mmail $(SEP) $(MAKE) dep $(SEP) cd ..

clean:
	$(RM) mm
	cd interfac $(SEP) $(MAKE) RM="$(RM)" clean $(SEP) cd ..
	cd mmail $(SEP) $(MAKE) RM="$(RM)" clean $(SEP) cd ..

install:
	install -c -s mm $(PREFIX)/bin
	install -c -m 644 mm.1 $(HELPDIR)
	$(RM) $(HELPDIR)/mmail.1
	ln $(HELPDIR)/mm.1 $(HELPDIR)/mmail.1
