From dc4ba7770d580800634f90b67a24e077b4a26d98 Mon Sep 17 00:00:00 2001
From: Steve Bennett <steveb@workware.net.au>
Date: Thu, 4 Jul 2019 12:06:01 +1000
Subject: build: improve build for shared objects

Rather than listing the build rules for each shared object
(loadable module) in the Makefile template, generate the build
rules in configure.

Also, if an extension is configured as a module, any automatic
dependencies required by the extension are configured as modules
by default.

Signed-off-by: Steve Bennett <steveb@workware.net.au>
---
 auto.def | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

(limited to 'auto.def')

diff --git a/auto.def b/auto.def
index e7afbc6..e80618a 100644
--- a/auto.def
+++ b/auto.def
@@ -495,6 +495,23 @@ define EXTRA_OBJS $extra_objs
 # Restore the user-specified LIBS
 define LIBS $LIBS
 
+# Now generate the Makefile rules to build the external C shared objects
+# It is easier to do this here rather than listing them out explicitly in Makefile.in
+set lines {}
+foreach mod $extinfo(module-c) {
+    set objs {}
+    set libs [get-define LDLIBS_$mod]
+    set src jim-$mod.c
+    lappend lines "$mod.so: $src"
+    set obj [file rootname $src].o
+    lappend lines "\t\$(ECHO)\t\"\tCC\t$obj\""
+    lappend lines "\t\$(Q)\$(CC) \$(CFLAGS) \$(SHOBJ_CFLAGS) -c -o $obj $src"
+    lappend lines "\t\$(ECHO)\t\"\tLDSO\t\$@\""
+    lappend lines "\t\$(Q)\$(CC) \$(CFLAGS) \$(LDFLAGS) \$(SHOBJ_LDFLAGS) -o \$@ $obj \$(SH_LIBJIM) $libs"
+    lappend lines ""
+}
+define BUILD_SHOBJS [join $lines \n]
+
 make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8} -bare JIM_VERSION -none *
 make-config-header jimautoconf.h -auto {jim_ext_* TCL_PLATFORM_* TCL_LIBRARY USE_* JIM_* _FILE_OFFSET*} -bare {S_I*}
 make-template Makefile.in
-- 
cgit v1.1

