# Makefile for ME
##########################################################################
##		     Start of User Configuration			##
##########################################################################

# You may also need to configure config.h.  It tries to self configure,
#   but there is a change it may not.

# Some of the files mentioned here are in the misc/ directory.  If you
# want to use one of them, copy it to this directory before compiling.

# Termainal driver.  Use 1 of:
#   tcap.o     : Termcap driver.  Use this for Unix.
#   blank      : If the terminal driver is in another file. Use this for X11.
#   pcfv.obj   : Fast video for IBM PCs and clones.  Use this for PCs.
#	         Set FASTVIDEO to 1 in config.h.
#   ansi.obj   : ANSI escape sequences, intended for PCs (in misc/).
#   hpterm.obj : HP terminals, intended for PCs (in misc/).  Don't use.
#
TERMINAL = tcap.o
#TERMINAL =

# Terminal library.
# If using termcap (TERMINAL = tcap.o), use one of:
#   -ltermcap : HP-UX, Apollo, Sun, atariST (TOS/MiNT)
#   -lcurses  : HP-UX, AIX 3.1 or earlier.  3.2 can use -ltermcap
# If using X11:
#   Normal case:  -lX11
#   If using HP-UX:
#     TERMLIB = /usr/lib/X11R5/libX11.sl 
#     X11_includes = -I/usr/include/X11R5
#   Set FASTVIDEO to 1 in config.h (for X11).
# Else blank : If not using tcap.c (PCs)
#
TERMLIB = -ltermcap
X11_includes =

#TERMLIB = /usr/lib/X11R5/libX11.sl
#X11_includes = -I/usr/include/X11R5
HP_X11_includes = -I/usr/include/X11R5

# I/O type.  Use 1 of (used to configure config.h):
#   blank	: The normal case
#   -DXIO	: If using X11
#
IO_TYPE =
#IO_TYPE = -DXIO=1

# I/O.  Use 1 of:
#   unixio.o    : Unix:  BSD, HP-UX, AIX, etc
#   pcio.obj    : PC-DOS and clones
#   stio.o      : atariST (TOS/MiNT) (in misc/)
#   msdosio.obj : Vanilla MS-DOS (in misc/)
#   X.o         : X11.  Includes the terminal driver.
#
IO = unixio.o
#IO = X.o

# "Special" keymap support (above and beyond ASCII).  Use 1 of:
#   blank      : The normal case, Unix, atariST-MiNT
#   Xkmap.o    : X11
#   pckmap.obj : Decodes the IBM PC keyboard
#   stkmap.o   : AtariST-TOS (in misc/)
#   hpkmap.o   : Knows a bit about HP terminals.
#	         (Set HPKB to 1 in config.h) (in misc/) Don't use.
#
KEYMAP =
#KEYMAP = Xkmap.o

# How to read and write files.  Use 1 of:
#   fileio.c     : The normal case
#   pcfileio.obj : Special support for IBM PCs.  Implements a cached
#		read using some asm code.  Your compiler may not be able to
#		compile it.  (in misc/).  You don't need this, fileio.c
#		works fine.
#
FILEIO = fileio.o

# Compute server library.  Make sure you sync this with COMPUTE_SERVER
#   in config.h.
#   if COMPUTE_SERVER is 1:
#     ../comserver/cliserve.a : non-SYSV unix, no MS-DOS
#   if COMPUTE_SERVER is 0:
#     blank : If your OS doesn't support the compute server.  The simple case.
#
PROCESS = ../comserver/cliserve.a	# unixen
# PROCESS =	# atariST (TOS/MiNT) (yes MiNT too!)

# What Mutt code to compile into ME
# Use:
#   ../mutt/builtin/me3.mco
#   or your own Mutt file.
# Note:  The Mutt code must be compiled before this Makefile is run.
#
internal_Mutt = ../mutt/builtin/me3.mco		#./boot.mco

##########################################################################
##			End of User Configuration			##
##########################################################################

SRC = bag.c basic.c buffer.c bvar.c display.c file.c line.c		 \
   main.c os.c misc.c mline.c mark.c random.c region.c regexp.c search.c \
   spawn.c window.c word.c undo.c key.c help.c mmaux.c mmfcn.c mmfcn2.c  \
   case.c process.c mutt.c

OBJ = $(SRC:.c=.o)

ME_OBJ = $(OBJ) $(TERMINAL) $(IO) $(KEYMAP) $(FILEIO)
X_OBJ = $(OBJ) X.o Xkmap.o fileio.o
TERMCAP_OBJ = $(OBJ) tcap.o unixio.o fileio.o

# GNUmake:
#ifeq ($(ATARI),atariST)
#CFLAGS = $(BASECFLAGS) -I. -I../mc -I../ed -I../util $(X11_includes)
#else
CFLAGS = $(BASECFLAGS) $(IO_TYPE)\
-I. -I../mc -I../ed -I../util -I../comserver $(X11_includes)
#endif

all: me3

announce:
	@echo "**** Building the Mutt Editor ********"
	@echo "CC is:" $(CC)
	@echo "CFLAGS are:" $(CFLAGS)


me3: announce mutt.c $(ME_OBJ)
	$(CC) -o me $(ME_OBJ) $(PROCESS) \
	../mc/mm2.a ../ed/led.a ../ed/ed.a ../util/util.a $(TERMLIB) $(LDFLAGS)

Xme: announce mutt.c $(X_OBJ)
	$(CC) -o xme $(X_OBJ) $(PROCESS) \
	../mc/mm2.a ../ed/led.a ../ed/ed.a ../util/util.a \
	$(LDFLAGS) -lX11

termcap_ME: announce mutt.c $(TERMCAP_OBJ)
	$(CC) -o me $(TERMCAP_OBJ) $(PROCESS) \
	../mc/mm2.a ../ed/led.a ../ed/ed.a ../util/util.a $(LDFLAGS) -ltermcap


    # build the internal Mutt code
mutt.c : $(internal_Mutt)
	../mc/mco_to_c $(internal_Mutt) > mutt.c

clean:
	rm -f *.o mutt.c

realclean:
	rm -f *.o mutt.c me xme me3
