Change behavior. (require racket-makefile) and use (make <target>) instead of racket Makefile.rkt <target>

This commit is contained in:
2026-08-08 22:38:13 +02:00
parent f32503f3e7
commit 57707e5fc0
11 changed files with 276 additions and 32 deletions
+11
View File
@@ -1,5 +1,16 @@
#lang racket-makefile
;; Load only:
;; racket -t Makefile.rkt
;;
;; Build the default target:
;; racket -t Makefile.rkt -e "(make)"
;;
;; Clean and rebuild:
;; racket -t Makefile.rkt -e "(make clean all)"
;;
;; In DrRacket, press Run and then enter (make), (make clean), etc.
(define CC 'cc)
(define CFLAGS '(-Wall -O2))
+22
View File
@@ -0,0 +1,22 @@
#lang racket-makefile
;; Ordinary Racket can generate targets and dependency lists.
(define sources '("foo.c" "bar.c" "baz.c"))
(define objects
(for/list ([src sources])
(define obj (path-replace-extension src #".o"))
(target obj
(deps src)
(run `(cc -c $< -o $target)))
obj))
(default-target all)
(phony all clean)
(target all
(deps objects))
(target clean
(apply rm-f objects))