diff options
-rw-r--r-- | COPYING.SOFORT | 2 | ||||
-rw-r--r-- | README | 13 | ||||
-rwxr-xr-x | aux/slibtool.sh | 37 | ||||
-rw-r--r-- | include/slibtool/slibtool.h | 6 | ||||
-rw-r--r-- | m4/slibtool.m4 | 77 | ||||
-rw-r--r-- | project/common.mk | 1 | ||||
-rw-r--r-- | project/extras.mk | 17 | ||||
-rw-r--r-- | project/headers.mk | 1 | ||||
-rw-r--r-- | sofort/cfgtest/cfgtest.sh | 2 | ||||
-rw-r--r-- | src/driver/slbt_amain.c | 22 | ||||
-rw-r--r-- | src/driver/slbt_driver_ctx.c | 100 | ||||
-rw-r--r-- | src/driver/slbt_split_argv.c | 14 | ||||
-rw-r--r-- | src/host/slbt_host_params.c | 65 | ||||
-rw-r--r-- | src/internal/slibtool_driver_impl.h | 5 | ||||
-rw-r--r-- | src/internal/slibtool_lconf_impl.c | 45 | ||||
-rw-r--r-- | src/internal/slibtool_lconf_impl.h | 3 | ||||
-rw-r--r-- | src/internal/slibtool_mkvars_impl.c | 245 | ||||
-rw-r--r-- | src/internal/slibtool_mkvars_impl.h | 13 | ||||
-rw-r--r-- | src/output/slbt_output_config.c | 90 | ||||
-rw-r--r-- | src/skin/slbt_skin_default.c | 17 | ||||
-rw-r--r-- | src/skin/slbt_skin_stoolie.c | 6 | ||||
-rw-r--r-- | src/stoolie/slbt_stoolie_ctx.c | 2 |
22 files changed, 736 insertions, 47 deletions
diff --git a/COPYING.SOFORT b/COPYING.SOFORT index 75a98e1..1c8a6c1 100644 --- a/COPYING.SOFORT +++ b/COPYING.SOFORT @@ -2,7 +2,7 @@ /* */ /* sofort: portable software project skeleton */ /* */ -/* Copyright (C) 2015--2023 SysDeer Technologies, LLC */ +/* Copyright (C) 2015--2024 SysDeer Technologies, LLC */ /* */ /* sofort provides a build system that can be incorporated into Works */ /* which may or may not be covered by a copyleft license. THE FOLLOWING */ @@ -115,22 +115,9 @@ that should be noted. - no-ops - `-R`, which adds a path to the generated program's run-time search path; this switch is currently not needed, and is accordingly ignored. - - `-export-symbols`, which exports symbols listed in a given file, and - `-export-symbols-regex`, which exports symbols matching a regex; - both are unimplemented because similar functionality has long been - provided by the compiler or toolchain; `gcc` has supported setting ELF - visibility since v4.0, for instance, and PE import library support is - provided by slibtool via the --output-def linker switch and a subsequent - invocation of dlltool. - `-no-install`, which considers the executable wrapper to be optional; this switch is not needed on modern systems, and is accordingly ignored. -- No `libltdl`. - libltdl is nowadays no longer needed; it serves to provide a `dlopen()` - functionality on systems which do not offer it, i.e. HP-UX and BeOS, - however since neither HP-UX nor BeOS is currently supported by slibtool, - there exists no urgent need to provide equivalent functionality. - ## Development Major changes to slibtool should be discussed on [#slibtool] prior to pursuing diff --git a/aux/slibtool.sh b/aux/slibtool.sh new file mode 100755 index 0000000..0bde87d --- /dev/null +++ b/aux/slibtool.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +##################################################################### +## slibtool: a strong libtool implementation, written in C ## +## Copyright (C) 2016--2024 SysDeer Technologies, LLC ## +## Released under the Standard MIT License; see COPYING.SLIBTOOL. ## +##################################################################### + +##################################################################### +## slibtool.sh: a backward compatible slibtool wrapper script ## +## ---------------------------------------------------------- ## +## This script only exists to satisfy build-time requirements in ## +## projects that directly invoke the generated libtool script at ## +## configure time (bad practice to beging with, should never be ## +## necessary in the first place). ## +## ## +## By default, slibtool.sh is _NOT_ copied to a project's build ## +## directory. If found by configure, however (either as a symlink ## +## to the system installed slibtool.sh or as a physical copy of ## +## the above, configure shall create ``libtool'' as a symlink to ## +## this script. ## +##################################################################### + +set -eu + +mb_escaped_arg= +mb_escaped_args= +mb_escaped_space= + +for arg ; do + mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\' + mb_escaped_arg="$mb_escaped_space$mb_escaped_arg" + mb_escaped_args="$mb_escaped_args$mb_escaped_arg" + mb_escaped_space=' ' +done + +eval ${SLIBTOOL:-slibtool} "$mb_escaped_args" diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h index d428e54..f05de74 100644 --- a/include/slibtool/slibtool.h +++ b/include/slibtool/slibtool.h @@ -71,8 +71,11 @@ extern "C" { #define SLBT_DRIVER_IMPLIB_DSOMETA SLBT_DRIVER_XFLAG(0x0002) #define SLBT_DRIVER_EXPORT_DYNAMIC SLBT_DRIVER_XFLAG(0x0010) #define SLBT_DRIVER_STATIC_LIBTOOL_LIBS SLBT_DRIVER_XFLAG(0x0100) + #define SLBT_DRIVER_OUTPUT_MACHINE SLBT_DRIVER_XFLAG(0x1000) #define SLBT_DRIVER_OUTPUT_CONFIG SLBT_DRIVER_XFLAG(0x2000) +#define SLBT_DRIVER_OUTPUT_AUX_DIR SLBT_DRIVER_XFLAG(0x4000) +#define SLBT_DRIVER_OUTPUT_M4_DIR SLBT_DRIVER_XFLAG(0x8000) #define SLBT_DRIVER_MODE_AR SLBT_DRIVER_XFLAG(0x010000) #define SLBT_DRIVER_MODE_AR_CHECK SLBT_DRIVER_XFLAG(0x020000) @@ -125,6 +128,9 @@ enum slbt_custom_error { SLBT_ERR_LCONF_OPEN, SLBT_ERR_LCONF_MAP, SLBT_ERR_LCONF_PARSE, + SLBT_ERR_MKVARS_OPEN, + SLBT_ERR_MKVARS_MAP, + SLBT_ERR_MKVARS_PARSE, SLBT_ERR_AR_FAIL, SLBT_ERR_AR_EMPTY_FILE, SLBT_ERR_AR_INVALID_SIGNATURE, diff --git a/m4/slibtool.m4 b/m4/slibtool.m4 index 29bfb8d..25c37a3 100644 --- a/m4/slibtool.m4 +++ b/m4/slibtool.m4 @@ -175,17 +175,47 @@ AC_BEFORE([$0],[SLIBTOOL_INIT]) # --------------------------------------------------------------------------- slibtool_set_flavor() { + if [[ -z "${SLIBTOOL:-}" ]]; then + SLIBTOOL="${LIBTOOL:-}" + fi + + _slibtool="${SLIBTOOL:-slibtool}" + + if [[ "${_slibtool%/*}" = "${_slibtool}" ]]; then + _slibtool_path= + else + _slibtool_path="${_slibtool%/*}/" + fi + + case "${_slibtool##*/}" in + 'rlibtool') + SLIBTOOL="${_slibtool_path}"'slibtool' + ;; + + 'rclibtool') + SLIBTOOL="${_slibtool_path}"'clibtool' + ;; + + 'rdlibtool') + SLIBTOOL="${_slibtool_path}"'dlibtool' + ;; + + 'rdclibtool') + SLIBTOOL="${_slibtool_path}"'dclibtool' + ;; + esac + case "_${slibtool_enable_shared}_${slibtool_enable_static}" in '_yes_yes') - SLIBTOOL='dlibtool' + SLIBTOOL="${SLIBTOOL:-slibtool}" ;; '_yes_no') - SLIBTOOL='dlibtool-shared' + SLIBTOOL="${SLIBTOOL:-slibtool}-shared" ;; '_no_yes') - SLIBTOOL='dlibtool-static' + SLIBTOOL="${SLIBTOOL:-slibtool}-static" ;; '_no_no') @@ -230,13 +260,6 @@ slibtool_set_flavor() enable_win32_dll=${slibtool_enable_win32_dll} enable_fast_install=${slibtool_enable_fast_install} pic_mode=${slibtool_pic_mode} - - # backward-compatible heuristics support - printf "%s\n%s=%s\n%s=%s\n" \ - '#!/dev/null' \ - 'build_libtool_libs' "${slibtool_enable_shared}" \ - 'build_old_libs' "${slibtool_enable_static}" \ - > libtool } ]) @@ -499,9 +522,11 @@ _SLIBTOOL_ARG_WITH([sysroot],[absolute path to the target's sysroot],[slibtool_s # -------------------- slibtool_set_flavor LIBTOOL='$(SLIBTOOL)' +SLIBTOOL="${SLIBTOOL} \$(SLIBTOOL_FLAGS)" AC_SUBST([LIBTOOL]) AC_SUBST([SLIBTOOL]) +AC_SUBST([SLIBTOOL_FLAGS]) AC_SUBST([SLIBTOOL_SYSROOT]) ]) @@ -534,6 +559,21 @@ AC_PROG_F77 ]) +# produce a backward compatible slibtool.cfg +AC_CONFIG_COMMANDS_PRE( + AC_CONFIG_FILES( + [slibtool.cfg:Makefile], + [rm -f slibtool.cfg || exit 2;] + [_slibtool="${SLIBTOOL:-slibtool}";] + [${_slibtool%% *} --mkvars=Makefile --config > slibtool.cfg])) + +# optionally create libtool as a symlink to slibtool.sh +AC_CONFIG_COMMANDS_PRE( + [if [[ -s slibtool.sh ]]; then + ln -f -s slibtool.sh libtool || exit 2 + fi]) + + # SLIBTOOL_PREREQ(_version_) # -------------------------- AC_DEFUN([SLIBTOOL_PREREQ],[ @@ -552,11 +592,21 @@ AC_PROG_MKDIR_P ]) +# SLIBTOOL_OUTPUT +# --------------- +AC_DEFUN([SLIBTOOL_OUTPUT],[ +_slibtool_cmd="${SLIBTOOL:-slibtool}" +_slibtool_cmd="${_slibtool_cmd%% *}" +_slibtool_aux_dir=$("${_slibtool_cmd}" -print-aux-dir) +cp -p "${_slibtool_aux_dir}/slibtool.sh" 'libtool' +]) + # drop-in replacement # ------------------- AC_DEFUN([LT_INIT], [SLIBTOOL_INIT($@)]) AC_DEFUN([LT_LANG], [SLIBTOOL_LANG($@)]) AC_DEFUN([LT_PREREQ], [SLIBTOOL_PREREQ($@)]) +AC_DEFUN([LT_OUTPUT], [SLIBTOOL_OUTPUT($@)]) AC_DEFUN([AC_PROG_LIBTOOL], [SLIBTOOL_INIT($@)]) AC_DEFUN([AM_PROG_LIBTOOL], [SLIBTOOL_INIT($@)]) @@ -594,3 +644,10 @@ AC_DEFUN([LT_LIB_DLLOAD], [SLIBTOOL_LFLAG_LTDL($@)]) AC_DEFUN([AC_LIBTOOL_DLOPEN],[]) AC_DEFUN([AC_LIBTOOL_WIN32_DLL],[]) AC_DEFUN([AC_DISABLE_FAST_INSTALL],[]) +AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC],[]) + +AC_DEFUN([LT_PATH_AR],[]) +AC_DEFUN([LT_PATH_AS],[]) +AC_DEFUN([LT_PATH_LD],[]) +AC_DEFUN([LT_PATH_NM],[]) +AC_DEFUN([LT_PATH_RANLIB],[]) diff --git a/project/common.mk b/project/common.mk index ace734f..d35b34f 100644 --- a/project/common.mk +++ b/project/common.mk @@ -74,6 +74,7 @@ INTERNAL_SRCS = \ src/internal/$(PACKAGE)_libmeta_impl.c \ src/internal/$(PACKAGE)_m4fake_impl.c \ src/internal/$(PACKAGE)_mapfile_impl.c \ + src/internal/$(PACKAGE)_mkvars_impl.c \ src/internal/$(PACKAGE)_objlist_impl.c \ src/internal/$(PACKAGE)_objmeta_impl.c \ src/internal/$(PACKAGE)_pecoff_impl.c \ diff --git a/project/extras.mk b/project/extras.mk index 804a7cc..ba3ff0f 100644 --- a/project/extras.mk +++ b/project/extras.mk @@ -13,6 +13,7 @@ src/driver/slbt_driver_ctx.lo: version.tag DBGNAME = dlibtool LEGABITS = clibtool +LEGADBGS = dclibtool RAPUNZEL = rlibtool RAPUNCEL = rclibtool RAPUNDEL = rdlibtool @@ -38,6 +39,11 @@ install-app-extras: rm -f bin/$(LEGABITS)-static$(OS_APP_SUFFIX).tmp rm -f bin/$(LEGABITS)-ar$(OS_APP_SUFFIX).tmp + rm -f bin/$(LEGADBGS)$(OS_APP_SUFFIX).tmp + rm -f bin/$(LEGADBGS)-shared$(OS_APP_SUFFIX).tmp + rm -f bin/$(LEGADBGS)-static$(OS_APP_SUFFIX).tmp + rm -f bin/$(LEGADBGS)-ar$(OS_APP_SUFFIX).tmp + rm -f bin/$(RAPUNZEL)$(OS_APP_SUFFIX).tmp rm -f bin/$(RAPUNCEL)$(OS_APP_SUFFIX).tmp rm -f bin/$(RAPUNDEL)$(OS_APP_SUFFIX).tmp @@ -59,6 +65,11 @@ install-app-extras: ln -s ./$(NICKNAME)$(OS_APP_SUFFIX) bin/$(LEGABITS)-static$(OS_APP_SUFFIX).tmp ln -s ./$(NICKNAME)$(OS_APP_SUFFIX) bin/$(LEGABITS)-ar$(OS_APP_SUFFIX).tmp + ln -s ./$(NICKNAME)$(OS_APP_SUFFIX) bin/$(LEGADBGS)$(OS_APP_SUFFIX).tmp + ln -s ./$(NICKNAME)$(OS_APP_SUFFIX) bin/$(LEGADBGS)-shared$(OS_APP_SUFFIX).tmp + ln -s ./$(NICKNAME)$(OS_APP_SUFFIX) bin/$(LEGADBGS)-static$(OS_APP_SUFFIX).tmp + ln -s ./$(NICKNAME)$(OS_APP_SUFFIX) bin/$(LEGADBGS)-ar$(OS_APP_SUFFIX).tmp + ln -s ./$(NICKNAME)$(OS_APP_SUFFIX) bin/$(RAPUNZEL)$(OS_APP_SUFFIX).tmp ln -s ./$(NICKNAME)$(OS_APP_SUFFIX) bin/$(RAPUNCEL)$(OS_APP_SUFFIX).tmp ln -s ./$(NICKNAME)$(OS_APP_SUFFIX) bin/$(RAPUNDEL)$(OS_APP_SUFFIX).tmp @@ -80,6 +91,11 @@ install-app-extras: mv bin/$(LEGABITS)-static$(OS_APP_SUFFIX).tmp $(DESTDIR)$(BINDIR)/$(LEGABITS)-static$(OS_APP_SUFFIX) mv bin/$(LEGABITS)-ar$(OS_APP_SUFFIX).tmp $(DESTDIR)$(BINDIR)/$(LEGABITS)-ar$(OS_APP_SUFFIX) + mv bin/$(LEGADBGS)$(OS_APP_SUFFIX).tmp $(DESTDIR)$(BINDIR)/$(LEGADBGS)$(OS_APP_SUFFIX) + mv bin/$(LEGADBGS)-shared$(OS_APP_SUFFIX).tmp $(DESTDIR)$(BINDIR)/$(LEGADBGS)-shared$(OS_APP_SUFFIX) + mv bin/$(LEGADBGS)-static$(OS_APP_SUFFIX).tmp $(DESTDIR)$(BINDIR)/$(LEGADBGS)-static$(OS_APP_SUFFIX) + mv bin/$(LEGADBGS)-ar$(OS_APP_SUFFIX).tmp $(DESTDIR)$(BINDIR)/$(LEGADBGS)-ar$(OS_APP_SUFFIX) + mv bin/$(RAPUNZEL)$(OS_APP_SUFFIX).tmp $(DESTDIR)$(BINDIR)/$(RAPUNZEL)$(OS_APP_SUFFIX) mv bin/$(RAPUNCEL)$(OS_APP_SUFFIX).tmp $(DESTDIR)$(BINDIR)/$(RAPUNCEL)$(OS_APP_SUFFIX) mv bin/$(RAPUNDEL)$(OS_APP_SUFFIX).tmp $(DESTDIR)$(BINDIR)/$(RAPUNDEL)$(OS_APP_SUFFIX) @@ -92,5 +108,6 @@ install-slibtoolize: cp -p $(SOURCE_DIR)/m4/slibtool.m4 $(DESTDIR)$(DATADIR)/$(PACKAGE) cp -p $(SOURCE_DIR)/aux/ltmain.sh $(DESTDIR)$(DATADIR)/$(PACKAGE) + cp -p $(SOURCE_DIR)/aux/slibtool.sh $(DESTDIR)$(DATADIR)/$(PACKAGE) .PHONY: install-slibtoolize diff --git a/project/headers.mk b/project/headers.mk index 1b77743..56c0a6a 100644 --- a/project/headers.mk +++ b/project/headers.mk @@ -18,6 +18,7 @@ INTERNAL_HEADERS = \ $(PROJECT_DIR)/src/internal/$(PACKAGE)_mapfile_impl.h \ $(PROJECT_DIR)/src/internal/$(PACKAGE)_metafile_impl.h \ $(PROJECT_DIR)/src/internal/$(PACKAGE)_mkdir_impl.h \ + $(PROJECT_DIR)/src/internal/$(PACKAGE)_mkvars_impl.h \ $(PROJECT_DIR)/src/internal/$(PACKAGE)_objlist_impl.h \ $(PROJECT_DIR)/src/internal/$(PACKAGE)_pecoff_impl.h \ $(PROJECT_DIR)/src/internal/$(PACKAGE)_readlink_impl.h \ diff --git a/sofort/cfgtest/cfgtest.sh b/sofort/cfgtest/cfgtest.sh index 8e1db07..7bb27a0 100644 --- a/sofort/cfgtest/cfgtest.sh +++ b/sofort/cfgtest/cfgtest.sh @@ -423,7 +423,7 @@ cfgtest_interface_presence() # init cfgtest_prolog 'interface' "${1}" - cfgtest_code_snippet=$(printf 'void * addr = &%s;\n' "${1}") + cfgtest_code_snippet=$(printf 'void (*addr)() = (void (*)())&%s;\n' "${1}") cfgtest_common_init diff --git a/src/driver/slbt_amain.c b/src/driver/slbt_amain.c index 73d1462..e0f4241 100644 --- a/src/driver/slbt_amain.c +++ b/src/driver/slbt_amain.c @@ -57,6 +57,16 @@ static ssize_t slbt_version(struct slbt_driver_ctx * dctx, int fdout) verclr[5],gitver ? "]" : ""); } +static ssize_t slbt_print_aux_dir(int fdout) +{ + return slbt_dprintf(fdout,"%s\n",SLBT_PACKAGE_DATADIR); +} + +static ssize_t slbt_print_m4_dir(int fdout) +{ + return slbt_dprintf(fdout,"%s\n",SLBT_PACKAGE_DATADIR); +} + static void slbt_perform_driver_actions(struct slbt_driver_ctx * dctx) { if (dctx->cctx->drvflags & SLBT_DRIVER_INFO) @@ -197,6 +207,18 @@ int slbt_main(char ** argv, char ** envp, const struct slbt_fd_ctx * fdctx) ? slbt_exit(dctx,SLBT_ERROR) : slbt_exit(dctx,SLBT_OK); + /* -print-aux-dir must be the first (and only) action */ + if (dctx->cctx->drvflags & SLBT_DRIVER_OUTPUT_AUX_DIR) + return (slbt_print_aux_dir(fdout) < 0) + ? slbt_exit(dctx,SLBT_ERROR) + : slbt_exit(dctx,SLBT_OK); + + /* -print-m4-dir must be the first (and only) action */ + if (dctx->cctx->drvflags & SLBT_DRIVER_OUTPUT_M4_DIR) + return (slbt_print_m4_dir(fdout) < 0) + ? slbt_exit(dctx,SLBT_ERROR) + : slbt_exit(dctx,SLBT_OK); + /* perform all other actions */ slbt_perform_driver_actions(dctx); diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index 85c75d2..76c7c4a 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -22,6 +22,7 @@ #include "slibtool_objlist_impl.h" #include "slibtool_errinfo_impl.h" #include "slibtool_lconf_impl.h" +#include "slibtool_mkvars_impl.h" #include "slibtool_txtline_impl.h" #include "slibtool_stoolie_impl.h" #include "slibtool_ar_impl.h" @@ -32,6 +33,7 @@ extern char ** environ; /* annotation strings */ static const char cfgexplicit[] = "command-line argument"; static const char cfglconf[] = "derived from <libtool>"; +static const char cfgmkvars[] = "derived from <makefile>"; /* package info */ static const struct slbt_source_version slbt_src_version = { @@ -398,6 +400,7 @@ int slbt_lib_get_driver_ctx( struct slbt_obj_list * objlistv; struct slbt_driver_ctx_impl * ctx; struct slbt_common_ctx cctx; + struct slbt_error_info** errinfp; const struct argv_option * optv[SLBT_OPTV_ELEMENTS]; struct argv_meta * meta; struct argv_entry * entry; @@ -407,6 +410,7 @@ int slbt_lib_get_driver_ctx( struct argv_entry * cmdnoshared; const char * program; const char * lconf; + const char * mkvars; uint64_t lflags; size_t ndlopen; struct argv_entry ** dlopenv; @@ -455,6 +459,7 @@ int slbt_lib_get_driver_ctx( return slbt_free_argv_buffer(&sargv,objlistv); lconf = 0; + mkvars = 0; program = argv_program_name(argv[0]); memset(&cctx,0,sizeof(cctx)); @@ -519,6 +524,10 @@ int slbt_lib_get_driver_ctx( lconf = entry->arg; break; + case TAG_MKVARS: + mkvars = entry->arg; + break; + case TAG_MODE: if (!strcmp("clean",entry->arg)) cctx.mode = SLBT_MODE_CLEAN; @@ -600,6 +609,14 @@ int slbt_lib_get_driver_ctx( cctx.drvflags |= SLBT_DRIVER_OUTPUT_MACHINE; break; + case TAG_PRINT_AUX_DIR: + cctx.drvflags |= SLBT_DRIVER_OUTPUT_AUX_DIR; + break; + + case TAG_PRINT_M4_DIR: + cctx.drvflags |= SLBT_DRIVER_OUTPUT_M4_DIR; + break; + case TAG_DEBUG: cctx.drvflags |= SLBT_DRIVER_DEBUG; break; @@ -862,6 +879,14 @@ int slbt_lib_get_driver_ctx( "--disable-static", "--disable-shared"); + if (lconf && mkvars) + return slbt_driver_fail_incompatible_args( + fdctx->fderr, + cctx.drvflags, + meta,program, + "--heuristics=<cfgfile>", + "--mkvars=<makefile>"); + /* -static? */ if (cmdstatic) { cctx.drvflags |= SLBT_DRIVER_STATIC; @@ -930,11 +955,81 @@ int slbt_lib_get_driver_ctx( ctx->cctx.cargv = sargv.cargv; ctx->meta = meta; + /* mkvars */ + if (mkvars) { + if (slbt_get_mkvars_flags(&ctx->ctx,mkvars,&lflags) < 0) + return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); + + if (ctx->cctx.host.host && !cfgmeta_host) + cfgmeta_host = cfgmkvars; + + if (ctx->cctx.host.ar && !cfgmeta_ar) + cfgmeta_ar = cfgmkvars; + + if (ctx->cctx.host.as && !cfgmeta_as) + cfgmeta_as = cfgmkvars; + + if (ctx->cctx.host.nm && !cfgmeta_nm) + cfgmeta_nm = cfgmkvars; + + if (ctx->cctx.host.ranlib && !cfgmeta_ranlib) + cfgmeta_ranlib = cfgmkvars; + + if (ctx->cctx.host.dlltool && !cfgmeta_dlltool) + cfgmeta_dlltool = cfgmkvars; + + if (cmdnoshared) + lflags &= ~(uint64_t)SLBT_DRIVER_DISABLE_STATIC; + + if (cmdnostatic) + if (lflags & SLBT_DRIVER_DISABLE_SHARED) + cctx.drvflags &= ~(uint64_t)SLBT_DRIVER_DISABLE_STATIC; + + cctx.drvflags |= lflags; + + /* -disable-static? */ + if (cctx.drvflags & SLBT_DRIVER_DISABLE_STATIC) + cctx.drvflags &= ~(uint64_t)SLBT_DRIVER_STATIC; + + /* -disable-shared? */ + if (cctx.drvflags & SLBT_DRIVER_DISABLE_SHARED) + cctx.drvflags &= ~(uint64_t)SLBT_DRIVER_SHARED; + + ctx->cctx.drvflags = cctx.drvflags; + } + /* heuristics */ + if (mkvars) + cctx.drvflags &= ~(uint64_t)SLBT_DRIVER_HEURISTICS; + if (cctx.drvflags & SLBT_DRIVER_HEURISTICS) { - if (slbt_get_lconf_flags(&ctx->ctx,lconf,&lflags) < 0) + if (slbt_get_lconf_flags(&ctx->ctx,lconf,&lflags,false) < 0) return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); + } else { + switch (cctx.mode) { + case SLBT_MODE_UNKNOWN: + case SLBT_MODE_STOOLIE: + break; + + case SLBT_MODE_CONFIG: + lconf = mkvars ? 0 : "slibtool.cfg"; + break; + + default: + lconf = "slibtool.cfg"; + break; + } + + if (lconf && (errinfp = ctx->errinfp)) + if (slbt_get_lconf_flags(&ctx->ctx,lconf,&lflags,true) < 0) + for (ctx->errinfp=errinfp; *errinfp; errinfp++) + *errinfp = 0; + + if (ctx->lconfctx) + cctx.drvflags |= SLBT_DRIVER_HEURISTICS; + } + if (cctx.drvflags & SLBT_DRIVER_HEURISTICS) { if (ctx->cctx.host.host && !cfgmeta_host) cfgmeta_host = cfglconf; @@ -1113,6 +1208,9 @@ static void slbt_lib_free_driver_ctx_impl(struct slbt_driver_ctx_alloc * ictx) if (ictx->ctx.lconfctx) slbt_lib_free_txtfile_ctx(ictx->ctx.lconfctx); + if (ictx->ctx.mkvarsctx) + slbt_lib_free_txtfile_ctx(ictx->ctx.mkvarsctx); + for (objlistp=ictx->ctx.objlistv; objlistp->name; objlistp++) { free(objlistp->objv); free(objlistp->addr); diff --git a/src/driver/slbt_split_argv.c b/src/driver/slbt_split_argv.c index 7ad20a3..8fd131a 100644 --- a/src/driver/slbt_split_argv.c +++ b/src/driver/slbt_split_argv.c @@ -59,6 +59,7 @@ slbt_hidden int slbt_split_argv( struct argv_entry * features; struct argv_entry * ccwrap; struct argv_entry * dumpmachine; + struct argv_entry * printdir; struct argv_entry * aropt; struct argv_entry * stoolieopt; const struct argv_option ** popt; @@ -124,7 +125,8 @@ slbt_hidden int slbt_split_argv( } /* missing all of --mode, --help, --version, --info, --config, --dumpmachine, --features, and --finish? */ - mode = help = version = info = config = finish = features = ccwrap = dumpmachine = aropt = stoolieopt = 0; + /* as well as -print-aux-dir and -print-m4-dir? */ + mode = help = version = info = config = finish = features = ccwrap = dumpmachine = printdir = aropt = stoolieopt = 0; for (entry=meta->entries; entry->fopt; entry++) if (entry->tag == TAG_MODE) @@ -145,6 +147,10 @@ slbt_hidden int slbt_split_argv( ccwrap = entry; else if (entry->tag == TAG_DUMPMACHINE) dumpmachine = entry; + else if (entry->tag == TAG_PRINT_AUX_DIR) + printdir = entry; + else if (entry->tag == TAG_PRINT_M4_DIR) + printdir = entry; /* alternate execusion mode? */ if (!altmode && mode && !strcmp(mode->arg,"ar")) @@ -169,7 +175,7 @@ slbt_hidden int slbt_split_argv( return -1; } - if (!mode && !help && !version && !info && !config && !finish && !features && !dumpmachine && !altmode) { + if (!mode && !help && !version && !info && !config && !finish && !features && !dumpmachine && !printdir && !altmode) { slbt_dprintf(fderr, "%s: error: --mode must be specified.\n", program); @@ -177,7 +183,7 @@ slbt_hidden int slbt_split_argv( } /* missing compiler? */ - if (!ctx.unitidx && !help && !info && !config && !version && !finish && !features && !dumpmachine) { + if (!ctx.unitidx && !help && !info && !config && !version && !finish && !features && !dumpmachine && !printdir) { if (!altmode && !aropt && !stoolieopt) { if (flags & SLBT_DRIVER_VERBOSITY_ERRORS) slbt_dprintf(fderr, @@ -339,7 +345,7 @@ slbt_hidden int slbt_split_argv( if (ctx.unitidx) { (void)0; - } else if (help || version || features || info || config || dumpmachine || altmode) { + } else if (help || version || features || info || config || dumpmachine || printdir || altmode) { for (i=0; i<argc; i++) sargv->targv[i] = argv[i]; diff --git a/src/host/slbt_host_params.c b/src/host/slbt_host_params.c index cd9ad87..6191ea5 100644 --- a/src/host/slbt_host_params.c +++ b/src/host/slbt_host_params.c @@ -4,6 +4,7 @@ /* Released under the Standard MIT License; see COPYING.SLIBTOOL. */ /*******************************************************************/ +#include <ctype.h> #include <stdint.h> #include <string.h> #include <unistd.h> @@ -24,6 +25,8 @@ /* annotation strings */ static const char cfgexplicit[] = "command-line argument"; static const char cfghost[] = "derived from <host>"; +static const char cfgar[] = "derived from <ar>"; +static const char cfgranlib[] = "derived from <ranlib>"; static const char cfgtarget[] = "derived from <target>"; static const char cfgcompiler[] = "derived from <compiler>"; static const char cfgnmachine[] = "native (cached in ccenv/host.mk)"; @@ -97,6 +100,7 @@ slbt_hidden int slbt_init_host_params( int arprobe; int arfd; int ecode; + int cint; size_t toollen; char * dash; char * base; @@ -106,6 +110,7 @@ slbt_hidden int slbt_init_host_params( bool fhost = false; bool fcompiler = false; bool fnative = false; + bool fnativear = false; bool fdumpmachine = false; char buf [256]; char hostbuf [256]; @@ -251,6 +256,7 @@ slbt_hidden int slbt_init_host_params( /* toollen */ toollen = fnative ? 0 : strlen(host->host); toollen += strlen("-utility-name"); + toollen += host->ranlib ? strlen(host->ranlib) : 0; /* ar */ if (host->ar) @@ -314,6 +320,7 @@ slbt_hidden int slbt_init_host_params( if (ecode && !strcmp(host->host,SLBT_MACHINE)) { strcpy(drvhost->ar,"ar"); cfgmeta->ar = cfgnative; + fnative = true; } /* fdcwd */ @@ -329,6 +336,13 @@ slbt_hidden int slbt_init_host_params( host->ar = drvhost->ar; } + if (!fnative && !strncmp(host->ar,"ar",2)) { + if (!host->ar[2] || isspace((cint = host->ar[2]))) { + fnative = true; + fnativear = true; + } + } + /* as */ if (host->as) cfgmeta->as = cfgmeta_as ? cfgmeta_as : cfgexplicit; @@ -338,12 +352,25 @@ slbt_hidden int slbt_init_host_params( if (fnative) { strcpy(drvhost->as,"as"); - cfgmeta->as = cfgnative; + cfgmeta->as = fnativear ? cfgar : cfgnative; } else { sprintf(drvhost->as,"%s-as",host->host); cfgmeta->as = cfghost; } + if (host->ranlib && (mark = strrchr(host->ranlib,'/'))) { + if (strcmp(++mark,"ranlib")) + if ((mark = strrchr(mark,'-'))) + if (strcmp(++mark,"ranlib")) + mark = 0; + + if (mark) { + strcpy(drvhost->as,host->ranlib); + strcpy(&drvhost->as[mark-host->ranlib],"as"); + cfgmeta->as = cfgranlib; + } + } + host->as = drvhost->as; } @@ -356,7 +383,7 @@ slbt_hidden int slbt_init_host_params( if (fnative) { strcpy(drvhost->nm,"nm"); - cfgmeta->nm = cfgnative; + cfgmeta->nm = fnativear ? cfgar : cfgnative; } else { sprintf(drvhost->nm,"%s-nm",host->host); cfgmeta->nm = cfghost; @@ -374,7 +401,7 @@ slbt_hidden int slbt_init_host_params( if (fnative) { strcpy(drvhost->ranlib,"ranlib"); - cfgmeta->ranlib = cfgnative; + cfgmeta->ranlib = fnativear ? cfgar : cfgnative; } else { sprintf(drvhost->ranlib,"%s-ranlib",host->host); cfgmeta->ranlib = cfghost; @@ -400,12 +427,25 @@ slbt_hidden int slbt_init_host_params( if (fnative) { strcpy(drvhost->windres,"windres"); - cfgmeta->windres = cfgnative; + cfgmeta->windres = fnativear ? cfgar : cfgnative; } else { sprintf(drvhost->windres,"%s-windres",host->host); cfgmeta->windres = cfghost; } + if ((mark = strrchr(host->ranlib,'/'))) { + if (strcmp(++mark,"ranlib")) + if ((mark = strrchr(mark,'-'))) + if (strcmp(++mark,"ranlib")) + mark = 0; + + if (mark) { + strcpy(drvhost->windres,host->ranlib); + strcpy(&drvhost->windres[mark-host->ranlib],"windres"); + cfgmeta->windres = cfgranlib; + } + } + host->windres = drvhost->windres; } @@ -426,12 +466,25 @@ slbt_hidden int slbt_init_host_params( if (fnative) { strcpy(drvhost->dlltool,"dlltool"); - cfgmeta->dlltool = cfgnative; + cfgmeta->dlltool = fnativear ? cfgar : cfgnative; } else { sprintf(drvhost->dlltool,"%s-dlltool",host->host); cfgmeta->dlltool = cfghost; } + if ((mark = strrchr(host->ranlib,'/'))) { + if (strcmp(++mark,"ranlib")) + if ((mark = strrchr(mark,'-'))) + if (strcmp(++mark,"ranlib")) + mark = 0; + + if (mark) { + strcpy(drvhost->dlltool,host->ranlib); + strcpy(&drvhost->dlltool[mark-host->ranlib],"dlltool"); + cfgmeta->dlltool = cfgranlib; + } + } + host->dlltool = drvhost->dlltool; } @@ -452,7 +505,7 @@ slbt_hidden int slbt_init_host_params( if (fnative) { strcpy(drvhost->mdso,"mdso"); - cfgmeta->mdso = cfgnative; + cfgmeta->mdso = fnativear ? cfgar : cfgnative; } else { sprintf(drvhost->mdso,"%s-mdso",host->host); cfgmeta->mdso = cfghost; diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index 65e5f96..429cdc4 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -28,7 +28,10 @@ enum app_tags { TAG_VERSION, TAG_INFO, TAG_CONFIG, + TAG_MKVARS, TAG_DUMPMACHINE, + TAG_PRINT_AUX_DIR, + TAG_PRINT_M4_DIR, TAG_DEBUG, TAG_DRY_RUN, TAG_FEATURES, @@ -114,6 +117,7 @@ enum app_tags { TAG_STLE_VERBOSE, TAG_STLE_WARNINGS, TAG_STLE_NO_WARNINGS, + TAG_STLE_LTDL, }; struct slbt_split_vector { @@ -160,6 +164,7 @@ struct slbt_driver_ctx_impl { struct slbt_fd_ctx fdctx; struct slbt_map_info lconf; struct slbt_txtfile_ctx * lconfctx; + struct slbt_txtfile_ctx * mkvarsctx; struct slbt_obj_list * objlistv; struct argv_entry ** dlopenv; diff --git a/src/internal/slibtool_lconf_impl.c b/src/internal/slibtool_lconf_impl.c index 33dfb23..ffe92b0 100644 --- a/src/internal/slibtool_lconf_impl.c +++ b/src/internal/slibtool_lconf_impl.c @@ -515,6 +515,7 @@ static int slbt_lconf_trace_result_annotated( static int slbt_lconf_open( struct slbt_driver_ctx * dctx, const char * lconf, + bool fsilent, char (*lconfpath)[PATH_MAX]) { int fderr; @@ -525,6 +526,7 @@ static int slbt_lconf_open( struct stat stcwd; struct stat stparent; ino_t stinode; + const char * mconf; int (*trace_lconf)(struct slbt_driver_ctx *, const char *); @@ -539,12 +541,19 @@ static int slbt_lconf_open( int,int,const char *,int, char (*)[PATH_MAX]); - lconf = lconf ? lconf : "libtool"; fderr = slbt_driver_fderr(dctx); fdcwd = slbt_driver_fdcwd(dctx); fdlconfdir = fdcwd; + fsilent |= (dctx->cctx->drvflags & SLBT_DRIVER_SILENT); - if (dctx->cctx->drvflags & SLBT_DRIVER_SILENT) { + if (lconf) { + mconf = 0; + } else { + mconf = "slibtool.cfg"; + lconf = "libtool"; + } + + if (fsilent) { trace_lconf = 0; trace_fstat = slbt_lconf_trace_fstat_silent; trace_openat = slbt_lconf_trace_openat_silent; @@ -580,8 +589,10 @@ static int slbt_lconf_open( trace_openat = slbt_lconf_trace_openat_silent; } - if (!(dctx->cctx->drvflags & SLBT_DRIVER_SILENT)) { - trace_lconf(dctx,lconf); + if (!fsilent) { + if (!mconf) + trace_lconf(dctx,lconf); + slbt_output_fdcwd(dctx); } @@ -594,7 +605,14 @@ static int slbt_lconf_open( return SLBT_SYSTEM_ERROR(dctx,0); stinode = stcwd.st_ino; - fdlconf = trace_openat(dctx,fdlconfdir,lconf,O_RDONLY,0); + fdlconf = -1; + + if (mconf) + if ((fdlconf = trace_openat(dctx,fdlconfdir,mconf,O_RDONLY,0)) >= 0) + lconf = mconf; + + if (fdlconf < 0) + fdlconf = trace_openat(dctx,fdlconfdir,lconf,O_RDONLY,0); while (fdlconf < 0) { fdparent = trace_openat(dctx,fdlconfdir,"../",O_DIRECTORY,0); @@ -623,8 +641,14 @@ static int slbt_lconf_open( } fdlconfdir = fdparent; - fdlconf = trace_openat(dctx,fdlconfdir,lconf,O_RDONLY,0); stinode = stparent.st_ino; + + if (mconf) + if ((fdlconf = trace_openat(dctx,fdlconfdir,mconf,O_RDONLY,0)) >= 0) + lconf = mconf; + + if (fdlconf < 0) + fdlconf = trace_openat(dctx,fdlconfdir,lconf,O_RDONLY,0); } trace_result(dctx,fdlconf,fdlconfdir,lconf,0,lconfpath); @@ -662,8 +686,10 @@ static int slbt_get_lconf_var( } /* not found? */ - if (!match) + if (!match) { + (*val)[0] = '\0'; return 0; + } /* support a single pair of double quotes */ match = &match[len]; @@ -723,7 +749,8 @@ static int slbt_get_lconf_var( slbt_hidden int slbt_get_lconf_flags( struct slbt_driver_ctx * dctx, const char * lconf, - uint64_t * flags) + uint64_t * flags, + bool fsilent) { struct slbt_driver_ctx_impl * ctx; struct slbt_txtfile_ctx * confctx; @@ -738,7 +765,7 @@ slbt_hidden int slbt_get_lconf_flags( ctx = slbt_get_driver_ictx(dctx); /* open relative libtool script */ - if ((fdlconf = slbt_lconf_open(dctx,lconf,&val)) < 0) + if ((fdlconf = slbt_lconf_open(dctx,lconf,fsilent,&val)) < 0) return SLBT_NESTED_ERROR(dctx); /* cache the configuration in library friendly form) */ diff --git a/src/internal/slibtool_lconf_impl.h b/src/internal/slibtool_lconf_impl.h index d2bd44c..05c7537 100644 --- a/src/internal/slibtool_lconf_impl.h +++ b/src/internal/slibtool_lconf_impl.h @@ -8,6 +8,7 @@ struct slbt_driver_ctx; int slbt_get_lconf_flags( struct slbt_driver_ctx * dctx, const char * lconf, - uint64_t * flags); + uint64_t * flags, + bool fsilent); #endif diff --git a/src/internal/slibtool_mkvars_impl.c b/src/internal/slibtool_mkvars_impl.c new file mode 100644 index 0000000..5245034 --- /dev/null +++ b/src/internal/slibtool_mkvars_impl.c @@ -0,0 +1,245 @@ +/*******************************************************************/ +/* slibtool: a strong libtool implementation, written in C */ +/* Copyright (C) 2016--2024 SysDeer Technologies, LLC */ +/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */ +/*******************************************************************/ + +#include <ctype.h> +#include <stdio.h> +#include <stdint.h> +#include <stdbool.h> + +#include "slibtool_mkvars_impl.h" +#include "slibtool_driver_impl.h" +#include "slibtool_errinfo_impl.h" +#include "slibtool_symlink_impl.h" +#include "slibtool_readlink_impl.h" +#include "slibtool_realpath_impl.h" +#include "slibtool_visibility_impl.h" + +static int slbt_get_mkvars_var( + const struct slbt_driver_ctx * dctx, + const struct slbt_txtfile_ctx * tctx, + const char * var, + const char space, + char (*val)[PATH_MAX]) +{ + const char ** pline; + const char * mark; + const char * match; + char * ch; + ssize_t len; + int cint; + + /* init */ + match = 0; + len = strlen(var); + + /* search for ^var= */ + for (pline=tctx->txtlinev; !match && *pline; pline++) { + if (!strncmp(*pline,var,len)) { + if (isspace((cint = (*pline)[len])) || ((*pline)[len] == '=')) { + mark = &(*pline)[len]; + + for (; isspace(cint = *mark); ) + mark++; + + if (mark[0] != '=') + return SLBT_CUSTOM_ERROR( + dctx, + SLBT_ERR_MKVARS_PARSE); + + mark++; + + for (; isspace(cint = *mark); ) + mark++; + + match = mark; + } + } + } + + /* not found? */ + if (!match) { + (*val)[0] = '\0'; + return 0; + } + + /* special case the SLIBTOOL make variable */ + if (!strcmp(var,"SLIBTOOL")) { + mark = match; + ch = *val; + + for (; *mark; ) { + if (isspace(cint = *mark)) { + *ch = '\0'; + return 0; + } + + *ch++ = *mark++; + } + } + + /* validate */ + for (mark=match; *mark; mark++) { + if ((*mark >= 'a') && (*mark <= 'z')) + (void)0; + + else if ((*mark >= 'A') && (*mark <= 'Z')) + (void)0; + + else if ((*mark >= '0') && (*mark <= '9')) + (void)0; + + else if ((*mark == '+') || (*mark == '-')) + (void)0; + + else if ((*mark == '/') || (*mark == '@')) + (void)0; + + else if ((*mark == '.') || (*mark == '_')) + (void)0; + + else if ((*mark == ':') || (*mark == space)) + (void)0; + + else + return SLBT_CUSTOM_ERROR( + dctx, + SLBT_ERR_MKVARS_PARSE); + } + + /* all done */ + strcpy(*val,match); + + return 0; +} + +slbt_hidden int slbt_get_mkvars_flags( + struct slbt_driver_ctx * dctx, + const char * mkvars, + uint64_t * flags) +{ + struct slbt_driver_ctx_impl * ctx; + struct slbt_txtfile_ctx * confctx; + char * dash; + uint64_t optshared; + uint64_t optstatic; + char val[PATH_MAX]; + + /* driver context (ar, ranlib, cc) */ + ctx = slbt_get_driver_ictx(dctx); + + /* cache the makefile in library friendly form) */ + if (slbt_lib_get_txtfile_ctx(dctx,mkvars,&ctx->mkvarsctx) < 0) + return SLBT_NESTED_ERROR(dctx); + + confctx = ctx->mkvarsctx; + + /* scan */ + optshared = 0; + optstatic = 0; + + /* slibtool */ + if (slbt_get_mkvars_var(dctx,confctx,"SLIBTOOL",0,&val) < 0) + return SLBT_NESTED_ERROR(dctx); + + if ((dash = strrchr(val,'-'))) { + if (!strcmp(dash,"-shared")) { + optshared = SLBT_DRIVER_SHARED; + optstatic = SLBT_DRIVER_DISABLE_STATIC; + + } else if (!strcmp(dash,"-static")) { + optshared = SLBT_DRIVER_DISABLE_SHARED; + optstatic = SLBT_DRIVER_STATIC; + } else { + return SLBT_CUSTOM_ERROR( + dctx, + SLBT_ERR_MKVARS_PARSE); + } + } else if (!strcmp(val,"false")) { + optshared = SLBT_DRIVER_DISABLE_SHARED; + optstatic = SLBT_DRIVER_DISABLE_STATIC; + } else { + optshared = SLBT_DRIVER_SHARED; + optstatic = SLBT_DRIVER_STATIC; + } + + *flags = optshared | optstatic; + + /* host */ + if (!ctx->cctx.host.host) { + if (slbt_get_mkvars_var(dctx,confctx,"host",0,&val) < 0) + return SLBT_NESTED_ERROR(dctx); + + if (val[0] && !(ctx->host.host = strdup(val))) + return SLBT_SYSTEM_ERROR(dctx,0); + + ctx->cctx.host.host = ctx->host.host; + } + + + /* ar tool */ + if (!ctx->cctx.host.ar) { + if (slbt_get_mkvars_var(dctx,confctx,"AR",0x20,&val) < 0) + return SLBT_NESTED_ERROR(dctx); + + if (val[0] && !(ctx->host.ar = strdup(val))) + return SLBT_SYSTEM_ERROR(dctx,0); + + ctx->cctx.host.ar = ctx->host.ar; + } + + + /* nm tool */ + if (!ctx->cctx.host.nm) { + if (slbt_get_mkvars_var(dctx,confctx,"NM",0x20,&val) < 0) + return SLBT_NESTED_ERROR(dctx); + + if (val[0] && !(ctx->host.nm = strdup(val))) + return SLBT_SYSTEM_ERROR(dctx,0); + + ctx->cctx.host.nm = ctx->host.nm; + } + + + /* ranlib tool */ + if (!ctx->cctx.host.ranlib) { + if (slbt_get_mkvars_var(dctx,confctx,"RANLIB",0x20,&val) < 0) + return SLBT_NESTED_ERROR(dctx); + + if (val[0] && !(ctx->host.ranlib = strdup(val))) + return SLBT_SYSTEM_ERROR(dctx,0); + + ctx->cctx.host.ranlib = ctx->host.ranlib; + } + + + /* as tool (optional) */ + if (!ctx->cctx.host.as) { + if (slbt_get_mkvars_var(dctx,confctx,"AS",0x20,&val) < 0) + return SLBT_NESTED_ERROR(dctx); + + if (val[0] && !(ctx->host.as = strdup(val))) + return SLBT_SYSTEM_ERROR(dctx,0); + + + ctx->cctx.host.as = ctx->host.as; + } + + + /* dlltool tool (optional) */ + if (!ctx->cctx.host.dlltool) { + if (slbt_get_mkvars_var(dctx,confctx,"DLLTOOL",0x20,&val) < 0) + return SLBT_NESTED_ERROR(dctx); + + if (val[0] && !(ctx->host.dlltool = strdup(val))) + return SLBT_SYSTEM_ERROR(dctx,0); + + ctx->cctx.host.dlltool = ctx->host.dlltool; + } + + + /* all done */ + return 0; +} diff --git a/src/internal/slibtool_mkvars_impl.h b/src/internal/slibtool_mkvars_impl.h new file mode 100644 index 0000000..00ebd99 --- /dev/null +++ b/src/internal/slibtool_mkvars_impl.h @@ -0,0 +1,13 @@ +#ifndef SLIBTOOL_MKVARS_IMPL_H +#define SLIBTOOL_MKVARS_IMPL_H + +#include <stdint.h> + +struct slbt_driver_ctx; + +int slbt_get_mkvars_flags( + struct slbt_driver_ctx * dctx, + const char * mkvars, + uint64_t * flags); + +#endif 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; } diff --git a/src/skin/slbt_skin_default.c b/src/skin/slbt_skin_default.c index 7c54f76..07f099d 100644 --- a/src/skin/slbt_skin_default.c +++ b/src/skin/slbt_skin_default.c @@ -18,6 +18,10 @@ const slbt_hidden struct argv_option slbt_default_options[] = { "the %s of which is either provided via this " "command-line argument, or detected by the program."}, + {"mkvars", 0,TAG_MKVARS,ARGV_OPTARG_REQUIRED,0,0,"<makefile>", + "obtain information about the current build project " + "from the specified %s."}, + {"mode", 0,TAG_MODE,ARGV_OPTARG_REQUIRED,0, "clean|compile|execute|finish" "|install|link|uninstall|ar" @@ -29,6 +33,19 @@ const slbt_hidden struct argv_option slbt_default_options[] = { "however its addition is expected before the " "next major release."}, + {"print-aux-dir", 0,TAG_PRINT_AUX_DIR,ARGV_OPTARG_NONE, + ARGV_OPTION_HYBRID_ONLY,0,0, + "print the directory of the package-installed, " + "backward-compatible ltmain.sh and slibtool.sh; " + "for additional information, see the slibtoolize(1) " + "manual page."}, + + {"print-m4-dir", 0,TAG_PRINT_M4_DIR,ARGV_OPTARG_NONE, + ARGV_OPTION_HYBRID_ONLY,0,0, + "print the directory of the package-installed slibtool.m4; " + "for additional information, see the slibtoolize(1) " + "manual page."}, + {"finish", 0,TAG_FINISH,ARGV_OPTARG_NONE,0,0,0, "same as --mode=finish"}, diff --git a/src/skin/slbt_skin_stoolie.c b/src/skin/slbt_skin_stoolie.c index 598a410..e058fed 100644 --- a/src/skin/slbt_skin_stoolie.c +++ b/src/skin/slbt_skin_stoolie.c @@ -48,5 +48,11 @@ const slbt_hidden struct argv_option slbt_stoolie_options[] = { {"no-warnings", 0,TAG_STLE_NO_WARNINGS,ARGV_OPTARG_NONE,0,0,0, "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 install library."}, + {0,0,0,0,0,0,0,0} }; diff --git a/src/stoolie/slbt_stoolie_ctx.c b/src/stoolie/slbt_stoolie_ctx.c index b74edd3..3457fbe 100644 --- a/src/stoolie/slbt_stoolie_ctx.c +++ b/src/stoolie/slbt_stoolie_ctx.c @@ -208,7 +208,7 @@ int slbt_st_get_stoolie_ctx( if (!ctx->m4buf && ctx->makam) { for (pline=ctx->makam->txtlinev; !ctx->m4argv && *pline; pline++) { if (!strncmp(*pline,"ACLOCAL_AMFLAGS",15)) { - if (isspace((*pline)[15]) || ((*pline)[15] == '=')) { + if (isspace((cint = (*pline)[15])) || ((*pline)[15] == '=')) { mark = &(*pline)[15]; for (; isspace(cint = *mark); ) |