#
# Makefile.in -- changed by Bruno Haible, 4 July 1994
#                changed by Marcus Daniels, 15 April 1994
#
# Makefile
#   Copyright (C) 1990, 1991, 1992 Free Software Foundation
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
#

#
# Makefile for readline and history libraries.
#

srcdir = .

prefix = /usr/local

exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
libdir = $(exec_prefix)/lib

datadir = $(prefix)/lib
mandir = $(prefix)/man
man1dir = $(mandir)/man1
man2dir = $(mandir)/man2
man3dir = $(mandir)/man3
man4dir = $(mandir)/man4
man5dir = $(mandir)/man5
man6dir = $(mandir)/man6
man7dir = $(mandir)/man7
man8dir = $(mandir)/man8
man9dir = $(mandir)/man9
infodir = $(prefix)/info
includedir = $(prefix)/include
docdir = $(datadir)/doc

SHELL = /bin/sh

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

CC = @CC@
CFLAGS = -O -g
INCLUDES = -I.
AR = ar
AR_FLAGS = qv
RANLIB = @RANLIB@
LIBS = @LIBS@

MAKEINFO = makeinfo

# Comment out "-DVI_MODE" if you don't think that anyone will ever desire
# the vi line editing mode and features.
READLINE_DEFINES = -DVI_MODE

RM = rm
CP = cp

CSOURCES = readline.c history.c funmap.c keymaps.c vi_mode.c \
	   emacs_keymap.c vi_keymap.c

HSOURCES = readline.h chardefs.h history.h keymaps.h
SOURCES  = $(CSOURCES) $(HSOURCES)

DOCUMENTATION = readline.texi inc-read.texi \
		history.texi inc-hist.texi

SUPPORT = COPYING Makefile $(DOCUMENTATION) ChangeLog

THINGS_TO_TAR = $(SOURCES) $(SUPPORT)

#### Host, target, and site specific Makefile fragments come in here.
###

STAGESTUFF = *.o

all: libreadline.a

check:
installcheck:
info:
dvi:

clean-info: force
	-rm -f *.info*

history.info: $(srcdir)/history.texi
	$(MAKEINFO) -o history.info $(srcdir)/history.texi

readline.info: $(srcdir)/readline.texi $(srcdir)/inc-read.texi
	$(MAKEINFO) -o readline.info $(srcdir)/readline.texi

libreadline.a:	readline.o history.o funmap.o keymaps.o tilde.o vi_mode.o @ALLOCA@ xmalloc.o
	$(RM) -f libreadline.a
	$(AR) $(AR_FLAGS) libreadline.a readline.o history.o funmap.o keymaps.o tilde.o vi_mode.o @ALLOCA@ xmalloc.o
	$(RANLIB) libreadline.a

# Specification of include file dependencies:
I_CONFIG_H    = config.h
I_SYSDEP_H    = $(srcdir)/sysdep.h $(I_CONFIG_H)
I_CHARDEFS_H  = $(srcdir)/chardefs.h
I_KEYMAPS_H   = $(srcdir)/keymaps.h $(I_CHARDEFS_H)
I_FUNMAP_H    = $(srcdir)/funmap.h
I_HISTORY_H   = $(srcdir)/history.h
I_READLINE_H  = $(srcdir)/readline.h $(I_KEYMAPS_H) $(I_FUNMAP_H)

readline.o:	$(srcdir)/readline.c $(I_SYSDEP_H) $(I_READLINE_H) $(I_HISTORY_H)
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/readline.c

history.o:	$(srcdir)/history.c $(I_SYSDEP_H) $(I_HISTORY_H)
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/history.c

funmap.o:	$(srcdir)/funmap.c $(I_SYSDEP_H) $(I_READLINE_H)
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/funmap.c

keymaps.o:	$(srcdir)/keymaps.c $(srcdir)/emacs_keymap.c $(srcdir)/vi_keymap.c $(I_SYSDEP_H) $(I_READLINE_H) $(I_KEYMAPS_H)
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/keymaps.c

tilde.o:	$(srcdir)/../glob/tilde.c $(I_SYSDEP_H)
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/../glob/tilde.c

vi_mode.o:	$(srcdir)/vi_mode.c $(I_SYSDEP_H) $(I_READLINE_H) $(I_HISTORY_H)
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/vi_mode.c

alloca.o:	$(srcdir)/alloca.c $(I_CONFIG_H)
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/alloca.c

xmalloc.o:	$(srcdir)/xmalloc.c $(I_SYSDEP_H)
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/xmalloc.c

libtest:	libreadline.a $(srcdir)/libtest.c
	$(CC) -o libtest $(CFLAGS) -I. $(READLINE_DEFINES) $(srcdir)/libtest.c libreadline.a -ltermcap

readline: $(srcdir)/readline.c history.o keymaps.o funmap.o readline.h chardefs.h vi_mode.o @ALLOCA@ xmalloc.o
	$(CC) $(CFLAGS) $(READLINE_DEFINES) -DTEST -o readline $(srcdir)/readline.c funmap.o keymaps.o history.o vi_mode.o @ALLOCA@ xmalloc.o -ltermcap

readline.tar:	$(THINGS_TO_TAR)
	tar -cf readline.tar $(THINGS_TO_TAR)

readline.tar.Z:	readline.tar
	compress -f readline.tar

readline.tar.gz:	readline.tar
	gzip readline.tar

install:
		$(INSTALL_DATA) libreadline.a $(libdir)/libreadline.a
		$(RANLIB) $(libdir)/libreadline.a
		$(INSTALL_DATA) $(srcdir)/readline.h $(includedir)/readline/readline.h
		$(INSTALL_DATA) $(srcdir)/keymaps.h $(includedir)/readline/keymaps.h
		$(INSTALL_DATA) $(srcdir)/chardefs.h $(includedir)/readline/chardefs.h

install-info: info
#		for i in *.info* ; do \
#			$(INSTALL_DATA) $$i $(infodir)/$$i ; \
#		done

includes:
		$(INSTALL_FILE) $(srcdir)/readline.h $(includedir)/readline/readline.h
		$(INSTALL_FILE) $(srcdir)/keymaps.h $(includedir)/readline/keymaps.h
		$(INSTALL_FILE) $(srcdir)/chardefs.h $(includedir)/readline/chardefs.h

clean mostlyclean:
		rm -f $(STAGESTUFF) *.a *.log *.cp *.tp *.vr *.fn
		rm -f *.aux *.pg *.toc

distclean realclean: clean
	rm -f Makefile config.status

$(DESTDIR)/libreadline.a: libreadline.a

# Copy the object files from a particular stage into a subdirectory.
stage1: force
	-mkdir stage1
	-mv $(STAGESTUFF) stage1

stage2: force
	-mkdir stage2
	-mv $(STAGESTUFF) stage2

stage3: force
	-mkdir stage3
	-mv $(STAGESTUFF) stage3

against=stage2

comparison: force
	for i in $(STAGESTUFF) ; do cmp $$i $(against)/$$i ; done

de-stage1: force
	-(cd stage1 ; mv -f * ..)
	-rmdir stage1

de-stage2: force
	-(cd stage2 ; mv -f * ..)
	-rmdir stage2

de-stage3: force
	-(cd stage3 ; mv -f * ..)
	-rmdir stage3

force:

# with the gnu make, this is done automatically.

Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)
	$(SHELL) ./config.status
