#
# Makefile.in:  template Makefile for Subversion
#
# ====================================================================
# Copyright (c) 2000-2006 CollabNet.  All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution.  The terms
# are also available at http://subversion.tigris.org/license-1.html.
# If newer versions of this license are posted there, you may use a
# newer version instead, at your option.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://subversion.tigris.org/.
# ====================================================================
#

top_builddir = .
top_srcdir = @top_srcdir@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
VPATH = @top_srcdir@

SVN_RA_LIB_DEPS = @SVN_RA_LIB_DEPS@
SVN_RA_LIB_INSTALL_DEPS = @SVN_RA_LIB_INSTALL_DEPS@
SVN_RA_LIB_LINK = @SVN_RA_LIB_LINK@

SVN_FS_LIB_DEPS = @SVN_FS_LIB_DEPS@
SVN_FS_LIB_INSTALL_DEPS = @SVN_FS_LIB_INSTALL_DEPS@
SVN_FS_LIB_LINK = @SVN_FS_LIB_LINK@

SWIG_SRC_DIR = $(abs_srcdir)/subversion/bindings/swig
SWIG_BUILD_DIR = $(abs_builddir)/subversion/bindings/swig

SVN_EXTERNAL_PROJECT_SUBDIRS = @SVN_EXTERNAL_PROJECT_SUBDIRS@

SCHEMA_DIR = subversion/svn/schema

NEON_LIBS = @NEON_LIBS@
SVN_APR_LIBS = @SVN_APR_LIBS@
SVN_APRUTIL_LIBS = @SVN_APRUTIL_LIBS@
SVN_DB_LIBS =
SVN_SERF_LIBS = @SVN_SERF_LIBS@
SVN_SASL_LIBS = @SVN_SASL_LIBS@
SVN_ZLIB_LIBS = @SVN_ZLIB_LIBS@

LIBS = @LIBS@

prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@
fsmod_libdir = @libdir@
ramod_libdir = @libdir@
neon_libdir = @libdir@
bdb_libdir = @libdir@
serf_libdir = @libdir@
bindir = @bindir@
includedir = @includedir@
mandir = @mandir@
srcdir = @srcdir@
datadir = @datadir@
localedir = @localedir@

# where to install libsvn_swig_*
swig_py_libdir = @libdir@
swig_pl_libdir = @libdir@
swig_rb_libdir = @libdir@

### these possibly need further discussion
swig_pydir = @libdir@/svn-python/libsvn
swig_pydir_extra = @libdir@/svn-python/svn
swig_pldir = @libdir@/svn-perl
swig_rbdir = $(SWIG_RB_SITE_ARCH_DIR)/svn/ext
contribdir = @bindir@/svn-contrib
toolsdir = @bindir@/svn-tools

javahl_javadir = @libdir@/svn-javahl
javahl_javahdir = @libdir@/svn-javahl/include
javahl_libdir = @libdir@
javahl_test_rootdir=$(abs_builddir)/subversion/bindings/javahl/test-work

MSGFMT = @MSGFMT@
MSGFMTFLAGS = @MSGFMTFLAGS@
MSGMERGE = @MSGMERGE@
XGETTEXT = @XGETTEXT@
TRANG = @TRANG@

PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_VERSION=@PACKAGE_VERSION@

CC = @CC@
CXX = @CXX@
EXEEXT = @EXEEXT@

SHELL = @SHELL@
LIBTOOL = @SVN_LIBTOOL@
LTFLAGS = --tag=CC --silent
LTCXXFLAGS = --tag=CXX --silent
LT_LDFLAGS = @LT_LDFLAGS@
LT_NO_UNDEFINED = @LT_NO_UNDEFINED@
LT_CXX_LIBADD = @LT_CXX_LIBADD@

INCLUDES = -I$(top_srcdir)/subversion/include -I$(top_builddir)/subversion \
           @SVN_NEON_INCLUDES@ \
           @SVN_APR_INCLUDES@ @SVN_APRUTIL_INCLUDES@ @SVN_SERF_INCLUDES@ \
           @SVN_SASL_INCLUDES@ @SVN_ZLIB_INCLUDES@

APACHE_INCLUDES = @APACHE_INCLUDES@
APACHE_TARGET = @APACHE_TARGET@
APACHE_LIBEXECDIR = $(DESTDIR)@APACHE_LIBEXECDIR@
APACHE_LDFLAGS = @APACHE_LDFLAGS@

