nrnrnr / noweb

The noweb tool for literate programming
BSD 2-Clause "Simplified" License
253 stars 27 forks source link

Remove generated makefile circular dependency #33

Open turboencabulator opened 1 year ago

turboencabulator commented 1 year ago

src/Makefile is generated from src/Makefile.nw, mainly to unroll some loops. Two potential problems:

  1. If I need to make any modifications (particularly for package building), the preferred place to do it is in src/Makefile.nw. However if I'm trying to bootstrap and don't already have notangle installed, I must edit the generated src/Makefile instead. Editing here is repetitive and increases the chances that I'll miss something.
  2. If src/Makefile was generated, it's left in a read-only state by chmod -w. If I'm following the installation instructions and just want to edit some variables directly (instead of scripting it), I first have to chmod +w it.

My solution is to put the loops directly into src/Makefile so we no longer need to generate it.

turboencabulator commented 9 months ago

I ran into another problem that this change will fix. If I don't already have noweb installed and am trying to bootstrap, and Makefile.nw is newer than Makefile (for whatever reason), then it dies at the make boot step:

chmod +w Makefile
notangle -R'script' Makefile.nw | sh > Makefile
/bin/sh: line 1: notangle: command not found
chmod -w Makefile
make: *** No rule to make target 'boot'.  Stop.

Make is smart enough to update the Makefile before updating any other targets. In this case it's wiping the Makefile contents since notangle doesn't exist yet, and then it can't continue.

If you're not interested in merging this change, I think we need an additional installation step to touch Makefile just before make boot.