#	$Id: INSTALL,v 1.9 1997-08-25 00:33:09+09 hayashi Exp $

1. How to Install Term::ReadLine::Gnu

1.1 Install GNU Readline library 2.1 and its header files.

	See the section `How to Install GNU Readline Library'.

1.2 Edit Makefile.PL

	Specify directory for libreadline.a ('LIBS') and include files
	of GNU Readline library ('INC').

1.3 Make and install

	$ perl Makefile.PL
	$ make
	$ make test
	$ make install

	If you use Solaris 2.5 and dynamic loading, "make test" causes
	core dump.  I have not fixed this bug yet.  But TRG
	(Term::Readline::Gnu) works if you link it statically as
	follows;

	$ perl Makefile.PL
	$ make perl
	$ cp perl /usr/local/bin	
	$ make install		# install .pm file, pod file and so on.
	$ perl t/readline.t	# try test program

	I've done following things to debug this.  If you have any
	suggestion, please let me know.

		When I debug TRG, I sometimes make this statically
		linked perl to use debugger.  But in this case this
		perl works well.  This problem occurs only when
		dynamic loading is used.

		I found the core dump occurred at calling free() in
		bind.c:rl_invoking_keyseqs_in_map of the GNU readline
		library.  So I suspect that memory cell which is
		allocated by perl internal malloc() is freed by free()
		included by the system dynamic link library.  I try
		make perl with usemymalloc=n.  But it still did not
		work.

		Next I added many printf()s. Then I found that a
		malloc() allocated a memory cell and the cell cannot
		be free()ed.  I put free() on the next line of the
		malloc().  The malloc() returns a pointer which is not
		NULL, but the free() on the next line causes core
		dump.  This is very very strange.

		Gnu readline library uses both malloc() and xmalloc()
		and both free() and xfree().  So I tried to change all
		malloc() to xmalloc() and change all free() to xfree()
		by using macro.  But it still did not work.

	That's all I've tried.  Any comments?


2. How to Install GNU Readline Library

Now this module supports only GNU Readline Library 2.1.
(readline-2.1.tar.gz or library which is included in the GNU Bash
version 2.0 or later)

In following example, the install prefix directory is
`/usr/local/gnu'.  If you install the library and header files in
another directory, you must edit `LIBS' and/or `INC' section in
Makefile.PL.

2.1. readline-2.1.tar.gz

	1. get and extract readline-2.1.tar.gz

	2. add following patch;
========================================================================
*** Makefile.in.orig	Wed Jun  4 00:29:31 1997
--- Makefile.in	Sun Jul 13 23:31:09 1997
***************
*** 194,200 ****
  	-test -n "$(RANLIB)" && -$(RANLIB) -t $(libdir)/libreadline.a
  	-( if test -d doc ; then \
  		cd doc && \
! 		${MAKE} ${MFLAGS} infodir=$(infodir) INSTALL_DATA=$(INSTALL_DATA) $@; \
  	  fi )
  
  installdirs: $(srcdir)/support/mkdirs
--- 194,200 ----
  	-test -n "$(RANLIB)" && -$(RANLIB) -t $(libdir)/libreadline.a
  	-( if test -d doc ; then \
  		cd doc && \
! 		${MAKE} ${MFLAGS} infodir=$(infodir) INSTALL_DATA="$(INSTALL_DATA)" $@; \
  	  fi )
  
  installdirs: $(srcdir)/support/mkdirs
========================================================================

	3. configure
		$ ./configure --prefix=/usr/local/gnu
	4. make and install
		$ make install

2.2. libreadline.a in bash-2.0.tar.gz

	The libreadline.a which is made when you make bash does not
	work as stand-alone library.  You must make it without defining
	a CPP macro `SHELL'.

	1. get and extract bash-2.0.tar.gz
	2. add following patch
	  (I reported this patch to bug-bash@prep.ai.mit.edu, so I
	   hope this patch will not be required by the future
	   releases.)

========================================================================
*** lib/readline/Makefile.in.orig	Tue Nov 26 02:40:21 1996
--- lib/readline/Makefile.in	Fri Dec 27 00:16:50 1996
***************
*** 4,9 ****
--- 4,16 ----
  #								   #
  ####################################################################
  
+ # Include some boilerplate Gnu makefile definitions.
+ prefix = @prefix@
+ 
+ exec_prefix = @exec_prefix@
+ libdir = $(exec_prefix)/lib
+ includedir = @includedir@
+ 
  srcdir = @srcdir@
  VPATH = .:@srcdir@
  topdir = @top_srcdir@
***************
*** 108,114 ****
  	done
  	-${MV} $(libdir)/libreadline.a $(libdir)/libreadline.old
  	${INSTALL_DATA} libreadline.a $(libdir)/libreadline.a
! 	-test -n "$(RANLIB)" && $(RANLIB) -t $(bindir)/libreadline.a
  
  installdirs:	$(topdir)/support/mkdirs
  	$(SHELL) $(topdir)/support/mkdirs $(includedir) \
--- 115,121 ----
  	done
  	-${MV} $(libdir)/libreadline.a $(libdir)/libreadline.old
  	${INSTALL_DATA} libreadline.a $(libdir)/libreadline.a
! 	-test -n "$(RANLIB)" && $(RANLIB) -t $(libdir)/libreadline.a
  
  installdirs:	$(topdir)/support/mkdirs
  	$(SHELL) $(topdir)/support/mkdirs $(includedir) \

========================================================================

	3. configure
		$ ./configure --prefix=/usr/local/gnu
	4. change directory to the Readline Library directory
		$ cd lib/readline
	5. remove *.a and *.o, if you made libreadline.a for bash in
	   the directory
		$ make clean
	6. make
		$ make
	7. install
		$ make install

EOF
