README: Declare formatting for scheme codeblocks

Currently all the codeblocks are unformatted as their formatting is not declared in makefile format, this fixes it to enable highlighting.
This commit is contained in:
Kreyren 2021-12-07 18:16:51 +00:00 committed by GitHub
parent 8aeef1d8eb
commit 651a633d2d
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23

156
README.md

@ -9,36 +9,42 @@ build script in Guile Scheme.
Add this at the top of your build script. Add this at the top of your build script.
#!/usr/bin/env sh ```scheme
exec guile -s "$0" "$@" #!/usr/bin/env sh
!# exec guile -s "$0" "$@"
!#
(use-modules (potato make)) (use-modules (potato make))
(initialize) (initialize)
```
Add this at the bottom of your build script Add this at the bottom of your build script
(execute) ```scheme
(execute)
```
The rules go in between `initialize` and `build`. The rules go in between `initialize` and `build`.
## A Simple Example ## A Simple Example
#!/usr/bin/env sh ```scheme
exec guile -s "$0" "$@" #!/usr/bin/env sh
!# exec guile -s "$0" "$@"
!#
(use-modules (potato make)) (use-modules (potato make))
(initialize) (initialize)
(:= CC "gcc") (:= CC "gcc")
(:= CFLAGS "-g -O2") (:= CFLAGS "-g -O2")
(: "all" '("foo")) (: "all" '("foo"))
(: "foo" '("foo.o" "bar.o") (: "foo" '("foo.o" "bar.o")
(~ ($ CC) "-o" $@ $^)) (~ ($ CC) "-o" $@ $^))
(-> ".c" ".o" (-> ".c" ".o"
(~ ($ CC) "-c" $<)) (~ ($ CC) "-c" $<))
(execute) (execute)
```
## Command-Line Arguments ## Command-Line Arguments
@ -108,70 +114,90 @@ You define makevars in the script, in the environment, or on the command line.
The *target rule* is for when the target, and the prerequisites, if any, The *target rule* is for when the target, and the prerequisites, if any,
have filenames or phony names. have filenames or phony names.
(: target-name '(prereq-name-1 prereq-name-2 ...) ```scheme
recipe-1 (: target-name '(prereq-name-1 prereq-name-2 ...)
recipe-2 recipe-1
...) recipe-2
...)
```
`target-name` is a string which is either a filename to be `target-name` is a string which is either a filename to be
created or an phony name like "all" or "clean". created or an phony name like "all" or "clean".
Recipe as a string to be evaluated by the system Recipe as a string to be evaluated by the system
(: "foo.o" '("foo.c") ```scheme
"cc -c foo.o") (: "foo.o" '("foo.c")
"cc -c foo.o")
```
Recipe as a procedure Recipe as a procedure
(: "clean-foo" '() ```scheme
(lambda () (: "clean-foo" '()
(delete-file "foo.o"))) (lambda ()
(delete-file "foo.o")))
Recipe as a procedure that returns #f to indicate failure ```
(: "recent" '() Recipe as a procedure that returns #f to indicate failure
(lambda ()
(if condition
#t
#f))))
Recipe as a procedure returning a string to be evaluated by the ```scheme
system (: "recent" '()
(lambda ()
(if condition
#t
#f))))
```
(: "foo.o" '("foo.c") Recipe as a procedure returning a string to be evaluated by the
(lambda () system
(format #f "cc ~A -c foo.c" some-flags))
Recipe using recipe helper procedures, which create a string to ```scheme
be evaluated by the system (: "foo.o" '("foo.c")
(lambda ()
(format #f "cc ~A -c foo.c" some-flags))
```
(: "foo.c" '("foo.c") Recipe using recipe helper procedures, which create a string to
(~ ($ CC) ($ CFLAGS) "-c" $<)) be evaluated by the system
Recipe as a boolean to indicate pass or failure without doing any ```scheme
processing. For example, the rule below tells Potato Make that (: "foo.c" '("foo.c")
the file "foo.c" exists without actually testing for it. (~ ($ CC) ($ CFLAGS) "-c" $<))
```
Recipe as a boolean to indicate pass or failure without doing any
processing. For example, the rule below tells Potato Make that
the file "foo.c" exists without actually testing for it.
```scheme
(: "foo.c" '() #t)
```
If there is no recipe at all, it is shorthand for the recipe #t,
indicating a recipe that always passes. This is used
in prerequisite-only target rules, such as below, which passes
so long as the prerequisites pass. These two rules are the same.
```scheme
(: "all" '("foo.exe"))
(: "all" '("foo.exe") #t)
```
(: "foo.c" '() #t) Lastly, if the recipe is #f, this target will always fail.
If there is no recipe at all, it is shorthand for the recipe #t, ```scheme
indicating a recipe that always passes. This is used (: "fail" '() #f)
in prerequisite-only target rules, such as below, which passes ```
so long as the prerequisites
pass. These two rules are the same.
(: "all" '("foo.exe"))
(: "all" '("foo.exe") #t)
Lastly, if the recipe is #f, this target will always fail.
(: "fail" '() #f)
The *suffix rule* is a generic rule to convert one source file to a The *suffix rule* is a generic rule to convert one source file to a
target file, based on the filename extensions. target file, based on the filename extensions.
(-> ".c" ".o" ```scheme
(~ ($ CC) ($ CFLAGS) "-c" $< "-o" $@)) (-> ".c" ".o"
(~ ($ CC) ($ CFLAGS) "-c" $< "-o" $@))
```
## Recipe Helpers ## Recipe Helpers