Waiting for shell command to execute in a makefile
<p>I've been trying to learn how to use <code>make</code> and hit a roadblock that I'm assuming has more to do with process management than make.</p>

<p>I have the following target</p>

<pre><code>install:
    ...
    @brew install postgres
    @pg_ctl -D data initdb
    @pg_ctl -D data start
    @createuser foo -s
</code></pre>

<p>I'm installing postgres, creating a database, starting it, then creating a user.</p>

<p>In this case, <code>createuser</code> continues to fail because the database hasn't started up yet.</p>

<p>I'm assuming what needs to happen is that I need to use <code>wait</code> to hold off on the createuser command until the database has started up, but after an hour of wrangling, I have a feeling I'm not using wait correctly with something like</p>

<pre><code>@pg_ctl -D data start &amp;
@wait $!
@createuser ...
</code></pre>

<p>Any idea what I'm missing?</p>