Created
October 12, 2013 07:20
-
-
Save emasaka/6946904 to your computer and use it in GitHub Desktop.
Makefile for GNU make 4.0 that rules are written by embedded Guile.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define dsl | |
(use-modules (srfi srfi-1)) | |
(define targets '()) | |
(define (showtargets) | |
(string-join (reverse targets) "\n") ) | |
(define-macro (push! place item) | |
`(set! ,place (cons ,item ,place)) ) | |
(define (mklist->str lst) | |
(string-join (map symbol->string lst)) ) | |
(define-macro (deftarget tgt dep . cmds) | |
(push! targets | |
(format #f "~a:~a~a" | |
tgt (mklist->str dep) | |
(fold (lambda (x r) | |
(string-append r "\n\t" (mklist->str x))) "" cmds )) )) | |
(deftarget all (foo) | |
(@./foo)) | |
(deftarget foo (foo.c) | |
(cc foo.c -o foo) ) | |
endef | |
dummy := $(guile $(dsl)) | |
$(guile (gmk-eval (showtargets))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment