/* $Id: Imakefile,v 1.25 92/10/05 15:36:44 bobo Exp $
 *
 *  Imakefile for xmailtool
 */
LOCAL_LIBRARIES = ../lib/libtamil.a XawClientLibs
        DEPLIBS = ../lib/libtamil.a XawClientDepLibs
#ifdef IngrArchitecture
  SYS_LIBRARIES = -lmath -lmalloc
#else
  SYS_LIBRARIES = -lm
#endif
           SRCS = check_mail.c xmailtool.c proc.c util.c mail_int.c \
		vars.c date.c aliases.c
      TOOL_SRCS = check_mail.c xmailtool.c proc.c util.c mail_int.c \
		vars.c aliases.c
           OBJS = check_mail.o xmailtool.o proc.o util.o mail_int.o \
		vars.o date.o aliases.o
        PROGRAM = xmailtool
        MANPAGE = $(PROGRAM).man
  INCLUDE_FILES = defs.h patchlevel.h

#ifdef DEBUG
    CDEBUGFLAGS = -g
#endif

/*
 * The following are used for porting.  You should have to only modify
 * these settings.  If you do... Please forward them to me as soon as possible.
 */

/*
 * The prefered location of the Help file.  This is probably site dependant
 * rather than Architecture dependant.
 */
       HELP_DIR = /home/gs4t/lib
         AD_DIR = $(HELP_DIR)/app-defaults
   DEF_HELPFILE = -DDEFAULT_HELPFILE=\"$(HELP_DIR)/xmailtool.help\"
    DEF_AD_FILE = -DDEF_AD_FILE=\"XENVIRONMENT=$(AD_DIR)/XMailTool-color.ad\"

/*
 * The location of the BSD-style mail reader. This is a command that displays
 * header lines.  On some SYSVish machines it wil be mailx or located in 
 * a BSDish directory (like /usr/ucb or /usr/bsd or /usr/sbin)
 */

#if defined(SYSV) || defined(SVR3) || defined(SQNTArchitecture) || defined(CrayArchitecture) || defined(HPArchitecture) || defined(IngrArchitecture) || defined(MacIIArchitecture)
#if defined(SGIArchitecture)
        MREADER = -DMREADER=\"/usr/sbin/Mail\"
#else  /* ! sgi */
        MREADER = -DMREADER=\"/usr/bin/mailx\"
#endif  /* sgi */
#else  /* ! SYSV */
#if defined(IBMArchitecture)
        MREADER = -DMREADER=\"/bin/mail\"
#else /* ! IBMArchitecture */
        MREADER = -DMREADER=\"/usr/ucb/mail\"
#endif /* IBMArchitecture */
#endif /* SYSV */


/*
 * The location of the system mailbox directory.  On many SYSVish machines
 * this will be /usr/mail. On many BSDish machines this will be /usr/spool/mail.
 */
#if defined(SYSV) || defined(SQNTArchitecture) || defined(CrayArchitecture) || defined(HPArchitecture) || defined(SGIArchitecture) || defined(IngrArchitecture) || defined(MacIIArchitecture)
        MBOXDIR = -DMAILBOX_DIRECTORY=\"/usr/mail\"
#else /* ! SYSV */
#if defined(SunArchitecture) || defined(IBMArchitecture)
        MBOXDIR = -DMAILBOX_DIRECTORY=\"/usr/spool/mail\"
#else /* ! Sun */
#if defined(vax) || defined(UltrixArchitecture)
        MBOXDIR = -DMAILBOX_DIRECTORY=\"/var/spool/mail\"
#endif /* vax */
#endif /* SUN */
#endif /* SYSV */

/*
 * If the BSD-style mail reader doesn't support the -t option for sending
 * outbound messages, then sendmail should be used.  The -t option is
 * almost equivaltent to the -t option in sendmail excepth that alias
 * expansion is done.
 */
#if defined(SunArchitecture)
        MSENDER =
#else /* ! Sun */
        MSENDER = -DUSE_SENDMAIL
#endif

/*
 * Some machines don't support lpr for printing.  If your machine
 * doesn't or you'ld like to specify a default that is different
 * than lpr, you should define the PRINTER_CMD variable.
 */
#ifdef IngrArchitecture
      PRINTER_CMD = -DPRINTER_CMD="\"qpr -t text\""
#else
      PRINTER_CMD =
