Rombobjörn

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Persson <bjorn@rombobjörn.se>2013-10-18 17:16:32 +0200
committerBjörn Persson <bjorn@rombobjörn.se>2013-10-18 17:16:32 +0200
commit2cc726f84b9a3b7c1c5a963b5adf840ba38754fe (patch)
tree49c886bc66b4c2e32da95611abda17e4449b2974
parentfb5c492242f8d3cb67473a5217718e86ee41f439 (diff)
Wrote a pattern rule for making directories.
-rw-r--r--comfignat.mk13
-rwxr-xr-xmanual.en.html15
2 files changed, 22 insertions, 6 deletions
diff --git a/comfignat.mk b/comfignat.mk
index e134d2e..42dc5d8 100644
--- a/comfignat.mk
+++ b/comfignat.mk
@@ -513,11 +513,12 @@ preprocessed_files_in_builddir = ${addprefix ${builddir}/,${preprocessed_files}}
Comfignat_default_goal: build
# How to make directories:
-${builddir} ${stage_gprdir}:
+%/:
mkdir -p $@
+.PRECIOUS: %/
# How to initialize a build directory with a delegating makefile:
-${builddir}/Makefile: | ${builddir}
+${builddir}/Makefile: | ${builddir}/
@echo 'Writing $@.'
@( echo 'Comfignat_default_goal: force ; ${delegation_command}'; \
echo '%: force ; ${delegation_command} $$@'; \
@@ -576,19 +577,19 @@ show_configuration::
true
# How to preprocess the project Comfignat:
-${builddir}/comfignat.gpr: comfignat.gpr.gp | ${builddir}
+${builddir}/comfignat.gpr: comfignat.gpr.gp | ${builddir}/
"${GNATPREP}" $< $@ -DInvoked_By_Makefile ${all_directories}
# How to preprocess files that are needed during the build:
-${builddir}/%: %.gp | ${builddir}
+${builddir}/%: %.gp | ${builddir}/
${preprocess_file}
# How to preprocess usage projects:
-${stage_gprdir}/%: %.gp | ${stage_gprdir}
+${stage_gprdir}/%: %.gp | ${stage_gprdir}/
${preprocess_file}
# How to stage usage projects that don't need preprocessing:
-${stage_gprdir}/%: % | ${stage_gprdir}
+${stage_gprdir}/%: % | ${stage_gprdir}/
cp -p $< $@
preprocess: $${preprocessed_files_in_builddir}
diff --git a/manual.en.html b/manual.en.html
index fbeb65c..e54dda0 100755
--- a/manual.en.html
+++ b/manual.en.html
@@ -520,6 +520,19 @@ root of the source tree. Here's an example:</p>
<pre class="example gpr">for Source_Dirs use ($Srcdir &amp; "/tools");</pre>
+<h3 id="rules">Writing Make Rules</h3>
+
+<h4 id="making_directories">Making Directories</h4>
+
+<p>There is no need to write rules to make directories. Comfignat has a pattern
+rule that matches all pathnames that end with a slash, and creates the
+directory and its ancestors. Just specify the directory as an order-only
+prerequisite and be sure to append a slash. This rule ensures that the
+directory <var>data</var> exists before the file <var>db</var> is written:</p>
+
+<pre class="example make">${stage_statedir}/example/data/db: | ${stage_statedir}/example/data/
+ echo stuff > $@</pre>
+
<h3 id="targets">Make Targets</h3>
<p>These phony targets are defined in <var>comfignat.mk</var>:</p>
@@ -627,6 +640,8 @@ working in subdirectories use the right build and staging directories.</p></li>
<li><p>The ability to save environment variables in the persistent
configuration was added.</p></li>
+<li><p>The pattern rule for making directories was added.</p></li>
+
<li><p>The Make targets <var>all</var>, <var>base</var> and
<var>show_configuration</var> were added.</p></li>
</ul>