#-------------------
# blueMail Makefile
#-------------------

PREFIX     = /usr/local
BINDIR     = $(PREFIX)/bin
MANDIR     = $(PREFIX)/man/man1

INSTALL    = install -c
INSTALLBIN = $(INSTALL) -s -m 755
INSTALLMAN = $(INSTALL) -m 644

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

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

#---------------------------------------------------------------------
# Defaults are for Linux, with ncurses:
# ("." is used as a placeholder)

CURS_INCDIR = .
CURS_LIBDIR = .
LIBS        = -lncurses
RANLIB      = ranlib
RM          = rm -f
SEP         = ;
POST        =

#CURS_INCDIR    (where curses header file <curses.h> can be found)
#CURS_LIBDIR    (where ncurses library can be found)
#LIBS           (library that need to be linked in)
#RANLIB         (ranlib command)
#RM             (delete command)
#SEP            (multi-statement lines separator)
#POST           (any post-processing that should take place)

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

#CURS_INCDIR = /djgpp/contrib/pdcurs22/include
#CURS_LIBDIR = ../contrib/pdcurs22/lib
#LIBS        = -lcurso
#RANLIB      = ranlib
#RM          = del
#SEP         = ;
# (attach pmode stub, optional):
#POST        = $(RM) bmail.exe $(SEP) strip bmail $(SEP) copy /b \
#		c:\compiler\gc\bin\pmodstub.exe + bmail bmail.exe

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

#CURS_INCDIR = /usr/include/ncurses
#CURS_LIBDIR = /usr/local/lib
#LIBS        = -lncurses
#RANLIB      = ranlib
#RM          = rm -f
#SEP         = ;
#POST        =

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

#CURS_INCDIR = .
#CURS_LIBDIR = .
#LIBS        = -lcurses
#RANLIB      = ranlib
#RM          = rm -f
#SEP         = ;
#POST        =

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

#CURS_INCDIR = ../../ncurses-4.2/include
#CURS_LIBDIR = ../ncurses-4.2/lib
#LIBS        = -lncurses
#RANLIB      = ranlib
#RM          = rm -f
#SEP         = ;
#POST        =

#---------------------------------------------------------------------
# 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.)

#CURS_INCDIR = /emx/PDCurses-2.3
#CURS_LIBDIR = .
#LIBS        = /emx/PDCurses-2.3/os2/pdcurses.a
#RANLIB      = ar -s
#RM          = del /n
#SEP         = &&
# (remove "emxbind -s" for a debug executable):
#POST        = emxbind bmail $(SEP) $(RM) bmail $(SEP) emxbind -s bmail


#=====================================================================


all:
	cd bluemail $(SEP) $(MAKE) RANLIB="$(RANLIB)" \
		OPTS="$(OPTS)" bmail.a $(SEP) cd ..
	cd interfac $(SEP) $(MAKE) RANLIB="$(RANLIB)" \
		OPTS="$(OPTS) -I$(CURS_INCDIR)" interfac.a $(SEP) cd ..
	$(MAKE) bmail

bmail:	bluemail/bmail.a interfac/interfac.a
	$(CXX) -o bmail interfac/interfac.a bluemail/bmail.a \
		-L$(CURS_LIBDIR) $(LIBS)
	$(POST)

dep:
	cd bluemail $(SEP) $(MAKE) dep $(SEP) cd ..
	cd interfac $(SEP) $(MAKE) dep $(SEP) cd ..

clean:
	$(RM) bmail
	cd bluemail $(SEP) $(MAKE) RM="$(RM)" clean $(SEP) cd ..
	cd interfac $(SEP) $(MAKE) RM="$(RM)" clean $(SEP) cd ..

install:
	$(INSTALLBIN) bmail $(BINDIR)
	$(INSTALLMAN) bmail.1 $(MANDIR)
