From 050bb5c4431b70e91a869039c8930d81970e047f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20=C5=A0tetiar?= Date: Fri, 4 Oct 2019 16:06:01 +0200 Subject: [PATCH] convert into CMake project MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Aligning it with other C based projects. Signed-off-by: Petr Å tetiar --- CMakeLists.txt | 39 +++++++++++++++++++++++++++++++++++++++ Makefile | 17 ----------------- libnl-tiny.pc | 10 ---------- libnl-tiny.pc.in | 10 ++++++++++ 4 files changed, 49 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 0000000..a81727d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,39 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 3.0) + +PROJECT(libnl-tiny C) +INCLUDE(GNUInstallDirs) + +INCLUDE_DIRECTORIES(include) + +ADD_DEFINITIONS(-Wall -Werror) +STRING(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") + +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 6f37160..0000000 --- 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 af79cd3..0000000 --- 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 0000000..691ba82 --- /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} -- 2.30.2