1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
From 06b1bc37b12028b5dba3635d5851639663dfc1e4 Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@debian.org>
Date: Tue, 14 Jan 2014 02:08:51 +0000
Subject: Modify build system to work outside glibc
Forwarded: no
Last-Update: 2012-06-22
Patch-Name: build-outside-glibc.patch
---
Makefile | 71 ++++++++++++++++----------------------------------------
Versions | 9 +++----
2 files changed, 25 insertions(+), 55 deletions(-)
diff --git a/Makefile b/Makefile
index ac08e78..ae4e1b5 100644
--- a/Makefile
+++ b/Makefile
@@ -20,54 +20,23 @@ libdb1-routines := bt_close bt_conv bt_debug bt_delete bt_get \
rec_close rec_delete rec_get rec_open rec_put rec_search \
rec_seq rec_utils
-db1-headers := db.h mpool.h ndbm.h
-distribute := compat.h \
- btree/btree.h btree/extern.h \
- hash/extern.h hash/hash.h hash/page.h \
- recno/extern.h recno/recno.h \
- $(db1-headers)
-
-include ../Makeconfig
-
-install-others := $(db1-headers:%=$(inst_includedir)/db1/%)
-
-ifeq (yes,$(build-shared))
-install-others += $(inst_slibdir)/libdb.so$(libdb1.so-version)
-endif
-
-$(inst_slibdir)/libdb.so$(libdb1.so-version): $(inst_slibdir)/libdb1-$(version).so $(+force)
- rm -f $@
- $(LN_S) $(<F) $@
-
-$(db1-headers:%=$(inst_includedir)/db1/%): $(inst_includedir)/db1/%: % $(+force)
- $(do-install)
-
-include ../Rules
-
-CPPFLAGS += -D__DBINTERFACE_PRIVATE -DUSE_LIBDB1
-
-# This file defines some static functions for alternative hash algorithms
-# that are not actually used.
-CFLAGS-hash_func.c := -Wno-unused
-
-# The db code outsmarts the compiler frequently.
-override CFLAGS += -Wno-uninitialized
-
-# Force the soname to be libdb.so for compatibility.
-LDFLAGS-db1.so = -Wl,-soname=lib$(libprefix)db.so$($(@F)-version)
-
-# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
-# This ensures they will load libc.so for needed symbols if loaded by
-# a statically-linked program that hasn't already loaded it.
-$(objpfx)libdb1.so: $(objpfx)libdb1_pic.a $(+preinit) $(+postinit) $(+interp) \
- $(common-objpfx)libc.so
-
-#subdir_install: $(inst_libdir)/libndbm.a
-#$(inst_libdir)/libndbm.a: $(inst_libdir)/libdb1.a $(+force)
-# $(make-link)
-#
-#ifeq ($(build-shared),yes)
-#subdir_install: $(inst_libdir)/libndbm.so
-#$(inst_libdir)/libndbm.so: $(inst_libdir)/libdb1.so $(+force)
-# $(make-link)
-#endif
+CFLAGS ?= -O2
+XCPPFLAGS = -I. -D_REENTRANT -D__DBINTERFACE_PRIVATE -DUSE_LIBDB1 -D_GNU_SOURCE
+libdb.so-version=.2
+
+all: libdb1.so$(libdb.so-version)
+
+%.o: %.c
+ $(CC) $(XCPPFLAGS) $(CPPFLAGS) $(CFLAGS) -c -g -o $@ $<
+%.os: %.c
+ $(CC) $(XCPPFLAGS) $(CPPFLAGS) $(CFLAGS) -c -fPIC -o $@ $<
+
+libdb1.so$(libdb.so-version): $(patsubst %,%.os,$(libdb1-routines))
+ $(CC) -Wl,-O1 -Wl,--version-script=Versions -Wl,-z,combreloc \
+ -Wl,-soname=libdb.so$(libdb.so-version) $(LDFLAGS) \
+ -shared -o $@ $^ -lc
+
+clean:
+ rm -f $(patsubst %,%.o,$(libdb1-routines))
+ rm -f $(patsubst %,%.os,$(libdb1-routines))
+ rm -f libdb1.so$(libdb.so-version) *~
diff --git a/Versions b/Versions
index 479604e..87e34c4 100644
--- a/Versions
+++ b/Versions
@@ -1,10 +1,11 @@
-libdb1 {
- GLIBC_2.0 {
+GLIBC_2.0 {
+ global:
# the real DB entry point.
dbopen; __dbopen;
# The compatibility functions.
dbm_clearerr; dbm_close; dbm_delete; dbm_dirfno; dbm_error;
dbm_fetch; dbm_firstkey; dbm_nextkey; dbm_open; dbm_store;
- }
-}
+ local:
+ *;
+};
|