convert into CMake project
authorPetr Štetiar <ynezz@true.cz>
Fri, 4 Oct 2019 14:06:01 +0000 (16:06 +0200)
committerPetr Štetiar <ynezz@true.cz>
Tue, 29 Oct 2019 21:14:03 +0000 (22:14 +0100)
Aligning it with other C based projects.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
CMakeLists.txt [new file with mode: 0644]
Makefile [deleted file]
libnl-tiny.pc [deleted file]
libnl-tiny.pc.in [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a81727d
--- /dev/null
@@ -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 (file)
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 (file)
index af79cd3..0000000
+++ /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 (file)
index 0000000..691ba82
--- /dev/null
@@ -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}