SWIG = @SWIG@
SWIG_PY_INCLUDES = @SWIG_PY_INCLUDES@ -I$(SWIG_SRC_DIR)/python/libsvn_swig_py
SWIG_PY_COMPILE = @SWIG_PY_COMPILE@
SWIG_PY_LINK = @SWIG_PY_LINK@
SWIG_PY_LIBS = @SWIG_PY_LIBS@
SWIG_PL_INCLUDES = @SWIG_PL_INCLUDES@
SWIG_RB_INCLUDES = @SWIG_RB_INCLUDES@ -I$(SWIG_SRC_DIR)/ruby/libsvn_swig_ruby
SWIG_RB_COMPILE = @SWIG_RB_COMPILE@
SWIG_RB_LINK = @SWIG_RB_LINK@
SWIG_RB_LIBS = @SWIG_RB_LIBS@
SWIG_RB_SITE_LIB_DIR = @SWIG_RB_SITE_LIB_DIR@
SWIG_RB_SITE_ARCH_DIR = @SWIG_RB_SITE_ARCH_DIR@
SWIG_RB_TEST_VERBOSE = @SWIG_RB_TEST_VERBOSE@
SWIG_RB_RI_DATADIR = $(DESTDIR)$(datadir)/ri/$(RUBY_MAJOR).$(RUBY_MINOR)/site

JAVAHL_INCLUDES= @JNI_INCLUDES@ -I$(abs_builddir)/subversion/bindings/javahl/include

SVN_APR_INCLUDES = @SVN_APR_INCLUDES@
SVN_APR_PREFIX = @SVN_APR_PREFIX@
SVN_APRUTIL_INCLUDES = @SVN_APRUTIL_INCLUDES@
SVN_APRUTIL_PREFIX = @SVN_APRUTIL_PREFIX@

SVN_SERF_INCLUDES = @SVN_SERF_INCLUDES@
SVN_SERF_PREFIX = @SVN_SERF_PREFIX@

SVN_ZLIB_PREFIX = @SVN_ZLIB_PREFIX@
SVN_ZLIB_INCLUDES = @SVN_ZLIB_INCLUDES@

MKDIR = @MKDIR@

# The EXTRA_ parameters can be used to pass extra flags at 'make' time.
CFLAGS = @CFLAGS@ $(EXTRA_CFLAGS)
CXXFLAGS = @CXXFLAGS@ $(EXTRA_CXXFLAGS)
### A few of the CFLAGS (e.g. -Wmissing-prototypes, -Wstrict-prototypes,
### -Wmissing-declarations) are not valid for C++, and should be somehow
### suppressed (but they may come from httpd or APR).
CPPFLAGS = @CPPFLAGS@ $(EXTRA_CPPFLAGS)
LDFLAGS = @LDFLAGS@ $(EXTRA_LDFLAGS)
SWIG_LDFLAGS = @SWIG_LDFLAGS@ $(EXTRA_SWIG_LDFLAGS)

COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDES)
COMPILE_CXX = $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES)
LT_COMPILE = $(LIBTOOL) $(LTFLAGS) --mode=compile $(COMPILE)

# special compilation for files destined for mod_dav_svn
COMPILE_APACHE_MOD = $(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) $(CPPFLAGS) $(CFLAGS) $(APACHE_INCLUDES) $(INCLUDES) -o $@ -c

# special compilation for files destined for libsvn_swig_* (e.g. swigutil_*.c)
COMPILE_SWIG_PY = $(LIBTOOL) $(LTFLAGS) --mode=compile $(SWIG_PY_COMPILE) $(CPPFLAGS) -DSWIGPYTHON $(CFLAGS) $(SWIG_PY_INCLUDES) $(INCLUDES) -o $@ -c
COMPILE_SWIG_PL = $(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) $(CPPFLAGS) $(CFLAGS) $(SWIG_PL_INCLUDES) $(INCLUDES) -o $@ -c
COMPILE_SWIG_RB = $(LIBTOOL) $(LTFLAGS) --mode=compile $(SWIG_RB_COMPILE) $(CPPFLAGS) $(CFLAGS) $(SWIG_RB_INCLUDES) $(INCLUDES) -o $@ -c

# special compilation for files destined for javahl (i.e. C++)
COMPILE_JAVAHL_CXX = $(LIBTOOL) $(LTCXXFLAGS) --mode=compile $(COMPILE_CXX) $(JAVAHL_INCLUDES) -o $@ -c
COMPILE_JAVAHL_JAVAC = $(JAVAC) $(JAVAC_FLAGS)
COMPILE_JAVAHL_JAVAH = $(JAVAH)

LINK = $(LIBTOOL) $(LTFLAGS) --mode=link $(CC) $(LT_LDFLAGS) $(CFLAGS) $(LDFLAGS) -rpath $(libdir)

