summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2019-07-04 04:25:40 +0200
committerSlávek Banko <slavek.banko@axis.cz>2019-07-04 16:05:56 +0200
commitc1af0d24170f02f8c9d267258bdb7741426c9a39 (patch)
tree669aedd4856e8b9af2d36d202210122cfaf97df9
parentbf76e158be9f0db60eb55bcb5395ebc76389dc3f (diff)
downloadsmartcardauth-c1af0d24170f02f8c9d267258bdb7741426c9a39.tar.gz
smartcardauth-c1af0d24170f02f8c9d267258bdb7741426c9a39.zip
Conversion to the cmake building system.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r--CMakeLists.txt121
-rw-r--r--ConfigureChecks.cmake113
-rw-r--r--config.h.cmake11
-rw-r--r--src/CMakeLists.txt43
-rw-r--r--src/smartauthmon.cpp6
5 files changed, 294 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..90b7812
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,121 @@
+############################################
+# #
+# Improvements and feedbacks are welcome #
+# #
+# This file is released under GPL >= 3 #
+# #
+############################################
+
+
+cmake_minimum_required( VERSION 2.8 )
+
+
+#### general package setup
+
+project( smartcardauth )
+set( VERSION R14.0.7 )
+
+
+#### include essential cmake modules
+
+include( FindPkgConfig )
+include( CheckFunctionExists )
+include( CheckSymbolExists )
+include( CheckIncludeFile )
+include( CheckLibraryExists )
+include( CheckCSourceCompiles )
+
+
+#### include our cmake modules
+
+set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" )
+include( TDEMacros )
+
+
+##### setup install paths
+
+include( TDESetupPaths )
+tde_setup_paths( )
+
+
+##### optional stuff
+
+option( WITH_ALL_OPTIONS "Enable all optional support" OFF )
+option( WITH_GCC_VISIBILITY "Enable fvisibility and fvisibility-inlines-hidden" ${WITH_ALL_OPTIONS} )
+
+
+##### configure checks
+
+include( ConfigureChecks.cmake )
+
+
+###### global compiler settings
+
+add_definitions( -DHAVE_CONFIG_H -UQT_NO_ASCII_CAST )
+
+set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TQT_CXX_FLAGS}" )
+set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" )
+set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined" )
+
+
+##### directories
+
+add_subdirectory( src )
+
+
+##### write configure files
+
+configure_file( config.h.cmake config.h @ONLY )
+
+
+##### scriptor_standalone (executable)
+
+file( READ scriptor_standalone.pl SCRIPTOR )
+string( REPLACE "scriptor" "scriptor_standalone" SCRIPTOR_STANDALONE "${SCRIPTOR}" )
+file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/scriptor_standalone.pl "${SCRIPTOR_STANDALONE}" )
+
+add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/scriptor_standalone
+ COMMAND ${PERL_PAR_PACKER}
+ -a ${PERL_LIB_CHIPCARD}
+ -o ${CMAKE_CURRENT_BINARY_DIR}/scriptor_standalone
+ ${CMAKE_CURRENT_BINARY_DIR}/scriptor_standalone.pl
+ COMMENT "Build scriptor_standalone"
+)
+
+add_custom_target( scriptor_standalone-binary ALL
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scriptor_standalone
+)
+
+install(
+ PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/scriptor_standalone
+ DESTINATION ${BIN_INSTALL_DIR}
+)
+
+
+##### other data
+
+install(
+ DIRECTORY etc/
+ DESTINATION ${SYSCONF_INSTALL_DIR}
+)
+
+file( GLOB SCRIPTS usr/bin/* )
+
+install(
+ PROGRAMS ${SCRIPTS}
+ DESTINATION ${BIN_INSTALL_DIR}
+)
+
+file( GLOB INITRAMFS_HOOKS usr/share/initramfs-tools/hooks/* )
+
+install(
+ PROGRAMS ${INITRAMFS_HOOKS}
+ DESTINATION ${SHARE_INSTALL_PREFIX}/initramfs-tools/hooks
+)
+
+install(
+ DIRECTORY
+ usr/share/applications
+ usr/share/icons
+ DESTINATION ${SHARE_INSTALL_PREFIX}
+)
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
new file mode 100644
index 0000000..cd1b4ea
--- /dev/null
+++ b/ConfigureChecks.cmake
@@ -0,0 +1,113 @@
+###########################################
+# #
+# Improvements and feedback are welcome #
+# #
+# This file is released under GPL >= 3 #
+# #
+###########################################
+
+# required stuff
+find_package( TQt )
+
+tde_setup_architecture_flags( )
+
+include(TestBigEndian)
+test_big_endian(WORDS_BIGENDIAN)
+
+tde_setup_largefiles( )
+
+
+##### check for gcc visibility support
+
+if( WITH_GCC_VISIBILITY )
+ tde_setup_gcc_visibility( )
+endif( WITH_GCC_VISIBILITY )
+
+
+##### check for TDE binary directory
+
+if( NOT DEFINED TDE_PREFIX AND IS_DIRECTORY /opt/trinity )
+ set( TDE_PREFIX "/opt/trinity" )
+else( )
+ set( TDE_PREFIX "/usr" )
+endif( )
+
+if( NOT DEFINED KDECONFIG_EXECUTABLE )
+ find_program( KDECONFIG_EXECUTABLE
+ NAMES tde-config
+ HINTS "${TDE_PREFIX}/bin" ${BIN_INSTALL_DIR} )
+ if( NOT KDECONFIG_EXECUTABLE )
+ tde_message_fatal( "tde-config are NOT found." )
+ endif( NOT KDECONFIG_EXECUTABLE )
+endif( NOT DEFINED KDECONFIG_EXECUTABLE )
+
+if( NOT DEFINED TRINITY_BIN_PREFIX )
+ execute_process(
+ COMMAND ${KDECONFIG_EXECUTABLE} --install exe
+ OUTPUT_VARIABLE TDE_BIN_DIR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ set( TRINITY_BIN_PREFIX "${TDE_BIN_DIR}" CACHE PATH "" )
+ message( STATUS "Found TDE binaries: ${TRINITY_BIN_PREFIX}" )
+endif( )
+
+
+##### check for Perl
+
+find_package( PerlLibs )
+if( NOT PERLLIBS_FOUND )
+ tde_message_fatal( "Perl is required but not found on your system." )
+endif( )
+
+if( NOT DEFINED PERL_PAR_PACKER )
+ find_program( PERL_PAR_PACKER pp )
+ if( NOT PERL_PAR_PACKER )
+ tde_message_fatal( "Perl PAR packer (pp binary) is required but not found on your system." )
+ else( )
+ message( STATUS "Found Perl PAR packer: ${PERL_PAR_PACKER}" )
+ endif( )
+endif( )
+
+
+if( NOT DEFINED PERL_LIB_CHIPCARD )
+ find_path( PERL_DIR_CHIPCARD Chipcard
+ HINTS
+ ${PERL_SITELIB}
+ ${PERL_VENDORARCH}
+ ${PERL_VENDORLIB}
+ ${PERL_ARCHLIB}
+ ${PERL_PRIVLIB}
+ )
+ if( NOT PERL_DIR_CHIPCARD )
+ tde_message_fatal( "libpcsc for perl is required but not found on your system." )
+ endif( )
+ set( PERL_LIB_CHIPCARD "${PERL_DIR_CHIPCARD}/Chipcard" CACHE PATH "" )
+ message( STATUS "Found PCSC-perl: ${PERL_LIB_CHIPCARD}" )
+endif( )
+
+
+##### check for crypt
+set( CRYPT_LIBRARY crypt )
+check_library_exists( ${CRYPT_LIBRARY} crypt "" HAVE_CRYPT )
+if( NOT HAVE_CRYPT )
+ unset( CRYPT_LIBRARY )
+ check_function_exists( crypt LIBC_HAVE_CRYPT )
+ if( LIBC_HAVE_CRYPT )
+ set( HAVE_CRYPT 1 CACHE INTERNAL "" FORCE )
+ endif( LIBC_HAVE_CRYPT )
+endif( NOT HAVE_CRYPT )
+
+
+##### check for pam
+
+if( NOT DEFINED PAM_FOUND )
+ find_path( PAM_INCLUDE_DIR NAMES security/pam_appl.h )
+ find_library( PAM_LIBRARY pam )
+ if( PAM_INCLUDE_DIR AND PAM_LIBRARY )
+ set( PAM_FOUND 1 CACHE BOOL "" )
+ set( PAM_LIBRARIES ${PAM_LIBRARY} ${CMAKE_DL_LIBS} CACHE INTERNAL "" )
+ message( STATUS "Found pam: ${PAM_LIBRARY}" )
+ else( )
+ tde_message_fatal( "pam is required but not found on your system." )
+ endif( )
+endif( )
diff --git a/config.h.cmake b/config.h.cmake
new file mode 100644
index 0000000..76f11c4
--- /dev/null
+++ b/config.h.cmake
@@ -0,0 +1,11 @@
+#define VERSION "@VERSION@"
+
+// Defined if you have fvisibility and fvisibility-inlines-hidden support.
+#cmakedefine __KDE_HAVE_GCC_VISIBILITY 1
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+ significant byte first (like Motorola and SPARC, unlike Intel). */
+#cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@
+
+/* Define path to Trinity binaries */
+#cmakedefine TRINITY_BIN_PREFIX "@TRINITY_BIN_PREFIX@/"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..474ac2d
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,43 @@
+include_directories(
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### smartauthckpasswd (executable)
+
+tde_add_executable( smartauthckpasswd
+
+ SOURCES
+ ckpasswd.c
+ xmalloc.c
+ messages.c
+ LINK
+ ${CRYPT_LIBRARY}
+ ${PAM_LIBRARIES}
+
+ DESTINATION ${BIN_INSTALL_DIR}
+)
+
+
+##### smartauthmon (executable)
+
+tde_add_executable( smartauthmon
+
+ SOURCES
+ smartauthmon.cpp
+ ckpass.c
+ xmalloc.c
+ messages.c
+ LINK
+ ${CRYPT_LIBRARY}
+ ${PAM_LIBRARIES}
+ ${TQT_LIBRARIES}
+
+ DESTINATION ${BIN_INSTALL_DIR}
+)
diff --git a/src/smartauthmon.cpp b/src/smartauthmon.cpp
index ea49442..cb93aea 100644
--- a/src/smartauthmon.cpp
+++ b/src/smartauthmon.cpp
@@ -14,6 +14,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#define _XOPEN_SOURCE 500
#include <stdio.h>
#include <stdlib.h>
@@ -42,7 +46,9 @@
#define SECURE_DIRECTORY_PATH "/tmp/smartauth"
// The Trinity binary directory
+#ifndef TRINTIY_BIN_PREFIX
#define TRINITY_BIN_PREFIX "/opt/trinity/bin/"
+#endif
// Some internal constants
#define CREATE_LIFE_CYCLE "01"