PRAAT = praat
UNAME := $(shell uname -s)
APPLICATIONNAME := $(shell cat ApplicationName.txt)

ifeq ($(UNAME), Darwin)
	PRAAT = /Applications/Praat.app/Contents/MacOS/Praat
endif

all: $(APPLICATIONNAME)expanded.h manual_$(APPLICATIONNAME).cpp
	bash makePraat.sh 2>&1
	bash makePraat.sh MinGW 2>&1

$(APPLICATIONNAME)expanded.praat: ../*.praat
	perl ./expandPraatScripts.pl ../$(APPLICATIONNAME).praat > $(APPLICATIONNAME)expanded.praat
	# perl ./WhatsNew.pl

%.h: %.praat
	perl ./praatscript2cprogram.pl $<  > $@

manual_$(APPLICATIONNAME).cpp:
	if [[ `ls ../ManPages/*.man 2>/dev/null` ]]; then perl ManPages2CPP.pl ../ManPages/*.man > manual_$(APPLICATIONNAME).cpp ; fi

clean:
	rm -f *expanded.h
	rm -f *expanded.praat
	rm -f manual_*.cpp
	rm -rf *.app*
	rm -f *.exe*
	rm -f *.icns *.ico
	rm -f Build_SHA.html
