aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile19
1 files changed, 19 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..bd97388
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,19 @@
+all: $(patsubst example/%.c, out/%, $(wildcard example/*.c))
+all: $(patsubst example/%.c, run/%, $(wildcard example/*.c))
+
+CFLAGS := -Wall -Wextra -g -O2
+CFLAGS_recurse2 := -lpthread
+
+run/%:
+ LD_PRELOAD=$(PWD)/libbt.so out/$* || test $$? -eq 42 && exit 0
+
+out/%: example/%.c libbt.so
+ @mkdir -p out
+ $(CC) -o $@ $< -rdynamic $(FLAGS) $(CFLAGS_$*)
+
+libbt.so: bt.c
+ $(CC) -o $@ $^ -shared -fPIC -static-libgcc -ldl $(FLAGS)
+
+clean:
+ $(RM) -r out
+ $(RM) libbt.so