diff options
author | midipix <writeonce@midipix.org> | 2016-04-17 17:16:40 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-04-17 17:35:43 -0400 |
commit | 9112ac22c80fd3f53262be2da59de35534cdac2c (patch) | |
tree | 009e2e9dd2ed52634dc4a4fddfb5ae0e9cf0a9e9 /src/logic/slbt_exec_link.c | |
parent | fbb80bbae0922694102e7afb4358d46da28889d2 (diff) | |
download | slibtool-9112ac22c80fd3f53262be2da59de35534cdac2c.tar.bz2 slibtool-9112ac22c80fd3f53262be2da59de35534cdac2c.tar.xz |
link mode: PE support: added implib generation.
Diffstat (limited to 'src/logic/slbt_exec_link.c')
-rw-r--r-- | src/logic/slbt_exec_link.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c index d205623..1d7b6a5 100644 --- a/src/logic/slbt_exec_link.c +++ b/src/logic/slbt_exec_link.c @@ -406,6 +406,46 @@ static int slbt_exec_link_create_dep_file( return 0; } +static int slbt_exec_link_create_import_library( + const struct slbt_driver_ctx * dctx, + struct slbt_exec_ctx * ectx, + char * impfilename, + char * deffilename, + char * soname) +{ + char * dlltool[8]; + char program[PATH_MAX]; + + /* dlltool argv */ + if ((size_t)snprintf(program,sizeof(program),"%s", + dctx->cctx->host.dlltool) >= sizeof(program)) + return -1; + + dlltool[0] = program; + dlltool[1] = "-l"; + dlltool[2] = impfilename; + dlltool[3] = "-d"; + dlltool[4] = deffilename; + dlltool[5] = "-D"; + dlltool[6] = soname; + dlltool[7] = 0; + + /* alternate argument vector */ + ectx->argv = dlltool; + ectx->program = program; + + /* step output */ + if (!(dctx->cctx->drvflags & SLBT_DRIVER_SILENT)) + if (slbt_output_link(dctx,ectx)) + return -1; + + /* dlltool spawn */ + if ((slbt_spawn(ectx,true) < 0) || ectx->exitcode) + return -1; + + return 0; +} + static int slbt_exec_link_create_archive( const struct slbt_driver_ctx * dctx, struct slbt_exec_ctx * ectx, @@ -769,6 +809,7 @@ int slbt_exec_link( char * dot; FILE * fout; struct slbt_exec_ctx * actx; + char soname[PATH_MAX]; /* context */ if (ectx) @@ -836,6 +877,51 @@ int slbt_exec_link( return -1; } } + + /* PE import libraries */ + if (dctx->cctx->drvflags & SLBT_DRIVER_IMAGE_PE) { + /* libfoo.lib.a */ + if ((size_t)snprintf(soname,sizeof(soname),"%s%s%s.%d", + dctx->cctx->settings.dsoprefix, + dctx->cctx->libname, + dctx->cctx->settings.dsosuffix, + dctx->cctx->verinfo.major) + >= sizeof(soname)) + return -1; + + if (slbt_exec_link_create_import_library( + dctx,ectx, + ectx->dimpfilename, + ectx->deffilename, + soname)) + return -1; + + /* libfoo.x.lib.a */ + if (slbt_exec_link_create_import_library( + dctx,ectx, + ectx->pimpfilename, + ectx->deffilename, + soname)) + return -1; + + /* libfoo.x.y.z.lib.a */ + if ((size_t)snprintf(soname,sizeof(soname),"%s%s%s.%d.%d.%d", + dctx->cctx->settings.dsoprefix, + dctx->cctx->libname, + dctx->cctx->settings.dsosuffix, + dctx->cctx->verinfo.major, + dctx->cctx->verinfo.minor, + dctx->cctx->verinfo.revision) + >= sizeof(soname)) + return -1; + + if (slbt_exec_link_create_import_library( + dctx,ectx, + ectx->vimpfilename, + ectx->deffilename, + soname)) + return -1; + } } /* executable */ |