#endif


/*
 * As far as I know there are two formats used for printing the variable
 * list and values when you enter the set command.  They are as follows
 *	variable[="value"]
 *		and
 *	variable<TAB>[value]
 * If your machine supports the second format, you'll need to set the
 * TAB_DELIMITED flag.
 */
#if defined(SGIArchitecture) || defined(IBMArchitecture)
  TAB_DELIMITED = -DTAB_DELIMITED
#else /* ! SGI */
  TAB_DELIMITED =
#endif

/*
 * Some versions of mail use reply/replyall to send to just one person, or
 * all recipients of the message.  Others use reply/Reply.
 * If your machine uses reply/Reply you should define REPLYBSD
 */
#if defined(CrayArchitecture) || defined(UltrixArchitecture) || defined(HPArchitecture) || defined(SQNTArchitecture) || defined(IBMArchitecture) || defined(IngrArchitecture)
       REPLYBSD = -DREPLYBSD
#else /* ! Cray */
       REPLYBSD =
#endif

/*
 *  The reply command is a fairly complex part of porting XMailTool.
 *  Some implementations use "reply" to indicate that all users are
 *  to be included in the address, while others use Reply or replyall
 *  to do this.  Some machines have a variable which allows the
 *  functionality of the reply command to be switched with Reply
 *  and replyall.  The goal of xmailtool is that when the face of
 *  the reply button reads "reply" only one user is addressed and
 *  when it reads "replyall" all users are addressed.  To acomplish
 *  this, you need to examine the lines bellow and determine what
 *  BSDREPLY should be set to.
 *
 *  If your machine uses the reply command to write to ALL users
 *  and Reply to write to ONE user, and doesn't have a variable to
 *  switch them... We will call you BSDREPLY=1
 *  
 *  If your machine uses the reply command to write to ALL users
 *  and Reply to write to ONE user, and has a variable named
 *  replyall to switch their meaning... We will call you BSDREPLY=2
 *  
 *  If your machine uses the reply command to write to ALL users
 *  and Reply to write to ONE user, and has a variable named
 *  Replyall to switch their meaning... We will call you BSDREPLY=3
 *  
 *  If your machine uses the reply command to write to ONE user
 *  and Reply to write to ALL users, and has a variable named
 *  replyall to switch their meaning... We will call you BSDREPLY=4
 *  
 *  If your machine uses the reply command to write to ONE user
 *  and Reply to write to ALL users, and has a variable named
 *  Replyall to switch their meaning... We will call you BSDREPLY=5
 *  
 *  If your machine uses the reply command to write to ONE user
 *  and replyall to write to ALL users, and has a variable named
 *  Replyall to switch their meaning... We will call you BSDREPLY=6
 *  
 *  If your machine uses the reply command to write to ONE user
 *  and Reply to write to ALL users, and has a variable named
 *  replyall to switch their meaning and a replyall command that isn't
 *  affected by the replyall variable... We will call you BSDREPLY=7
 *
 *  If your machine doesn't fit into one of these categories, you need
 *  to send me E-mail as soon as possible letting me know what you have.
 *  so that I can make this porting experience as pleasant as possible.
 */
#if defined(CrayArchitecture) || defined(MacIIArchitecture) || defined(UltrixArchitecture) || defined(IngrArchitecture) || defined(HPArchitecture)
       BSDREPLY = -DBSDREPLY=1
#endif
#if defined(IBMArchitecture)
       BSDREPLY = -DBSDREPLY=3
#endif
#if defined(SunArchitecture)
       BSDREPLY = -DBSDREPLY=7
#endif
#if defined(SGIArchitecture)
       BSDREPLY = -DBSDREPLY=6
#endif


/*
 * Some machines support the directory record structure by the name of
 * dirent. These machines will include a header file named dirent.h. Other
 * machines support the directory record structure by the name of direct.
 * These machines will include a header file named sys/dir.h.  Some machines
 * support both.  If the DIRENT flag is set then the dirent.h file and
 * dirent structure will be used.
 */
#if defined(CrayArchitecture) || defined(HPArchitecture) || defined(SQNTArchitecture) || defined(IBMArchitecture) || defined(IngrArchitecture) 
    NEED_DIRENT = -DDIRENT 
#else /* ! Cray */
    NEED_DIRENT =
#endif


