summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-04-20 21:43:20 -0400
committermidipix <writeonce@midipix.org>2016-04-21 16:39:56 -0400
commit372423a58ff43384ac090c2b572a877c3a0a20a9 (patch)
tree599210f3601e83de26a2c6667a241aa2277fdc97 /src
parentf7645c9729a4776529a40bef24a11e3bcd921508 (diff)
downloadslibtool-372423a58ff43384ac090c2b572a877c3a0a20a9.tar.bz2
slibtool-372423a58ff43384ac090c2b572a877c3a0a20a9.tar.xz
link mode: added -all-static support.
Diffstat (limited to 'src')
-rw-r--r--src/internal/slibtool_symlink_impl.c5
-rw-r--r--src/logic/slbt_exec_link.c43
2 files changed, 41 insertions, 7 deletions
diff --git a/src/internal/slibtool_symlink_impl.c b/src/internal/slibtool_symlink_impl.c
index db72feb..f1af5d4 100644
--- a/src/internal/slibtool_symlink_impl.c
+++ b/src/internal/slibtool_symlink_impl.c
@@ -27,7 +27,10 @@ int slbt_create_symlink(
char atarget[PATH_MAX];
/* atarget */
- if ((slash = strrchr(target,'/')))
+ if ((dctx->cctx->drvflags & SLBT_DRIVER_ALL_STATIC)
+ && !strcmp(target,"/dev/null"))
+ slash = target;
+ else if ((slash = strrchr(target,'/')))
slash++;
else
slash = target;
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index eb72dec..141229d 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -637,9 +637,13 @@ static int slbt_exec_link_create_library(
*ectx->symfile = symfile;
}
- /* shared object */
- *ectx->dpic = "-shared";
- *ectx->fpic = "-fPIC";
+ /* shared/static */
+ if (dctx->cctx->drvflags & SLBT_DRIVER_ALL_STATIC) {
+ *ectx->dpic = "-static";
+ } else {
+ *ectx->dpic = "-shared";
+ *ectx->fpic = "-fPIC";
+ }
/* output */
if (dctx->cctx->drvflags & SLBT_DRIVER_AVOID_VERSION) {
@@ -697,6 +701,7 @@ static int slbt_exec_link_create_executable(
char wrapper[PATH_MAX];
char wraplnk[PATH_MAX];
bool fabspath;
+ bool fpic;
struct slbt_deps_meta depsmeta = {0};
/* initial state */
@@ -705,9 +710,12 @@ static int slbt_exec_link_create_executable(
/* placeholders */
slbt_reset_placeholders(ectx);
+ /* fpic */
+ fpic = !(dctx->cctx->drvflags & SLBT_DRIVER_ALL_STATIC);
+
/* input argument adjustment */
for (parg=ectx->cargv; *parg; parg++)
- slbt_adjust_input_argument(*parg,".lo",".o",true);
+ slbt_adjust_input_argument(*parg,".lo",".o",fpic);
/* linker argument adjustment */
for (parg=ectx->cargv; *parg; parg++)
@@ -856,6 +864,8 @@ int slbt_exec_link(
char * dot;
FILE * fout;
struct slbt_exec_ctx * actx;
+ bool fpic;
+ bool fstaticonly;
char soname[PATH_MAX];
/* context */
@@ -887,18 +897,39 @@ int slbt_exec_link(
return -1;
}
+ /* fpic, fstaticonly */
+ if (dctx->cctx->drvflags & SLBT_DRIVER_ALL_STATIC) {
+ fstaticonly = true;
+ fpic = false;
+ } else if (dctx->cctx->drvflags & SLBT_DRIVER_SHARED) {
+ fstaticonly = false;
+ fpic = true;
+ } else {
+ fstaticonly = false;
+ fpic = false;
+ }
+
/* pic libfoo.a */
if (dot && !strcmp(dot,".la"))
if (slbt_exec_link_create_archive(
dctx,ectx,
ectx->arfilename,
- dctx->cctx->drvflags & SLBT_DRIVER_SHARED)) {
+ fpic)) {
slbt_free_exec_ctx(actx);
return -1;
}
+ /* -all-static library */
+ if (fstaticonly && dctx->cctx->libname)
+ if (slbt_create_symlink(
+ dctx,ectx,
+ "/dev/null",
+ ectx->dsofilename,
+ false))
+ return -1;
+
/* dynamic library */
- if (dot && !strcmp(dot,".la") && dctx->cctx->rpath) {
+ if (dot && !strcmp(dot,".la") && dctx->cctx->rpath && !fstaticonly) {
/* linking: libfoo.so.x.y.z */
if (slbt_exec_link_create_library(
dctx,ectx,