All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v5] leveldb: new package
@ 2015-01-09 17:09 Steve James
  2015-01-10 10:19 ` Thomas Petazzoni
  0 siblings, 1 reply; 3+ messages in thread
From: Steve James @ 2015-01-09 17:09 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Steve James <ste@junkomatic.net>
---
Changes v4 -> v5:
  - Simplify our make by patching Buildroot support into upstream
Changes v3 -> v4:
  - Don't damage global scope make macros
  - Add dependency on threads toolchain
Changes v2 -> v3:
  - Re-submit without line wrapping
Changes v1 -> v2:
  - Upstream release labels don't include package name, giving us an
    anonymous download archive, so use $(call github) method instead
  - Use $(TARGET_CONFIGURE_OPTS)
  - Support new shared vs static vs shared+static possibilities

 package/Config.in                                  |  1 +
 package/leveldb/001-ssize_t-undefined.patch        | 17 +++++
 ...002-facilitate-integration-into-buildroot.patch | 78 ++++++++++++++++++++++
 package/leveldb/Config.in                          | 13 ++++
 package/leveldb/leveldb.mk                         | 46 +++++++++++++
 5 files changed, 155 insertions(+)
 create mode 100644 package/leveldb/001-ssize_t-undefined.patch
 create mode 100644 package/leveldb/002-facilitate-integration-into-buildroot.patch
 create mode 100644 package/leveldb/Config.in
 create mode 100644 package/leveldb/leveldb.mk

diff --git a/package/Config.in b/package/Config.in
index 90d334c..e9f2255 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -631,6 +631,7 @@ menu "Database"
 	source "package/berkeleydb/Config.in"
 	source "package/cppdb/Config.in"
 	source "package/gdbm/Config.in"
+	source "package/leveldb/Config.in"
 	source "package/mysql/Config.in"
 	source "package/postgresql/Config.in"
 	source "package/redis/Config.in"
diff --git a/package/leveldb/001-ssize_t-undefined.patch b/package/leveldb/001-ssize_t-undefined.patch
new file mode 100644
index 0000000..9a958d8
--- /dev/null
+++ b/package/leveldb/001-ssize_t-undefined.patch
@@ -0,0 +1,17 @@
+Fix leveldb issue 233 leveldb does not compile with g++ 4.8.2
+
+Where db_iter.cc fails to get a typedef for ssize_t when compiled by GCC.
+
+Upstream-Status: Submitted [https://github.com/google/leveldb/issues/233]
+Signed-off-by: Steve James <ste@junkomatic.net>
+
+--- a/db/db_iter.cc.orig	2014-12-08 16:54:31.384615752 +0000
++++ b/db/db_iter.cc	2014-12-08 16:54:35.464656890 +0000
+@@ -13,6 +13,7 @@
+ #include "util/logging.h"
+ #include "util/mutexlock.h"
+ #include "util/random.h"
++#include <sys/types.h> // for ssize_t
+ 
+ namespace leveldb {
+ 
diff --git a/package/leveldb/002-facilitate-integration-into-buildroot.patch b/package/leveldb/002-facilitate-integration-into-buildroot.patch
new file mode 100644
index 0000000..c256f34
--- /dev/null
+++ b/package/leveldb/002-facilitate-integration-into-buildroot.patch
@@ -0,0 +1,78 @@
+From 83d4b0db22f661718e9568e8bcde549ad3fd4222 Mon Sep 17 00:00:00 2001
+From: Steve James <ste@junkomatic.net>
+Date: Fri, 9 Jan 2015 10:38:21 +0000
+Subject: [PATCH 1/1] facilitate integration into Buildroot:
+  - Add Buildroot TARGET_OS
+  - Allow flags from the environment
+  - Add install recipe
+
+Signed-off-by: Steve James <ste@junkomatic.net>
+Upstream-Status: Submitted [https://github.com/google/leveldb/pull/274]
+---
+ Makefile              | 25 +++++++++++++++++++++----
+ build_detect_platform |  8 ++++++++
+ 2 files changed, 29 insertions(+), 4 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 24f214a..130fd19 100644
+--- a/Makefile
++++ b/Makefile
+@@ -20,11 +20,11 @@ $(shell CC="$(CC)" CXX="$(CXX)" TARGET_OS="$(TARGET_OS)" \
+ # this file is generated by the previous line to set build flags and sources
+ include build_config.mk
+ 
+-CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
+-CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT)
++override CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
++override CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT)
+ 
+-LDFLAGS += $(PLATFORM_LDFLAGS)
+-LIBS += $(PLATFORM_LIBS)
++override LDFLAGS += $(PLATFORM_LDFLAGS)
++override LIBS += $(PLATFORM_LIBS)
+ 
+ LIBOBJECTS = $(SOURCES:.cc=.o)
+ MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o)
+@@ -229,3 +229,20 @@ else
+ .c.o:
+ 	$(CC) $(CFLAGS) -c $< -o $@
+ endif
++
++INSTALL_ROOT =
++INSTALL_PREFIX= usr
++
++install: $(SHARED) $(LIBRARY)
++	install -d -m 0755 $(INSTALL_ROOT)/$(INSTALL_PREFIX)/include/leveldb
++	install -D -m 0644 include/leveldb/*.h $(INSTALL_ROOT)/$(INSTALL_PREFIX)/include/leveldb
++	install -d -m 0755 $(INSTALL_ROOT)/$(INSTALL_PREFIX)/lib
++  ifneq (,$(LIBRARY))
++	install -m 0644 $(LIBRARY) $(INSTALL_ROOT)/$(INSTALL_PREFIX)/lib
++  endif
++  ifneq (,$(SHARED))
++	install -m 0755 $(SHARED3) $(INSTALL_ROOT)/$(INSTALL_PREFIX)/lib
++	ln -sf $(SHARED3) $(INSTALL_ROOT)/$(INSTALL_PREFIX)/lib/$(SHARED1)
++	ln -sf $(SHARED3) $(INSTALL_ROOT)/$(INSTALL_PREFIX)/lib/$(SHARED2)
++  endif
++
+diff --git a/build_detect_platform b/build_detect_platform
+index bb76c4f..0ad4f8d 100755
+--- a/build_detect_platform
++++ b/build_detect_platform
+@@ -147,6 +147,14 @@ case "$TARGET_OS" in
+         PLATFORM_SHARED_CFLAGS=
+         PLATFORM_SHARED_VERSIONED=
+         ;;
++    Buildroot)
++        PLATFORM=OS_LINUX
++        COMMON_FLAGS="$MEMCMP_FLAG -pthread -DOS_LINUX -DLEVELDB_PLATFORM_POSIX -DLEVELDB_ATOMIC_PRESENT"
++        PLATFORM_LDFLAGS="-pthread"
++        PLATFORM_CXXFLAGS="-std=c++0x"
++        PORT_FILE=port/port_posix.cc
++        CROSS_COMPILE=true
++        ;;
+     *)
+         echo "Unknown platform!" >&2
+         exit 1
+-- 
+1.9.1
+
diff --git a/package/leveldb/Config.in b/package/leveldb/Config.in
new file mode 100644
index 0000000..af097e5
--- /dev/null
+++ b/package/leveldb/Config.in
@@ -0,0 +1,13 @@
+config BR2_PACKAGE_LEVELDB
+	bool "leveldb"
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	select BR2_PACKAGE_SNAPPY
+	help
+	  LevelDB is a fast key-value storage library written at Google that
+	  provides an ordered mapping from string keys to string values.
+
+	  https://github.com/google/leveldb
+
+comment "leveldb needs a toolchain w/ C++, threads"
+	depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_HAS_THREADS
diff --git a/package/leveldb/leveldb.mk b/package/leveldb/leveldb.mk
new file mode 100644
index 0000000..ffbcc3e
--- /dev/null
+++ b/package/leveldb/leveldb.mk
@@ -0,0 +1,46 @@
+################################################################################
+#
+# leveldb
+#
+################################################################################
+
+LEVELDB_VERSION = 803d69203a62faf50f1b77897310a3a1fcae712b
+LEVELDB_SITE = $(call github,google,leveldb,$(LEVELDB_VERSION))
+LEVELDB_LICENSE = BSD-3c
+LEVELDB_LICENSE_FILES = LICENSE
+LEVELDB_INSTALL_STAGING = YES
+LEVELDB_DEPENDENCIES = snappy
+
+LEVELDB_MAKE_ARGS += TARGET_OS=Buildroot
+
+# We will pass optimisation level via CFLAGS so remove leveldb default
+LEVELDB_MAKE_ARGS += OPTIM=
+
+ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),)
+# Dynamic library not required
+LEVELDB_MAKE_ARGS += SHARED=
+endif
+
+ifeq ($(BR2_STATIC_LIBS)$(BR2_SHARED_STATIC_LIBS),)
+# Static library not required
+LEVELDB_MAKE_ARGS += LIBRARY=
+endif
+
+define LEVELDB_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) \
+		$(LEVELDB_MAKE_ARGS) -C $(@D)
+endef
+
+define LEVELDB_INSTALL_STAGING_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) \
+		$(LEVELDB_MAKE_ARGS) -C $(@D) INSTALL_ROOT=$(STAGING_DIR) install
+endef
+
+ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
+define LEVELDB_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) \
+		$(LEVELDB_MAKE_ARGS) -C $(@D) INSTALL_ROOT=$(TARGET_DIR) install
+endef
+endif
+
+$(eval $(generic-package))
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH v5] leveldb: new package
  2015-01-09 17:09 [Buildroot] [PATCH v5] leveldb: new package Steve James
@ 2015-01-10 10:19 ` Thomas Petazzoni
  2015-01-12 17:43   ` Steve James
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni @ 2015-01-10 10:19 UTC (permalink / raw)
  To: buildroot

Dear Steve James,

Thanks for this new version!

On Fri,  9 Jan 2015 17:09:46 +0000, Steve James wrote:

> diff --git a/package/leveldb/002-facilitate-integration-into-buildroot.patch b/package/leveldb/002-facilitate-integration-into-buildroot.patch
> new file mode 100644
> index 0000000..c256f34
> --- /dev/null
> +++ b/package/leveldb/002-facilitate-integration-into-buildroot.patch
> @@ -0,0 +1,78 @@
> +From 83d4b0db22f661718e9568e8bcde549ad3fd4222 Mon Sep 17 00:00:00 2001
> +From: Steve James <ste@junkomatic.net>
> +Date: Fri, 9 Jan 2015 10:38:21 +0000
> +Subject: [PATCH 1/1] facilitate integration into Buildroot:
> +  - Add Buildroot TARGET_OS
> +  - Allow flags from the environment
> +  - Add install recipe

There are three different things being done, so it should be three
separate patches, especially for upstream submission.

However, I believe adding a Buildroot TARGET_OS is a mistake, and has
no chance of being merged upstream. Buildroot is not an OS. It builds
Linux based systems, so the existing TARGET_OS=Linux should work just
fine for Buildroot.

> +-CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
> +-CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT)
> ++override CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
> ++override CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT)
> + 
> +-LDFLAGS += $(PLATFORM_LDFLAGS)
> +-LIBS += $(PLATFORM_LIBS)
> ++override LDFLAGS += $(PLATFORM_LDFLAGS)
> ++override LIBS += $(PLATFORM_LIBS)

So this should be one patch.

> + 
> + LIBOBJECTS = $(SOURCES:.cc=.o)
> + MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o)
> +@@ -229,3 +229,20 @@ else
> + .c.o:
> + 	$(CC) $(CFLAGS) -c $< -o $@
> + endif
> ++
> ++INSTALL_ROOT =
> ++INSTALL_PREFIX= usr
> ++
> ++install: $(SHARED) $(LIBRARY)
> ++	install -d -m 0755 $(INSTALL_ROOT)/$(INSTALL_PREFIX)/include/leveldb
> ++	install -D -m 0644 include/leveldb/*.h $(INSTALL_ROOT)/$(INSTALL_PREFIX)/include/leveldb
> ++	install -d -m 0755 $(INSTALL_ROOT)/$(INSTALL_PREFIX)/lib
> ++  ifneq (,$(LIBRARY))
> ++	install -m 0644 $(LIBRARY) $(INSTALL_ROOT)/$(INSTALL_PREFIX)/lib
> ++  endif
> ++  ifneq (,$(SHARED))
> ++	install -m 0755 $(SHARED3) $(INSTALL_ROOT)/$(INSTALL_PREFIX)/lib
> ++	ln -sf $(SHARED3) $(INSTALL_ROOT)/$(INSTALL_PREFIX)/lib/$(SHARED1)
> ++	ln -sf $(SHARED3) $(INSTALL_ROOT)/$(INSTALL_PREFIX)/lib/$(SHARED2)
> ++  endif

This should be another patch.

> ++    Buildroot)
> ++        PLATFORM=OS_LINUX
> ++        COMMON_FLAGS="$MEMCMP_FLAG -pthread -DOS_LINUX -DLEVELDB_PLATFORM_POSIX -DLEVELDB_ATOMIC_PRESENT"
> ++        PLATFORM_LDFLAGS="-pthread"
> ++        PLATFORM_CXXFLAGS="-std=c++0x"
> ++        PORT_FILE=port/port_posix.cc
> ++        CROSS_COMPILE=true
> ++        ;;

This should not be needed.

> +ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),)
> +# Dynamic library not required
> +LEVELDB_MAKE_ARGS += SHARED=
> +endif
> +
> +ifeq ($(BR2_STATIC_LIBS)$(BR2_SHARED_STATIC_LIBS),)
> +# Static library not required
> +LEVELDB_MAKE_ARGS += LIBRARY=
> +endif

I found this a bit odd to read, maybe:

# Disable the static library for shared only build
ifeq ($(BR2_SHARED_LIBS),y)
LEVELDB_MAKE_ARGS += LIBRARY=
endif

# Disable the shared library for static only build
ifeq ($(BR2_STATIC_LIBS),y)
LEVELDB_MAKE_ARGS += SHARED=
endif

is more readable.

> +ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),y)

Not needed, just call install unconditionally. It will install the
static library to $(TARGET_DIR), but that's not a problem, as it gets
removed afterwards by Buildroot anyway.

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH v5] leveldb: new package
  2015-01-10 10:19 ` Thomas Petazzoni
