###########################################################################
#
# Makefile -- gsdl
# A component of the Greenstone digital library software
# from the New Zealand Digital Library Project at the
# University of Waikato, New Zealand.
#
# Copyright (C) 1999  The New Zealand Digital Library Project
#
#
# This program 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 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
###########################################################################
srcdir = @srcdir@

PACKAGE = @PACKAGE@
VERSION = @VERSION@

@SET_MAKE@
CC = @CC@
CXX = @CXX@
CFLAGS = @CFLAGS@
CXXFLAGS = @CXXFLAGS@
LIBS   = @LIBS@
MDEFINES =

GSDLOS = @gsdlos@

COMPILE = $(CC) -c

SOURCES = 

OBJECTS = 

ALLFILES = $(OBJECTS)

SPECIAL_COMPILEDIRS = common-src
COMPILEDIRS = build-src runtime-src

SPECIAL_INSTALLDIRS = common-src
INSTALLDIRS = build-src runtime-src

MODULEDIRS = @MODULEDIRS@

ENABLE_JNI=@ENABLE_JNI@
ifeq ($(ENABLE_JNI), 1)
COMPILE_TARGET=with-jni
else
COMPILE_TARGET=without-jni
endif


# with some compilers, just calling another target is insufficient
# so an extra echo stmt is added after each call to another target
all:	$(COMPILE_TARGET)
	@echo "Compile done"

install: install-$(COMPILE_TARGET)
	@echo "Install done"


with-jni without-jni:
	for odir in $(SPECIAL_COMPILEDIRS); do \
	  if test -d $$odir; then \
	    echo making $(COMPILE_TARGET) in $$odir; \
	    (cd $$odir && $(MAKE) $(MDEFINES) $(COMPILE_TARGET)) || exit 1; \
	  fi; \
	done
	for odir in $(COMPILEDIRS) $(MODULEDIRS); do \
	  if test -d $$odir; then \
	    echo making all in $$odir; \
	    (cd $$odir && $(MAKE) $(MDEFINES) all) || exit 1; \
	  fi; \
	done

install-with-jni install-without-jni: all
	for idir in $(SPECIAL_INSTALLDIRS); do \
	  if test -d $$idir; then \
	    echo installing $$idir $(COMPILE_TARGET); \
	    (cd $$idir && $(MAKE) install-$(COMPILE_TARGET)) || exit 1; \
	  fi; \
	done
	for idir in $(INSTALLDIRS); do \
	  if test -d $$idir; then \
	    echo installing $$idir; \
	    (cd $$idir && $(MAKE) install) || exit 1; \
	  fi; \
	done

apache-for-dist:
	if test -d runtime-src; then \
	  (cd runtime-src/packages && $(MAKE) apache-for-dist) || exit 1; \
	fi

distclean: clean
	rm -f Makefile config.cache config.h config.log stamp-h config.status
	for subdir in $(SPECIAL_COMPILEDIRS) $(COMPILEDIRS); do \
	  if test -d $$subdir; then \
	    echo cleaning $@ in $$subdir; \
	    (cd $$subdir && $(MAKE) distclean) || exit 1; \
	  fi; \
	done

clean:
	for subdir in $(SPECIAL_COMPILEDIRS) $(COMPILEDIRS); do \
	  if test -d $$subdir; then \
	    echo cleaning $@ in $$subdir; \
	    (cd $$subdir && $(MAKE) clean) || exit 1; \
	  fi; \
	done

# commented out - jrm21 Dec 2004 - can get confused by cvs timestamps
# (and might run the wrong version of autoconf)
#
## For an explanation of the following Makefile rules, see node
## `Automatic Remaking' in GNU Autoconf documentation.
#Makefile: Makefile.in config.status
#	CONFIG_FILES=$@ CONFIG_HEADERS= ./config.status
#config.status: configure
#	./config.status --recheck
#configure: configure.in aclocal.m4
#	cd $(srcdir) && autoconf
#
#config.h: stamp-h
#stamp-h: config.h.in config.status
#	CONFIG_FILES= CONFIG_HEADERS=config.h ./config.status
#config.h.in: stamp-h.in
#stamp-h.in: configure.in aclocal.m4 acconfig.h
#	cd $(srcdir) && autoheader
#	$(TOUCH) $(srcdir)/stamp-h.in



