/* $Id: Imakefile,v 1.44 1995/05/12 22:09:30 bobo Exp $
 *
 *  Imakefile for xmailtool
 */
/*

Copyright 1990 by Cray Research, Inc.

Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation, and that the name of Cray Research, Inc. not be used in 
advertising or publicity pertaining to distribution of the software without
specific, written prior permission.  Cray Research, Inc. makes no 
representations about the suitability of this software for any purpose.  It 
is provided "as is" without express or implied warranty.

*/

#ifndef NO_XFACE

       COMPDIR = compface
/*
 * Comment the following lines if you cannot get compfaces to work
 * on your system.  
 */
HAS_XFACE     = -DHAS_XFACE
#define XFACELIB compface/libcompface.a 

XFACE_SRC = xface.c
XFACE_OBJ = xface.o

#else
       COMPDIR =
#endif

#ifdef LOCAL_HYPER_TEXT

   HYPERTEXTDIR = /usr/www/htdocs/XMailTool
         HYPDIR = hypertext

#endif

        SUBDIRS = $(COMPDIR)

#define IHaveSubdirs
#define PassCDebugFlags
MakeSubdirs($(SUBDIRS))

#ifndef XFACELIB
#define XFACELIB
#endif

LOCAL_LIBRARIES = XawClientLibs
        DEPLIBS = XawClientDepLibs
#ifdef IngrArchitecture
  SYS_LIBRARIES = -lmath -lmalloc XFACELIB
#else
  SYS_LIBRARIES = -lm XFACELIB
#endif
           SRCS = check_mail.c xmailtool.c proc.c util.c mail_int.c \
		date.c $(XFACE_SRC) expand_value.c get_UV_value.c \
		mailhandler.c mailrc.c setaliases.c setvars.c uname.c

      TOOL_SRCS = check_mail.c xmailtool.c proc.c util.c mail_int.c \
		setvars.c aliases.c $(XFACE_SRC) mailhandler.c \
                expand_value.c get_UV_value.c setaliases.c

           OBJS = check_mail.o xmailtool.o proc.o util.o mail_int.o \
		date.o $(XFACE_OBJ) expand_value.o get_UV_value.o \
		mailhandler.o mailrc.o setaliases.o setvars.o uname.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.
 */

#ifdef HPArchitecture
      CCOPTIONS = -Ae
#endif

/*
 * The prefered location of the Help file.  This is probably site dependant
 * rather than Architecture dependant.
 */
       HELP_DIR = $(LIBDIR)/xmailtool
   DEF_HELPFILE = -DDEFAULT_HELPFILE=\"$(HELP_DIR)/xmailtool.help\"

/*
 * 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) || (defined(SunArchitecture) && (OSMajorVersion >= 5))
        MBOXDIR = -DMAILBOX_DIRECTORY=\"/usr/mail\"
#else /* ! SYSV */
#if defined(SunArchitecture) || defined(IBMArchitecture) || defined(LinuxArchitecture) || defined(ConvexArchitecture)
        MBOXDIR = -DMAILBOX_DIRECTORY=\"/usr/spool/mail\"
#else /* ! Sun */
#if defined(vax) || defined(UltrixArchitecture) || defined(AlphaArchitecture)
        MBOXDIR = -DMAILBOX_DIRECTORY=\"/var/spool/mail\"
#endif /* vax */
#endif /* SUN */
#endif /* SYSV */
#if defined(i386BsdArchitecture)
        MBOXDIR = -DMAILBOX_DIRECTORY=\"/var/mail\"
#endif

/*
 * 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.
 */
/*
 * There have been some reports of security issues related to using
 * /usr/ucb/mail as te mail sending agent on Sun machines.  For this
 * reason, XMailTool should use sendmail instead.  But, if you
 * really feel strongly about using /usr/ucb/mail, you may uncomment
 * this segment and the corresponding #endif
 */
/*#if defined(SunArchitecture)
        MSENDER =
       SENDMAIL = -DMSENDER=\"/usr/ucb/mail\"
#else /* ! Sun */ 
        MSENDER = -DUSE_SENDMAIL
#if defined(i386BsdArchitecture)
       SENDMAIL = -DMSENDER=\"/usr/sbin/sendmail\"
#else
       SENDMAIL = -DMSENDER=\"/usr/lib/sendmail\"
