
# package name
package = sdl4gcj
version = 0.0.5

# for build
srcdir = .
top_srcdir = .

# for install
prefix = /usr/local
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
includedir = ${prefix}/include
libdir = ${exec_prefix}/lib
datadir = ${prefix}/share
sysconfdir = ${prefix}/etc

pkgdatadir = ${prefix}/share/sdl4gcj
pkgsysconfdir = ${prefix}/etc/sdl4gcj

extdir = ${prefix}/share/java/ext


INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644

MAKE = make -j 1

# for packaging
DISTDIR = $(package)-$(version)
SNAPSHOTDIR=$(package)-`date +%Y%m%d`

DIST_SUBDIRS = doc src test test-mixer test-image test-gl
EXTRA_DIST = Makefile Makefile.in \
	README \
	config.sub config.guess configure.in configure install-sh \
	sdl4gcj.spec sdl4gcj.spec.in \


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

LIBRARY = lib$(package).a

############################################################
# 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)
	$(INSTALL) -d doc/en
	$(INSTALL) -d doc/ja
	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)

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

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

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


distclean : clean
	-rm config.cache config.log  config.status 
	cd test; $(MAKE) $@; cd $(top_srcdir)
	cd test-mixer; $(MAKE) $@; cd $(top_srcdir)
	cd test-image; $(MAKE) $@; cd $(top_srcdir)
	cd test-gl; $(MAKE) $@; cd $(top_srcdir)

clean :
	cd src; $(MAKE) $@; cd $(top_srcdir)
	cd test; $(MAKE) $@; cd $(top_srcdir)
	cd test-mixer; $(MAKE) $@; cd $(top_srcdir)
	cd test-image; $(MAKE) $@; cd $(top_srcdir)
	cd test-gl; $(MAKE) $@; cd $(top_srcdir)

