iperf3: add shared libiperf library and link iperf3 dynamically
authorNick Hainke <vincent@systemli.org>
Sun, 11 Sep 2022 12:31:33 +0000 (14:31 +0200)
committerRosen Penev <rosenp@gmail.com>
Wed, 14 Sep 2022 09:37:44 +0000 (02:37 -0700)
Add library for creating own functions with iperf3 functionality.
Example: https://github.com/esnet/iperf/blob/master/examples/mis.c
This library is needed by python3-iperf3.

Build iperf3 binary with dynamically linked libiperf3. However, still
build iperf3-ssl as static binary due to a lack of shipping two libiperf
versions.

Signed-off-by: Nick Hainke <vincent@systemli.org>
net/iperf3/Makefile

index de17f81c2e1a1929629de06d8dc37947b4b60d75..db3b6e432646338682c702ededb119e4526c88f0 100644 (file)
@@ -32,6 +32,7 @@ define Package/iperf3/default
   CATEGORY:=Network
   TITLE:=Internet Protocol bandwidth measuring tool
   URL:=https://github.com/esnet/iperf
+  DEPENDS:=+libiperf3
 endef
 
 define Package/iperf3
@@ -43,14 +44,20 @@ define Package/iperf3-ssl
 $(call Package/iperf3/default)
   TITLE+= with iperf_auth support
   VARIANT:=ssl
-  DEPENDS:= +libopenssl
+  DEPENDS+=+libopenssl
+endef
+
+define Package/libiperf3
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Internet Protocol bandwidth measuring library
+  URL:=https://github.com/esnet/iperf
 endef
 
 TARGET_CFLAGS += -D_GNU_SOURCE
-CONFIGURE_ARGS += --disable-shared
 
 ifeq ($(BUILD_VARIANT),ssl)
-       CONFIGURE_ARGS += --with-openssl="$(STAGING_DIR)/usr"
+       CONFIGURE_ARGS += --with-openssl="$(STAGING_DIR)/usr" --disable-shared
 else
        CONFIGURE_ARGS += --without-openssl
 endif
@@ -63,6 +70,17 @@ define Package/iperf3/description
  characteristics.
 endef
 
+define Package/libiperf3/description
+ Libiperf is a library providing an API for iperf3 functionality.
+endef
+
+define Build/InstallDev
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(INSTALL_DIR) $(1)/usr/include
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiperf.* $(1)/usr/lib/
+       $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+endef
+
 # autoreconf fails if the README file isn't present
 define Build/Prepare
        $(call Build/Prepare/Default)
@@ -79,5 +97,11 @@ define Package/iperf3-ssl/install
        $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/iperf3 $(1)/usr/bin/
 endef
 
+define Package/iperf3/install
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiperf.so.* $(1)/usr/lib
+endef
+
 $(eval $(call BuildPackage,iperf3))
 $(eval $(call BuildPackage,iperf3-ssl))
+$(eval $(call BuildPackage,libiperf3))