INSTALL=@INSTALL@
LN_S=@LN_S@
DESTDIR=@prefix@/
DESTINC=$(DESTDIR)include
DESTLIB=$(DESTDIR)lib
MAKE=@MAKE@
MAJOR_VERSION=@MAJOR_VERSION@
MINOR_VERSION=@MINOR_VERSION@
MICRO_VERSION=@MICRO_VERSION@
VERSION=$(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)

all: configure config.h.in
	cd jlib && $(MAKE) all
	cd src  && $(MAKE) all
	cd doc  && $(MAKE) all

tags:
	ctags `find . -name "*.[ch]" -print`

etags:
	etags `find . -name "*.[ch]" -print`

clean:
	cd jlib && $(MAKE) clean
	cd doc && $(MAKE) clean
	cd src && $(MAKE) clean
	cd audioconvert && $(MAKE) clean

distclean:
	cd jlib && $(MAKE) distclean
	cd doc && $(MAKE) distclean
	cd src && $(MAKE) distclean
	cd audioconvert && $(MAKE) distclean
	cd test && $(MAKE) distclean
	-rm -Rf Makefile config.log config.cache config.status tags gmon.out

test:	all
	cd test && $(MAKE)

install: all
	$(INSTALL) -d -m 755 $(DESTINC)
	$(INSTALL) -d -m 755 $(DESTINC)/AL
	$(INSTALL) -d -m 755 $(DESTLIB)
	$(INSTALL) -m 755 src/libopenal.a $(DESTLIB)
	$(INSTALL) -m 755 src/libopenal.so.$(VERSION) $(DESTLIB)
	$(LN_S) -f $(DESTLIB)/libopenal.so.$(VERSION) $(DESTLIB)/libopenal.so.$(MAJOR_VERSION)
	$(LN_S) -f $(DESTLIB)/libopenal.so.$(VERSION) $(DESTLIB)/libopenal.so
	$(INSTALL) -m 444 ../include/AL/al.h $(DESTINC)/AL
	$(INSTALL) -m 444 ../include/AL/alc.h $(DESTINC)/AL
	$(INSTALL) -m 444 ../include/AL/alu.h $(DESTINC)/AL
	$(INSTALL) -m 444 ../include/AL/alut.h $(DESTINC)/AL
	$(INSTALL) -m 444 ../include/AL/altypes.h $(DESTINC)/AL
	$(INSTALL) -m 444 ../include/AL/alctypes.h $(DESTINC)/AL
	$(INSTALL) -m 444 ../include/AL/alutypes.h $(DESTINC)/AL
	$(INSTALL) -m 444 ../include/AL/aluttypes.h $(DESTINC)/AL
	$(INSTALL) -m 444 include/AL/alext.h $(DESTINC)/AL
	$(INSTALL) -m 444 include/AL/alexttypes.h $(DESTINC)/AL

configure: configure.in
	@echo "configure.in newer than configure...Please re-./configure"
	autoconf
	@exit 1

config.h.in: acconfig.h
	@echo "acconfig.h newer than config.h.in...Please run autogen.sh and reconfigure."
	@exit 1
