summaryrefslogtreecommitdiff
path: root/src/logic/slbt_exec_compile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/logic/slbt_exec_compile.c')
-rw-r--r--src/logic/slbt_exec_compile.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/logic/slbt_exec_compile.c b/src/logic/slbt_exec_compile.c
index 53de294..4d645d2 100644
--- a/src/logic/slbt_exec_compile.c
+++ b/src/logic/slbt_exec_compile.c
@@ -13,6 +13,21 @@
#include <slibtool/slibtool.h>
#include "slibtool_spawn_impl.h"
+static int slbt_exec_compile_remove_file(
+ const struct slbt_driver_ctx * dctx,
+ struct slbt_exec_ctx * ectx,
+ const char * target)
+{
+ /* remove target (if any) */
+ if (!(unlink(target)) || (errno == ENOENT))
+ return 0;
+
+ if (!(dctx->cctx->drvflags & SLBT_DRIVER_SILENT))
+ strerror(errno);
+
+ return -1;
+}
+
int slbt_exec_compile(
const struct slbt_driver_ctx * dctx,
struct slbt_exec_ctx * ectx)
@@ -30,6 +45,10 @@ int slbt_exec_compile(
else
actx = ectx;
+ /* remove old .lo wrapper */
+ if (slbt_exec_compile_remove_file(dctx,ectx,ectx->ltobjname))
+ return -1;
+
/* .libs directory */
if (dctx->cctx->drvflags & SLBT_DRIVER_SHARED) {
if ((fdlibs = open(ectx->ldirname,O_DIRECTORY)) >= 0)