Library: makefile-edn


Original Idea - provide mappers from EDN to Makefiles - and back again.

Message from 2022-10-07: I no longer think this is a good idea.

I now believe:

  1. Build dependencies are just data and code
  2. Generally, it’s nice to have a auto-caching build everything-command
  3. This can be solved with EDN, babashka.fs/glob and babashka.fs/modified-since


  1. It’s possible to get equivalent performance with just babashka - perhaps even better if we don’t have to start / restart processes
  2. There’s just one language
  3. The “do we check in the Makefile?” question does not exist
  4. Other things can use the same EDN data that models build dependencies.


Read this:

Makefile EDN spec

:comment Makefile comment with # string
:target Makefile target string
:dependencies Dependencies for makefile target sequence of strings
:commands Sequence of commands to produce target sequence of strings

Example makefile as EDN

(def makefile
  [{:comment "Generate target for root index"}
   ;; # Generate target for root index

   {:target "index.html"
    :dependencies ["index.clj" "aphorisms/index.html" "aphorisms/play.edn"]
    :commands ["./index.clj"]}
   ;; index.html: index.clj aphorisms/index.html aphorisms/play.edn
   ;;     ./index.clj

   {:target "aphorisms/index.html"
    :dependencies ["aphorisms/"]
    :commands ["pandoc -s --shift-heading-level-by=1 --toc --from=org+smart -H live.html -i aphorisms/ -o aphorisms/index.html"]}
   ;; aphorisms/index.html: aphorisms/
   ;;   pandoc -s --shift-heading-level-by=1 --toc --from=org+smart -H live.html -i aphorisms/ -o aphorisms/index.html

Library API

makefile-edn/<-makefile-str - read from makefile string makefile-edn/->makefile-str - write to makefile string


Either as Clojure library or as babashka script. Could perhaps just provide the library — then babashka pulls in the library as needed.