Am Mittwoch, den 30.12.2009, 15:15 +0100 schrieb Matthias Wächter:
> Am 29.12.2009 23:55, schrieb Ulf Bro:
> > Dieses ist ein Beispiel dafür, wie sehr man die dritte Ebene lieben
> > lernen kann. […]
> 
> Danke, Ulf, jetzt hast du mir den Tag „versaut“ – du hast mir endlich
> den entscheidenden Anstoß gegeben, mich mit LilyPond auseinander zu
> setzen. Als hätte ich nichts Wichtigeres zu tun! ;-)

da hier offenbar so viele Leute Spaß an LilyPond haben paste ich hier
mal mein Makefile, was ich immer damit benutze…
probiert damit mal „make watch“

Ben

DOC=$(shell basename $(shell pwd))

default: $(foreach i,$(DOC),$i.pdf)

PDFVIEWER=evince

%.pdf: *.ly
	lilypond $*

distclean: $(foreach i,$(DOC),distclean_$i)
distclean_%: 
	rm -f $(foreach ext,midi pdf,$*.$(ext))

clean: 
	rm -f $(foreach ext,ps,*.$(ext))

watch: $(foreach i,$(DOC),watch_$i)
watch_%: %.pdf
	if [ -f /tmp/$*_watch.pid ];then\
		WATCHID=`cat /tmp/$*_watch.pid`;\
		if [ `ps --pid $$WATCHID|wc -l` = 2 ];then echo "\033[31mThere is another \"make watch\" running!\033[0m"; return 1; fi;\
	fi
	echo $$PPID > /tmp/$*_watch.pid
	cp $< /tmp/
	if [ -z "`ps x |grep "$(PDFVIEWER) /tmp/$<" |grep -v grep`" ];then $(PDFVIEWER) /tmp/$<; fi&
	while true; do\
		FILE=`inotifywait -r -e close_write --format="%w%f" --exclude '(/[^\\.]*\$$|\\.swp\$$)' . 2>/dev/null`;\
		EXT=`echo $$FILE|sed -e 's/^.*\.\([^.]*\)$$/\1/g'`;\
		case $$EXT in\
		ly);;\
		*)\
			echo "$$FILE was modified and I don't know what to do!";\
			continue;\
			;;\
		esac;\
		lilypond $*;\
		if [ $$? -eq 0 ];then\
			cp $< /tmp/;\
		else\
			echo "\033[31mSOMETHING WENT WRONG, PLEASE CHECK THE CONSOLE!!!\033[0m";\
		fi;\
	done

Antwort per Email an