# Makefile.in -- input for the src directory's Makefile
# Copyright (C) 1998 John Harper <john@dcs.warwick.ac.uk>
# $Id: Makefile.in,v 1.41 1999/12/10 22:37:53 john Exp $
#
# This file is part of Jade.
#
# Jade 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, or (at your option)
# any later version.
#
# Jade 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 Jade; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

top_builddir=..
VPATH=@top_srcdir@/src:.

COMMON_SRCS =	debug-buffer.c files.c find.c lisp.c lispcmds.c lispmach.c \
		main.c message.c misc.c regexp.c regsub.c streams.c \
		symbols.c values.c
UNIX_SRCS =	unix_dl.c unix_files.c unix_main.c unix_processes.c

INSTALL_HDRS = rep.h rep_lisp.h rep_regexp.h rep_subrs.h

SRCS = $(COMMON_SRCS) $(UNIX_SRCS)
OBJS = $(SRCS:.c=.lo)

SDBM_SRCS = sdbm.c sdbm_pair.c sdbm_hash.c
SDBM_OBJS = $(SDBM_SRCS:.c=.lo)

DL_SRCS = repsdbm.c timers.c gettext.c readline.c
DL_OBJS = libsdbm.la libtimers.la libgettext.la libreadline.la

REP_SRCS =	rep.c
REP_OBJS =	$(REP_SRCS:.c=.o)

all : libxsdbm.la librep.la $(DL_OBJS) rep rep-config rep-remote rep-xgettext

libxsdbm.la : $(SDBM_OBJS)
	$(LIBTOOL) $(CC) $(LDFLAGS) -o $@ $^ -rpath $(libdir)

librep.la : $(OBJS) $(LIBOBJS) $(ALLOCA)
	$(LIBTOOL) $(CC) $(LDFLAGS) -version-info $(libversion) \
	  -o $@ $^ -rpath $(libdir)

rep : $(REP_OBJS) $(EXTRA_LIBOBJS) librep.la
	$(LIBTOOL) $(CC) -export-dynamic $(CPPFLAGS) $(CFLAGS) -o $@ \
	  $(REP_OBJS) librep.la $(EXTRA_LIBOBJS) $(LIBS)

rep-remote : rep-remote.c

rep-xgettext : rep-xgettext.jl rep
	$(COMPILE_ENV) $(rep_prog) compiler -f compile-batch $< \
	  && mv $<c $@ && chmod +x $@

install : all installdirs
	$(LIBTOOL) $(INSTALL_PROGRAM) librep.la $(DESTDIR)${libdir}
	$(LIBTOOL) -n --finish $(DESTDIR)${libdir}
	$(LIBTOOL) $(INSTALL_PROGRAM) -m 755 rep $(DESTDIR)${bindir}
	$(LIBTOOL) $(INSTALL_PROGRAM) -m 755 repdoc $(DESTDIR)${bindir}
	$(INSTALL_SCRIPT) -m 755 rep-config $(DESTDIR)${bindir}
	$(INSTALL_SCRIPT) -m 755 rep-xgettext $(DESTDIR)${bindir}
	$(INSTALL_PROGRAM) -m 755 rep-remote $(DESTDIR)${bindir}
	for dl in $(DL_OBJS); do \
	  $(LIBTOOL) $(INSTALL_PROGRAM) $$dl $(DESTDIR)${repexecdir}; \
	done
	for i in $(INSTALL_HDRS); do \
	  $(INSTALL_DATA) $$i $(DESTDIR)$(includedir); \
	done

installdirs : $(top_srcdir)/mkinstalldirs
	$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(libdir) $(DESTDIR)$(bindir) \
	  $(DESTDIR)$(repexecdir) $(DESTDIR)$(includedir)

uninstall :
	$(LIBTOOL) rm $(DESTDIR)${libdir}/librep.la
	$(LIBTOOL) rm $(DESTDIR)${bindir}/rep
	$(LIBTOOL) rm $(DESTDIR)${bindir}/repdoc
	rm -f $(DESTDIR)${bindir}/rep-config
	rm -f $(DESTDIR)${bindir}/rep-xgettext
	rm -f $(DESTDIR)${bindir}/rep-remote
	for dl in $(DL_OBJS); do \
	  $(LIBTOOL) rm $(DESTDIR)${repexecdir}/$$dl; \
	done
	for i in $(INSTALL_HDRS); do \
	  rm $(DESTDIR)$(includedir)/$$i; \
	done

rep-config : rep-config.sh
	$(SHELL) $< "${prefix}" "${libdir}" "${version}" "${LIBS}" "${repcommonexecdir}" >$@
	chmod +x $@

repdoc : repdoc.o libxsdbm.la
	$(LIBTOOL) $(CC) -static $(LDFLAGS) -o $@ repdoc.o libxsdbm.la

libsdbm.la : $(SDBM_OBJS) repsdbm.lo
	$(LIBTOOL) $(CC) $(LDFLAGS) -module -o $@ \
	 $(SDBM_OBJS) repsdbm.lo -rpath $(repexecdir)

libgettext.la : gettext.lo
	$(LIBTOOL) $(CC) $(LDFLAGS) -module -o $@ \
	 $^ ../intl/*.lo -rpath $(repexecdir)

libreadline.la : readline.lo
	$(LIBTOOL) $(CC) $(LDFLAGS) -module -o $@ \
	 $^ $(READLINE_LIBS) -rpath $(repexecdir)

clean :
	rm -f *~ *.o *.lo *.la build.h
	rm -f repdoc core rep rep-remote

realclean : clean
	rm -f .*.d Makefile rep.h dump.out dumped.s rep-config
	rm -rf .libs

include $(SRCS:%.c=.%.d) $(DL_SRCS:%.c=.%.d) $(REP_SRCS:%.c=.%.d)
