# This file is part of Java-GNOME.
#
# Java-GNOME 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.
#
# Java-GNOME 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 Java-GNOME; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#

gtkversion=@gtkversion@
gtkapiversion=@gtkapiversion@

# Directories for configure.
prefix=@prefix@
exec_prefix=@exec_prefix@
datadir=@datadir@
libdir=@libdir@

INSTALL=@INSTALL@

DOCUMENTS:= AUTHORS COPYING INSTALL NEWS README THANKS TODO 

all: distro 

distro:
	$(MAKE) -C src all
	$(MAKE) -C doc all

# Install core gtk java libraries and required libraries
install:  @GCJ_INSTALL_TARGETS@
	-$(INSTALL) -d $(DESTDIR)$(datadir)/java/
	-$(INSTALL) -d $(DESTDIR)$(datadir)/doc/libgtk$(apiversion)-java/
	-$(INSTALL) -d $(DESTDIR)$(libdir)/
	$(INSTALL) -s -m644 lib/libgtkjava$(gtkapiversion).so.$(gtkversion) $(DESTDIR)$(libdir)/
	$(INSTALL) -m644 lib/gtk$(gtkapiversion)-$(gtkversion).jar $(DESTDIR)$(datadir)/java/
	ln -s -f libgtkjava$(gtkapiversion).so.$(gtkversion) $(DESTDIR)$(libdir)/libgtkjava$(gtkapiversion).so
	ln -s -f gtk$(gtkapiversion)-$(gtkversion).jar $(DESTDIR)$(datadir)/java/gtk$(gtkapiversion).jar
	-for f in $(DOCUMENTS); do $(INSTALL) -m644 $$f $(DESTDIR)$(datadir)/doc/libgtk$(gtkapiversion)-java || exit 1; done;
	-$(INSTALL) -d $(DESTDIR)$(libdir)/pkgconfig/
	$(INSTALL) -m644 gtk2-java.pc $(DESTDIR)$(libdir)/pkgconfig/
	-$(INSTALL) -d $(DESTDIR)$(datadir)/libgtk-java/macros/
	$(INSTALL) -m644 macros/*.m4 $(DESTDIR)$(datadir)/libgtk-java/macros/
	$(MAKE) -C doc install

# install native (gcj compiled) libraries
native_install:
	-$(INSTALL) -d $(DESTDIR)$(libdir)/
	$(INSTALL) -s -m644 lib/libgtkjar$(gtkapiversion).so.$(gtkversion) $(DESTDIR)$(libdir)/
	@ln -s -f libgtkjar$(gtkapiversion).so.$(gtkversion) $(DESTDIR)$(libdir)/libgtkjar$(gtkapiversion).so

# Uninstall targets
uninstall: @GCJ_UNINSTALL_TARGETS@
	rm -f $(libdir)/libgtkjava$(gtkapiversion).so.$(gtkversion)
	rm -f $(libdir)/libgtkjava$(gtkapiversion).so
	rm -f $(datadir)/java-gnome/gtk$(gtkapiversion)-$(gtkversion).jar
	rm -f $(datadir)/java-gnome/gtk$(gtkapiversion).jar
	rm -rf $(datadir)/java-gnome
	rm -rf $(datadir)/doc/java-gnome-$(gtkapiversion)

native_uninstall:
	rm -f $(libdir)/libgtkjar$(gtkapiversion).so.$(gtkversion)
	rm -f $(libdir)/libgtkjar$(gtkapiversion).so

.PHONY: all distro install native_install uninstall native_uninstall

# Targets to clean up after us

.PHONY: mostlyclean clean distclean maintainer-clean

mostlyclean:
	-$(MAKE) -C src mostlyclean
	-$(MAKE) -C doc mostlyclean

clean: mostlyclean
	-$(MAKE) -C src clean
	-$(MAKE) -C doc clean

distclean: clean
	-$(MAKE) -C src distclean
	-$(MAKE) -C doc distclean
	rm -f config.* Makefile *.spec

maintainer-clean: distclean
	-$(MAKE) -C src maintainer-clean
	-$(MAKE) -C doc maintainer-clean