#endif
/*#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


/*
 * The help window is supported through HyperText.  If you don't
 * have a HyperText client such as Mosaic, HYPERTEXT should be empty.
 * Otherwise, it should point to the name of the HyperText client.
 */
      HYPERTEXT = -DHYPERTEXT=\"netscape\"


/*
 * The latest and greatest stuff should be accessable from MY machine.
 * If you don't have access to MY machine, you will need to install
 * the hypertext documentation on your machine and change the DEFURL
 * to point to where users should get help.
 */
DEFURL = -DDEFURL=\"http:\/\/www.cray.com/XMailTool/XMailTool.shtml\"


/*
 * 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) || defined (AlphaArchitecture) || defined (SunArchitecture) || defined(ConvexArchitecture)
    NEED_DIRENT = -DDIRENT 
#else /* ! Cray */
    NEED_DIRENT =
#endif

#if defined (SunArchitecture) || defined(SGIArchitecture) || defined(HPArchitecture)
    NEED_SETENV = -DNEED_SETENV
#else
    NEED_SETENV =
#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 function named strerror() which prints a string
 * based on the value passed in (usually errno).  On most systems that
 * support this feature, more error strings are provided than are in the
 * sys_err[] array.  Since XMailTool wants to print the error messatge
 * in the warning window rather than to the controlling tty, this type
 * of function is handy.  If your system doesn't support this funciton
 * then XMailTool will fake it by definging a macro by the same name
 * that simply returns the value of sys_err[errno].
 */
#if (defined(SunArchitecture) &&  (OSMajorVersion == 4))
   NEED_STRERROR = -DNEED_STRERROR
#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

#if defined(SunArchitecture)
   INSTMAILFLAGS = -g mail -m 2755
#else
   INSTMAILFLAGS =
#endif


        DEFINES = $(MREADER) $(MBOXDIR) $(MSENDER) $(NEED_DIRENT) \
  $(NEED_TRUNCATE) $(NEED_MKSTEMP) $(NO_UNISTD) $(SENDMAIL) $(DEFURL)\
  $(NEED_STRSTR) $(NEED_CASECMP) $(SPECIAL_FLAG) $(DEF_HELPFILE) \
  $(PRINTER_CMD) $(HAS_XFACE) $(NEED_STRERROR) $(HYPERTEXT) $(NEED_SETENV)
	
#ifndef NullParameter
#define NullParameter /**/
#endif

AllTarget(xmailtool)
NormalProgramTarget(xmailtool,$(OBJS),$(DEPLIBS),$(LOCAL_LIBRARIES),NullParameter)
InstallProgramWithFlags(xmailtool,$(BINDIR),$(INSTMAILFLAGS))
InstallManPage(xmailtool,$(MANDIR))

InstallAppDefaults(XMailTool)
InstallAppDefaults(XMailTool-color)
MakeDirectories(install,$(HELP_DIR))
InstallNonExec(xmailtool.help,$(HELP_DIR))

uname.c:
	@(if [ ! -h uname.c ]; then \
	set -x; \
	rm -f uname.c; \
	uname -a | awk '{print "char *UNAME_STRING = \"" $$0 "\";"}' > uname.c;\
	fi)

clean::
	rm -f uname.c

#ifdef LOCAL_HYPER_TEXT

install.www:: 
	MakeDir($(DESTDIR)$(HYPERTEXTDIR))
	@case '${MFLAGS}' in *[i]*) set +e;; esac; \
	list=`ls -a $(HYPDIR)`; \
	for i in $$list; do \
		(if [ ! -d $(HYPDIR)/$$i ]; then \
		set -x; \
		$(RM) $(DESTDIR)$(HYPERTEXTDIR)/$$i; \
		$(CP) $(HYPDIR)/$$i $(DESTDIR)$(HYPERTEXTDIR)/$$i; \
		fi); \
	done
	$(RM) $(DESTDIR)$(HYPERTEXTDIR)/index.html
	$(LN) $(DESTDIR)$(HYPERTEXTDIR)/XMailTool.shtml $(DESTDIR)$(HYPERTEXTDIR)/index.html
#endif
/*
		$(INSTALL) -c $(INSTDATFLAGS) $(HYPDIR)/$$i $(DESTDIR)$(HYPERTEXTDIR)/$$i; \

*/

