
# package name
package = @PACKAGE@
version = @VERSION@

# for build
srcdir = @srcdir@
top_srcdir = @top_srcdir@

# for install
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
includedir = @includedir@
libdir = @libdir@
datadir = @datadir@
sysconfdir = @sysconfdir@

pkgdatadir = @datadir@/@PACKAGE@
pkgsysconfdir = @sysconfdir@/@PACKAGE@


INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

MAKE = make -j 1

# for packaging
DISTDIR = $(package)-$(version)

DIST_SUBDIRS = doc src test
EXTRA_DIST = Makefile Makefile.in \
	README \
	config.sub config.guess configure.in configure install-sh \
	gl4gcj.spec gl4gcj.spec.in \


ALL_DIST_FILES = \
	$(DIST_SUBDIRS) \
	$(EXTRA_DIST) \

############################################################
# rules
############################################################
all : 
	cd src; $(MAKE) $@; cd $(top_srcdir)

lib : 
	cd src; $(MAKE) $@; cd $(top_srcdir)

jar : 
	cd src; $(MAKE) $@; cd $(top_srcdir)

apidoc : $(SOURCES) $(NATIVE_CLASS_JAVA_SOURCES)
	doxygen doc/Doxyfile.en
	doxygen doc/Doxyfile.ja

## install rules
install: install-target-dirs
	cd src; $(MAKE) $@; cd $(top_srcdir)
	-cp -pLR doc $(pkgdatadir)

install-target-dirs:
	$(INSTALL) -d $(pkgdatadir)


## distribution rules
dist : dist-targz 

dist-dir : distclean apidoc
	if [ -x $(DISTDIR) ] ; then \
		rm -rf $(DISTDIR) ;\
	fi;
	-mkdir $(DISTDIR)
	-cp -pLR $(ALL_DIST_FILES) $(DISTDIR)
	rm -rf `find $(DISTDIR) -name CVS`

dist-targz : dist-dir
	if [ -f $(DISTDIR).tar.gz ] ; then \
		rm $(DISTDIR).tar.gz ;\
	fi;
	if [ -f $(DISTDIR).tar ] ; then \
		rm $(DISTDIR).tar ;\
	fi;
	-tar cvf $(DISTDIR).tar $(DISTDIR)
	-gzip -9 $(DISTDIR).tar 
	-rm -rf $(DISTDIR)

dist-bzip2 : dist-dir
	if [ -f $(DISTDIR).tar.bz2 ] ; then \
		rm $(DISTDIR).tar.bz2 ;\
	fi;
	if [ -f $(DISTDIR).tar ] ; then \
		rm $(DISTDIR).tar ;\
	fi;
	-tar cvf $(DISTDIR).tar $(DISTDIR)
	-bzip2 -9 $(DISTDIR).tar 
	-rm -rf $(DISTDIR)


rpm :
	rpm -ta $(DISTDIR).tar.gz 


distclean : clean
	-rm config.cache config.log  config.status 

clean :
	cd src; make $@; cd $(top_srcdir)


