[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH 6/7] Buildsystem: libc in src/modules/c dynamisch linken



+ libc: Zusätzlich zur statischen Bibliothek auch eine dynamische bauen

+ modules/c/*: Die libc dynamisch linken

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 buildmk.sh                            | 13 +++++++++++--
 src/modules/c/Makefile.conf           |  1 +
 src/modules/lib/Makefile.all          |  4 ++++
 src/modules/lib/rpc/Makefile.all      |  1 -
 src/modules/lib/syscalls/Makefile.all |  1 -
 5 files changed, 16 insertions(+), 4 deletions(-)
 create mode 100644 src/modules/c/Makefile.conf
 delete mode 100644 src/modules/lib/rpc/Makefile.all
 delete mode 100644 src/modules/lib/syscalls/Makefile.all

diff --git a/buildmk.sh b/buildmk.sh
index abbd359..ea0b22f 100644
--- a/buildmk.sh
+++ b/buildmk.sh
@@ -69,7 +69,11 @@ if [ -d lib ]; then
     if [ -f lib/crt0.c ]; then
         LIBDIRS="`pwd`/lib/crt0.o $LIBDIRS"
     fi
-    LIBDIRS="`pwd`/lib/library.a $LIBDIRS"
+    if (grep library.so lib/Makefile.all > /dev/null 2>&1); then
+        LIBDIRS="`pwd`/lib/library.so $LIBDIRS"
+    else
+        LIBDIRS="`pwd`/lib/library.a $LIBDIRS"
+    fi
 fi
 
 if [ -f "user-$LOST_ARCH.ld" ]; then
@@ -146,7 +150,12 @@ EOF
 fi
 
 if [ -f Makefile.all ]; then
-  echo -e \\tLOST_BUILDMK_ROOT="$LOST_BUILDMK_ROOT" LDSCRIPT="'$LDSCRIPT'" bash Makefile.all '$(BUILD_ROOT)' \'$LIBDIRS $LIB_GCC\' \'$LOST_BUILDMK_ROOT\' >> Makefile
+    if [ -z "$ENABLE_SHARED" ]; then
+        LOCAL_LIBDIRS="$(echo "$LIBDIRS" | sed -e 's/\.so/\.a/g')"
+    else
+        LOCAL_LIBDIRS="$LIBDIRS"
+    fi
+    echo -e \\tLOST_BUILDMK_ROOT="$LOST_BUILDMK_ROOT" LDSCRIPT="'$LDSCRIPT'" bash Makefile.all '$(BUILD_ROOT)' \'$LOCAL_LIBDIRS $LIB_GCC\' \'$LOST_BUILDMK_ROOT\' >> Makefile
 fi
 
 cat <<EOF >> Makefile
diff --git a/src/modules/c/Makefile.conf b/src/modules/c/Makefile.conf
new file mode 100644
index 0000000..66f20c5
--- /dev/null
+++ b/src/modules/c/Makefile.conf
@@ -0,0 +1 @@
+export ENABLE_SHARED=1
diff --git a/src/modules/lib/Makefile.all b/src/modules/lib/Makefile.all
index 6c3c3a4..e20a908 100644
--- a/src/modules/lib/Makefile.all
+++ b/src/modules/lib/Makefile.all
@@ -2,3 +2,7 @@ echo "AR   library.a"
 source $LOST_BUILDMK_ROOT/config.sh
 
 $LOST_TOOLS_AR rs library.a *.o */*.o */*/*.o
+
+echo "LD   library.so"
+$LOST_TOOLS_LD -shared -soname=libc -olibrary.so *.o */*.o */*/*.o $LIB_GCC
+$LOST_TOOLS_STRIP -s library.so -o $1/system/libc.so
diff --git a/src/modules/lib/rpc/Makefile.all b/src/modules/lib/rpc/Makefile.all
deleted file mode 100644
index e9b03f4..0000000
--- a/src/modules/lib/rpc/Makefile.all
+++ /dev/null
@@ -1 +0,0 @@
-cp *.o ..
diff --git a/src/modules/lib/syscalls/Makefile.all b/src/modules/lib/syscalls/Makefile.all
deleted file mode 100644
index e9b03f4..0000000
--- a/src/modules/lib/syscalls/Makefile.all
+++ /dev/null
@@ -1 +0,0 @@
-cp *.o ..
-- 
2.1.4