* zzuf.c: retrieve library object name from libtool's .la file so we don't

need to hardcode .so, .sl, .dylib etc. for various platforms.
This commit is contained in:
Sam Hocevar 2008-07-16 09:52:08 +00:00 committed by sam
parent 3c6188a48b
commit a5dcebc637
3 changed files with 8 additions and 9 deletions

View File

@ -17,6 +17,7 @@
*/
#define VERSION "0.7 (msvc)"
#define SONAME "libzzuf.dll"
#define HAVE_WINDOWS_H 1
#define HAVE_WINSOCK2_H 1
@ -42,4 +43,4 @@ typedef int pid_t;
#define __attribute__(x) /* undefined */
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
#define STDERR_FILENO 2

View File

@ -8,8 +8,9 @@ endif
bin_PROGRAMS = zzuf
zzuf_SOURCES = zzuf.c $(COMMON) $(GETOPT) \
opts.c opts.h md5.c md5.h timer.c timer.h
zzuf_CFLAGS = -DLIBDIR=\"$(libdir)/zzuf\"
zzuf_CFLAGS = -DLIBDIR=\"$(libdir)/zzuf\" -DSONAME=\"$$(grep dlname libzzuf.la | cut -f2 -d"'")\"
zzuf_LDFLAGS = $(MATH_LIBS) $(WINSOCK2_LIBS)
zzuf_DEPENDENCIES = libzzuf.la
pkglib_LTLIBRARIES = libzzuf.la
libzzuf_la_SOURCES = libzzuf.c libzzuf.h $(COMMON) debug.c debug.h sys.c sys.h \

View File

@ -905,16 +905,13 @@ static int run_process(struct opts *opts, int pipes[][2])
char *libpath, *tmp;
int pid, j, len = strlen(opts->oldargv[0]);
# if defined __APPLE__
# define FILENAME "libzzuf.dylib"
# define EXTRAINFO ""
# define PRELOAD "DYLD_INSERT_LIBRARIES"
setenv("DYLD_FORCE_FLAT_NAMESPACE", "1", 1);
# elif defined __osf__
# define FILENAME "libzzuf.so"
# define EXTRAINFO ":DEFAULT"
# define PRELOAD "_RLD_LIST"
# else
# define FILENAME "libzzuf.so"
# define EXTRAINFO ""
# define PRELOAD "LD_PRELOAD"
# endif
@ -977,7 +974,7 @@ static int run_process(struct opts *opts, int pipes[][2])
#if defined HAVE_FORK
/* Make sure there is space for everything we might do. */
libpath = malloc(len + strlen(LIBDIR "/.libs/" FILENAME EXTRAINFO) + 1);
libpath = malloc(len + strlen(LIBDIR "/.libs/" SONAME EXTRAINFO) + 1);
strcpy(libpath, opts->oldargv[0]);
/* If the binary name contains a '/', we look for a libzzuf in the
@ -986,12 +983,12 @@ static int run_process(struct opts *opts, int pipes[][2])
tmp = strrchr(libpath, '/');
if(tmp)
{
strcpy(tmp + 1, ".libs/" FILENAME);
strcpy(tmp + 1, ".libs/" SONAME);
if(access(libpath, R_OK) < 0)
strcpy(libpath, LIBDIR "/" FILENAME);
strcpy(libpath, LIBDIR "/" SONAME);
}
else
strcpy(libpath, LIBDIR "/" FILENAME);
strcpy(libpath, LIBDIR "/" SONAME);
/* OSF1 only */
strcat(libpath, EXTRAINFO);