libnatpmp: Switch to CMake 9236/head
authorRosen Penev <rosenp@gmail.com>
Sat, 15 Jun 2019 21:20:09 +0000 (14:20 -0700)
committerRosen Penev <rosenp@gmail.com>
Sat, 15 Jun 2019 21:52:06 +0000 (14:52 -0700)
Allows simplifying the Makefile. CMake patch is from upstream.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
libs/libnatpmp/Makefile
libs/libnatpmp/patches/001-install_declspec.patch [deleted file]
libs/libnatpmp/patches/010-cmake.patch [new file with mode: 0644]

index b7b52b4a60a98fbaaa4077a2009a689267328550..6e2dce29d38426412e5282efaa5296c407332d9c 100644 (file)
@@ -9,22 +9,25 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=libnatpmp
 PKG_VERSION:=20150609
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://miniupnp.tuxfamily.org/files
 PKG_HASH:=e1aa9c4c4219bc06943d6b2130f664daee213fb262fcb94dd355815b8f4536b0
-PKG_MAINTAINER:=Hauke Mehrtens <hauke@hauke-m.de>
-PKG_LICENSE:=BSD-3c
+
+PKG_MAINTAINER:=Rosen Penev <rosenp@gmail.com>
+PKG_LICENSE:=BSD-3-Clause
 PKG_LICENSE_FILES:=LICENSE
 
-PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+CMAKE_INSTALL:=1
 
 include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
 
 define Package/libnatpmp/Default
   TITLE:=NAT Port Mapping Protocol (NAT-PMP)
-  URL:=http://miniupnp.free.fr/libnatpmp.html
+  URL:=https://miniupnp.tuxfamily.org/libnatpmp.html
 endef
 
 define Package/libnatpmp/Default/description
@@ -39,6 +42,7 @@ define Package/libnatpmp
   SECTION:=libs
   CATEGORY:=Libraries
   TITLE+= library
+  ABI_VERSION:=1
 endef
 
 define Package/libnatpmp/description
@@ -60,22 +64,9 @@ define Package/natpmpc/description
   This package contains the natpmp client.
 endef
 
-MAKE_FLAGS += \
-       COPTS="$(TARGET_CFLAGS)" \
-       PREFIX="$(PKG_INSTALL_DIR)" \
-       OS="Linux"
-
-define Build/InstallDev
-       $(INSTALL_DIR) $(1)/usr/include
-       $(CP) $(PKG_INSTALL_DIR)/usr/include/declspec.h $(1)/usr/include/
-       $(CP) $(PKG_INSTALL_DIR)/usr/include/natpmp.h $(1)/usr/include/
-       $(INSTALL_DIR) $(1)/usr/lib
-       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnatpmp*.{so*,a} $(1)/usr/lib/
-endef
-
 define Package/libnatpmp/install
        $(INSTALL_DIR) $(1)/usr/lib
-       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/libnatpmp.so.* $(1)/usr/lib/
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnatpmp.so.* $(1)/usr/lib/
 endef
 
 define Package/natpmpc/install
diff --git a/libs/libnatpmp/patches/001-install_declspec.patch b/libs/libnatpmp/patches/001-install_declspec.patch
deleted file mode 100644 (file)
index d79dd3f..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/Makefile
-+++ b/Makefile
-@@ -56,7 +56,7 @@ else
- endif
- endif
--HEADERS = natpmp.h
-+HEADERS = natpmp.h declspec.h
- EXECUTABLES = testgetgateway natpmpc-shared natpmpc-static
diff --git a/libs/libnatpmp/patches/010-cmake.patch b/libs/libnatpmp/patches/010-cmake.patch
new file mode 100644 (file)
index 0000000..c3909ed
--- /dev/null
@@ -0,0 +1,53 @@
+--- /dev/null
++++ b/CMakeLists.txt
+@@ -0,0 +1,50 @@
++cmake_minimum_required(VERSION 2.8.12)
++
++if(POLICY CMP0048)
++      cmake_policy(SET CMP0048 NEW)
++endif()
++
++project(natpmp C)
++
++set (NATPMP_VERSION 20150609)
++set (NATPMP_API_VERSION 1)
++
++set (NATPMP_SOURCES
++        natpmp.c
++        getgateway.c
++)
++
++if (WIN32)
++    set (NATPMP_SOURCES ${NATPMP_SOURCES} wingettimeofday.c)
++endif (WIN32)
++
++# Library itself
++add_library(natpmp SHARED ${NATPMP_SOURCES})
++set_target_properties (natpmp PROPERTIES OUTPUT_NAME "natpmp")
++set_target_properties (natpmp PROPERTIES VERSION ${NATPMP_VERSION})
++set_target_properties (natpmp PROPERTIES SOVERSION ${NATPMP_API_VERSION})
++target_compile_definitions(natpmp PRIVATE -DENABLE_STRNATPMPERR)
++target_include_directories(natpmp PUBLIC ${CMAKE_CURRENT_LIST_DIR})
++
++if (WIN32)
++      target_link_libraries(natpmp PUBLIC ws2_32 Iphlpapi)
++      target_compile_definitions(natpmp PUBLIC -DNATPMP_STATICLIB)
++endif (WIN32)
++
++install(TARGETS natpmp
++      RUNTIME DESTINATION bin
++      LIBRARY DESTINATION lib${LIB_SUFFIX}
++      ARCHIVE DESTINATION lib${LIB_SUFFIX})
++
++# Executables
++add_executable(natpmpc natpmpc.c)
++target_link_libraries(natpmpc natpmp)
++
++install(FILES natpmpc DESTINATION bin)
++
++add_executable(testgetgateway
++      testgetgateway.c
++      getgateway.c)
++target_link_libraries(testgetgateway natpmp)
++
++install(FILES natpmp.h DESTINATION include)