diff options
-rw-r--r-- | aux/sltdl.h.in | 9 | ||||
-rw-r--r-- | aux/sltdl.mk.in | 26 | ||||
-rw-r--r-- | include/slibtool/slibtool.h | 2 | ||||
-rw-r--r-- | project/extras.mk | 2 | ||||
-rw-r--r-- | src/internal/slibtool_driver_impl.h | 4 | ||||
-rw-r--r-- | src/logic/slbt_exec_stoolie.c | 143 | ||||
-rw-r--r-- | src/skin/slbt_skin_stoolie.c | 6 | ||||
-rw-r--r-- | src/stoolie/slbt_stoolie_ctx.c | 62 |
8 files changed, 250 insertions, 4 deletions
diff --git a/aux/sltdl.h.in b/aux/sltdl.h.in new file mode 100644 index 0000000..100ea0e --- /dev/null +++ b/aux/sltdl.h.in @@ -0,0 +1,9 @@ +/****************************************************************/ +/* slibtoolize: always use the system-installed sltdl library. */ +/****************************************************************/ + +#include <sltdl/sltdl.h> + +#ifndef LTDL_SET_PRELOADED_SYMBOLS +#define LTDL_SET_PRELOADED_SYMBOLS() +#endif diff --git a/aux/sltdl.mk.in b/aux/sltdl.mk.in new file mode 100644 index 0000000..4e77f28 --- /dev/null +++ b/aux/sltdl.mk.in @@ -0,0 +1,26 @@ +# a stub Makefile for the build's libltdl (or LT_CONFIG_LTDL_DIR) directory. +# copied from (or symlinked to) the installed sltdl.mk.in by slibtoolize. + +all: +check: +clean: +cscope: +cscopelist: +ctags: +distcheck: +distclean: +distcleancheck: +distdir: +distuninstallcheck: +dvi: +html: +info: +install: +installcheck: +installdirs: +mostlyclean: +pdf: +ps: +tags: +uninstall: + @true diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h index 0642e9c..ce10d30 100644 --- a/include/slibtool/slibtool.h +++ b/include/slibtool/slibtool.h @@ -94,6 +94,7 @@ extern "C" { #define SLBT_DRIVER_STOOLIE_COPY SLBT_DRIVER_XFLAG(0x01000000) #define SLBT_DRIVER_STOOLIE_FORCE SLBT_DRIVER_XFLAG(0x02000000) #define SLBT_DRIVER_STOOLIE_INSTALL SLBT_DRIVER_XFLAG(0x04000000) +#define SLBT_DRIVER_STOOLIE_LTDL SLBT_DRIVER_XFLAG(0x08000000) #define SLBT_DRIVER_DLOPEN_SELF SLBT_DRIVER_XFLAG(0x10000000) #define SLBT_DRIVER_DLOPEN_FORCE SLBT_DRIVER_XFLAG(0x20000000) @@ -408,6 +409,7 @@ struct slbt_stoolie_ctx { const struct slbt_txtfile_ctx * makam; const char * const * auxarg; const char * const * m4arg; + const char * const * ltdldir; }; /* raw input api */ diff --git a/project/extras.mk b/project/extras.mk index 1a7c872..674da1e 100644 --- a/project/extras.mk +++ b/project/extras.mk @@ -111,5 +111,7 @@ install-slibtoolize: cp -p $(SOURCE_DIR)/aux/ltmain.sh $(DESTDIR)$(DATADIR)/$(PACKAGE) cp -p $(SOURCE_DIR)/aux/slibtool.sh $(DESTDIR)$(DATADIR)/$(PACKAGE) cp -p $(SOURCE_DIR)/aux/ar-lib $(DESTDIR)$(DATADIR)/$(PACKAGE) + cp -p $(SOURCE_DIR)/aux/sltdl.h.in $(DESTDIR)$(DATADIR)/$(PACKAGE) + cp -p $(SOURCE_DIR)/aux/sltdl.mk.in $(DESTDIR)$(DATADIR)/$(PACKAGE) .PHONY: install-slibtoolize diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index 26a9095..6d8a027 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -182,6 +182,7 @@ struct slbt_driver_ctx_impl { const struct slbt_archive_ctx * arctx; const char * arpath; + const char * ltdlarg; char * libname; char * dargs; char ** dargv; @@ -256,11 +257,14 @@ struct slbt_stoolie_ctx_impl { int fdtgt; int fdaux; int fdm4; + int fdltdl; const char * auxarg; char * auxbuf; const char * m4arg; char * m4buf; char ** m4argv; + const char * ltdldir; + char * ltdlbuf; struct slbt_txtfile_ctx * acinc; struct slbt_txtfile_ctx * cfgac; struct slbt_txtfile_ctx * makam; diff --git a/src/logic/slbt_exec_stoolie.c b/src/logic/slbt_exec_stoolie.c index d8cd9c0..0a7c8d1 100644 --- a/src/logic/slbt_exec_stoolie.c +++ b/src/logic/slbt_exec_stoolie.c @@ -84,15 +84,25 @@ static int slbt_exec_stoolie_perform_actions( { struct slbt_stoolie_ctx_impl * ictx; struct stat st; + char m4dir [PATH_MAX]; char auxdir[PATH_MAX]; + char slibm4[PATH_MAX]; char sltdl [PATH_MAX]; char m4tag [PATH_MAX]; char ltmain[PATH_MAX]; char arlib [PATH_MAX]; + + char sltdlh[PATH_MAX]; + char mkfile[PATH_MAX]; + char ltdlfn[PATH_MAX]; + bool fslibm4; bool fltmain; + bool fltdlh; + bool fsltdlh; + bool fmkfile; bool fsysltdl; ictx = slbt_get_stoolie_ictx(stctx); @@ -124,6 +134,18 @@ static int slbt_exec_stoolie_perform_actions( "ar-lib") < 0) return SLBT_BUFFER_ERROR(dctx); + if (slbt_snprintf( + sltdlh,sizeof(sltdlh),"%s/%s", + SLBT_PACKAGE_DATADIR, + "sltdl.h.in") < 0) + return SLBT_BUFFER_ERROR(dctx); + + if (slbt_snprintf( + mkfile,sizeof(mkfile),"%s/%s", + SLBT_PACKAGE_DATADIR, + "sltdl.mk.in") < 0) + return SLBT_BUFFER_ERROR(dctx); + /* --force? */ if (dctx->cctx->drvflags & SLBT_DRIVER_STOOLIE_FORCE) { if (ictx->fdm4 >= 0) @@ -138,6 +160,18 @@ static int slbt_exec_stoolie_perform_actions( if (slbt_exec_stoolie_remove_file(dctx,ictx->fdm4,"sysltdl.tag") < 0) return SLBT_NESTED_ERROR(dctx); + if (ictx->fdltdl >= 0) + if (slbt_exec_stoolie_remove_file(dctx,ictx->fdltdl,"ltdl.h") < 0) + return SLBT_NESTED_ERROR(dctx); + + if (ictx->fdltdl >= 0) + if (slbt_exec_stoolie_remove_file(dctx,ictx->fdltdl,"sltdl.h") < 0) + return SLBT_NESTED_ERROR(dctx); + + if (ictx->fdltdl >= 0) + if (slbt_exec_stoolie_remove_file(dctx,ictx->fdltdl,"Makefile") < 0) + return SLBT_NESTED_ERROR(dctx); + if (slbt_exec_stoolie_remove_file(dctx,ictx->fdaux,"ltmain.sh") < 0) return SLBT_NESTED_ERROR(dctx); @@ -146,6 +180,10 @@ static int slbt_exec_stoolie_perform_actions( fslibm4 = (ictx->fdm4 >= 0); fltmain = true; + + fltdlh = (ictx->fdltdl >= 0); + fsltdlh = fltdlh; + fmkfile = fltdlh; } else { if (ictx->fdm4 < 0) { fslibm4 = false; @@ -169,6 +207,45 @@ static int slbt_exec_stoolie_perform_actions( } else { return SLBT_SYSTEM_ERROR(dctx,"ltmain.sh"); } + + if (ictx->fdltdl < 0) { + fltdlh = false; + + } else if (fstatat(ictx->fdltdl,"ltdl.h",&st,AT_SYMLINK_NOFOLLOW) == 0) { + fltdlh = false; + + } else if (errno == ENOENT) { + fltdlh = true; + + } else { + return SLBT_SYSTEM_ERROR(dctx,"ltdl.h"); + } + + if (ictx->fdltdl < 0) { + fsltdlh = false; + + } else if (fstatat(ictx->fdltdl,"sltdl.h",&st,AT_SYMLINK_NOFOLLOW) == 0) { + fsltdlh = false; + + } else if (errno == ENOENT) { + fsltdlh = true; + + } else { + return SLBT_SYSTEM_ERROR(dctx,"sltdl.h"); + } + + if (ictx->fdltdl < 0) { + fmkfile = false; + + } else if (fstatat(ictx->fdltdl,"Makefile",&st,AT_SYMLINK_NOFOLLOW) == 0) { + fmkfile = false; + + } else if (errno == ENOENT) { + fmkfile = true; + + } else { + return SLBT_SYSTEM_ERROR(dctx,"Makefile"); + } } /* --copy? */ @@ -203,6 +280,37 @@ static int slbt_exec_stoolie_perform_actions( if (slbt_util_copy_file(ectx,arlib,auxdir) < 0) return SLBT_NESTED_ERROR(dctx); } + + /* ltdl.h is always a symlink to the same-dir sltdl.h wrapper */ + if (fltdlh) { + if (slbt_create_symlink_ex( + dctx,ectx, + ictx->fdltdl, + "sltdl.h", + "ltdl.h", + SLBT_SYMLINK_LITERAL) < 0) + return SLBT_NESTED_ERROR(dctx); + } + + if (fsltdlh) { + if (slbt_snprintf( + ltdlfn,sizeof(ltdlfn),"%s/%s", + ictx->ltdldir,"sltdl.h") < 0) + return SLBT_BUFFER_ERROR(dctx); + + if (slbt_util_copy_file(ectx,sltdlh,ltdlfn) < 0) + return SLBT_NESTED_ERROR(dctx); + } + + if (fmkfile) { + if (slbt_snprintf( + ltdlfn,sizeof(ltdlfn),"%s/%s", + ictx->ltdldir,"Makefile") < 0) + return SLBT_BUFFER_ERROR(dctx); + + if (slbt_util_copy_file(ectx,mkfile,ltdlfn) < 0) + return SLBT_NESTED_ERROR(dctx); + } } else { /* default to symlinks */ if (fslibm4) { @@ -249,6 +357,36 @@ static int slbt_exec_stoolie_perform_actions( SLBT_SYMLINK_LITERAL) < 0) return SLBT_NESTED_ERROR(dctx); } + + if (fltdlh) { + if (slbt_create_symlink_ex( + dctx,ectx, + ictx->fdltdl, + "sltdl.h", + "ltdl.h", + SLBT_SYMLINK_LITERAL) < 0) + return SLBT_NESTED_ERROR(dctx); + } + + if (fsltdlh) { + if (slbt_create_symlink_ex( + dctx,ectx, + ictx->fdltdl, + sltdlh, + "sltdl.h", + SLBT_SYMLINK_LITERAL) < 0) + return SLBT_NESTED_ERROR(dctx); + } + + if (fmkfile) { + if (slbt_create_symlink_ex( + dctx,ectx, + ictx->fdltdl, + mkfile, + "Makefile", + SLBT_SYMLINK_LITERAL) < 0) + return SLBT_NESTED_ERROR(dctx); + } } return 0; @@ -361,6 +499,11 @@ int slbt_exec_stoolie(const struct slbt_driver_ctx * dctx) ictx->cctx.drvflags |= SLBT_DRIVER_VERBOSE; break; + case TAG_STLE_LTDL: + ictx->cctx.drvflags |= SLBT_DRIVER_STOOLIE_LTDL; + ictx->ltdlarg = entry->arg; + break; + case TAG_STLE_SYSTEM_LTDL: ictx->cctx.drvflags &= ~(uint64_t)SLBT_DRIVER_PREFER_SLTDL; break; diff --git a/src/skin/slbt_skin_stoolie.c b/src/skin/slbt_skin_stoolie.c index 39117c5..b648701 100644 --- a/src/skin/slbt_skin_stoolie.c +++ b/src/skin/slbt_skin_stoolie.c @@ -49,10 +49,8 @@ const slbt_hidden struct argv_option slbt_stoolie_options[] = { "suppress all warning messages (or not)."}, {"ltdl", 0,TAG_STLE_LTDL,ARGV_OPTARG_OPTIONAL,0,0,"<dir>", - "install [s]ltdl sources to %s; this option " - "provided is provided for the purpose of backward " - "compatibility, and is currently a no-op, thereby " - "deferring -lltdl to the system installed library."}, + "install the shim [s]ltdl sources to %s; otherwise " + "to 'libltdl' if no directory had been specified."}, {"system-ltdl",0,TAG_STLE_SYSTEM_LTDL,ARGV_OPTARG_NONE,0,0,0, "Create the empty tag file (or symlink) sysltdl.tag; " diff --git a/src/stoolie/slbt_stoolie_ctx.c b/src/stoolie/slbt_stoolie_ctx.c index 7899b3c..cb30846 100644 --- a/src/stoolie/slbt_stoolie_ctx.c +++ b/src/stoolie/slbt_stoolie_ctx.c @@ -10,6 +10,7 @@ #include <stdint.h> #include <stddef.h> #include <stdlib.h> +#include <stdbool.h> #include <string.h> #include <sys/stat.h> @@ -43,12 +44,16 @@ static int slbt_st_free_stoolie_ctx_impl( if (ctx->fdm4 >= 0) close(ctx->fdm4); + if (ctx->fdltdl >= 0) + close(ctx->fdltdl); + for (parg=ctx->m4argv; parg && *parg; parg++) free(*parg); free(ctx->m4buf); free(ctx->m4argv); free(ctx->auxbuf); + free(ctx->ltdlbuf); free(ctx->pathbuf); slbt_lib_free_txtfile_ctx(ctx->acinc); @@ -71,6 +76,8 @@ int slbt_st_get_stoolie_ctx( int fdcwd; int fdtgt; int fdsrc; + int fltdl; + const char * ltdlarg; const char ** pline; char ** margv; const char * mark; @@ -97,6 +104,7 @@ int slbt_st_get_stoolie_ctx( ctx->fdtgt = fdtgt; ctx->fdaux = (-1); ctx->fdm4 = (-1); + ctx->fdltdl= (-1); /* target directory real path */ if (!(ctx->pathbuf = strdup(pathbuf))) @@ -248,6 +256,46 @@ int slbt_st_get_stoolie_ctx( } } + /* ltdl dir */ + fltdl = (dctx->cctx->drvflags & SLBT_DRIVER_STOOLIE_LTDL) ? true : false; + + if (!fltdl && ctx->cfgac) + for (pline=ctx->cfgac->txtlinev; !fltdl && *pline; pline++) + if ((fltdl = !strncmp(*pline,"LTDL_INIT",9))) + if (pline[0][9] && (pline[0][9] != '(')) + if (pline[0][9] != ' ') + if (pline[0][9] != '\t') + fltdl = false; + + if (fltdl && ctx->cfgac) { + if (slbt_m4fake_expand_cmdarg( + dctx,ctx->cfgac, + "LT_CONFIG_LTDL_DIR", + &pathbuf) < 0) + return slbt_st_free_stoolie_ctx_impl( + ctx,(-1), + SLBT_NESTED_ERROR(dctx)); + + if (pathbuf[0]) + if (!(ctx->ltdlbuf = strdup(pathbuf))) + return slbt_st_free_stoolie_ctx_impl( + ctx,(-1), + SLBT_NESTED_ERROR(dctx)); + } + + if (fltdl && !ctx->ltdlbuf) + if ((ltdlarg = (slbt_get_driver_ictx(dctx))->ltdlarg)) + if (!(ctx->ltdlbuf = strdup(ltdlarg))) + return slbt_st_free_stoolie_ctx_impl( + ctx,(-1), + SLBT_NESTED_ERROR(dctx)); + + if (fltdl && !ctx->ltdlbuf) + if (!(ctx->ltdlbuf = strdup("libltdl"))) + return slbt_st_free_stoolie_ctx_impl( + ctx,(-1), + SLBT_NESTED_ERROR(dctx)); + /* build-aux directory */ if (!(dpath = ctx->auxbuf)) dpath = slbt_this_dir; @@ -274,10 +322,23 @@ int slbt_st_get_stoolie_ctx( ctx,(-1), SLBT_SYSTEM_ERROR(dctx,dpath)); + /* ltdl directory */ + if ((dpath = fltdl ? ctx->ltdlbuf : 0)) + if ((ctx->fdltdl = openat(fdtgt,dpath,O_DIRECTORY,0)) < 0) + if (errno == ENOENT) + if (!mkdirat(fdtgt,dpath,0755)) + ctx->fdltdl = openat(fdtgt,dpath,O_DIRECTORY,0); + + if (dpath && (ctx->fdltdl < 0)) + return slbt_st_free_stoolie_ctx_impl( + ctx,(-1), + SLBT_SYSTEM_ERROR(dctx,dpath)); + /* all done */ ctx->path = ctx->pathbuf; ctx->auxarg = ctx->auxbuf; ctx->m4arg = ctx->m4buf; + ctx->ltdldir = ctx->ltdlbuf; ctx->zctx.path = &ctx->path; ctx->zctx.acinc = ctx->acinc; @@ -285,6 +346,7 @@ int slbt_st_get_stoolie_ctx( ctx->zctx.makam = ctx->makam; ctx->zctx.auxarg = &ctx->auxarg; ctx->zctx.m4arg = &ctx->m4arg; + ctx->zctx.ltdldir= &ctx->ltdldir; *pctx = &ctx->zctx; return 0; |