aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2024-09-09 22:58:51 +0200
committerJohannes Stoelp <johannes.stoelp@gmail.com>2024-09-09 22:58:51 +0200
commitfe0c58e5fbaa37668779ec10d2761e6657b824f4 (patch)
tree9d13c3764887ec9b3751973d2e402b1e79830c76 /Makefile
downloadpreload-libbt-fe0c58e5fbaa37668779ec10d2761e6657b824f4.tar.gz
preload-libbt-fe0c58e5fbaa37668779ec10d2761e6657b824f4.zip
initial commit of libbt
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