# -*- sh -*-

# C compiler and C flags
CC = @CC@
CFLAGS = @CFLAGS@ @X_CFLAGS@
LDFLAGS = @LDFLAGS@

#---------------------------------------------------------------------------
# Installation information.  All jed library files will be placed under
# $JED_ROOT.  /usr/local/jed is a good choice.  For a private installation,
# use, e.g., $(HOME)/src/jed
#---------------------------------------------------------------------------
prefix = @prefix@
exec_prefix = @exec_prefix@
#JED_ROOT = $(HOME)/src/jed# <--- make sure # is at end of file!!
#JED_ROOT = $(prefix)/jed# <--- make sure # is at end of file!!
JED_ROOT = @JED_ROOT@# <--- make sure # is at end of file!!
BIN_DIR = @bindir@
MAN_DIR = @mandir@/man1
INSTALL		= @INSTALL@
INSTALL_DATA	= @INSTALL_DATA@
MKINSDIR = ../autoconf/mkinsdir.sh

#---------------------------------------------------------------------------
# Location of jed source code 
#---------------------------------------------------------------------------
# Location of jed source code (absolute path)
SRCDIR = @SRCDIR@

# Location of compiled object code (absolute path)
OBJDIR = @OBJDIR@

#---------------------------------------------------------------------------
# Special features (See also features.h)
#---------------------------------------------------------------------------
# 1. Linux GPM Mouse support
#    Uncomment next FOUR lines for GPM mouse support
#MOUSEFLAGS = -DUSE_GPM_MOUSE
#MOUSELIB = -lgpm
#GPMMOUSEO = gpmmouse.o
#OBJGPMMOUSEO = $(OBJDIR)/$(GPMMOUSEO)

#---------------------------------------------------------------------------
# S-Lang library location
#---------------------------------------------------------------------------
# Location of libslang.a 
SLANG_LIB_DIR = @SLANG_LIB_DIR@

# Location of slang.h
SLANG_INCLUDE = @SLANG_INCLUDE@

#---------------------------------------------------------------------------
# X and Miscellaneous libraries
#---------------------------------------------------------------------------
# Some systems need -ltermcap (NeXT)
TERMCAP_LIB = @TERMCAP@

# X library location
XLIBDIR = @X_LIBS@

# X Include directory
XINCLUDE = @X_CFLAGS@

# Extra libraries needed by X some systems
X_XTRA_LIBS = @X_EXTRA_LIBS@

#---------------------------------------------------------------------------
# There should be no need to modify anything below here.
#---------------------------------------------------------------------------

MIN_SLANG_VERSION = 10000
MAX_SLANG_VERSION =
XLIB = $(X_XTRA_LIBS) $(XLIBDIR) -lX11 $(TERMCAP_LIB)
MISCLIBS = $(MOUSELIB) $(TERMCAP_LIB)

ALL_CFLAGS = $(CFLAGS) -Dunix -DJED $(MOUSEFLAGS) -I$(SLANG_INCLUDE)
COMPILE_CMD = \
 $(CC) -c $(ALL_CFLAGS) $(XINCLUDE) -DJED_ROOT='"$(JED_ROOT)"'

CONFIG_H = config.h

OBJS = @PROGRAM_OBJECTS@
OFILES = @PROGRAM_OFILES@

jprocess_O_DEP = $(SRCDIR)/pty.c

all: jed rgrep


jed: $(OBJDIR) $(CONFIG_H) slangversion $(OBJDIR)/jed
	@echo jed created in $(OBJDIR)
$(OBJDIR)/jed: $(OBJS) $(OBJDIR)/display.o $(OBJGPMMOUSEO)
	cd $(OBJDIR); $(CC) $(OFILES) display.o $(GPMMOUSEO) \
           -o jed $(LDFLAGS) -L$(SLANG_LIB_DIR) -lslang $(MISCLIBS) -lm

slangversion: $(OBJDIR)/chkslang
	$(OBJDIR)/chkslang jed $(MIN_SLANG_VERSION) $(MAX_SLANG_VERSION)

$(OBJDIR):
	-mkdir $(OBJDIR)

$(CONFIG_H) : $(SRCDIR)/sysconf.h
	/bin/cp $(SRCDIR)/sysconf.h $(CONFIG_H)

$(OBJDIR)/chkslang: $(OBJDIR)/chkslang.o
	$(CC) $(OBJDIR)/chkslang.o -o $(OBJDIR)/chkslang

$(SRCDIR)/sysdep.c: $(SRCDIR)/unix.c
	touch $(SRCDIR)/sysdep.c
$(SRCDIR)/xterm.c: $(SRCDIR)/xkeys.c
	touch $(SRCDIR)/xterm.c
$(SRCDIR)/syntax.c: $(SRCDIR)/dfasyntx.c
	touch $(SRCDIR)/syntax.c
#
xjed : $(OBJDIR) $(CONFIG_H) slangversion $(OBJDIR)/xjed
	@echo xjed created in $(OBJDIR)
$(OBJDIR)/xjed : $(OBJS) $(OBJDIR)/xterm.o
	cd $(OBJDIR); \
	$(CC) $(OFILES) xterm.o -o xjed $(LDFLAGS) -L$(SLANG_LIB_DIR) -lslang  $(XLIB) -lm
#
rgrep: $(OBJDIR)/rgrep
	@echo rgrep created in $(OBJDIR)
$(OBJDIR)/rgrep: $(OBJDIR)/vfile.o $(OBJDIR)/rgrep.o
	cd $(OBJDIR); $(CC) vfile.o rgrep.o -o rgrep $(LDFLAGS) -L$(SLANG_LIB_DIR) -lslang
#
getmail: $(OBJDIR)/getmail
	@echo getmail created in $(OBJDIR)
$(OBJDIR)/getmail: $(OBJDIR)/getmail.o
	cd $(OBJDIR); $(CC) getmail.o -o getmail $(LDFLAGS)
#---------------------------------------------------------------------------
clean:
	/bin/rm -f $(OBJDIR)/* *~
distclean: clean
	/bin/rm -rf $(OBJDIR) Makefile sysconf.h
install: all $(JED_ROOT) $(BIN_DIR)/
	/bin/cp $(OBJDIR)/jed $(BIN_DIR)/
	- /bin/cp $(OBJDIR)/xjed $(BIN_DIR)/
	/bin/cp $(OBJDIR)/rgrep $(BIN_DIR)/
	- /bin/cp $(OBJDIR)/getmail $(JED_ROOT)/bin/
	- /bin/cp ../doc/rgrep.1 ../doc/jed.1 $(MAN_DIR)/
	@echo You will have to install the lib files manually.
$(BIN_DIR):
	- $(MKINSDIR) $(BIN_DIR)
$(JED_ROOT):
	$(MKINSDIR) $(JED_ROOT)/lib
	$(MKINSDIR) $(JED_ROOT)/bin
	$(MKINSDIR) $(JED_ROOT)/info
	$(MKINSDIR) $(JED_ROOT)/doc
# The symlinks target is for my own private use.  It simply creates the object
# directory as a symbolic link to a local disk instead of an NFS mounted one.
symlinks:
	-/bin/rm -f $(ARCH)objs
	mkdir -p $(HOME)/sys/$(ARCH)/objs/jed/src
	ln -s $(HOME)/sys/$(ARCH)/objs/jed/src $(ARCH)objs
#---------------------------------------------------------------------------
# Rules (automatically generated)
#---------------------------------------------------------------------------
