#  Copyright (C) 2009 Fons Adriaensen <fons@kokkinizita.net>
#
#  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 Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser 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/local
SUFFIX := $(shell uname -m | sed -e 's/^unknown/$//' -e 's/^i.86/$//' -e 's/^x86_64/$/64/')
LIBDIR = lib$(SUFFIX)


MAJVERS = 0
MINVERS = 1.1
VERSION = $(MAJVERS).$(MINVERS)
DISTDIR = zita-resampler-$(VERSION)


CPPFLAGS += -Wall -I. -fPIC -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -O2 -ffast-math
#CPPFLAGS += -march=native
LDFLAGS += 
LDLIBS +=


ZITA-RESAMPLER_SO = libzita-resampler.so
ZITA-RESAMPLER_MAJ = $(ZITA-RESAMPLER_SO).$(MAJVERS)
ZITA-RESAMPLER_MIN = $(ZITA-RESAMPLER_MAJ).$(MINVERS)
ZITA-RESAMPLER_DEP =
ZITA-RESAMPLER_O = zita-resampler.o
ZITA-RESAMPLER_H = zita-resampler.h 


$(ZITA-RESAMPLER_MIN): $(ZITA-RESAMPLER_O)
	g++ -shared $(LDFLAGS) -Wl,-soname,$(ZITA-RESAMPLER_MAJ) -o $(ZITA-RESAMPLER_MIN) $(ZITA-RESAMPLER_O) $(ZITA-RESAMPLER_DEP)

$(ZITA-RESAMPLER_O):	$(ZITA-RESAMPLER_H)


install:	$(ZITA-RESAMPLER_MIN)
	install -d $(PREFIX)/include
	install -d $(PREFIX)/$(LIBDIR)
	install -m 644 $(ZITA-RESAMPLER_H) $(PREFIX)/include
	install -m 755 $(ZITA-RESAMPLER_MIN) $(PREFIX)/$(LIBDIR)
	/sbin/ldconfig -n $(PREFIX)/$(LIBDIR)
	ln -sf $(ZITA-RESAMPLER_MIN) $(PREFIX)/$(LIBDIR)/$(ZITA-RESAMPLER_SO)


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

