protobuf: Switch to CMake
authorRosen Penev <rosenp@gmail.com>
Fri, 13 Sep 2019 02:33:03 +0000 (19:33 -0700)
committerRosen Penev <rosenp@gmail.com>
Mon, 16 Sep 2019 23:34:23 +0000 (16:34 -0700)
Allows PKG_BUILD_PARALLEL to work properly.

Replaced InstallDev section with CMAKE_INSTALL.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
libs/protobuf/Makefile

index 49d6d74f1946a1d872c2dacfa217ea601311f831..fb2d84fddd8851b51bc5f6260797f64758e5dd95 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=protobuf
 PKG_VERSION:=3.8.0
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-cpp-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://github.com/google/protobuf/releases/download/v$(PKG_VERSION)
@@ -19,12 +19,14 @@ PKG_MAINTAINER:=Ken Keys <kkeys@caida.org>
 PKG_LICENSE:=BSD-3-Clause
 PKG_LICENSE_FILES:=LICENSE
 
-PKG_BUILD_DEPENDS:=protobuf/host
+HOST_BUILD_PARALLEL:=1
 PKG_BUILD_PARALLEL:=1
-PKG_INSTALL:=1
+CMAKE_INSTALL:=1
+CMAKE_SOURCE_SUBDIR:=cmake
 
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/host-build.mk
+include $(INCLUDE_DIR)/cmake.mk
 
 define Package/protobuf/Default
   SECTION:=libs
@@ -64,20 +66,24 @@ This package provides the libprotobuf-lite library.
 
 endef
 
-CONFIGURE_ARGS += --with-protoc=$(STAGING_DIR_HOSTPKG)/bin/protoc
+CMAKE_HOST_OPTIONS += \
+       -Dprotobuf_BUILD_PROTOC_BINARIES=ON \
+       -Dprotobuf_BUILD_TESTS=OFF
 
-define Build/InstallDev
-       $(INSTALL_DIR) \
-               $(1)/usr/lib \
-               $(1)/usr/include
+CMAKE_OPTIONS += \
+       -Dprotobuf_BUILD_PROTOC_BINARIES=ON \
+       -Dprotobuf_BUILD_TESTS=OFF \
+       -Dprotobuf_WITH_ZLIB=ON \
+       -DBUILD_SHARED_LIBS=ON
 
-       $(CP) \
-               $(PKG_INSTALL_DIR)/usr/include/* \
-               $(1)/usr/include/
+TARGET_LDFLAGS += -latomic
 
-       $(CP) \
-               $(PKG_INSTALL_DIR)/usr/lib/* \
-               $(1)/usr/lib/
+define Build/InstallDev
+       $(call Build/InstallDev/cmake,$(1))
+       $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/protobuf.pc
+       $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/protobuf.pc
+       $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/protobuf-lite.pc
+       $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/protobuf-lite.pc
 endef
 
 define Package/protobuf-lite/install