Description: Use cmake as build system
Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
Bug-Debian: https://bugs.debian.org/912132
Last-Update: 2019-02-24

--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,34 @@
+cmake_minimum_required(VERSION 3.7)
+project(netkit-telnet-ssl)
+
+set(BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin")
+set(SBIN_DIR "${CMAKE_INSTALL_PREFIX}/sbin")
+set(MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man")
+
+set(USE_GLIBC 1)
+
+set(
+    CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
+    -D_GNU_SOURCE \
+    -Ddebian \
+    -DACCEPT_USERVAR \
+    -DSSL_LOG_FILE='\"/var/tmp/telnetd.log\"' \
+    -Wall \
+    -Wno-trigraphs \
+")
+set(
+    CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
+    -D_GNU_SOURCE \
+    -Ddebian \
+    -DACCEPT_USERVAR \
+    -DSSL_LOG_FILE='\"/var/tmp/telnetd.log\"' \
+    -Wall \
+    -Wno-trigraphs \
+")
+
+find_library(USE_TERMCAP ncurses REQUIRED)
+
+add_subdirectory(telnet)
+add_subdirectory(telnetd)
+add_subdirectory(telnetlogin)
+add_subdirectory(libtelnet)
--- /dev/null
+++ b/telnet/CMakeLists.txt
@@ -0,0 +1,49 @@
+
+include_directories(
+    BEFORE
+    /usr/include/openssl
+    ..
+)
+
+set(
+    CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
+    -DUSE_TERMIO \
+    -DKLUDGELINEMODE \
+    -DAUTHENTICATE \
+    -DUSE_SSL \
+")
+
+add_executable(
+    telnet-ssl
+    commands.cc
+    environ.cc
+    genget.cc
+    main.cc
+    netlink.cc
+    network.cc
+    ring.cc
+    sys_bsd.cc
+    telnet.cc
+    terminal.cc
+    tn3270.cc
+    utilities.cc
+    glue.cc
+    glue2.cc
+)
+target_link_libraries(
+    telnet-ssl
+    crypto
+    curses
+    ssl
+    libtelnet
+)
+install(
+    TARGETS telnet-ssl
+    DESTINATION ${BIN_DIR}
+)
+
+install(
+    FILES telnet.1
+    DESTINATION ${MAN_DIR}/man1/
+    RENAME telnet-ssl.1
+)
--- /dev/null
+++ b/telnetd/CMakeLists.txt
@@ -0,0 +1,54 @@
+
+include_directories(
+    BEFORE
+    /usr/include/openssl
+    ..
+)
+
+set(CMAKE_C_FLAGS "\
+    ${CMAKE_C_FLAGS} \
+    -DISSUE_FILE='\"/etc/issue.net\"' \
+    -DPARANOID_TTYS \
+    -DNO_REVOKE \
+    -DKLUDGELINEMODE \
+    -DDIAGNOSTICS \
+    -DAUTHENTICATE \
+    -DLOGIN_WRAPPER='\"/usr/lib/telnetlogin\"' \
+    -DUSE_SSL \
+")
+
+add_executable(
+    in.telnetd
+    global.c
+    setproctitle.c
+    slc.c
+    state.c
+    sys_term.c
+    telnetd.c
+    termstat.c
+    utility.c
+)
+target_link_libraries(
+    in.telnetd
+    ncurses
+    util
+    ssl
+    crypto
+    crypt
+    libtelnet
+)
+install(
+    TARGETS in.telnetd
+    DESTINATION ${SBIN_DIR}
+)
+
+install(
+    FILES issue.net.5
+    DESTINATION ${MAN_DIR}/man5/
+)
+
+install(
+    FILES telnetd.8
+    DESTINATION ${MAN_DIR}/man8/
+    RENAME in.telnetd.8
+)
--- /dev/null
+++ b/telnetlogin/CMakeLists.txt
@@ -0,0 +1,14 @@
+
+add_executable(
+    telnetlogin
+    telnetlogin.c
+)
+install(
+    TARGETS telnetlogin
+    DESTINATION ${BIN_DIR}
+)
+
+install(
+    FILES telnetlogin.8
+    DESTINATION ${MAN_DIR}/man8/
+)
--- /dev/null
+++ b/libtelnet/CMakeLists.txt
@@ -0,0 +1,22 @@
+
+include_directories(
+    BEFORE
+    /usr/include/openssl
+    .
+)
+
+set(
+    CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
+    -DUSE_TERMIO \
+    -DKLUDGELINEMODE \
+    -DAUTHENTICATE \
+    -DUSE_SSL \
+")
+
+add_library(
+    libtelnet
+    auth.c
+    misc.c
+    ssl.c
+    sslapp.c
+)