/*
 * On some machines the BSD-style mail reader supports an alwaysignore
 * variable, or the copy command honors the ignore and retain lists as
 * the print command does.  If your machine does not support one of these
 * features, then a work around is needed so as to honor the ignore and
 * retain lists.  This is done through an internal version of copy which
 * actually uses the print command.  This is turned on by setting the
 * NEED_COPYMSG flag.
 */
#if defined(CrayArchitecture) || defined(SGIArchitecture) || defined(IBMArchitecture) || defined(SQNTArchitecture) || defined(IngrArchitecture) || defined(MacIIArchitecture)
   NEED_COPYMSG = -DNEED_COPYMSG
#else /* ! Cray */
   NEED_COPYMSG =
#endif

/*
 * So as to preserve the permissions (SECURITY ALERT) of the message file
 * being viewed, XMailTool creates an empty file and truncates this file
 * between messages.  Some machines support a truncate function for this
 * purpose, others need to use the O_TRUNC option on open to acheive this.
 * If your machine doesn't support the truncate function, you'll need
 * to set the NEED_TRUNCATE flag.
 */
#if defined(CrayArchitecture) || defined(IngrArchitecture)
  NEED_TRUNCATE = -DNEED_TRUNCATE
#else /* ! Cray */
  NEED_TRUNCATE =
#endif

/*
 * Some machines have a function mkstemp() which returns the file descriptor
 * for newly created temporary file, given a format string.  This is
 * like combining the mktemp() call with an open call.  If your machine
 * doesn't support this function, you'll need to set the NEED_MKSTEMP
 * flag.
 */
#if defined(SYSV) || defined(UltrixArchitecture) || defined(CrayArchitecture) || defined(SQNTArchitecture) || defined(IngrArchitecture) || defined(MacIIArchitecture)
   NEED_MKSTEMP = -DNEED_MKSTEMP
#else /* ! SYSV */
   NEED_MKSTEMP =
#endif

/*
 * Some machines support a function named strstr(s1,s2) which returns a
 * pointer to the first occurance of string s2 in s1. If your machine
 * doesn't support this function, you'll need to set the NEED_STRSTR flag.
 */
#if defined(IBMArchitecture) || defined(SQNTArchitecture) || defined(MacIIArchitecture)
    NEED_STRSTR = -DNEED_STRSTR
#else /* ! IBM */
    NEED_STRSTR =
#endif

/*
 * Some machines support a case insensitive version of strcmp() called
 * strcasecmp(). If your machine doesn't support this function, you'll need
 * to set the NEED_CASECMP flag.
 */
#if defined(IBMArchitecture) || defined(SQNTArchitecture) || defined(MacIIArchitecture)
   NEED_CASECMP = -DNEED_CASECMP
#else /* ! IBM */
   NEED_CASECMP =
#endif

/*
 * On IBM S/6000s the header <string.h> has a strchr macro that expands
 * strchr to __strchr, and the latter is then used by the compiler to
 * generate inline code for strchr.  Because of the macro, extern
 * declarations contains an invalid macro expansion. This can be avoided
 * by the use of the following flag:
 */
#if defined(IBMArchitecture)
    SPECIAL_FLAG = -U__STR__
#else /* ! IBM */
    SPECIAL_FLAG =
#endif



        DEFINES = $(MREADER) $(MBOXDIR) $(MSENDER) $(NEED_DIRENT) \
  $(NEED_COPYMSG) $(TAB_DELIMITED) $(NEED_TRUNCATE) $(NEED_MKSTEMP) \
  $(NEED_STRSTR) $(NEED_CASECMP) $(SPECIAL_FLAG) $(DEF_HELPFILE) \
  $(BSDREPLY) $(PRINTER_CMD) $(DEF_AD_FILE)
	

ComplexProgramTarget(xmailtool)
/*
InstallAppDefaults(XMailTool)
InstallAppDefaults(XMailTool-color)
*/
install-files: xmailtool.help XMailTool.ad XMailTool-color.ad	
	MakeDir($(AD_DIR))
	MakeDir($(HELP_DIR))
	$(INSTALL) -c $(INSTDATFLAGS) xmailtool.help $(HELP_DIR)
	$(INSTALL) -c $(INSTDATFLAGS) XMailTool.ad $(AD_DIR)
	$(INSTALL) -c $(INSTDATFLAGS) XMailTool-color.ad $(AD_DIR)
