blob: a078c079c73f31922c09e3891cd12a4d15a5287a (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
(use-modules (gnu packages commencement)
(guix gexp))
(define set-up-gcc-gexp
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils))
(set-path-environment-variable "PATH"
'("bin")
(list #$gcc-toolchain))
(set-path-environment-variable "C_INCLUDE_PATH"
'("include")
(list #$gcc-toolchain))
(set-path-environment-variable "LIBRARY_PATH"
'("lib")
(list #$gcc-toolchain)))))
(define* (compile source-filename #:key (flags '()))
(computed-file (string-append (basename source-filename ".c")
".o")
#~(begin
#$set-up-gcc-gexp
(invoke "gcc" "-c" #$(local-file source-filename)
"-o" #$output
#$@flags))))
(define* (link output-filename object-files #:key (flags '()))
(computed-file output-filename
#~(begin
#$set-up-gcc-gexp
(invoke "gcc" "-o" #$output
#$@object-files
#$@flags))))
(let ((include (list "-I" (file-union "include"
`(("print.h" ,(local-file "print.h")))))))
(link "hello"
(list (compile "hello.c"
#:flags include)
(compile "print.c"
#:flags include))))
|