diff --git a/.gitignore b/.gitignore index 54de19e3e9409e22545c6f004cd36c36bd7ac56b..a594f86d0f1d0e1b70136432cce3baea458aa97d 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,5 @@ elf-dump print-libstubs TAGS tags +shim/lib*.so.map +shim/lib*.so.symbols diff --git a/Makefile.am b/Makefile.am index dbbfe01e60ac2bb53ca619da08a43ef45c524ad9..1e5688c1be05c863fb5f7cb630304832e655c062 100644 --- a/Makefile.am +++ b/Makefile.am @@ -41,17 +41,18 @@ libcapsule_la_LDFLAGS = -lelf libz_la_SOURCES = shim/libz.so.c libz_la_LDFLAGS = -lcapsule -version-info 1:1:0 \ - -Wl,--version-script=shim/libz.so.c.map + -Wl,--version-script=shim/libz.so.map libGL_la_SOURCES = shim/libGL.so.c libGL_la_LDFLAGS = -lcapsule -version-info 1:1:0 shims = z GL shim_srcs = $(foreach l,$(shims),shim/lib$l.so.c) -shim_files = $(foreach y,map symbols,$(foreach x,$(shim_srcs),$x.$y)) +shim_base = $(basename $(shim_srcs)) +shim_files = $(foreach y,map symbols,$(foreach x,$(shim_base),$x.$y)) GENSTUB_V1 = -GENSTUB_V0 = @echo " GENSTUB " $@.excluded $@.shared $@; +GENSTUB_V0 = @echo " GENSTUB " $(subst $(word 1, $(basename $(filter shim/lib%,$^))),,$(filter shim/lib%,$^)) : $@; GENSTUB = $(GENSTUB_V$(V)) CLEANFILES = $(shim_files) $(shim_srcs) @@ -59,7 +60,9 @@ BUILT_SOURCES = $(shim_srcs) include disabled.mk -shim/lib%.so.c: generate-stublib.sh print-libstubs capsule-shim.h shim/lib%.so.c.excluded shim/lib%.so.c.shared +# explicitly depend on the generators and .excluded and .shared metafiles +# depend on the .dlopen file IFF it exists +shim/lib%.so.c: generate-stublib.sh print-libstubs capsule-shim.h shim/lib%.so.c.* $(GENSTUB)$(top_srcdir)/$< $$(basename $@ .c) $@.excluded $@.shared $@ debug: diff --git a/generate-stublib.sh b/generate-stublib.sh index 490fb668627f6bd7b0d44950e0c1c8ccbce4ce07..e04637ec616141e10d9b86eb65551d4c7db0637f 100755 --- a/generate-stublib.sh +++ b/generate-stublib.sh @@ -28,8 +28,10 @@ proxied_dso=$1; shift; proxy_excluded=$1; shift; proxy_extra=$1; shift; proxy_src=$1; shift; -echo -n > $proxy_src.symbols; -echo -n > $proxy_src.map; +symbol_file=${proxy_src%.c}.symbols; +map_file=${proxy_src%.c}.map; +echo -n > $symbol_file; +echo -n > $map_file; exec >& $proxy_src; @@ -38,7 +40,7 @@ cat $top/capsule-shim.h; for pt in $proxied_dso $(cat $proxy_extra); do $top/print-libstubs $pt; -done > $proxy_src.symbols; +done > $symbol_file; while read symbol version dependency; do @@ -52,7 +54,7 @@ do echo "UNVERSIONED_STUB( $symbol );"; ;; esac; -done < $proxy_src.symbols; +done < $symbol_file; cat - <<EOF static Lmid_t symbol_ns; @@ -97,7 +99,7 @@ static void __attribute__ ((constructor)) _capsule_init (void) { EOF -while read sym x; do echo " { \"$sym\" },"; done < $proxy_src.symbols; +while read sym x; do echo " { \"$sym\" },"; done < $symbol_file; cat - <<EOF { NULL } @@ -133,7 +135,7 @@ cat - <<EOF } EOF -exec >& $proxy_src.map; +exec >& $map_file; for node in ${!NODE[@]}; do