#
# ${R_HOME}/src/extra/tre/Makefile

VPATH = @srcdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@

top_builddir = ../../..
subdir = src/extra/tre
R_HOME = $(top_builddir)

include $(top_builddir)/Makeconf

TRE_CPPFLAGS = -I$(srcdir)
ALL_CPPFLAGS = $(TRE_CPPFLAGS) $(R_XTRA_CPPFLAGS) $(CPPFLAGS) $(DEFS)

# xmalloc.c (only for debugging)
SOURCES = regcomp.c regerror.c regexec.c tre-ast.c tre-compile.c \
  tre-match-approx.c tre-match-backtrack.c tre-match-parallel.c \
  tre-mem.c tre-parse.c tre-stack.c 

HEADERS = tre.h tre-ast.h tre-compile.h tre-config.h tre-internal.h \
  tre-match-utils.h tre-mem.h tre-parse.h tre-stack.h xmalloc.h

DEPENDS = $(SOURCES:.c=.d)
OBJECTS = $(SOURCES:.c=.o)
@WANT_R_SHLIB_TRUE@ALL_CFLAGS = $(ALL_CFLAGS_LO) @C_VISIBILITY@

distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
# xmalloc.c (only for debugging)
DISTFILES = LICENSE Makefile.in Makefile.win R_changes \
  $(SOURCES) $(HEADERS) xmalloc.c
noinst_LIBRARIES = libtre.a
libtre_a_SOURCES = $(SOURCES)
libtre_a_OBJECTS = $(OBJECTS)


all: @BUILD_TRE_TRUE@ R

Makefile: $(srcdir)/Makefile.in \
  $(top_builddir)/config.status \
  $(SOURCES)
	@cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@

Makedeps: Makefile $(DEPENDS)
	@cat $(DEPENDS) >> Makefile
	@touch $@

R: Makefile @BUILD_TRE_TRUE@
	@BUILD_TRE_TRUE@ @$(MAKE) Makedeps
	@BUILD_TRE_TRUE@ @$(MAKE) $(noinst_LIBRARIES)

libtre.a: $(libtre_a_OBJECTS)
	@rm -f $@
	$(AR) -cr $@ $(libtre_a_OBJECTS)
	$(RANLIB) $@

mostlyclean: clean
clean:
	@-rm -f Makedeps *.d *.o *.lo *.a
distclean: clean
	@-rm -f Makefile dftables chartables.h
maintainer-clean: distclean

install install-strip uninstall TAGS info dvi check:

distdir: $(DISTFILES)
	@for f in $(DISTFILES); do \
	  test -f $(distdir)/$${f} \
	    || ln $(srcdir)/$${f} $(distdir)/$${f} 2>/dev/null \
	    || cp -p $(srcdir)/$${f} $(distdir)/$${f}; \
	done

## Automagically generated dependencies:

