# -------------------------------------------------------------------------
#
#  Copyright (C) 2003-2013 Fons Adriaensen <fons@linuxaudio.org>
#  Copyright (C) 2008 Hans Fugal <hans@fugal.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 3 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, see <http://www.gnu.org/licenses/>.
#
# -------------------------------------------------------------------------


PREFIX = /usr/local
SUFFIX := $(shell uname -p | sed -e 's/^unknown/$//' -e 's/^i.86/$//' -e 's/^x86_64/$/64/')
LIBDIR = lib$(SUFFIX)
VERSION = 0.9.0
CPPFLAGS += -DVERSION=\"$(VERSION)\" -DLIBDIR=\"$(PREFIX)/$(LIBDIR)\"
CXXFLAGS += -O2 -Wall -MMD -MP
CXXFLAGS += -march=native

all:	aeolus aeolus_x11.so aeolus_txt.so


AEOLUS_O =	main.o audio.o model.o slave.o imidi-osx.o addsynth.o scales.o \
		reverb.o asection.o division.o rankwave.o rngen.o exp2ap.o lfqueue.o
aeolus:	LDLIBS += -lclthreads -lpthread -ljack -lpthread -framework Cocoa -framework CoreMIDI
aeolus: LDFLAGS += -L$(PREFIX)/$(LIBDIR)
aeolus:	$(AEOLUS_O)
	g++ $(LDFLAGS) -o $@ $(AEOLUS_O) $(LDLIBS)

addsynth.o:	CPPFLAGS += -dynamic -D_REENTRANT
$(AEOLUS_O):
-include $(AEOLUS_O:%.o=%.d)


XIFACE_O =	styles.o mainwin.o midiwin.o audiowin.o instrwin.o editwin.o midimatrix.o \
		multislider.o functionwin.o xiface.o addsynth.o
aeolus_x11.so:	CPPFLAGS += -dynamic -D_REENTRANT -I/usr/X11R6/include `freetype-config --cflags`
aeolus_x11.so:	LDLIBS += -lclthreads -lclxclient -lXft -lX11
aeolus_x11.so:	LDFLAGS += -dynamiclib -L$(PREFIX)/$(LIBDIR) -L/usr/X11R6/$(LIBDIR)
aeolus_x11.so: $(XIFACE_O) $(LIBCLX)
	g++ $(LDFLAGS) -o $@ $(XIFACE_O) $(LDLIBS)

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



TIFACE_O =	tiface.o
aeolus_txt.so:	CPPFLAGS += -dynamic -D_REENTRANT
aeolus_txt.so:	LDLIBS += -lclthreads -lreadline
aeolus_txt.so:	LDFLAGS += -dynamiclib -L$(PREFIX)/$(LIBDIR)
aeolus_txt.so: $(TIFACE_O)
	g++ $(LDFLAGS) -o $@ $(TIFACE_O) $(LDLIBS)

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



install:	aeolus aeolus_x11.so aeolus_txt.so 
	/usr/bin/install -d $(PREFIX)/$(LIBDIR)
	/usr/bin/install -m 755 aeolus $(PREFIX)/bin
	/usr/bin/install -m 755 aeolus_x11.so $(PREFIX)/$(LIBDIR)
	/usr/bin/install -m 755 aeolus_txt.so $(PREFIX)/$(LIBDIR)

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

