commit f4f8b1e8b02d434a81940ce40e3d79a1fba49691
parent ad4ee88e9a9bf135318d4a1cf9bb4ab18cf56550
Author: Joris Vink <joris@coders.se>
Date: Sun, 3 Aug 2014 17:44:29 +0200
Allow users to set ldflags via KORE_LDFLAGS
Diffstat:
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/cli.c b/src/cli.c
@@ -53,6 +53,8 @@
#define PRI_TIME_T "ld"
#endif
+#define LD_FLAGS_MAX 10
+
struct cmd {
const char *name;
const char *descr;
@@ -839,9 +841,13 @@ cli_compile_cfile(void *arg)
static void
cli_link_library(void *arg)
{
- int idx;
struct cfile *cf;
- char *args[cfiles_count + 10], *libname;
+ int idx, f, i;
+ char *p, *libname, *flags[LD_FLAGS_MAX];
+ char *args[cfiles_count + 10 + LD_FLAGS_MAX];
+
+ if ((p = getenv("KORE_LDFLAGS")) != NULL)
+ f = kore_split_string(p, " ", flags, LD_FLAGS_MAX);
(void)cli_vasprintf(&libname, "%s/%s.so", rootdir, appl);
@@ -857,6 +863,9 @@ cli_link_library(void *arg)
args[idx++] = "-shared";
#endif
+ for (i = 0; i < f; i++)
+ args[idx++] = flags[i];
+
TAILQ_FOREACH(cf, &source_files, list)
args[idx++] = cf->opath;