#
#  Makefile.sub.in - Common rules and definitions
#
#  $Id: Makefile.comm.in,v 1.5 1999/08/22 14:37:43 Avi Exp $
#
#  Copyright (C) 1998 Cees de Groot <cg@sgmltools.org>
#

TOP=@TOP@
prefix=@prefix@
exec_prefix=@exec_prefix@
srcdir=@srcdir@
bindir=@bindir@
libdir=@libdir@
datadir=@datadir@

CXX=@CXX@
CC=@CC@
PERL=@PERL@
LIBTOOL=@LIBTOOL@
INSTALL=@INSTALL@

LIBOBJS=@LIBOBJS@
LIBS=@LIBS@
DEFS=@DEFS@ -DDEFAULT_SCHEME_BUILTINS=\"${datadir}/builtins.dsl\"
INCS=-I$(srcdir) -I$(srcdir)/../include $(INCLUDE)
CXXFLAGS=@CXXFLAGS@ $(INCS) $(DEBUG) $(DEFS)
CFLAGS=@CFLAGS@ $(DEBUG) $(DEFS)
LDFLAGS=@LDFLAGS@
MSGGENFLAGS=
CXXDEPGENFLAGS=-MM

.SUFFIXES: .cxx .c .o .m4 .msg .lo

.cxx.o:
	$(CXX) $(CXXFLAGS) -c $<

.cxx.lo:
	@$(LIBTOOL) --mode=compile $(CXX) $(CXXFLAGS) -c $<

.c.o:
	$(CC) $(CFLAGS) -c $<

.c.lo:
	@$(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $<

.m4.cxx:
	rm -f $@
	$(PERL) $(srcdir)/../lib/instmac.pl $< >$@
	chmod -w $@

%.h %.cxx %.rc: %.msg
	$(PERL) -w $(srcdir)/../msggen.pl $(MSGGENFLAGS) $<

.msg.h:
	$(PERL) -w $(srcdir)/../msggen.pl $(MSGGENFLAGS) $<

depend_src: depend.temp
	mv depend.temp Makefile.dep

depend.temp: FORCE
	$(CXX) -MM $(CXXFLAGS) $(CXXDEPGENFLAGS) $(OBJS:.o=.cxx) \
	  | sed -e 's; \([^/ ][^/ ]*\)/; $$(srcdir)/\1/;g' >depend.temp1
	cat depend.temp1 > depend.temp
	cat depend.temp1 | sed -e 's/\.o:/.lo:/g' >> depend.temp
	rm depend.temp1

clean: FORCE
	-rm -f $(CLEANFILES)

FORCE:

%: RCS/%,v
	test -w $@ || co -u $@