# special link rule for mod_dav_svn
LINK_APACHE_MOD = $(LIBTOOL) $(LTFLAGS) --mode=link $(CC) $(LT_LDFLAGS) $(CFLAGS) $(LDFLAGS) -rpath $(APACHE_LIBEXECDIR) -avoid-version -module $(APACHE_LDFLAGS)

# Compilation of SWIG-generated C source code
COMPILE_PY_WRAPPER = $(LIBTOOL) $(LTFLAGS) --mode=compile $(SWIG_PY_COMPILE) $(CPPFLAGS) $(SWIG_PY_INCLUDES) -prefer-pic -c -o $@
COMPILE_RB_WRAPPER = $(LIBTOOL) $(LTFLAGS) --mode=compile $(SWIG_RB_COMPILE) $(CPPFLAGS) $(SWIG_RB_INCLUDES) -prefer-pic -c -o $@

# these commands link the wrapper objects into an extension library/module
LINK_PY_WRAPPER = $(LIBTOOL) $(LTFLAGS) --mode=link $(SWIG_PY_LINK) $(SWIG_LDFLAGS) -rpath $(swig_pydir) -avoid-version -module
LINK_RB_WRAPPER = $(LIBTOOL) $(LTFLAGS) --mode=link $(SWIG_RB_LINK) $(SWIG_LDFLAGS) -rpath $(swig_rbdir) -avoid-version -module

LINK_JAVAHL_CXX = $(LIBTOOL) $(LTCXXFLAGS) --mode=link $(CXX) $(LT_LDFLAGS) $(CXXFLAGS) $(LDFLAGS) $(LT_CXX_LIBADD) -rpath $(libdir)

INSTALL = @INSTALL@
INSTALL_LIB = $(LIBTOOL) --mode=install $(INSTALL)
INSTALL_FSMOD_LIB = $(INSTALL_LIB)
INSTALL_RAMOD_LIB = $(INSTALL_LIB)
INSTALL_BDB_LIB = $(INSTALL_LIB)
INSTALL_NEON_LIB = $(INSTALL_LIB)
INSTALL_SERF_LIB = $(INSTALL_LIB)
INSTALL_BIN = $(LIBTOOL) --mode=install $(INSTALL)
INSTALL_CONTRIB = $(LIBTOOL) --mode=install $(INSTALL)
INSTALL_TOOLS = $(LIBTOOL) --mode=install $(INSTALL)
INSTALL_INCLUDE = $(INSTALL) -m 644
INSTALL_MOD_SHARED = @APXS@ -i -S LIBEXECDIR="$(APACHE_LIBEXECDIR)" @MOD_ACTIVATION@
INSTALL_MOD_STATIC = $(INSTALL) -m 644
INSTALL_DATA = $(INSTALL) -m 644
INSTALL_LOCALE = $(INSTALL_DATA)

### this isn't correct yet
INSTALL_SWIG_PY = $(INSTALL_LIB)
INSTALL_SWIG_PY_LIB = $(INSTALL_LIB)
INSTALL_SWIG_PL_LIB = $(INSTALL_LIB)
INSTALL_SWIG_RB = $(INSTALL_LIB)
INSTALL_SWIG_RB_LIB = $(INSTALL_LIB)

INSTALL_JAVAHL_LIB = $(INSTALL_LIB)

