Recursive make considered harmful.
authorRicardo Wurmus <rekado@elephly.net>
Fri, 24 Feb 2017 19:31:13 +0000 (20:31 +0100)
committerRicardo Wurmus <rekado@elephly.net>
Fri, 24 Feb 2017 19:31:13 +0000 (20:31 +0100)
Makefile
rules.mk [new file with mode: 0644]
targets.mk [deleted file]

index 46cf293..d46637d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,26 @@
-SUBDIRS := $(wildcard 0*/)
+# What soundfont to use to generate the MIDI file
+SOUNDFONT = $(HOME)/soundfonts/FluidR3GM.sf2
+# Determine how many processors are present
+CPU_CORES=`grep -m1 "cpu cores" /proc/cpuinfo | tr -cd '[:digit:]'`
+# The command to run lilypond
+LILY_CMD = lilypond -ddelete-intermediate-files -drelative-includes -djob-count=$(CPU_CORES)
 
-all : $(SUBDIRS)
+SUBDIRS := 01-song1 02-song2 03-circus 04-white-noise
 
+all: $(SUBDIRS)
 guide: guide.wav
-guide.wav: $(addsuffix guide.wav,$(SUBDIRS)) | all
+guide.wav: $(addsuffix /guide.wav,$(SUBDIRS))
        sox --combine concatenate $(sort $^) $@
+clean:
+       - rm guide.wav $(wildcard */guide.wav) $(wildcard $(addsuffix /*.wav,$(SUBDIRS)))
 
-$(SUBDIRS) :
-       $(MAKE) -C $@
+NAME := 01-song1
+include rules.mk
+NAME := 02-song2
+include rules.mk
+NAME := 03-circus
+include rules.mk
+NAME := 04-white-noise
+include rules.mk
 
-.PHONY : all $(SUBDIRS)
+.PHONY: $(SUBDIRS) clean
diff --git a/rules.mk b/rules.mk
new file mode 100644 (file)
index 0000000..9420e6a
--- /dev/null
+++ b/rules.mk
@@ -0,0 +1,31 @@
+$(NAME): $(NAME)/$(NAME).wav
+
+$(NAME)/$(NAME).wav: $(NAME)/$(NAME).midi
+       fluidsynth -r 48000 -F $@ -l -R no -i -n -a alsa $(SOUNDFONT) $<
+
+$(NAME)/parts/%.pdf: $(NAME)/parts/%.ly $(NAME)/music/%.ly
+       $(LILY_CMD) $<
+
+$(NAME)/$(NAME).pdf: $(NAME)/$(NAME).ly $(wildcard $(NAME)/music/*.ly)
+       $(LILY_CMD) $<
+
+$(NAME)/$(NAME).midi: $(NAME)/$(NAME).ly $(wildcard $(NAME)/music/*.ly)
+       $(LILY_CMD) $<
+
+$(NAME)/$(NAME)-klick-mono.wav: $(NAME)/$(NAME).tempo
+       klick -W $@ -f $<
+
+$(NAME)/$(NAME)-klick.wav: $(NAME)/$(NAME)-klick-mono.wav
+       sox $< $@ channels 2
+
+$(NAME)/guide.wav: $(NAME)/$(NAME)-klick.wav $(NAME)/$(NAME).wav
+       sox --combine mix $< -v 0.5 $(word 2,$^) $@
+
+%.ogg: %.wav
+       oggenc $<
+
+$(NAME)/upload-ogg: $(NAME)/$(NAME).ogg
+       cd $(NAME) && scp $(NAME).ogg elephly.net:~/elephly.net/secret/band/$(NAME)/$(NAME).ogg
+
+$(NAME)/upload-wav: $(NAME)/$(NAME).wav
+       cd $(NAME) && scp $(NAME).wav elephly.net:~/elephly.net/secret/band/$(NAME)/$(NAME).wav
diff --git a/targets.mk b/targets.mk
deleted file mode 100644 (file)
index 1c6b854..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-# Project root directory
-TOP := $(dir $(lastword $(MAKEFILE_LIST)))
-
-# What soundfont to use to generate the MIDI file
-SOUNDFONT = $(HOME)/soundfonts/FluidR3GM.sf2
-# Determine how many processors are present
-CPU_CORES=`grep -m1 "cpu cores" /proc/cpuinfo | tr -cd '[:digit:]'`
-# The command to run lilypond
-LILY_CMD = lilypond -ddelete-intermediate-files -drelative-includes -djob-count=$(CPU_CORES)
-
-wav: $(NAME).wav
-ogg: $(NAME).ogg
-guide: guide.wav
-
-upload-ogg: ogg
-       scp $(NAME).ogg elephly.net:~/elephly.net/secret/band/$(NAME)/$(NAME).ogg
-
-upload-wav: wav
-       scp $(NAME).wav elephly.net:~/elephly.net/secret/band/$(NAME)/$(NAME).wav
-
-
-parts/%.pdf: parts/%.ly music/%.ly
-       $(LILY_CMD) $<
-
-%.pdf: %.ly music/*.ly
-       $(LILY_CMD) $<
-
-%.midi: %.ly music/*.ly
-       $(LILY_CMD) $<
-
-$(NAME).wav: $(NAME).midi
-       fluidsynth -r 48000 -F $@ -l -R no -i -n -a alsa $(SOUNDFONT) $<
-
-%-klick-mono.wav: %.tempo
-       klick -W $@ -f $<
-
-%-klick.wav: %-klick-mono.wav
-       sox $< $@ channels 2
-
-guide.wav: $(NAME)-klick.wav $(NAME).wav
-       sox --combine mix $(NAME)-klick.wav -v 0.25 $(NAME).wav $@
-
-%.ogg: %.wav
-       oggenc $<