# --- INSTALLATION ---
# Modify this constatn to be the place where you have installed the
# argus directory.  
#
TOPDIR = 

# --- INSTALLATION ---
# Modify this constatn to be the place where you have installed the
# argus directory.  This must be an absolute and not relative
# directory pathname (i.e. /mit/projects/argus ).
#
TOPDIR_ABSOLUTE = 

# --- INSTALLATION ---
# Modify this constant to point to the mh 'rcvstore' command.  If
# 'rcvstore' is not in its normal accesable place, specify its full
# path in this constant, otherwise just specify 'rcvstore'.  
MH_RCVSTORE_FIX= -DAlMH_RCVSTORE_PATH=\"/usr/new/mh/lib/rcvstore\"

# --- INSTALLATION ---
# Modify these constatns to be the Motif include directory and the
# Motif library directories on your system
#
MOTIF_INCLUDE_DIR= 
MOTIF_LIB_DIR= 

# --- INSTALLATION ---
# This should be defined as the directories where the include files
# can be found for the Motif toolkit.  This should specify the
# directory where the directories X11/ and Xt/ are located.
#
MOTIF_XT_INCLUDE_DIR= 

# --- INSTALLATION ---
# If your system uses the hesiod name server uncomment the following lines.
# 
# HESIOD_LIB=    -lhesiod
# HESIOD_LIB_DIR= -L/usr/athena/lib
# HESIOD_COMP_FLAG= -Dathena_unix=1



#
# Include directories for argus code
#
ARGUS_SRC= $(TOPDIR)/src
ARGUS_ANSI_INCLUDE_DIR= $(ARGUS_SRC)/ansi-include

INCLUDEDIRS= 	-I$(ARGUS_ANSI_INCLUDE_DIR) \
		-I$(ARGUS_SRC) \
		-I$(MOTIF_INCLUDE_DIR)	\
		-I$(MOTIF_XT_INCLUDE_DIR)

# --- INSTALLATION ---
# modify any of these defenitions if necessary.  Note that argus makes
# use of the 'const' declaration modifier.  If your compiler does not
# support const then add a -Dconst= to the CC defenition below
#
CC 		= gcc -Dconst= 
AR 		= ar q
RANLIB 		= ranlib
RM		= rm -f
MV		= mv -f

# --- INSTALLATION ---
#
#			  COMPILATION FLAGS
#
# Please read these descriptions and add the appropriate defenitions
# to the COMPFLAGS defenition below.  To add an option simply add
# "-D<option-name>" to the COMPLFLAGS defenition.
#
# 
# If you have the motif utilities (libMu.a and header files) then
# define MOTIF_UTILITIES 
#
# If your system has the function setenv(,,) then uncomment then
# define HAVE_SETENV

# If you wish to compile the ruleeditor with menu accelerators, define
# WITH_ACC.

# ALWAYS define BUG_1_EXISTS.  This enables code to get around a Motif
# bug.  By the time this bug is fixes in Motif, there will be a new
# version of Argus available.

#
# DEBUGGING COMPILATION FLAGS
# 
# For memory debugging put these two flags into the COMPFLAGS
# defenition below  
#	-DMEMORY_LEAK_COUNT=1
#	-DMEMORY_CHECK_POINTERS=1 
#
# For message object debugging information insert this flag into the
# COMPFLAGS defenition below.  Increasing the number of this flag
# increases the debuggong information.  The message object is the
# internal object which represents a single message as it is processed
# by the runrules command
#       -DMSGDEBUG=1
#


COMPFLAGS= 	$(HESIOD_COMP_FLAG) \
		-Dbsd_unix \
		-Dunix \
		$(MH_RCVSTORE_FIX) \
		${INCLUDEDIRS} \
		-DSYSTEM_LENS_PROFILE=\"$(TOPDIR_ABSOLUTE)/argusprofile\" \
		-DX11_R3 \
		-DBUG_1_EXISTS \
		-DWITH_ACC \
		-DMOTIF_UTILITIES \
		-DHAVE_SETENV

# --- INSTALLATION ---
# If you have define MOTIF_UTILITIES then uncomment the following line
MOTIF_UTILITIES_LIB = -lMu.a

#
#
# Libraries
#
LIBS= -largus $(HESIOD_LIB)
XLIBS= -lxargus ${LIBS} $(MOTIF_UTILITIES_LIB) -lXm -lXt -lXmu -lX

#
# Library directories
#
LIBDIRS= $(HESIOD_LIB_DIR) -L$(ARGUS_SRC)
XLIBDIRS= ${LIBDIRS} -L$(MOTIF_LIB_DIR)

#
# Link flags
#
LINKFLAGS= $(LIBDIRS)
XLINKFLAGS= ${XLIBDIRS}