# additional installation rules for the SWIG wrappers
INSTALL_EXTRA_SWIG_PY=\
  $(MKDIR) $(DESTDIR)$(swig_pydir); \
  $(MKDIR) $(DESTDIR)$(swig_pydir_extra); \
  for i in $(abs_srcdir)/subversion/bindings/swig/python/svn/*.py; do \
    $(INSTALL_DATA) "$$i" $(DESTDIR)$(swig_pydir_extra); \
  done; \
  for i in $(abs_srcdir)/subversion/bindings/swig/python/*.py; do \
    $(INSTALL_DATA) "$$i" $(DESTDIR)$(swig_pydir); \
  done; \
  if test "$(abs_srcdir)" != "$(abs_builddir)"; then \
    for i in $(abs_builddir)/subversion/bindings/swig/python/*.py; do \
      $(INSTALL_DATA) "$$i" $(DESTDIR)$(swig_pydir); \
    done; \
  fi; \
  $(PYTHON) -c 'import compileall; \
    compileall.compile_dir("$(DESTDIR)$(swig_pydir)", 1, "$(swig_pydir)"); \
    compileall.compile_dir("$(DESTDIR)$(swig_pydir_extra)", 1, \
    "$(swig_pydir_extra)");'

# The path to generated and complementary source files for the SWIG
# bindings.
SWIG_PL_DIR = $(abs_builddir)/subversion/bindings/swig/perl
SWIG_PY_DIR = $(abs_builddir)/subversion/bindings/swig/python
SWIG_RB_DIR = $(abs_builddir)/subversion/bindings/swig/ruby

# The path to the source files for the SWIG bindings
SWIG_PL_SRC_DIR = $(abs_srcdir)/subversion/bindings/swig/perl
SWIG_PY_SRC_DIR = $(abs_srcdir)/subversion/bindings/swig/python
SWIG_RB_SRC_DIR = $(abs_srcdir)/subversion/bindings/swig/ruby

### Automate JAR creation using Makefile generator's javahl-java.jar
### property.  Enhance generator to support JAR installation.
INSTALL_EXTRA_JAVAHL_JAVA=\
	$(JAR) cf subversion/bindings/javahl/svn-javahl.jar -C subversion/bindings/javahl/classes org; \
	$(INSTALL_DATA) subversion/bindings/javahl/svn-javahl.jar $(DESTDIR)$(javahl_javadir);

INSTALL_EXTRA_JAVAHL_LIB=@INSTALL_EXTRA_JAVAHL_LIB@

INSTALL_EXTRA_SWIG_RB=\
  @echo $(MKDIR) $(DESTDIR)$(SWIG_RB_SITE_LIB_DIR)/svn; \
  $(MKDIR) $(DESTDIR)$(SWIG_RB_SITE_LIB_DIR)/svn; \
  for i in $(abs_srcdir)/subversion/bindings/swig/ruby/svn/*.rb; do \
    echo $(INSTALL_DATA) "$$i" $(DESTDIR)$(SWIG_RB_SITE_LIB_DIR)/svn; \
    $(INSTALL_DATA) "$$i" $(DESTDIR)$(SWIG_RB_SITE_LIB_DIR)/svn; \
  done

APXS = @APXS@ 

PYTHON = @PYTHON@
PERL = @PERL@

JDK = @JDK@
JAVA = @JAVA@
JAVAC = @JAVAC@
JAVADOC = @JAVADOC@
JAVAC_FLAGS = @JAVAC_FLAGS@
JAVAH = @JAVAH@
JAR = @JAR@

JAVA_CLASSPATH=@JAVA_CLASSPATH@
javahl_java_CLASSPATH=$(JAVA_CLASSPATH)
javahl_tests_CLASSPATH=$(JAVA_CLASSPATH)

RUBY = @RUBY@
RUBY_MAJOR = @RUBY_MAJOR@
RUBY_MINOR = @RUBY_MINOR@
RDOC = @RDOC@

ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@

TESTS = $(TEST_PROGRAMS) @BDB_TEST_PROGRAMS@

all: external-all local-all
clean: external-clean local-clean
distclean: external-distclean local-distclean
extraclean: external-extraclean local-extraclean
install: external-install local-install revision-install

@INCLUDE_OUTPUTS@

local-all: @BUILD_RULES@

locale-gnu-pot:
	cd $(abs_srcdir) && XGETTEXT="$(XGETTEXT)" MSGMERGE="$(MSGMERGE)" \
	  tools/po/po-update.sh pot

# "make locale-gnu-po-update" updates all translations.
# "make locale-gnu-po-update PO=ll" updates only the ll.po file.
locale-gnu-po-update:
	cd $(abs_srcdir) && XGETTEXT="$(XGETTEXT)" MSGMERGE="$(MSGMERGE)" \
	  tools/po/po-update.sh $(PO)

# clean everything but the bulky test output, returning the system back
# to before 'make' was run.
fast-clean: doc-clean
	@list='$(BUILD_DIRS)'; for i in $$list; do                   \
            echo "Cleaning $$i ..." ;                                \
            (cd $$i && rm -f *.o *.lo *.la *.la-a *.spo *.mo && \
             rm -rf .libs) ; \
        done
	rm -f $(CLEAN_FILES)
	find $(abs_srcdir) -name "*.pyc" -exec rm {} ';'

# clean all but bulky test output, returning to before './configure' was run.
SVN_CONFIG_SCRIPT_FILES = @SVN_CONFIG_SCRIPT_FILES@
fast-distclean: fast-clean
	rm -f Makefile config.cache config.log config.status libtool \
              subversion/svn_private_config.h \
              $(SVN_CONFIG_SCRIPT_FILES)

# clean everything out, returning to before './autogen.sh' was run.
local-extraclean: local-distclean extraclean-swig
	rm -f $(top_srcdir)/build-outputs.mk \
              $(top_srcdir)/subversion/svn_private_config.h.in \
              $(top_srcdir)/configure \
              $(top_srcdir)/build/config.guess \
              $(top_srcdir)/build/config.sub \
              $(top_srcdir)/build/libtool.m4 \
              $(top_srcdir)/build/ltoptions.m4 \
              $(top_srcdir)/build/ltsugar.m4 \
              $(top_srcdir)/build/ltversion.m4 \
              $(top_srcdir)/build/lt~obsolete.m4 \
              $(top_srcdir)/build/ltmain.sh

# clean everything, including test output.
local-clean: fast-clean check-clean clean-swig

# clean everything, including test output.
local-distclean: fast-distclean check-clean

local-install: @INSTALL_RULES@

### HACK!! Find a better way to do this
revision-install:
	subversion/svnversion/svnversion $(top_srcdir) /repos/svn/trunk > $(DESTDIR)$(includedir)/subversion-1/svn-revision.txt

install-static: @INSTALL_STATIC_RULES@

# JavaHL target aliases
javahl: mkdir-init javahl-java javahl-javah javahl-lib @JAVAHL_TESTS_TARGET@
install-javahl: install-javahl-java install-javahl-javah install-javahl-lib

clean-javahl:
	rm -rf $(javahl_java_PATH) $(javahl_javah_PATH) @JAVAHL_OBJDIR@
	rm -fr $(javahl_test_rootdir)
	rm -f $(libsvnjavahl_PATH)/*.la
	rm -f $(libsvnjavahl_PATH)/*.lo
	rm -f $(libsvnjavahl_PATH)/*.o

check-javahl: javahl
	@FIX_JAVAHL_LIB@
	$(JAVA) "-Dtest.rootdir=$(javahl_test_rootdir)" "-Dtest.fstype=$(FS_TYPE)" -Djava.library.path=@JAVAHL_OBJDIR@:$(libdir) -classpath $(javahl_tests_PATH):$(javahl_tests_CLASSPATH) "-Dtest.tests=$(JAVAHL_TESTS)" org.tigris.subversion.javahl.RunTests

# "make check CLEANUP=true" will clean up directories for successful tests.
# "make check TESTS=subversion/tests/cmdline/basic_tests.py"
#  will perform only basic tests (likewise for other tests).
check: $(TEST_DEPS) @BDB_TEST_DEPS@
	@if test "$(PYTHON)" != "none"; then                                 \
	  flags="--verbose";                                                 \
	  if test "$(CLEANUP)" != ""; then                                   \
	    flags="--cleanup $$flags";                                       \
	  fi;                                                                \
	  if test "$(BASE_URL)" != ""; then                                  \
	    flags="--url $(BASE_URL) $$flags";                               \
	  fi;                                                                \
	  if test "$(FS_TYPE)" != ""; then                                   \
	    flags="--fs-type $(FS_TYPE) $$flags";                            \
	  fi;                                                                \
	  if test "$(HTTP_LIBRARY)" != ""; then                              \
	    flags="--http-library $(HTTP_LIBRARY) $$flags";                  \
	  fi;                                                                \
	  if test "$(SERVER_MINOR_VERSION)" != ""; then                      \
	    flags="--server-minor-version $(SERVER_MINOR_VERSION) $$flags";  \
	  fi;                                                                \
	  if test "$(ENABLE_SASL)" != ""; then                               \
	    flags="--enable-sasl $$flags";                                   \
	  fi;                                                                \
	  if test "$(PARALLEL)" != ""; then                                  \
	    flags="--parallel $$flags";                                      \
	  fi;                                                                \
	  $(PYTHON) $(top_srcdir)/build/run_tests.py $$flags                 \
		    '$(abs_srcdir)' '$(abs_builddir)' $(TESTS);              \
	else                                                                 \
	  echo "make check: Python 2.2 or greater is required,";             \
	  echo "            but was not detected during configure";          \
	  exit 1;                                                            \
	fi;

# First, set up Apache as documented in
# subversion/tests/cmdline/README.
davcheck: 
	@$(MAKE) check BASE_URL=http://localhost

# Automatically configure and run Apache httpd on a random port, and then
# run make check.
davautocheck: 
	@APXS=$(APXS) bash $(top_srcdir)/subversion/tests/cmdline/davautocheck.sh

# First, run:
#   subversion/svnserve/svnserve -d -r `pwd`/subversion/tests/cmdline
svncheck: 
	@$(MAKE) check BASE_URL=svn://127.0.0.1

# 'make svnserveautocheck' runs svnserve for you and kills it.
svnserveautocheck: svnserve
	bash $(top_srcdir)/subversion/tests/cmdline/svnserveautocheck.sh

# First, run:
#   subversion/svnserve/svnserve --listen-host "::1" -d -r `pwd`/subversion/tests/cmdline

svncheck6: 
	@$(MAKE) check BASE_URL=svn://\[::1\]

# First make sure you can ssh to localhost and that "svnserve" is in
# the path of the resulting shell.
svnsshcheck:
	@$(MAKE) check \
	  BASE_URL=svn+ssh://localhost`pwd`/subversion/tests/cmdline

bdbcheck:
	@$(MAKE) check FS_TYPE=bdb

check-clean:
	rm -rf subversion/tests/cmdline/svn-test-work              \
               subversion/tests/libsvn_fs/test-repo-*          \
               subversion/tests/libsvn_fs_base/test-repo-*     \
               subversion/tests/libsvn_ra_local/test-repo-*    \
               subversion/tests/libsvn_repos/test-repo-*       \
               subversion/tests/libsvn_subr/z                  \
               subversion/tests/svnserveautocheck.pid          \
               tests.log

mkdir-init:
	@list='$(BUILD_DIRS) $(SCHEMA_DIR) doc';         \
        for i in $$list; do                              \
            if [ ! -d $$i ]; then                        \
                echo "$(MKDIR) $$i" ;                    \
                $(MKDIR) $$i ;                           \
            fi;                                          \
        done

# recursive targets to handle external projects (e.g. APR, Neon)
external-all external-install:
	@target=`echo $@ | sed s/external-//`;          \
        list='$(SVN_EXTERNAL_PROJECT_SUBDIRS)';         \
        for i in $$list; do                             \
            echo "------ making $$target in $$i";       \
            (cd $$i && $(MAKE) $$target) || exit 1;     \
            echo "------ completed $$target in $$i";    \
        done;

### apr-util relies on generated files in apr, so reverse the
### list so that it is cleaned before apr.
external-clean external-distclean:
	@target=`echo $@ | sed s/external-//`;          \
        list='$(SVN_EXTERNAL_PROJECT_SUBDIRS)';         \
        for i in $$list; do                             \
            revlist="$$i $$revlist";                    \
        done;                                           \
        for i in $$revlist; do                          \
            echo "------ making $$target in $$i";       \
            (cd $$i && $(MAKE) $$target) || exit 1;     \
            echo "------ completed $$target in $$i";    \
        done;

### temporary hack. Neon does not have an "extraclean" and neither does db
### If we don't have extraclean -- do the next best thing.
external-extraclean:
	@list='$(SVN_EXTERNAL_PROJECT_SUBDIRS)';                         \
        for i in $$list; do                                              \
            revlist="$$i $$revlist";                                     \
        done;                                                            \
        for i in $$revlist; do                                           \
            if test "$$i" = "neon" || test "$$i" = "db/dist"; then       \
                echo "------ making distclean(no extraclean) in $$i";    \
                (cd $$i && $(MAKE) distclean) || exit 1;                 \
                echo "------ completed distclean(no extraclean) in $$i"; \
            else                                                         \
                echo "------ making extraclean in $$i";                  \
                (cd $$i && $(MAKE) extraclean) || exit 1;                \
                echo "------ completed extraclean in $$i";               \
            fi;                                                          \
        done;


# DOCUMENTATION RULES

# Every single document in every format.
doc: doc-misc-docs doc-api doc-javahl

# Generate API documentation for the C libraries.
### This could also generate POD for swig-perl, etc.
doc-api:
	( cd $(top_srcdir) && \
	  sed "s,\(OUTPUT_DIRECTORY *= *\),\1$(abs_builddir)/," \
	  doc/doxygen.conf | doxygen - )

# Generate API documentation for the JavaHL package.
doc-javahl:
	$(JAVADOC) -d $(top_srcdir)/doc/javadoc \
	  -sourcepath $(top_srcdir)/subversion/bindings/javahl/src \
	  -link http://java.sun.com/javase/6/docs/api/ \
	  org.tigris.subversion.javahl

# Build all types of a certain doc.
doc-misc-docs: doc-misc-docs-html doc-misc-docs-pdf doc-misc-docs-ps

# Build all docs of a certain type.
doc-all-html: doc-misc-docs-html
doc-all-pdf: doc-misc-docs-pdf
doc-all-ps: doc-misc-docs-ps

# Assumes you have {xsltproc, fop, stylesheets} installed.
doc-misc-docs-html:
	cd $(top_srcdir)/doc/misc-docs && $(MAKE) all-html
doc-misc-docs-pdf:
	cd $(top_srcdir)/doc/misc-docs && $(MAKE) pdf
doc-misc-docs-ps:
	cd $(top_srcdir)/doc/misc-docs && $(MAKE) ps

doc-clean:
	cd $(top_srcdir)/doc/misc-docs && $(MAKE) clean
	rm -rf $(top_srcdir)/doc/doxygen
	rm -rf $(top_srcdir)/doc/javadoc

# Converting from the .rnc XML shcemas to various other schema formats.
SCHEMAS_DTD = $(SCHEMA_DIR)/blame.dtd $(SCHEMA_DIR)/info.dtd \
              $(SCHEMA_DIR)/list.dtd $(SCHEMA_DIR)/log.dtd \
              $(SCHEMA_DIR)/status.dtd $(SCHEMA_DIR)/props.dtd

SCHEMAS_RNG = $(SCHEMA_DIR)/blame.rng $(SCHEMA_DIR)/info.rng \
              $(SCHEMA_DIR)/list.rng $(SCHEMA_DIR)/log.rng \
              $(SCHEMA_DIR)/status.rng $(SCHEMA_DIR)/props.rng

SCHEMAS_XSD = $(SCHEMA_DIR)/blame.xsd $(SCHEMA_DIR)/info.xsd \
              $(SCHEMA_DIR)/list.xsd $(SCHEMA_DIR)/log.xsd \
              $(SCHEMA_DIR)/status.xsd $(SCHEMA_DIR)/props.xsd

schema: schema-rng schema-dtd schema-xsd

schema-rng: $(SCHEMAS_RNG)
schema-dtd: $(SCHEMAS_DTD)
schema-xsd: $(SCHEMAS_XSD)

$(SCHEMAS_RNG) $(SCHEMAS_DTD) $(SCHEMAS_XSD): $(SCHEMA_DIR)/common.rnc

schema-clean:
	(cd $(SCHEMA_DIR) && rm -f *.rng *.dtd *.xsd)

#
# Implicit rules for creating outputs from input files
#
.SUFFIXES:
.SUFFIXES: .c .lo .o .la-a .la \
           .po .spo .mo .rnc .rng .dtd .xsd

.c.o:
	$(COMPILE) -o $@ -c $<

.c.lo:
	$(LT_COMPILE) -o $@ -c $<

.la.la-a:
	sed "/library_names/s/'.*'/''/" $< > $@


# Strip the Content-Type: header from the po file if we don't have a
# gettext that supports bind_textdomain_codeset, so it doesn't try
# to convert our UTF-8 .po files to the locale encoding.
@NO_GETTEXT_CODESET@.po.spo:
@NO_GETTEXT_CODESET@	sed \
@NO_GETTEXT_CODESET@	'/^"Content-Type: text\/plain; charset=UTF-8\\n"$$/d' \
@NO_GETTEXT_CODESET@	$< > $@

@NO_GETTEXT_CODESET@.spo.mo:
@NO_GETTEXT_CODESET@	$(MSGFMT) $(MSGFMTFLAGS) -o $@ $<

# For systems with bind_textdomain_codeset, just leave the Content-Type:
# header alone.
@GETTEXT_CODESET@.po.mo:
@GETTEXT_CODESET@	$(MSGFMT) $(MSGFMTFLAGS) -o $@ $<

.rnc.rng:
	@TRANG@ $< $@

.rnc.dtd:
	@TRANG@ $< $@

.rnc.xsd:
	@TRANG@ $< $@

install-docs: install-man

manroot = $(mandir)/man
install-man:
	@list='$(MANPAGES)';                                               \
        for i in $$list; do                                                \
          if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i;               \
          else file=$$i; fi;                                               \
          ext=`echo $$i | sed -e 's/^.*\\.//'`;                            \
          $(MKDIR) $(DESTDIR)$(manroot)$$ext;                              \
          inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`;                   \
          inst=`echo $$inst | sed -e 's/^.*\///'`;                         \
          inst=`echo $$inst`.$$ext;                                        \
          echo "$(INSTALL_DATA) $$file $(DESTDIR)$(manroot)$$ext/$$inst";  \
          $(INSTALL_DATA) $$file $(DESTDIR)$(manroot)$$ext/$$inst;         \
        done

install-swig-py: install-swig-py-lib
install-swig-rb: install-swig-rb-lib

clean-swig: clean-swig-headers clean-swig-py clean-swig-rb clean-swig-pl
extraclean-swig: extraclean-swig-headers extraclean-swig-py \
                 extraclean-swig-rb extraclean-swig-pl

EXTRACLEAN_SWIG_HEADERS=rm -f $(SWIG_SRC_DIR)/proxy/*.swg

clean-swig-headers:
	if test -z "$(RELEASE_MODE)"; then \
	  $(EXTRACLEAN_SWIG_HEADERS); \
	fi

extraclean-swig-headers: clean-swig-headers
	$(EXTRACLEAN_SWIG_HEADERS)

$(SWIG_PL_DIR)/native/Makefile.PL: $(SWIG_SRC_DIR)/perl/native/Makefile.PL.in
	./config.status subversion/bindings/swig/perl/native/Makefile.PL

$(SWIG_PL_DIR)/native/Makefile: $(SWIG_PL_DIR)/native/Makefile.PL
	cd $(SWIG_PL_DIR)/native; $(PERL) Makefile.PL

swig-pl_DEPS = autogen-swig-pl libsvn_swig_perl \
  $(SWIG_PL_DIR)/native/Makefile
swig-pl: $(swig-pl_DEPS)
	if test "$(SWIG_PL_DIR)" != "$(SWIG_PL_SRC_DIR)"; then \
	  ln -sf $(SWIG_PL_SRC_DIR)/native/*.c $(SWIG_PL_DIR)/native; \
	fi
	cd $(SWIG_PL_DIR)/native; $(MAKE) OTHERLDFLAGS="$(SWIG_LDFLAGS)"

check-swig-pl: swig-pl swig-pl-lib
	cd $(SWIG_PL_DIR)/native; $(MAKE) test

install-swig-pl: swig-pl install-swig-pl-lib
	cd $(SWIG_PL_DIR)/native; $(MAKE) install

EXTRACLEAN_SWIG_PL=rm -f $(SWIG_PL_SRC_DIR)/native/svn_*.c \
                         $(SWIG_PL_SRC_DIR)/native/core.c

# Running Makefile.PL at this point *fails* (cannot find ..../.libs) so if the
# Makefile does not exist, DO NOT try to make it. But, if it doesn't exist,
# then the directory is probably clean anyway.
clean-swig-pl:
	if test -z "$(RELEASE_MODE)"; then \
	  $(EXTRACLEAN_SWIG_PL); \
	fi
	for d in $(SWIG_PL_DIR)/libsvn_swig_perl; \
	do \
	  cd $$d; \
	  rm -rf *.lo *.la *.o .libs; \
	done
	if [ -f "$(SWIG_PL_DIR)/native/Makefile" ]; then \
	  cd $(SWIG_PL_DIR)/native; $(MAKE) clean; \
	fi

extraclean-swig-pl: clean-swig-pl
	$(EXTRACLEAN_SWIG_PL)

$(SWIG_PY_DIR)/libsvn:
	mkdir $(SWIG_PY_DIR)/libsvn

copy-swig-py: autogen-swig-py $(SWIG_PY_DIR)/libsvn
	@cp -pf $(SWIG_PY_SRC_DIR)/*.py $(SWIG_PY_DIR)/libsvn

swig-py: autogen-swig-py copy-swig-py

check-swig-py: swig-py
	cd $(SWIG_PY_DIR); \
	  $(PYTHON) $(SWIG_PY_SRC_DIR)/tests/run_all.py

EXTRACLEAN_SWIG_PY=rm -rf $(SWIG_PY_SRC_DIR)/svn_*.c $(SWIG_PY_SRC_DIR)/core.c \
                          $(SWIG_PY_SRC_DIR)/[a-z]*.py
clean-swig-py:
	rm -rf $(SWIG_PY_DIR)/libsvn
	if test -z "$(RELEASE_MODE)"; then \
	  $(EXTRACLEAN_SWIG_PY); \
	fi
	for d in $(SWIG_PY_DIR) $(SWIG_PY_DIR)/libsvn_swig_py; \
	do \
	  cd $$d && rm -rf *.lo *.la *.o *.pyc .libs; \
	done
	find $(SWIG_PY_SRC_DIR) $(SWIG_PY_DIR) -name "*.pyc" -exec rm {} ';'

extraclean-swig-py: clean-swig-py
	$(EXTRACLEAN_SWIG_PY)

swig-rb: autogen-swig-rb

check-swig-rb: swig-rb svnserve
	cd $(SWIG_RB_DIR); \
	  $(RUBY) -I $(SWIG_RB_SRC_DIR) \
	    $(SWIG_RB_SRC_DIR)/test/run-test.rb \
	    --verbose=$(SWIG_RB_TEST_VERBOSE)

EXTRACLEAN_SWIG_RB=rm -f $(SWIG_RB_SRC_DIR)/svn_*.c $(SWIG_RB_SRC_DIR)/core.c

clean-swig-rb:
	rm -rf $(SWIG_RB_DIR)/test/repos $(SWIG_RB_DIR)/test/wc
	if test -z "$(RELEASE_MODE)"; then \
	  $(EXTRACLEAN_SWIG_RB); \
	fi
	for d in $(SWIG_RB_DIR) $(SWIG_RB_DIR)/libsvn_swig_ruby; \
	do \
	  cd $$d; \
	  rm -rf *.lo *.la *.o .libs; \
	done

extraclean-swig-rb: clean-swig-rb
	$(EXTRACLEAN_SWIG_RB)

install-swig-rb-doc:
	$(RDOC) --all --ri --op "$(SWIG_RB_RI_DATADIR)" "$(SWIG_RB_SRC_DIR)/svn"
