#  Copyright (C) 2008 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 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.


PREFIX = /usr/local
SUFFIX := $(shell uname -m | sed -e 's/^unknown/$//' -e 's/^i.86/$//' -e 's/^x86_64/$/64/')
LIBDIR = lib$(SUFFIX)
SHARED = $(PREFIX)/share
PROGRAM = jmeters
VERSION = 0.2.0
DISTDIR = jmeters-$(VERSION)
CPPFLAGS += -O3 -Wall -MMD -MP -DPROGRAM=\"$(PROGRAM)\" -DVERSION=\"$(VERSION)\" -DSHARED=\"$(SHARED)\"
#CPPFLAGS += -march=pentium4


all:	jmeters


JMETERS_O = jmeters.o styles.o mainwin.o jclient.o mkimage.o meterwin.o

jmeters:	CPPFLAGS += -ffast-math -I/usr/include/freetype2
jmeters:	LDLIBS += -lsndfile -lclxclient -lclthreads -ljack -lpng -lXft -lX11 -lrt
jmeters:	LDFLAGS += -L/usr/X11R6/lib
jmeters:	$(JMETERS_O)
	g++ $(LDFLAGS) -o $@ $(JMETERS_O) $(LDLIBS)

$(JMETERS_O):
-include $(JMETERS_O:%.o=%.d)


install:	all
	/usr/bin/install -d $(PREFIX)/bin
	/usr/bin/install -m 755 jmeters $(PREFIX)/bin
	/usr/bin/install -d $(SHARED)/jmeters
	/usr/bin/install -m 644 ../share/* $(SHARED)/jmeters

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


tarball:
	cd ../..; \
	/bin/rm -f -r $(DISTDIR); \
	svn export jmeters $(DISTDIR); \
	tar cvjf $(DISTDIR).tar.bz2 $(DISTDIR); \
	/bin/rm -f -r $(DISTDIR);

