From 9c181c1e3e0597bff268bbc9a856d5fe673e2ad9 Mon Sep 17 00:00:00 2001 From: Emil Date: Sun, 24 Sep 2023 16:54:34 +0000 Subject: [PATCH] Removed need of LD_LIBRARY_PATH --- Makefile | 16 +++++++--------- README | 6 +----- plug/Makefile | 2 +- src/Makefile | 2 +- src/main.c | 4 +++- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 3ea759c..5d0c946 100644 --- a/Makefile +++ b/Makefile @@ -4,17 +4,15 @@ PREFIX := . CP := cp -f -export CFLAGS := -std=c89 -Wall -Wextra -Wpedantic -Wshadow -Wundef +export CFLAGS := -std=c89 -Werror -Wall -Wextra -Wpedantic -Wshadow -Wundef export CPPFLAGS := -D_FORTIFY_SOURCE=2 -all: plug/libplug.so src/plugin +all: plug src -plug/libplug.so: - make -C plug - $(CP) $@ $(PREFIX) +plug: + make -C $@ -src/plugin: - make -C src - $(CP) $@ $(PREFIX) +src: + make -C $@ -.PHONY: all plug/libplug.so src/plugin +.PHONY: all plug src diff --git a/README b/README index 97502d2..7d54fcb 100644 --- a/README +++ b/README @@ -1,8 +1,4 @@ -Run make and LD_LIBRARY_PATH='.' ./plugin for the example. - -the LD_LIBRARY_PATH part could be removed by either adding -something into your .bashrc. With some internal messing with - get/setenv it's probably possible. +Run make and ./plugin for the example. There's a good reason for the fragmentation and recursion of the Makefiles, as how the files are compiled vary at compile-time diff --git a/plug/Makefile b/plug/Makefile index 7f16e9c..0e7753f 100644 --- a/plug/Makefile +++ b/plug/Makefile @@ -1,4 +1,4 @@ CFLAGS += -shared -fPIC -libplug.so: plug.o +../libplug.so: plug.o ${LINK.c} $+ -o $@ diff --git a/src/Makefile b/src/Makefile index 7f6540a..015dc0f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,5 +1,5 @@ CPPFLAGS += -I../plug -L../plug LDLIBS += -ldl -plugin: main.o +../plugin: main.o ${LINK.c} $+ -o $@ ${LDLIBS} diff --git a/src/main.c b/src/main.c index d382b58..5dc17cc 100644 --- a/src/main.c +++ b/src/main.c @@ -1,4 +1,6 @@ #include +#include +#include #include #include @@ -8,7 +10,7 @@ int main (void) { int x = 0; - char * libplug_fn = "libplug.so"; + char * libplug_fn = "./libplug.so"; void * libplug = NULL; while (1) {