makefile-targets and some other meta info functions added

This commit is contained in:
2026-08-18 02:15:33 +02:00
parent a21f4a4a39
commit 635d2d40d1
13 changed files with 538 additions and 251 deletions
+7 -7
View File
@@ -8,23 +8,23 @@
(define CC 'cc)
(define CFLAGS '(-Wall -O2))
(makefile hello
(default-target all)
(phony all clean setup test)
(makefile 'hello
(default-target 'all)
(phony 'all 'clean 'setup 'test)
(target all
(target 'all
(deps "hello"))
(target "hello"
(deps "hello.c")
(run `(,CC ,@CFLAGS -o $target $<)))
(target clean
(target 'clean
(rm-f "hello")
(rm-rf "compiled"))
(target setup
(target 'setup
(raco '(setup racket-makefile)))
(target test
(target 'test
(raco '(test -p racket-makefile))))
+5 -5
View File
@@ -2,14 +2,14 @@
(require racket-makefile)
(makefile cleanup-example
(default-target all)
(phony all clean)
(makefile 'cleanup-example
(default-target 'all)
(phony 'all 'clean)
(target all
(target 'all
(displayln "use (make 'clean)"))
(target clean
(target 'clean
(display "cleaning up...")
(apply rm-rf
(list-dirs "." #px"compiled$" #:recursive #t))
+20 -16
View File
@@ -1,22 +1,26 @@
#lang racket-makefile
#lang racket
;; Ordinary Racket can generate targets and dependency lists.
(require racket-makefile)
(define sources '("foo.c" "bar.c" "baz.c"))
;; A makefile body is ordinary Racket. Target names that are expressions are
;; evaluated while the makefile is registered, so a loop can generate targets.
(define objects
(for/list ([src sources])
(define obj (path-replace-extension src #".o"))
(target obj
(deps src)
(run `(cc -c $< -o $target)))
obj))
(makefile 'stuff
(define sources '("foo.c" "bar.c" "baz.c"))
(default-target all)
(phony all clean)
(define objects
(for/list ([src sources])
(define obj (path-replace-extension src #".o"))
(target obj
(deps src)
(run `(cc -c $< -o $target)))
obj))
(target all
(deps objects))
(default-target 'all)
(phony 'all 'clean)
(target clean
(apply rm-f objects))
(target 'all
(deps objects))
(target 'clean
(apply rm-f objects)))