#  Copyright (C) 2003-2006 Fons Adriaensen <fons.adriaensen@skynet.be>
#
#  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.


# Modify as required.
#
PREFIX = /usr
SUFFIX := $(shell uname -m | sed -e 's/^unknown/$//' -e 's/^i.86/$//' -e 's/^x86_64/$/64/')
LIBDIR = lib$(SUFFIX)


MAJVERS = 1
MINVERS = 2.2
VERSION = $(MAJVERS).$(MINVERS)
DISTDIR = clalsadrv-$(VERSION)


CPPFLAGS += -Wall -I. -fpic -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -O2 
LDLFAGS +=
LDLIBS += -lclalsadrv -lclthreads -lrt 


CLALSADRV_SO = libclalsadrv.so
CLALSADRV_MAJ = $(CLALSADRV_SO).$(MAJVERS)
CLALSADRV_MIN = $(CLALSADRV_MAJ).$(MINVERS)
CLALSADRV_DEP = -lasound
CLALSADRV_O = clalsadrv.o
CLALSADRV_H = clalsadrv.h


$(CLALSADRV_MIN): $(CLALSADRV_O)
	g++ -shared $(LDFLAGS) -Wl,-soname,$(CLALSADRV_MAJ) -o $(CLALSADRV_MIN) $(CLALSADRV_O) $(CLALSADRV_DEP)


install:	$(CLALSADRV_MIN)
	/usr/bin/install -d $(PREFIX)/$(LIBDIR)
	/usr/bin/install -m 644 $(CLALSADRV_H) $(PREFIX)/include
	/usr/bin/install -m 755 $(CLALSADRV_MIN) $(PREFIX)/$(LIBDIR)
	/sbin/ldconfig -n $(PREFIX)/$(LIBDIR)
	ln -sf $(CLALSADRV_MIN) $(PREFIX)/$(LIBDIR)/$(CLALSADRV_SO)


clean:
	/bin/rm -f *~ *.o *.a *.d *.so.* loopback


tarball:
	cd ..; \
	/bin/rm -f -r $(DISTDIR)*; \
	svn export clalsadrv $(DISTDIR); \
	tar cvf $(DISTDIR).tar $(DISTDIR); \
	bzip2 $(DISTDIR).tar; \
	/bin/rm -f -r $(DISTDIR);