@ 2015-01-12 17:43   ` Steve James
  0 siblings, 0 replies; 3+ messages in thread
From: Steve James @ 2015-01-12 17:43 UTC (permalink / raw)
  To: buildroot

On Saturday 10 Jan 2015 10:19:50 Thomas Petazzoni wrote:
> Dear Steve James,
> 
> Thanks for this new version!
> 
--snip--
> > +Subject: [PATCH 1/1] facilitate integration into Buildroot:
> > +  - Add Buildroot TARGET_OS
> > +  - Allow flags from the environment
> > +  - Add install recipe
> 
> There are three different things being done, so it should be three
> separate patches, especially for upstream submission.

OK.

> However, I believe adding a Buildroot TARGET_OS is a mistake, and has
> no chance of being merged upstream. Buildroot is not an OS. It builds
> Linux based systems, so the existing TARGET_OS=Linux should work just
> fine for Buildroot.

Hmm. Yes TARGET_OS=Linux should be enough, but I failed to make this work with 
Leveldb's home-brew autoconf script. Unfortunately that was a while ago so I 
can't added any data here. It may just be that I was simply failing to pass 
the target compiler path to the configure script...

> 
> > +-CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
--snip--
> > ++override LIBS += $(PLATFORM_LIBS)
> 
> So this should be one patch.

OK, now submitted upstream.

> > + LIBOBJECTS = $(SOURCES:.cc=.o)
> > + MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o)
--snip--
> 
> This should be another patch.

OK, now submitted upstream.

> > ++    Buildroot)
> > ++        PLATFORM=OS_LINUX
> > ++        COMMON_FLAGS="$MEMCMP_FLAG -pthread -DOS_LINUX
> > -DLEVELDB_PLATFORM_POSIX -DLEVELDB_ATOMIC_PRESENT"
> > ++        PLATFORM_LDFLAGS="-pthread"
> > ++        PLATFORM_CXXFLAGS="-std=c++0x"
> > ++        PORT_FILE=port/port_posix.cc
> > ++        CROSS_COMPILE=true
> > ++        ;;
> 
> This should not be needed.

The configure-style script uses the usual method of compiling test programs to 
detect target features and libraries. The one exception to this method is when 
TARGET_OS=Android. In this case the compile options are set in-line in the 
case statement. What I have done is re-use the Android method for Buildroot.

Note that TARGET_OS does not appear in the code: PLATFORM is set to OS_LINUX 
when TARGET_OS=Linux|CYGWIN_*|Buildroot and it is PLATFORM that affects the 
code.

So something is needed somewhere to capture the correct combination of flags 
for use with Buildroot. My first attempt of putting them in leveldb.mk was 
ugly. At least my later proposed changes for Buildroot are simple, confined to 
a new case statement and follow the precedent set by Android.

That said, I will try once more to make the the configure script work as 
intended.

> > +ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),)
> > +# Dynamic library not required
> > +LEVELDB_MAKE_ARGS += SHARED=
> > +endif
> > +
> > +ifeq ($(BR2_STATIC_LIBS)$(BR2_SHARED_STATIC_LIBS),)
> > +# Static library not required
> > +LEVELDB_MAKE_ARGS += LIBRARY=
> > +endif
> 
> I found this a bit odd to read, maybe:
> 
> # Disable the static library for shared only build
> ifeq ($(BR2_SHARED_LIBS),y)
> LEVELDB_MAKE_ARGS += LIBRARY=
> endif
> 
> # Disable the shared library for static only build
> ifeq ($(BR2_STATIC_LIBS),y)
> LEVELDB_MAKE_ARGS += SHARED=
> endif
> 
> is more readable.

Agreed, that's better.

> > +ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
> 
> Not needed, just call install unconditionally. It will install the
> static library to $(TARGET_DIR), but that's not a problem, as it gets
> removed afterwards by Buildroot anyway.

OK.

Thanks,
Steve.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-12 17:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-09 17:09 [Buildroot] [PATCH v5] leveldb: new package Steve James
2015-01-10 10:19 ` Thomas Petazzoni
2015-01-12 17:43   ` Steve James

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.