diff options
author | midipix <writeonce@midipix.org> | 2018-07-11 06:18:35 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2018-07-11 02:30:33 -0400 |
commit | 11e2771a23a1f20df8d6a371c3c889b174609576 (patch) | |
tree | 2b7b57e6f6f24b1c3fa104db51b90c92794ad8fd | |
parent | 46aa6f554c0f2ef1affa5ae292fffec6907ff4b3 (diff) | |
download | slibtool-11e2771a23a1f20df8d6a371c3c889b174609576.tar.bz2 slibtool-11e2771a23a1f20df8d6a371c3c889b174609576.tar.xz |
compile & link modes: accommodate conceptually challenged, PICky targets.
-rw-r--r-- | include/slibtool/slibtool.h | 1 | ||||
-rw-r--r-- | src/driver/slbt_driver_ctx.c | 44 | ||||
-rw-r--r-- | src/logic/slbt_exec_compile.c | 16 | ||||
-rw-r--r-- | src/logic/slbt_exec_link.c | 4 |
4 files changed, 34 insertions, 31 deletions
diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h index 2db22b9..e413602 100644 --- a/include/slibtool/slibtool.h +++ b/include/slibtool/slibtool.h @@ -215,6 +215,7 @@ struct slbt_flavor_settings { const char * impprefix; const char * impsuffix; const char * ldpathenv; + char * picswitch; }; struct slbt_common_ctx { diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index 8a1b0ec..37e10f8 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -29,15 +29,15 @@ static const struct slbt_source_version slbt_src_version = { }; /* flavor settings */ -#define SLBT_FLAVOR_SETTINGS(flavor,bfmt,arp,ars,dsop,dsos,exep,exes,impp,imps,ldenv) \ +#define SLBT_FLAVOR_SETTINGS(flavor,bfmt,pic,arp,ars,dsop,dsos,exep,exes,impp,imps,ldenv) \ static const struct slbt_flavor_settings flavor = { \ - bfmt,arp,ars,dsop,dsos,exep,exes,impp,imps,ldenv} + bfmt,arp,ars,dsop,dsos,exep,exes,impp,imps,ldenv,pic} -SLBT_FLAVOR_SETTINGS(host_flavor_default, "elf", "lib",".a", "lib",".so", "","", "", "", "LD_LIBRARY_PATH"); -SLBT_FLAVOR_SETTINGS(host_flavor_midipix, "pe", "lib",".a", "lib",".so", "","", "lib",".lib.a", "PATH"); -SLBT_FLAVOR_SETTINGS(host_flavor_mingw, "pe", "lib",".a", "lib",".dll", "",".exe", "lib",".dll.a", "PATH"); -SLBT_FLAVOR_SETTINGS(host_flavor_cygwin, "pe", "lib",".a", "lib",".dll", "",".exe", "lib",".dll.a", "PATH"); -SLBT_FLAVOR_SETTINGS(host_flavor_darwin, "macho","lib",".a", "lib",".dylib", "","", "", "", "DYLD_LIBRARY_PATH"); +SLBT_FLAVOR_SETTINGS(host_flavor_default, "elf", "-fPIC","lib",".a", "lib",".so", "","", "", "", "LD_LIBRARY_PATH"); +SLBT_FLAVOR_SETTINGS(host_flavor_midipix, "pe", "-fPIC","lib",".a", "lib",".so", "","", "lib",".lib.a", "PATH"); +SLBT_FLAVOR_SETTINGS(host_flavor_mingw, "pe", 0, "lib",".a", "lib",".dll", "",".exe", "lib",".dll.a", "PATH"); +SLBT_FLAVOR_SETTINGS(host_flavor_cygwin, "pe", 0, "lib",".a", "lib",".dll", "",".exe", "lib",".dll.a", "PATH"); +SLBT_FLAVOR_SETTINGS(host_flavor_darwin, "macho","-fPIC","lib",".a", "lib",".dylib", "","", "", "", "DYLD_LIBRARY_PATH"); /* annotation strings */ @@ -1245,25 +1245,21 @@ int slbt_get_driver_ctx( ctx->cctx.cargv = sargv.cargv; /* host params */ - if (cctx.mode == SLBT_MODE_COMPILE) { - (void)0; - - } else { - if (slbt_init_host_params( - &ctx->ctx, - &ctx->cctx, - &ctx->host, - &ctx->cctx.host, - &ctx->cctx.cfgmeta)) { - slbt_free_driver_ctx(&ctx->ctx); - return -1; - } - - slbt_init_flavor_settings( - &ctx->cctx,0, - &ctx->cctx.settings); + if (slbt_init_host_params( + &ctx->ctx, + &ctx->cctx, + &ctx->host, + &ctx->cctx.host, + &ctx->cctx.cfgmeta)) { + slbt_free_driver_ctx(&ctx->ctx); + return -1; } + /* flavor settings */ + slbt_init_flavor_settings( + &ctx->cctx,0, + &ctx->cctx.settings); + /* ldpath */ if (slbt_init_ldrpath(&ctx->cctx,&ctx->cctx.host)) { slbt_free_driver_ctx(&ctx->ctx); diff --git a/src/logic/slbt_exec_compile.c b/src/logic/slbt_exec_compile.c index 9e4e7a1..f3d3b48 100644 --- a/src/logic/slbt_exec_compile.c +++ b/src/logic/slbt_exec_compile.c @@ -66,10 +66,12 @@ int slbt_exec_compile( /* shared library object */ if (dctx->cctx->drvflags & SLBT_DRIVER_SHARED) { - if (!(dctx->cctx->drvflags & SLBT_DRIVER_ANTI_PIC)) { + if (!(dctx->cctx->drvflags & SLBT_DRIVER_ANTI_PIC)) *ectx->dpic = "-DPIC"; - *ectx->fpic = "-fPIC"; - } + + if (!(dctx->cctx->drvflags & SLBT_DRIVER_ANTI_PIC)) + if (dctx->cctx->settings.picswitch) + *ectx->fpic = dctx->cctx->settings.picswitch; *ectx->lout[0] = "-o"; *ectx->lout[1] = ectx->lobjname; @@ -91,10 +93,12 @@ int slbt_exec_compile( if (dctx->cctx->drvflags & SLBT_DRIVER_STATIC) { slbt_reset_placeholders(ectx); - if (dctx->cctx->drvflags & SLBT_DRIVER_PRO_PIC) { + if (dctx->cctx->drvflags & SLBT_DRIVER_PRO_PIC) *ectx->dpic = "-DPIC"; - *ectx->fpic = "-fPIC"; - } + + if (dctx->cctx->drvflags & SLBT_DRIVER_PRO_PIC) + if (dctx->cctx->settings.picswitch) + *ectx->fpic = dctx->cctx->settings.picswitch; *ectx->lout[0] = "-o"; *ectx->lout[1] = ectx->aobjname; diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c index 4f422d2..a2501b9 100644 --- a/src/logic/slbt_exec_link.c +++ b/src/logic/slbt_exec_link.c @@ -1221,9 +1221,11 @@ static int slbt_exec_link_create_library( /* shared/static */ if (dctx->cctx->drvflags & SLBT_DRIVER_ALL_STATIC) { *ectx->dpic = "-static"; + } else if (dctx->cctx->settings.picswitch) { + *ectx->dpic = "-shared"; + *ectx->fpic = dctx->cctx->settings.picswitch; } else { *ectx->dpic = "-shared"; - *ectx->fpic = "-fPIC"; } /* output */ |