# Unix Makefile for JED

# Note!!!  You also need to build the S-Lang library.  You should have
#          received a copy of it with this distribution.
#          Build it first.

# This file is divided into three sections.  The first section consists of 
# compile time options.  The second section is system specific so read it
# carefully.  The final section can be ignored.

#-------------------------------------------------------------------------
# You must undefine any of these if you compiler does not have the appropriate
# function (memset, memcpy, memcmp, memchr)
# I have come to the conclusion that most Unix memchr routines are poor.
# JED's is MUCH better.
CFLAGS1A = -DHAS_MEMSET -DHAS_MEMCPY -DHAS_MEMCMP #-DHAS_MEMCHR

# Root directory where jed files are going to be kept.  This is the parent 
# of JED's src, lib, etc, bin, and info directories.  MAKE SURE THAT THE '#' 
# IMMEDIATELY FOLLOWS THE PATH.  THERE CAN BE NO WHITESPACE HERE!
JED_ROOT = /usr/local/jed#

# S-Lang Library include path.  This one assumes that slang and jed are on
# the same level in the directory tree.
SLIB = ../../slang/src

# Note that since version 0.92, JED has had the ability to do floating point
# arithmetic.  This is enable by defining FLOAT_TYPE.  If you do not want 
# floating point support, comment out next two lines:
CFLAGS1 = $(CFLAGS1A) -DFLOAT_TYPE
LFLAGS = -lm

#------------------------------------------------------------
# XWindow version of JED specifics
# 
# If you are also compiling an XWindows version of JED, you need to 
# set up the path for the X11 include files.  This is simply the directory
# that contains the X11 directory.  Try using the one below.
XINCLUDE = -I/usr/include/mit

# Library to use for linkiing in the X11 code.  On many systems, it is simply
# given by -lX11, while for some, it is -lX11-mit
#XLIB = -lX11
XLIB = -lX11-mit

#------------------------ machine specific flags --------------------------
#
# Look for your machine in right margin and comment out others.
#
#                                                                   ULTRIX
CFLAGS = -O
CC =cc

#                                                                   SunOS
#CC =gcc  #also try acc
#CFLAGS = -O  -traditional-cpp


#                                                                  HP-UX
# CFLAGS =-Aa -D_HPUX_SOURCE -Dunix 
# CC = cc

#                                                                 AIX 
#CFLAGS = -DAIX -Dunix 
#CC = cc
# This was also suggested for AIX.  I do not know what the flags 
# mean though: CFLAGS = -O3 -DAIX -Dunix -v -qphsinfo -qsource -qlistopt


#                                                                  NeXT
#CFLAGS = -Dsequent                                              
#CC = cc   # or: gcc

#                                                                 Linux
# Someone suggested using -O6 instead of -O2.
#CFLAGS= -O2 -fstrength-reduce -DPOSIX_SOURCE 
#CC=gcc

#                                                         SYSV ISC R3.2 v3.0 
#CC=gcc
#CFLAGS= -Dunix -DSYSV
#LIBS = -linet -lnsl_s -lcposix
#                                                For Sequent Dynix use CC=gcc

#
#  some systems may need to define POSIX as well,          e.g., IRIX
#CFLAGS = -c -prototypes -DPOSIX

#                                                              OSF
#CC = cc                                               
#CFLAGS = -O -DXLIB_ILLEGAL_ACCESS



#-----------------------------------------------------------------------
CFILES = buffer.c cmds.c misc.c file.c main.c display.c ins.c sig.c\
         sysdep.c screen.c paste.c ledit.c line.c vterm.c search.c text.c\
         keymap.c replace.c window.c undo.c mem.c vfile.c\
	 intrin.c
OBJS = buffer.o cmds.o misc.o file.o main.o ins.o sig.o\
         sysdep.o screen.o paste.o ledit.o line.o vterm.o search.o text.o\
         keymap.o replace.o window.o undo.o mem.o vfile.o\
	 intrin.o syntax.o
HFILES = buffer.h cmds.h display.h file.h ins.h keymap.h ledit.h line.h\
         misc.h paste.h screen.h search.h sig.h sysdep.h text.h vterm.h\
	 replace.h window.h undo.h mem.h
MFILES = makefile.unx video.c vmsmake.com ibmpc.c unix.c\
         vms.c makecom.vms makefile.dos\
         fortran.jed jed.jed emacs.jed jed.rc most.jed

.c.o:
	$(CC) -c $(CFLAGS) $(CFLAGS1) -DJED  -I$(SLIB) $(XINCLUDE) $*.c

jed: $(OBJS) display.o
	$(CC) $(OBJS) display.o -o jed -L$(SLIB) -ltermcap -lslang $(LFLAGS)

main.o: main.c
	$(CC) -c $(CFLAGS) $(CFLAGS1) -DJED -DJED_ROOT='"$(JED_ROOT)"' -DJED_LIBRARY='"$(JED_ROOT)/lib"' -I. -I$(SLIB) main.c

xjed: $(OBJS) xterm.o
	$(CC) $(OBJS) xterm.o -o xjed -L$(SLIB) -lslang  $(XLIB) $(LFLAGS)

export:
	export -f zip.lis

rgrep: mem.o vfile.o rgrep.o
	$(CC) mem.o vfile.o rgrep.o -o rgrep -L$(SLIB) -lslang 

getmail: getmail.o
	$(CC) getmail.o -o ../bin/getmail
