aboutsummaryrefslogtreecommitdiffhomepage
path: root/content/2022-06-18-libclang-c-to-llvm-ir/Makefile
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2022-06-18 19:41:38 +0200
committerJohannes Stoelp <johannes.stoelp@gmail.com>2022-06-18 19:41:38 +0200
commit394366cf1c32aae428e588b262a9dc365d897a70 (patch)
treec73a1e6b673ab84ec0519361999efdd5e8393b90 /content/2022-06-18-libclang-c-to-llvm-ir/Makefile
parentdf6dfea1ac8b9040afeb7acf3607a355a898fa6b (diff)
downloadblog-394366cf1c32aae428e588b262a9dc365d897a70.tar.gz
blog-394366cf1c32aae428e588b262a9dc365d897a70.zip
clang: add post about in memory c -> llvm ir
Diffstat (limited to 'content/2022-06-18-libclang-c-to-llvm-ir/Makefile')
-rw-r--r--content/2022-06-18-libclang-c-to-llvm-ir/Makefile27
1 files changed, 27 insertions, 0 deletions
diff --git a/content/2022-06-18-libclang-c-to-llvm-ir/Makefile b/content/2022-06-18-libclang-c-to-llvm-ir/Makefile
new file mode 100644
index 0000000..ec36db3
--- /dev/null
+++ b/content/2022-06-18-libclang-c-to-llvm-ir/Makefile
@@ -0,0 +1,27 @@
+LIBS = $(shell llvm-config --libs)
+LIBS += -lclang-cpp
+
+CXXFLAGS = -Wall
+CXXFLAGS += -Wextra
+CXXFLAGS += -Werror
+CXXFLAGS += -O3
+
+SAN ?= 1
+ifeq ($(SAN),1)
+FLAGS = -fsanitize=address -fsanitize=leak -fsanitize=undefined
+endif
+
+run: gen-ir
+ ./$^
+
+gen-ir: gen-ir.o
+ $(CXX) -o $@ $^ $(LIBS) $(FLAGS)
+
+%.o: %.cc
+ $(CXX) -o $@ -c $^ $(CXXFLAGS) $(FLAGS)
+
+fmt:
+ clang-format -i *.cc
+
+clean:
+ $(RM) gen-ir *.o