Skip to contentSkip to conversation

leveldb: new package

PATCH Superseded Steve James 2 participants 2 messages Dec 24, 2014 1 message not in the archive

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v3 1/1 leveldb: new package

Quoted 5 lines · On Wednesday 24 Dec 2014 10:55:59 Steve James wrote:

Adds new package: leveldb

LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.

--snip--

Review

Quoted 5 lines
(quoted diff) +5 -0
+
+TARGET_CFLAGS += $(LEVELDB_CFLAGS)
+TARGET_CXXFLAGS += $(LEVELDB_CFLAGS)
+TARGET_MAKE_ARGS += $(LEVELDB_MAKE_ARGS)
+

--snip--

Hang on, have I done something evil there? I'm working on another package now and these flags are leaking into it. Looks like apending to TARGET_CFLAGS is a no-no. So the rule to follow is: all Make macros should be scoped with the package name. What I wanted to do was add to the value of CFLAGS as passed by TARGET_CONFIGURE_OPTS. I'm looking for the right way to do that...

Steve.

#2 lore raw

PATCH v3 1/1 leveldb: new package

In reply to a message not in the archive

Steve, All,

On 2014-12-24 10:55 +0000, Steve James spake thusly:

Quoted 7 lines

Adds new package: leveldb

LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.

Cc "Yann E. MORIN" <[email protected]>

[--SNIP--]

Quoted 20 lines
package/leveldb/leveldb.mk new file +14 -0
new file mode 100644
index 0000000..0a4a079
@@ -0,0 +1,59 @@
+################################################################################
+#
+# 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
+
+# The leveldb build has some basic autoconf-like behaviour which assumes the

package/leveldb/leveldb.mk line 24

Quoted 10 lines
package/leveldb/leveldb.mk new file +10 -0
+# target is the host. We hard-wire it to the right outcome for Buildroot
+# irrespective of the host.
+LEVELDB_MAKE_ARGS = TARGET_OS=Linux
+
+# Default leveldb compiler flags
+LEVELDB_CFLAGS = -DNDEBUG -I. -I./include -std=c++0x -pthread -DOS_LINUX -DLEVELDB_PLATFORM_POSIX
+
+TARGET_CFLAGS += $(LEVELDB_CFLAGS)
+TARGET_CXXFLAGS += $(LEVELDB_CFLAGS)
+TARGET_MAKE_ARGS += $(LEVELDB_MAKE_ARGS)

As you have already noticed, this is wrong: variables in Makefiles have a global scope, so what you are doign here is simply overwriting those variables for all packages.

What you want to do instead is:

package/leveldb/leveldb.mk line 27

Quoted 3 lines
package/leveldb/leveldb.mk new file +3 -0
+define LEVELDB_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) $(TARGET_MAKE_ARGS)
+endef
    define LEVELDB_BUILD_CMDS
        $(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) \
            CFLAGS="$(TARGET_CFLAGS) $(LEVELDB_CFLAGS)" \
            CXXFLAGS="$(TARGET_CXXFLAGS) $(LEVELDB_CFLAGS)" \
            TARGET_OS=Linux
    endef

(and get rid of no longer needed variables, of course.)

Regards,
Yann E. MORIN.

Quoted 33 lines
package/leveldb/leveldb.mk new file +30 -0
+ifeq ($(BR2_STATIC_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
+define LEVELDB_INSTALL_STAGING_CMDS_STATIC
+	$(INSTALL) -D -m 0644 $(@D)/libleveldb.a $(STAGING_DIR)/usr/lib
+endef
+endif
+
+ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
+define LEVELDB_INSTALL_STAGING_CMDS_SHARED
+	$(INSTALL) -D -m 0755 $(@D)/libleveldb.so.1.18 $(STAGING_DIR)/usr/lib
+	$(HOSTLN) -sf libleveldb.so.1.18 $(STAGING_DIR)/usr/lib/libleveldb.so.1
+	$(HOSTLN) -sf libleveldb.so.1.18 $(STAGING_DIR)/usr/lib/libleveldb.so
+endef
+endif
+
+define LEVELDB_INSTALL_STAGING_CMDS
+	$(LEVELDB_INSTALL_STAGING_CMDS_STATIC)
+	$(LEVELDB_INSTALL_STAGING_CMDS_SHARED)
+	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include/leveldb
+	$(INSTALL) -D -m 0644 $(@D)/include/leveldb/*.h $(STAGING_DIR)/usr/include/leveldb
+endef
+
+ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
+define LEVELDB_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 0755 $(@D)/libleveldb.so.1.18 $(TARGET_DIR)/usr/lib
+	$(HOSTLN) -sf libleveldb.so.1.18 $(TARGET_DIR)/usr/lib/libleveldb.so.1
+	$(HOSTLN) -sf libleveldb.so.1.18 $(TARGET_DIR)/usr/lib/libleveldb.so
+endef
+endif
+
+$(eval $(generic-package))
Signature · 1 line
1.7.10.4
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'