#############################################################################
#
#  Makefile for building Otter 3.0.  There is no configuration script
#  or higher-level make.  Edit this file to configure Otter.  There are
#  three things you may need to change:
#
#    DFLAGS  - to control conditional compilation to enable/disable things
#    CC      - to specify the C compiler (usually cc or gcc)
#    CFLAGS  - to specify optimization, debugging, and profiling
#
#  For current versions of Linux, SunOS, AIX, NeXTStep, and IRIX, you
#  shouldn't have to make any modifictions to this file.  See below for
#  HP-UX and DYNIX.  Other OSs have not yet been tested; see below for
#  clues, and let me know what happens (otter@mcs.anl.gov).
#
#  To compile otter, "make otter" and cross your fingers!
#  The binary will be left in this directory.  There is no man page.
#
#############################################################################

#############################################################################
#
#  The DFLAGS symbol, defined after this section of comments, controls
#  conditional compilation; it enables or disables various features.
#
#  Enable features:
#
#    -DTP_NAMES will get username, hostname.
#        Don't use if you get errors about gethostname, getuid, getpwuid.
#    -DTP_SIGNAL will cause some signals to be caught.
#        Don't use if you get errors about signal, SIGINT, SIGSEGV.
#    -DTP_FORK will allow interactive forks.
#        Don't use if you get errors about fork, wait.
#    -DTP_RUSAGE for calls to getrusage() (user time, system time).
#        Don't use if you get errors about rusage, getrusage, RUSAGE_SELF.
#        For HP-UX, also need -DHP_UX to use getrusage().
#
#  Disable features:
#
#    -DTP_NO_CLOCKS disables most timing---this can save a lot of system
#        CPU time, because many operations are timed.
#    -DTP_ABSOLUTELY_NO_CLOCKS disables all of the timing.
#        Use this as a last resort for timing or clock errrors.
#    -DTP_DYNIX is for our Sequent Symmetry (DYNIX 3.1.4), an oldish
#        BSDish unix; this flag disables several things, apparently
#        not available in DYNIX 3.1.4.
#    -DDOS_GCC is for the DOS version of GCC (djgpp).
#
#  The following DFLAGS are not normally used in a UNIX makefile such as this.
#
#    (-DTURBO_C is for Turbo C in DOS.)
#    (-DTHINK_C is for Macintosh.)
#
#  The following DFLAGS are for experimental versions of Otter.
#
#    (-DROO is for ROO, the shared-memory parallel version.)
#    (-DSCOTT is for SCOTT, the Otter/FINDER collaboration.)
#
###############
#  Here are some operating systems that have been tested and seem
#  to work correctly with the full set of features:
#
#  DFLAGS = -DTP_NAMES -DTP_SIGNAL -DTP_FORK -DTP_RUSAGE
#
#  Linux 99.pl13 (i486 gyro)
#  SunOS 4.1.3 (sparc lutra)
#  AIX 3.2.2 (RS6000 skiff)
#  NeXTStep 3.1 (NeXTStation pelican)
#  NeXTStep 3.1 (i486 raptor)
#  IRIX 4.0.5 (SGI amenhotep)
#
###############
#  HP-UX A.09.01 (snake) needs HP_UX to be defined (for getrusage macro):
#
#  DFLAGS = -DHP_UX -DTP_NAMES -DTP_SIGNAL -DTP_FORK -DTP_RUSAGE
###############
#  DYNIX 3.1.4 (anagram) cannot handle several things (see DYNIX in code)
#
#  DFLAGS = -DTP_DYNIX -DTP_NAMES -DTP_SIGNAL -DTP_FORK -DTP_RUSAGE
###############
#  MS-DOS 6.0, GCC (DJGPP 2.4.1, NDMAKE45)
#  Seems ok, but not fully tested.  Also see link step below.
#
#  DFLAGS = -DTP_RUSAGE -DDOS_GCC
###############
#  Others, not yet tested
#
#  Solaris (??)
#  OSF/?? (DEC Alpha)
#  Ultrix (Dec 5000)
#  MS-DOS (Turbo C)
#  Macintosh
#
# OK, here is where to define the DFLAGS:

DFLAGS = -DTP_NAMES -DTP_SIGNAL -DTP_FORK -DTP_RUSAGE

#############################################################################
# Specify the C compiler.  I recommend gcc (GNU C Compiler) if you have it.
#
CC = cc
#CC = gcc
#CC = /usr/local/gcc-2.4.5/bin/gcc

#############################################################################
# Specify the compiler flags (also include DFLAGS)
#
# optimized
CFLAGS = -O $(DFLAGS)
#
# save symbols for debuggers
#CFLAGS = -g $(DFLAGS)
#
# optimized, debugging  (gcc and gdb can handle this)
#CFLAGS = -O -g $(DFLAGS)
#
# gprof profiling
#CFLAGS = -pg -O $(DFLAGS)

#############################################################################

FILES =   av.c io.c share.c fpa.c clocks.c unify.c demod.c weight.c imd.c is.c clause.c options.c resolve.c index.c paramod.c formula.c process.c misc.c lrpo.c linkur.c linkhyp.c foreign.c geometry.c hot.c nonport.c dp_util.c check.c

OBJECTS = av.o io.o share.o fpa.o clocks.o unify.o demod.o weight.o imd.o is.o clause.o options.o resolve.o index.o paramod.o formula.o process.o misc.o lrpo.o linkur.o linkhyp.o foreign.o geometry.o hot.o nonport.o dp_util.o check.o

#############################################################################

##########
#
# For MS-DOS with DJGPP and NDMAKE, the link command below is too long.
# put OBJECTS in file link.rsp and run `gcc -o otter main.o @link.rsp'.
#
##########

otter: main.o $(OBJECTS)
	$(CC) $(CFLAGS) main.o $(OBJECTS) -o otter
	size otter

dosotter: main.o $(OBJECTS)
	gcc $(CFLAGS) -o otter main.o @link.rsp
        copy /b c:\djgpp\bin\go32.exe+otter otter301.exe

clean:
	/bin/rm *.o

proto_old:
	/bin/csh prot_old main.c $(FILES)

lint:
	lint $(DFLAGS) main.c $(FILES)

main.o $(OBJECTS): header.h
main.o $(OBJECTS): types.h
main.o $(OBJECTS): macros.h
main.o $(OBJECTS): cos.h
main.o $(OBJECTS): proto.h
foreign.o: foreign.h

#############################################################################
#
#  The following is for FormEd, a separate program for displaying and
#  editing formulas.
#

display.o callback.o formed.o: formed.h

# You may have to specify the directory where your X libraries reside

XLIBS = -L/usr/local/X11R5/lib -lXaw -lXmu -lXext -lXt -lX11 -lm
# XLIBS = -lXaw -lXmu -lXext -lXt -lX11 -lm

formed : formed.o display.o callback.o $(OBJECTS)
	$(CC) $(CFLAGS) formed.o display.o callback.o $(OBJECTS) $(XLIBS) -o formed