# Following two lines are used just for bookeeping so we remember whats what
OPROGS= runrules.o alcomp.o lensdc.o anyone.o
XPROGS= rsedit.o mteditor.o ruleeditor.o rulebrowser.o

OSUBS= FTreg.o FieldCore.o FieldType.o MTreg.o MsgType.o OSinter.o RSreg.o \
 a1client.o a1server.o action.o al.o altime.o argpack.o \
 biregistry.o boolfield.o cicommafield.o \
 cistringfield.o commafield.o \
 darray.o data.o datefield.o \
 folder.o foldert.o getdate.o help.o intfield.o \
 memory.o mh_folder.o msg.o predeval.o profile.o \
 registry.o rm_folder.o rule.o rulerun.o ruleset.o \
 ruleprint.o stringfield.o \
 sysreg.o text.o useful.o verb.o verbs.o verbrgy.o \
 version.o RMFBuffer.o \
 opvalscan.o rap.o debug.o

XSUBS= ArgPack.o alpop.o alxms.o almonitor.o alfonts.o rebox.o \
        menupack.o childpack.o xstuff.o d2args.o d2field.o d2fieldargs.o \
	global.o \
	rem.o d2.o rl.o ed.o ft.o mt.o ru.o rs.o df.o

# mte.o mteEd.o

libs: lib xlib
	touch libs

lib: libargus.a
	touch lib

xlib: libxargus.a
	touch xlib

basic:  libargus.a runrules alcomp argusdc anyone
	touch basic

xbasic:  libxargus.a ruleeditor argusi rulebrowser
	touch xbasic

all: basic xbasic
	touch all

# mteditor 
	
.c.o:
	$(RM) $*.o
	${CC} ${COMPFLAGS} -c $*.c

.c.s:
	$(RM) $*.o
	${CC} ${COMPFLAGS} -S $*.c

###### Basic Applications	
runrules: runrules.o libargus.a
	$(RM) runrules.new
	${CC} ${LINKFLAGS} -o runrules.new runrules.o libargus.a ${LIBS}
	$(MV) runrules.new runrules

alcomp: alcomp.o libargus.a
	$(RM) alcomp.new
	${CC} ${LINKFLAGS} -o alcomp.new alcomp.o libargus.a ${LIBS}
	$(MV) alcomp.new alcomp

argusdc: lensdc.o libargus.a
	$(RM) lensdc.new
	${CC}  ${LINKFLAGS} -o lensdc.new lensdc.o libargus.a ${LIBS}
	$(MV) lensdc.new argusdc

anyone: anyone.o libargus.a
	$(RM) anyone.new
	${CC}  ${LINKFLAGS} -o anyone.new anyone.o libargus.a ${LIBS}
	$(MV) anyone.new anyone

###### X applications
rsedit: rsedit.o libargus.a libxargus.a
	$(RM) rsedit.new
	${CC}  ${XLINKFLAGS} -o rsedit.new rsedit.o  ${XLIBS}
	$(MV) rsedit.new rsedit
      
ruleeditor: ruleeditor.o libargus.a libxargus.a
	$(RM) ruleeditor.new
	${CC}  ${XLINKFLAGS} -o ruleeditor.new ruleeditor.o  ${XLIBS}
	$(MV) ruleeditor.new ruleeditor
      
rulebrowser: rulebrowser.o libargus.a libxargus.a
	$(RM) rulebrowser.new
	${CC}  ${XLINKFLAGS} -o rulebrowser.new rulebrowser.o  ${XLIBS}
	$(MV) rulebrowser.new rulebrowser

argusi: argusi.o libargus.a libxargus.a
	${CC} ${XLINKFLAGS} -o argusi.new argusi.o ${XLIBS}
	$(MV) argusi.new argusi

###### Libraries
libargus.a: ${OSUBS}
	$(RM) newlibargus.a
	$(AR) newlibargus.a ${OSUBS}
	$(RANLIB) newlibargus.a
	$(MV) newlibargus.a libargus.a

libxargus.a: ${XSUBS}
	$(RM) newlibxargus.a
	$(AR) newlibxargus.a ${XSUBS}
	$(RANLIB) newlibxargus.a
	$(MV) newlibxargus.a libxargus.a

###### yacc code
getdate.c: getdate.y
	@echo "expect 8 shift/reduce conflicts"
	$(RM) y.tab.c
	yacc getdate.y
	$(MV) y.tab.c getdate.c

###### depend	
depend:	
	sh ./makedepend.sh ${COMPFLAGS} 
	chmod g+rw Makefile


	
# AUTOMATIC DEPENDENCIES--DO NOT EDIT THIS LINE OR BELOW
