git » libfiu » commit d5946a4

preload: Only link against libdl when available

author Alberto Bertogli
2009-07-03 00:29:48 UTC
committer Alberto Bertogli
2009-07-03 00:29:48 UTC
parent 67b4a220f4c474b04f74ef18a30168ea51e8dfee

preload: Only link against libdl when available

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

preload/posix/Makefile +5 -1
preload/run/Makefile +5 -1

diff --git a/preload/posix/Makefile b/preload/posix/Makefile
index 34664e2..0713dff 100644
--- a/preload/posix/Makefile
+++ b/preload/posix/Makefile
@@ -49,8 +49,12 @@ $(GEN_OBJS): $(GEN_C)
 .c.o:
 	$(NICE_CC) $(ALL_CFLAGS) -c $< -o $@
 
+# some platforms do not have libdl, we only use it if available
+NEED_LIBDL := $(shell ld -o dlcheck.so -shared -ldl 2>/dev/null && echo -ldl; \
+	rm -f dlcheck.so)
+
 fiu_posix_preload.so: $(OBJS)
-	$(NICE_CC) $(ALL_CFLAGS) -shared -fPIC $(OBJS) -lfiu -ldl \
+	$(NICE_CC) $(ALL_CFLAGS) -shared -fPIC $(OBJS) -lfiu $(NEED_LIBDL) \
 		-o fiu_posix_preload.so
 
 # this should only be needed when building the function list and not the
diff --git a/preload/run/Makefile b/preload/run/Makefile
index 1cc160d..366cee1 100644
--- a/preload/run/Makefile
+++ b/preload/run/Makefile
@@ -35,8 +35,12 @@ all: fiu_run_preload.so fiu-run
 .c.o:
 	$(NICE_CC) $(ALL_CFLAGS) -c $< -o $@
 
+# some platforms do not have libdl, we only use it if available
+NEED_LIBDL := $(shell ld -o dlcheck.so -shared -ldl 2>/dev/null && echo -ldl; \
+	rm -f dlcheck.so)
+
 fiu_run_preload.so: $(OBJS)
-	$(NICE_CC) $(ALL_CFLAGS) -shared -fPIC $(OBJS) -lfiu -ldl \
+	$(NICE_CC) $(ALL_CFLAGS) -shared -fPIC $(OBJS) -lfiu $(NEED_LIBDL) \
 		-o fiu_run_preload.so
 
 fiu-run: fiu-run.in