From e0a26bc0a8d6c8021c0a2da5bb66008a1c7a51de Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Sat, 9 Nov 2019 17:57:19 +0000 Subject: [PATCH] Add Makefile for building stdlib There are two ways we can go about including our standard library in our language. The first method is via statically linking it into our final executable, by compiling our Haskell code and standard library object file with it. The second method is to compile the standard library into a shared library and dynamically load it at runtime. Here we are going to do the latter, since it means we can still run our code with runghc, at the cost of needing to locate the path to the library inside Main.hs. (I'll include an example later on of how to include it the static way) macOS produces dylibs - Linux typically uses .so files. You may want to rename the rule to align with whatever operating system you are targeting. --- .gitignore | 1 + Makefile | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..699f4dd --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +stdlib.dylib diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4e533dc --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +stdlib.dylib: stdlib.c + clang -shared $< -o $@ -- 2.30.2