aboutsummaryrefslogtreecommitdiff
path: root/make/examples
diff options
context:
space:
mode:
Diffstat (limited to 'make/examples')
-rw-r--r--make/examples/aterm/aterm/default.nix34
-rw-r--r--make/examples/aterm/default.nix1
-rw-r--r--make/examples/aterm/test/default.nix18
-rw-r--r--make/examples/default.nix6
-rw-r--r--make/examples/not-so-simple-header-auto/bar/hello.h1
-rw-r--r--make/examples/not-so-simple-header-auto/default.nix11
-rw-r--r--make/examples/not-so-simple-header-auto/foo/fnord/indirect.h3
-rw-r--r--make/examples/not-so-simple-header-auto/foo/hello.c9
-rw-r--r--make/examples/not-so-simple-header/bar/hello.h1
-rw-r--r--make/examples/not-so-simple-header/default.nix14
-rw-r--r--make/examples/not-so-simple-header/foo/fnord/indirect.h3
-rw-r--r--make/examples/not-so-simple-header/foo/hello.c9
-rw-r--r--make/examples/simple-header/default.nix11
-rw-r--r--make/examples/simple-header/hello.c9
-rw-r--r--make/examples/simple-header/hello.h1
-rw-r--r--make/examples/trivial/default.nix8
-rw-r--r--make/examples/trivial/hello.c7
17 files changed, 146 insertions, 0 deletions
diff --git a/make/examples/aterm/aterm/default.nix b/make/examples/aterm/aterm/default.nix
new file mode 100644
index 000000000..8b139219e
--- /dev/null
+++ b/make/examples/aterm/aterm/default.nix
@@ -0,0 +1,34 @@
+{sharedLib ? true}:
+
+rec {
+
+ inherit (import ../../../lib) compileC makeLibrary;
+
+ sources = [
+ ./afun.c
+ ./aterm.c
+ ./bafio.c
+ ./byteio.c
+ ./gc.c
+ ./hash.c
+ ./list.c
+ ./make.c
+ ./md5c.c
+ ./memory.c
+ ./tafio.c
+ ./version.c
+ ];
+
+ compile = fn: compileC {
+ main = fn;
+ localIncludes = "auto";
+ forSharedLib = sharedLib;
+ };
+
+ libATerm = makeLibrary {
+ libraryName = "ATerm";
+ objects = map compile sources;
+ inherit sharedLib;
+ };
+
+}
diff --git a/make/examples/aterm/default.nix b/make/examples/aterm/default.nix
new file mode 100644
index 000000000..edaac40aa
--- /dev/null
+++ b/make/examples/aterm/default.nix
@@ -0,0 +1 @@
+import test/default.nix \ No newline at end of file
diff --git a/make/examples/aterm/test/default.nix b/make/examples/aterm/test/default.nix
new file mode 100644
index 000000000..b7a9dd361
--- /dev/null
+++ b/make/examples/aterm/test/default.nix
@@ -0,0 +1,18 @@
+let {
+
+ inherit (import ../../../lib) compileC link;
+
+ inherit (import ../aterm {}) libATerm;
+
+ compile = fn: compileC {
+ main = fn;
+ localIncludes = "auto";
+ cFlags = "-I../aterm";
+ };
+
+ fib = link {objects = compile ./fib.c; libraries = libATerm;};
+
+ primes = link {objects = compile ./primes.c; libraries = libATerm;};
+
+ body = [fib primes];
+}
diff --git a/make/examples/default.nix b/make/examples/default.nix
new file mode 100644
index 000000000..8b5b8bca5
--- /dev/null
+++ b/make/examples/default.nix
@@ -0,0 +1,6 @@
+[ (import ./trivial)
+ (import ./simple-header)
+ (import ./not-so-simple-header)
+ (import ./not-so-simple-header-auto)
+ (import ./aterm)
+] \ No newline at end of file
diff --git a/make/examples/not-so-simple-header-auto/bar/hello.h b/make/examples/not-so-simple-header-auto/bar/hello.h
new file mode 100644
index 000000000..4595fad98
--- /dev/null
+++ b/make/examples/not-so-simple-header-auto/bar/hello.h
@@ -0,0 +1 @@
+#define WHAT "World"
diff --git a/make/examples/not-so-simple-header-auto/default.nix b/make/examples/not-so-simple-header-auto/default.nix
new file mode 100644
index 000000000..9e84b0c28
--- /dev/null
+++ b/make/examples/not-so-simple-header-auto/default.nix
@@ -0,0 +1,11 @@
+let {
+
+ inherit (import ../../lib) compileC findIncludes link;
+
+ hello = link {programName = "hello"; objects = compileC {
+ main = ./foo/hello.c;
+ localIncludes = "auto";
+ };};
+
+ body = [hello];
+}
diff --git a/make/examples/not-so-simple-header-auto/foo/fnord/indirect.h b/make/examples/not-so-simple-header-auto/foo/fnord/indirect.h
new file mode 100644
index 000000000..2fde1e26c
--- /dev/null
+++ b/make/examples/not-so-simple-header-auto/foo/fnord/indirect.h
@@ -0,0 +1,3 @@
+#define HELLO "Hello"
+
+#include "../../bar/hello.h"
diff --git a/make/examples/not-so-simple-header-auto/foo/hello.c b/make/examples/not-so-simple-header-auto/foo/hello.c
new file mode 100644
index 000000000..7d5b402ce
--- /dev/null
+++ b/make/examples/not-so-simple-header-auto/foo/hello.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+#include "fnord/indirect.h"
+
+int main(int argc, char * * argv)
+{
+ printf(HELLO " " WHAT "\n");
+ return 0;
+}
diff --git a/make/examples/not-so-simple-header/bar/hello.h b/make/examples/not-so-simple-header/bar/hello.h
new file mode 100644
index 000000000..4595fad98
--- /dev/null
+++ b/make/examples/not-so-simple-header/bar/hello.h
@@ -0,0 +1 @@
+#define WHAT "World"
diff --git a/make/examples/not-so-simple-header/default.nix b/make/examples/not-so-simple-header/default.nix
new file mode 100644
index 000000000..61ded57c8
--- /dev/null
+++ b/make/examples/not-so-simple-header/default.nix
@@ -0,0 +1,14 @@
+let {
+
+ inherit (import ../../lib) compileC link;
+
+ hello = link {programName = "hello"; objects = compileC {
+ main = ./foo/hello.c;
+ localIncludes = [
+ [./foo/fnord/indirect.h "fnord/indirect.h"]
+ [./bar/hello.h "fnord/../../bar/hello.h"]
+ ];
+ };};
+
+ body = [hello];
+}
diff --git a/make/examples/not-so-simple-header/foo/fnord/indirect.h b/make/examples/not-so-simple-header/foo/fnord/indirect.h
new file mode 100644
index 000000000..2fde1e26c
--- /dev/null
+++ b/make/examples/not-so-simple-header/foo/fnord/indirect.h
@@ -0,0 +1,3 @@
+#define HELLO "Hello"
+
+#include "../../bar/hello.h"
diff --git a/make/examples/not-so-simple-header/foo/hello.c b/make/examples/not-so-simple-header/foo/hello.c
new file mode 100644
index 000000000..7d5b402ce
--- /dev/null
+++ b/make/examples/not-so-simple-header/foo/hello.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+#include "fnord/indirect.h"
+
+int main(int argc, char * * argv)
+{
+ printf(HELLO " " WHAT "\n");
+ return 0;
+}
diff --git a/make/examples/simple-header/default.nix b/make/examples/simple-header/default.nix
new file mode 100644
index 000000000..e943471aa
--- /dev/null
+++ b/make/examples/simple-header/default.nix
@@ -0,0 +1,11 @@
+let {
+
+ inherit (import ../../lib) compileC link;
+
+ hello = link {objects = compileC {
+ main = ./hello.c;
+ localIncludes = [ [./hello.h "hello.h"] ];
+ };};
+
+ body = [hello];
+}
diff --git a/make/examples/simple-header/hello.c b/make/examples/simple-header/hello.c
new file mode 100644
index 000000000..15f1ac714
--- /dev/null
+++ b/make/examples/simple-header/hello.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+#include "hello.h"
+
+int main(int argc, char * * argv)
+{
+ printf("Hello " WHAT "\n");
+ return 0;
+}
diff --git a/make/examples/simple-header/hello.h b/make/examples/simple-header/hello.h
new file mode 100644
index 000000000..4595fad98
--- /dev/null
+++ b/make/examples/simple-header/hello.h
@@ -0,0 +1 @@
+#define WHAT "World"
diff --git a/make/examples/trivial/default.nix b/make/examples/trivial/default.nix
new file mode 100644
index 000000000..132245e58
--- /dev/null
+++ b/make/examples/trivial/default.nix
@@ -0,0 +1,8 @@
+let {
+
+ inherit (import ../../lib) compileC link;
+
+ hello = link {objects = compileC {main = ./hello.c;};};
+
+ body = [hello];
+}
diff --git a/make/examples/trivial/hello.c b/make/examples/trivial/hello.c
new file mode 100644
index 000000000..237ad8ffe
--- /dev/null
+++ b/make/examples/trivial/hello.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(int argc, char * * argv)
+{
+ printf("Hello World\n");
+ return 0;
+}