Thank you all for you advices. I have finally put some work into it. I'll show some code (few lines so far) but first, for every one with the patience, here are 2 things that occurred to me since last time.
1. I want to either run make recursively and build every .ly it encouters or target a specific .ly file.
I was naively considering two approaches:
$ make artist/[album/[tune.ly]]
or
$ cd artist/[album] && make [tune.ly]
With the 1st approach I was hoping to have a single centralized makefile at the root folder but this solution seems unrealistic. There is the "-C" switch but it's the same behavior as the 2nd approach (
$ cd /folder/ && make
)
So I took the 2nd approach (more readable) which then requires a Makefile in every folder.
So far I have a makefile that goes with the .ly files that will build "all" .ly or a specific file. Keep in mind that I am a musician. I love C programming but shell script and makefiles will never make sense to me. They seem so aliens to me.
Code:
all:
lilypond *.ly
%: %.ly
lilypond $<
Then I have another makefile that goes in every parent folders (artist and album folders) that runs
make in every sub-folders sub-folders:
Code:
SUBDIRS = $(shell ls -d */)
.PHONY: subdirs $(SUBDIRS)
subdirs: $(SUBDIRS)
$(SUBDIRS):
make -C $@ (or cd $@ && make && cd ..)
This works with my minimalist test tree. I have one concern though:
- Every makefiles will be a clone of one of those 2 "stem makefiles".
Should I use hardlinks instead of copies? symlinks break (of course!) if I change folders architecture.
As
ocicat mentionned, I want an artist/album template that I can easily copy, adapt (i.e: artist/album/arrangement/) and maintain (evolve the build process)! So far (7 years):
$ $ ls -R | grep .ly | wc
286 388 3610
2. Have a single
.OBJDIR (thanks
J65nko). My problem is to have every makefiles aware of the
.OBJDIR path. I was thinking:
- export the path during login (
$ export LILYOUT=/home/funkygoby/somewhere/
). That's dirty and easily forgettable while migrating between system)
- hardcode the path is the makefiles. Remember that my folder architecture have heterogeneous depths so a hardcoded relative path (
../../output/) will breaks. An absolute path looks dirty too but maybe that is the solution?
- My first idea was to include a Makefile.inc containing some variables ($MAKE, .OBJDIR, etc...) but then the problem is only moved: how do you pass the path to every makefiles?
- Then I dug into the ports tree. In a the
archivers/bzip2 Makefile, I found
.include <bsd.port.mk>.
What's does this means? Why is it
.include instead of
include?
bsd.port.mk is not in the same folder as the Makefile. How can
make find it?
Summary:
In older to naively solve my problems, I attend to use 2 "stem makefiles". Every others makefiles are hardlinks to those 2. In order to specify an
.OBJDIR, I am planning to hardcode the path in one of the "stem makefiles".
Any inputs?