Description: Use cmake as build system
Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
Bug-Debian: https://bugs.debian.org/912124
Last-Update: 2018-11-25

--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 3.7)
+project(netkit-bootparamd)
+
+set(BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin")
+set(SBIN_DIR "${CMAKE_INSTALL_PREFIX}/sbin")
+set(MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man")
+
+add_subdirectory(rpc.bootparamd)
--- /dev/null
+++ b/rpc.bootparamd/CMakeLists.txt
@@ -0,0 +1,89 @@
+include_directories(
+    BEFORE
+    ${CMAKE_CURRENT_BINARY_DIR}
+)
+
+add_executable(
+    rpc.bootparamd
+
+    bootparam_prot_svc.c
+    bootparam_prot_xdr.c
+    rpc.bootparamd.c
+    main.c
+
+    bootparam_prot.h
+)
+add_executable(
+    callbootd
+
+    callbootd.c
+    bootparam_prot_clnt.c
+    bootparam_prot_xdr.c
+
+    bootparam_prot.h
+)
+
+install(
+    TARGETS rpc.bootparamd
+    DESTINATION ${SBIN_DIR}
+)
+install(
+    FILES bootparamd.8
+    DESTINATION ${MAN_DIR}/man8/
+    RENAME rpc.bootparamd.8
+)
+install(
+    CODE "execute_process( \
+        COMMAND ${CMAKE_COMMAND} -E create_symlink \
+        rpc.bootparamd.8 \$ENV{DESTDIR}${MAN_DIR}/man8/tftpd.8 \
+    )"
+)
+
+add_custom_command(
+    COMMENT "Creating bootparam_prot.x"
+    OUTPUT bootparam_prot.x
+    COMMAND
+        ${CMAKE_COMMAND} -E copy
+        ${CMAKE_CURRENT_SOURCE_DIR}/bootparam_prot.x.real bootparam_prot.x
+    DEPENDS bootparam_prot.x.real
+)
+
+add_custom_command(
+    COMMENT "Creating bootparam_prot.h"
+    OUTPUT bootparam_prot.h
+    COMMAND rpcgen
+    ARGS
+        -h bootparam_prot.x
+        -o bootparam_prot.h
+    DEPENDS bootparam_prot.x
+)
+
+add_custom_command(
+    COMMENT "Creating bootparam_prot_xdr.c"
+    OUTPUT bootparam_prot_xdr.c
+    COMMAND rpcgen
+    ARGS
+        -c bootparam_prot.x
+        -o ${CMAKE_CURRENT_BINARY_DIR}/bootparam_prot_xdr.c
+    DEPENDS bootparam_prot.x
+)
+
+add_custom_command(
+    COMMENT "Creating bootparam_prot_clnt.c"
+    OUTPUT bootparam_prot_clnt.c
+    COMMAND rpcgen
+    ARGS
+        -l bootparam_prot.x
+        -o bootparam_prot_clnt.c
+    DEPENDS bootparam_prot.x
+)
+
+add_custom_command(
+    COMMENT "Creating bootparam_prot_svc.c"
+    OUTPUT bootparam_prot_svc.c
+    COMMAND rpcgen
+    ARGS
+        -m bootparam_prot.x
+        -o bootparam_prot_svc.c
+    DEPENDS bootparam_prot.x
+)
