[OpenWrt-Devel] [PATCH libnl-tiny 2/5] convert into CMake project

Petr Štetiar ynezz at true.cz
Mon Oct 21 05:36:39 EDT 2019


Aligning it with other C based projects.

Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
 CMakeLists.txt   | 38 ++++++++++++++++++++++++++++++++++++++
 Makefile         | 17 -----------------
 libnl-tiny.pc    | 10 ----------
 libnl-tiny.pc.in | 10 ++++++++++
 4 files changed, 48 insertions(+), 27 deletions(-)
 create mode 100644 CMakeLists.txt
 delete mode 100644 Makefile
 delete mode 100644 libnl-tiny.pc
 create mode 100644 libnl-tiny.pc.in

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 000000000000..4924586e893c
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,38 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
+
+PROJECT(libnl-tiny C)
+INCLUDE(GNUInstallDirs)
+
+INCLUDE_DIRECTORIES(include)
+
+ADD_DEFINITIONS(-Wall -Werror)
+
+ADD_LIBRARY(nl-tiny SHARED
+	attr.c
+	cache.c
+	cache_mngt.c
+	error.c
+	genl.c
+	genl_ctrl.c
+	genl_family.c
+	genl_mngt.c
+	handlers.c
+	msg.c
+	nl.c
+	object.c
+	socket.c
+	unl.c
+)
+
+CONFIGURE_FILE(
+	"${CMAKE_CURRENT_SOURCE_DIR}/libnl-tiny.pc.in"
+	"${CMAKE_CURRENT_BINARY_DIR}/libnl-tiny.pc"
+	@ONLY
+)
+
+INSTALL(TARGETS nl-tiny LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+INSTALL(
+	DIRECTORY ${CMAKE_SOURCE_DIR}/include/
+	DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libnl-tiny
+	FILES_MATCHING PATTERN "*.h"
+)
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 6f37160a8c35..000000000000
--- a/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-CC=gcc
-WFLAGS=-Wall
-CFLAGS=-O2
-INCLUDES=-Iinclude
-
-LIBNAME=libnl-tiny.so
-
-all: $(LIBNAME)
-
-%.o: %.c
-	$(CC) $(WFLAGS) -c -o $@ $(INCLUDES) $(CFLAGS) $<
-
-LIBNL_OBJ=nl.o handlers.o msg.o attr.o cache.o cache_mngt.o object.o socket.o error.o
-GENL_OBJ=genl.o genl_family.o genl_ctrl.o genl_mngt.o unl.o
-
-$(LIBNAME): $(LIBNL_OBJ) $(GENL_OBJ)
-	$(CC) $(CFLAGS) -Wl,-Bsymbolic-functions -shared -o $@ $^
diff --git a/libnl-tiny.pc b/libnl-tiny.pc
deleted file mode 100644
index af79cd301e23..000000000000
--- a/libnl-tiny.pc
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=/usr
-exec_prefix=/usr
-libdir=${exec_prefix}/lib
-includedir=${prefix}/include/libnl-tiny
-
-Name: libnl-tiny
-Description: Convenience library for netlink sockets
-Version: 2.0
-Libs: -L${libdir} -lnl-tiny
-Cflags: -I${includedir}
diff --git a/libnl-tiny.pc.in b/libnl-tiny.pc.in
new file mode 100644
index 000000000000..691ba8261b28
--- /dev/null
+++ b/libnl-tiny.pc.in
@@ -0,0 +1,10 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}
+libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/libnl-tiny
+
+Name: libnl-tiny
+Description: Convenience library for netlink sockets
+Version: 2.0
+Libs: -L${libdir} -lnl-tiny
+Cflags: -I${includedir}

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list