# Linux makefile for scorealign
# please use either make -f Makfile.linux
# -OR- ln -s Makfile.linux Makefile

# profile = -pg
profile = 

DEBUGFLAGS = 

optimize = -g $(DEBUGFLAGS) $(profile)
# optimize = -O

#PORTSMF LIBRARY PATH:
# (set this to the location of allegro.cpp, allegrosmfrd.cpp, allegrosmfwr.cpp, etc.)
# (if you do not have this directory, look for portsmf in the portmedia project
#  on sourceforge)
PORTSMF = ../portsmf

INCLUDES = -Isnd -Ifft3 -I$(PORTSMF)

#OPTIONS FOR LINUX:
c_opts = $(optimize) -DLINUX $(INCLUDES)

cc = gcc $(c_opts)
c++ = g++ $(c_opts)
cclink = gcc
c++link = g++
syslibs = -lm

scorealign_o = comp_chroma.o gen_chroma.o scorealign.o snd/audionone.o \
               snd/sndcvt.o snd/sndheader.o snd/sndio.o snd/snd.o \
               snd/ieeecvt.o snd/sndlinux.o snd/sndfaillinux.o \
               fft3/FFT.o $(PORTSMF)/mfmidi.o $(PORTSMF)/allegro.o \
               $(PORTSMF)/allegrosmfrd.o $(PORTSMF)/allegrosmfwr.o \
               $(PORTSMF)/allegrord.o $(PORTSMF)/strparse.o trace.o \
               regression.o sautils.o curvefit.o hillclimb.o

.SUFFIXES: .cpp .c .h .aur .o

.cpp.o:
	$(c++) -c $< -o $*.o

.c.o:
	$(cc) -c $< -o $*.o

all: scorealign

header:
	echo "**********************************************************"
	echo "**********************************************************"

clean: 
	echo "removing objects"
	find . -name "*~" | xargs rm -f
	rm -f $(scorealign_o)
	rm -f core*

cleaner: clean
	rm -f TAGS

cleanest: cleaner
	rm -f scorealign
	rm -f scorealign.ncb
	rm -f scorealign.opt
	rm -f scorealign.plg

TAGS: 
	find . \( -name "*.cpp" -o -name "*.h" \) -print | etags -

tags: TAGS

backup: cleanest
	tar cvf ../scorealign.tar .
	gzip ../scorealign.tar
	echo "please rename ../scorealign.tar.gz"


scorealign: $(scorealign_o)
	$(c++link) $(scorealign_o) -o scorealign $(syslibs)

test0:
	./scorealign /home/rbd/wdh/music/nyquist-temp.wav /home/rbd/wdh/music/chrom_nyquist-temp.wav > output.txt
	diff output.txt /home/rbd/wdh/music/output.txt | less

test:
	./scorealign /home/rbd/scorealign/data/live-beeth-s5m1-25s-mono.wav  /home/rbd/scorealign/data/midi-beeth-s5m1-25s-mono.wav > output.txt
	diff output.txt /home/rbd/wdh/music/output.txt | less

bigtest:
	./scorealign data/live-Beethoven_Symphony_No5_Mvt1.wav data/midi-Beethoven_Symphony_No5_Mvt1.wav

bigtest2: 
	./scorealign data/midi-Beethoven_Symphony_No5_Mvt1.wav data/live-Beethoven_Symphony_No5_Mvt1.wav


# DEPENDENCIES











