From 1b12612023f99ddf8a71bb93c368440c8290adfe Mon Sep 17 00:00:00 2001 From: midipix Date: Mar 31 2024 03:10:25 +0000 Subject: slbt_output_config(): produce a backward compatible output with without lconf. --- diff --git a/src/output/slbt_output_config.c b/src/output/slbt_output_config.c index 5d52e44..0442884 100644 --- a/src/output/slbt_output_config.c +++ b/src/output/slbt_output_config.c @@ -13,8 +13,12 @@ #include "slibtool_dprintf_impl.h" #include "slibtool_errinfo_impl.h" +static const char enable[] = "yes"; +static const char disable[] = "no"; + static const char lconf_begin[] = "# ### BEGIN LIBTOOL CONFIG\n"; static const char lconf_end [] = "# ### END LIBTOOL CONFIG\n"; +static const char lconf_guard[] = "# ### ##################\n"; static int slbt_output_config_lconf( const struct slbt_driver_ctx * dctx, @@ -84,6 +88,89 @@ static int slbt_output_config_lconf( return 0; } +static int slbt_output_config_mkvars(const struct slbt_driver_ctx * dctx) +{ + int fdout; + const char * shared_option; + const char * static_option; + const struct slbt_source_version * verinfo; + const struct slbt_common_ctx * cctx; + + /* init */ + fdout = slbt_driver_fdout(dctx); + + shared_option = (dctx->cctx->drvflags & SLBT_DRIVER_DISABLE_SHARED) + ? disable : enable; + + static_option = (dctx->cctx->drvflags & SLBT_DRIVER_DISABLE_STATIC) + ? disable : enable; + + cctx = dctx->cctx; + + /* header */ + verinfo = slbt_api_source_version(); + + if (slbt_dprintf( + fdout, + "%s\n\n" + "%s\n" + "# %s\n" + "# Generated by %s (slibtool %d.%d.%d)\n" + "# [commit reference: %s]\n\n", + "#!/dev/null", + lconf_begin, + "Backward compatible build configuration", + dctx->program, + verinfo->major,verinfo->minor,verinfo->revision, + verinfo->commit) < 0) + return SLBT_SYSTEM_ERROR(dctx,0); + + /* shared & static build options */ + if (slbt_dprintf(fdout,"# shared libraries?\n" "build_libtool_libs=%s\n\n",shared_option) < 0) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_dprintf(fdout,"# static libraries?\n" "build_old_libs=%s\n\n",static_option) < 0) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_dprintf(fdout,"# host identification\n" "host=%s\n\n",cctx->host.host) < 0) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_dprintf(fdout,"# archiver\n" "AR=\"%s\"\n\n",cctx->host.ar) < 0) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_dprintf(fdout,"# name mangler\n" "NM=\"%s\"\n\n",cctx->host.nm) < 0) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_dprintf(fdout,"# archive librarian\n" "RANLIB=\"%s\"\n\n",cctx->host.ranlib) < 0) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_dprintf(fdout,"# assembler\n" "AS=\"%s\"\n\n",cctx->host.as) < 0) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_dprintf(fdout,"# PE targets: modern import library compiler\n" "MDSO=%s%s%s\n\n", + cctx->host.mdso[0] ? "\"" : "", + cctx->host.mdso[0] ? cctx->host.mdso : "", + cctx->host.mdso[0] ? "\"" : "") < 0) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_dprintf(fdout,"# PE targets: coff import library compiler\n" "DLLTOOL=%s%s%s\n\n", + cctx->host.dlltool[0] ? "\"" : "", + cctx->host.dlltool[0] ? cctx->host.dlltool : "", + cctx->host.dlltool[0] ? "\"" : "") < 0) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_dprintf(fdout,"# PE targets: resource compiler\n" "WINDRES=%s%s%s\n\n", + cctx->host.windres[0] ? "\"" : "", + cctx->host.windres[0] ? cctx->host.windres : "", + cctx->host.windres[0] ? "\"" : "") < 0) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (slbt_dprintf(fdout,"%s%s%s\n",lconf_end,lconf_guard,lconf_guard) < 0) + return SLBT_SYSTEM_ERROR(dctx,0); + + return 0; +} + int slbt_output_config(const struct slbt_driver_ctx * dctx) { struct slbt_driver_ctx_impl * ictx; @@ -96,5 +183,8 @@ int slbt_output_config(const struct slbt_driver_ctx * dctx) return slbt_output_config_lconf( dctx,lconf); + if (ictx->mkvarsctx || true) + return slbt_output_config_mkvars(dctx); + return 0; }