summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Viennot <nicolas@viennot.biz>2016-01-11 02:20:10 -0800
committerNicolas Viennot <nicolas@viennot.biz>2016-01-11 02:54:09 -0800
commit6dc58ab6deef30020953882331c88ca6c80b4f2d (patch)
treeec400ef2c9a2f934a836672b0f06e259e907eb00
parenta2520da19591599538f8dc26b3bd6bf7a2619300 (diff)
Lower the required glib version to 2.8 for static builds
-rw-r--r--Makefile.static-build15
-rw-r--r--compat/clock_gettime.c9
-rw-r--r--compat/memcpy.c11
-rw-r--r--configure.ac7
4 files changed, 40 insertions, 2 deletions
diff --git a/Makefile.static-build b/Makefile.static-build
index 809ac9db..6db26d76 100644
--- a/Makefile.static-build
+++ b/Makefile.static-build
@@ -8,6 +8,10 @@ MSGPACK_LIB=ext/lib/libmsgpack.a
TMATE_CONFIGURE=PKG_CONFIG_PATH=./ext/lib/pkgconfig
+LIBC=$(shell gcc -print-file-name=libc.a)
+STATIC_LIBC_OBJECTS=fdelt_chk
+STATIC_COMPAT_OBJECTS=memcpy clock_gettime
+
all: tmate
dependencies:
@@ -39,11 +43,18 @@ $(MSGPACK_LIB): $(MSGPACK)/.ready
cd $(MSGPACK)/build; ([ -f Makefile ] || cmake -DCMAKE_INSTALL_PREFIX:PATH=$(shell pwd)/ext ..)
+make -C $(MSGPACK)/build install
-tmate: $(MSGPACK_LIB) $(LIBSSH_LIB)
+libc/%.o:
+ mkdir -p libc
+ cd libc; ar x $(LIBC) $(notdir $@)
+
+compat/%.o: compat/%.c
+ gcc -c -o $@ $<
+
+tmate: $(MSGPACK_LIB) $(LIBSSH_LIB) $(patsubst %,libc/%.o,$(STATIC_LIBC_OBJECTS)) $(patsubst %,compat/%.o,$(STATIC_COMPAT_OBJECTS))
./autogen.sh
$(TMATE_CONFIGURE) ./configure --enable-static
+make
clean:
- rm -rf ext $(LIBSSH) $(MSGPACK)
+ rm -rf ext libc $(LIBSSH) $(MSGPACK)
+make clean
diff --git a/compat/clock_gettime.c b/compat/clock_gettime.c
new file mode 100644
index 00000000..0b631b79
--- /dev/null
+++ b/compat/clock_gettime.c
@@ -0,0 +1,9 @@
+#define _GNU_SOURCE
+#include <time.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+int clock_gettime(clockid_t clk_id, struct timespec *tp)
+{
+ return syscall(SYS_clock_gettime, clk_id, tp);
+}
diff --git a/compat/memcpy.c b/compat/memcpy.c
new file mode 100644
index 00000000..37092a33
--- /dev/null
+++ b/compat/memcpy.c
@@ -0,0 +1,11 @@
+// http://stackoverflow.com/questions/8823267/linking-against-older-symbol-version-in-a-so-file
+
+#include <string.h>
+
+/* some systems do not have newest memcpy@@GLIBC_2.14 - stay with old good one */
+asm (".symver memcpy, memcpy@GLIBC_2.2.5");
+
+void *__wrap_memcpy(void *dest, const void *src, size_t n)
+{
+ return memcpy(dest, src, n);
+}
diff --git a/configure.ac b/configure.ac
index 663a51c5..10d761bc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,6 +61,7 @@ if test "x$found_static" = xyes; then
CPPFLAGS="$LIBCRYPTO_CFLAGS $CPPFLAGS"
LIBS="$LIBCRYPTO_LIBS $LIBS"
])
+ # See more static settings below... (search for found_static)
fi
# Is this gcc?
@@ -451,6 +452,12 @@ AM_CONDITIONAL(NO_GETOPT, [test "x$found_getopt" = xno])
if test "x$found_static" = xyes; then
# libc and libdl should be dynamically linked.
+ # but we want to lower our requirements for libc's version.
+ # so we extract some symobls and add them here
+ if test `uname -m` = x86_64; then
+ LIBS="compat/memcpy.o -Wl,--wrap=memcpy $LIBS"
+ fi
+ LIBS="compat/clock_gettime.o libc/fdelt_chk.o $LIBS"
LIBS="-Wl,-Bstatic ${LIBS/-ldl/} -Wl,-Bdynamic -ldl"
fi