author | Alberto Bertogli
<albertito@blitiri.com.ar> 2010-10-11 02:09:13 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2010-10-11 02:09:13 UTC |
parent | 418652ec8c19d31dc88006c1909b64c50e91d9d5 |
.gitignore | +3 | -0 |
preload/posix/Makefile | +22 | -10 |
preload/run/Makefile | +10 | -4 |
diff --git a/.gitignore b/.gitignore index 83b1c17..24e7bb9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ libfiu/build-flags preload/posix/*.o preload/posix/*.so preload/posix/build-flags +preload/posix/build-libcsoname +preload/posix/build-needlibdl preload/posix/build-env.h preload/posix/function_list preload/posix/modules/*.o @@ -19,4 +21,5 @@ preload/run/*.o preload/run/*.so preload/run/fiu-run preload/run/build-flags +preload/run/build-needlibdl diff --git a/preload/posix/Makefile b/preload/posix/Makefile index e8d3c1e..20d658f 100644 --- a/preload/posix/Makefile +++ b/preload/posix/Makefile @@ -60,23 +60,34 @@ $(OBJS): build-flags .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) +build-needlibdl: + @$(LD) -ldl -o dlcheck.so 2>/dev/null \ + && echo -ldl > $@ || echo > $@ + @rm dlcheck.so # libc's soname depends on the platform (most use libc.so.6, but for example # ia64 and alpha use libc.so.6.1), so find which one to use at build-time -LIBC_SONAME = $(shell ld -o libccheck.so -lc -shared && \ - ldd libccheck.so | grep libc.so | awk '{ print $$1 }'; rm -f libccheck.so) - -build-env.h: build-env.h.in +build-libcsoname: + @$(CC) -x c /dev/null -lc -shared -o build-libccheck.so + @ldd build-libccheck.so | grep libc.so | awk '{ print $$1 }' > $@ + @rm build-libccheck.so + @test "`cat $@`" != "" || \ + (echo "Error finding soname, please report"; rm $@; exit 1) + +build-env.h: build-env.h.in build-libcsoname @echo " GEN $@" - $(Q) sed "s+@@LIBC_SONAME@@+$(LIBC_SONAME)+g" build-env.h.in > build-env.h + $(Q) sed "s+@@LIBC_SONAME@@+`cat build-libcsoname`+g" build-env.h.in \ + > build-env.h -fiu_posix_preload.so: build-flags build-env.h $(OBJS) - $(NICE_CC) $(ALL_CFLAGS) -shared -fPIC $(OBJS) -lfiu $(NEED_LIBDL) \ + +fiu_posix_preload.so: build-flags build-env.h build-needlibdl $(OBJS) + $(NICE_CC) $(ALL_CFLAGS) -shared -fPIC $(OBJS) \ + -lfiu `cat build-needlibdl` \ -o fiu_posix_preload.so + # this should only be needed when building the function list and not the # preload library %.mod.fl: %.mod @@ -95,7 +106,8 @@ uninstall: $(RM) $(PREFIX)/lib/fiu_posix_preload.so clean: - rm -f $(OBJS) $(GEN_OBJS:.o=.c) $(GEN_FL) build-flags build-env.h + rm -f $(OBJS) $(GEN_OBJS:.o=.c) $(GEN_FL) + rm -f build-flags build-env.h build-libcsoname build-needlibdl rm -f function_list fiu_posix_preload.so rm -f *.bb *.bbg *.da *.gcov *.gcda *.gcno gmon.out diff --git a/preload/run/Makefile b/preload/run/Makefile index bd4fca3..72d3c4c 100644 --- a/preload/run/Makefile +++ b/preload/run/Makefile @@ -49,14 +49,20 @@ $(OBJS): build-flags .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) +build-needlibdl: + @$(LD) -ldl -o dlcheck.so 2>/dev/null \ + && echo -ldl > $@ || echo > $@ + @rm dlcheck.so + -fiu_run_preload.so: build-flags $(OBJS) - $(NICE_CC) $(ALL_CFLAGS) -shared -fPIC $(OBJS) -lfiu $(NEED_LIBDL) \ +fiu_run_preload.so: build-flags build-needlibdl $(OBJS) + $(NICE_CC) $(ALL_CFLAGS) -shared -fPIC $(OBJS) \ + -lfiu `cat build-needlibdl` \ -o fiu_run_preload.so + fiu-run: build-flags fiu-run.in cat fiu-run.in | sed "s+@@PLIBPATH@@+$(PLIBPATH)+g" > fiu-run chmod +x fiu-run