summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wong <mark@2ndQuadrant.com>2018-05-20 17:38:45 -0700
committerMark Wong <mark@2ndQuadrant.com>2018-06-08 08:21:56 -0700
commit2ea613fa5e07bebf8950d565f613c69bf187ae04 (patch)
tree91fc4c1b4b321ac681246407a16d43161cf000fe
parentaa8e8442e06c2b23f313bf6a2a01a916be1abcab (diff)
Add cmake files
-rw-r--r--.gitignore2
-rw-r--r--CMakeLists.txt287
-rw-r--r--HISTORY4
-rw-r--r--INSTALL64
-rw-r--r--config.h.in23
5 files changed, 343 insertions, 37 deletions
diff --git a/.gitignore b/.gitignore
index 2579d1d..f37973b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@
.deps
Makefile
config.h
+!config.h.in
depcomp
pg_top
pg_top.1
@@ -17,3 +18,4 @@ tags
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
+install_manifest.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..145b6f8
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,287 @@
+cmake_minimum_required(VERSION 2.8)
+
+include(CheckFunctionExists)
+include(CheckLibraryExists)
+include(CheckIncludeFiles)
+include(CheckCSourceCompiles)
+
+project(pg_top C)
+
+set(PROJECT_VERSION_MAJOR 4)
+set(PROJECT_VERSION_MINOR 0)
+set(PROJECT_VERSION_PATCH "devel")
+set(PROJECT_VERSION
+ ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
+
+set(CMAKE_C_FLAGS "-Wall")
+
+# Handle cmake -D command line options
+
+if (DESTDIR)
+ set(INSTALLDEST ${DESTDIR})
+endif (DESTDIR)
+
+if (NOT DEFINED ENABLE_COLOR)
+ set(ENABLE_COLOR 1)
+elseif(ENABLE_COLOR EQUAL 0)
+ unset(ENABLE_COLOR)
+else()
+ set(ENABLE_COLOR "${ENABLE_COLOR}")
+endif (NOT DEFINED ENABLE_COLOR)
+
+if (NOT DEFINED ENABLE_KILL)
+ set(ENABLE_KILL 1)
+elseif(ENABLE_KILL EQUAL 0)
+ unset(ENABLE_KILL)
+else()
+ set(ENABLE_KILL "${ENABLE_KILL}")
+endif (NOT DEFINED ENABLE_KILL)
+
+# Determine which machine module to build
+
+execute_process(
+ COMMAND uname -s
+ OUTPUT_VARIABLE MACHINE
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+string(TOLOWER "${MACHINE}" MACHINE)
+message("-- machine - ${MACHINE}")
+
+# Some machines modules need additional information.
+
+execute_process(
+ COMMAND uname -r
+ OUTPUT_VARIABLE OSREV
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+string(REGEX MATCH "^([0-9]*)" OSMAJOR "${OSREV}")
+string(REPLACE "." "" OSREV "${OSREV}")
+string(REPLACE "-" "" OSREV "${OSREV}")
+string(REPLACE "_" "" OSREV "${OSREV}")
+
+# Get PostgreSQL include and library directories.
+
+execute_process(
+ COMMAND pg_config --includedir
+ OUTPUT_VARIABLE PGINCLUDEDIR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+message("-- pg_config --includedir - ${PGINCLUDEDIR}")
+if(PGINCLUDEDIR)
+ set(PGINCLUDE "-I${PGINCLUDEDIR}")
+endif(PGINCLUDEDIR)
+
+execute_process(
+ COMMAND pg_config --libdir
+ OUTPUT_VARIABLE PGLIBDIR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+message("-- pg_config --libdir - ${PGLIBDIR}")
+
+# Check for include files.
+
+check_include_files("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
+
+check_include_files("string.h" HAVE_STRING_H)
+check_include_files("strings.h" HAVE_STRINGS_H)
+check_include_files("sys/time.h;time.h" TIME_WITH_SYS_TIME)
+check_include_files("sys/time.h" HAVE_SYS_TIME_H)
+check_include_files("sys/resource.h" HAVE_SYS_RESOURCE_H)
+check_include_files("unistd.h" HAVE_UNISTD_H)
+
+# Check for library functions.
+
+check_function_exists(getopt HAVE_GETOPT)
+check_function_exists(memcpy HAVE_MEMCPY)
+check_function_exists(setpriority HAVE_SETPRIORITY)
+check_function_exists(sigaction HAVE_SIGACTION)
+check_function_exists(sighold HAVE_SIGHOLD)
+check_function_exists(sigprocmask HAVE_SIGPROCMASK)
+check_function_exists(sigrelse HAVE_SIGRELSE)
+check_function_exists(snprintf HAVE_SNPRINTF)
+check_function_exists(strchr HAVE_STRCHR)
+check_function_exists(strerror HAVE_STRERROR)
+
+# Test return type of signal().
+
+check_c_source_compiles("
+#include <sys/types.h>
+#include <signal.h>
+int main () { return *(signal (0, 0)) (0) == 1; return 0; }
+" SIGNAL_RETURN)
+if(SIGNAL_RETURN)
+ set(RETSIGTYPE "int")
+else()
+ set(RETSIGTYPE "void")
+endif(SIGNAL_RETURN)
+
+# Test whether time_t is defined.
+
+check_c_source_compiles("
+#include <sys/types.h>
+int main () { time_t a; return 0; }
+" TIME_T_DEFINED)
+if(NOT TIME_T_DEFINED)
+ set(time_t "long")
+endif(NOT TIME_T_DEFINED)
+
+# Build sigdesc.h file.
+
+foreach(f
+ /usr/include/signal.h
+ /usr/include/sys/signal.h
+ /usr/include/sys/iso/signal_iso.h
+ /usr/include/bits/signum.h
+ /usr/include/asm-generic/signal.h
+ )
+ execute_process(
+ COMMAND grep SIGKILL ${f}
+ RESULT_VARIABLE CHECK_FOR_SIGKILL
+ OUTPUT_QUIET ERROR_QUIET
+ )
+ if(CHECK_FOR_SIGKILL EQUAL 0)
+ execute_process(
+ COMMAND awk -f sigconv.awk ${f}
+ OUTPUT_FILE sigdesc.h
+ )
+ break()
+ endif(CHECK_FOR_SIGKILL EQUAL 0)
+endforeach(f)
+
+# Build config.h header.
+
+configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/config.h
+)
+
+# Build manual page with appropriate machine specific notes.
+
+configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/pg_top.1.in
+ ${CMAKE_CURRENT_BINARY_DIR}/pg_top.1
+)
+if(EXISTS "machine/m_${MACHINE}.man")
+ execute_process(
+ COMMAND cat machine/m_${MACHINE}.man
+ OUTPUT_VARIABLE MANUAL_SUPPLIMENT
+ )
+ file(APPEND pg_top.1 "${MANUAL_SUPPLIMENT}")
+endif(EXISTS "machine/m_${MACHINE}.man")
+file(APPEND pg_top.1 "${MANUAL_SUPPLIMENT}")
+
+# Set appropriate compile flags.
+
+set_source_files_properties(
+ color.c
+ commands.c
+ display.c
+ pg.c
+ pg_top.c
+ screen.c
+ sprompt.c
+ username.c
+ utils.c
+ PROPERTIES COMPILE_FLAGS "${PGINCLUDE}"
+)
+set_source_files_properties(
+ version.c
+ PROPERTIES COMPILE_FLAGS
+ "-DPACKAGE_VERSION=\\\"${PROJECT_VERSION}\\\" ${PGINCLUDE}"
+)
+set_source_files_properties(
+ machine/m_common.c
+ machine/m_remote.c
+ machine/m_${MACHINE}.c
+ PROPERTIES COMPILE_FLAGS "-I${CMAKE_HOME_DIRECTORY} ${PGINCLUDE}"
+)
+
+add_executable(
+ ${PROJECT_NAME}
+ color.c
+ commands.c
+ display.c
+ getopt.c
+ screen.c
+ sprompt.c
+ pg.c
+ pg_top.c
+ username.c
+ utils.c
+ version.c
+ machine/m_remote.c
+ machine/m_common.c
+ machine/m_${MACHINE}.c
+)
+
+# Determine appropriate linker flags.
+
+find_library(LIBPQ pq PATHS ${PGLIBDIR})
+if(LIBPQ)
+ target_link_libraries(${PROJECT_NAME} ${LIBPQ})
+endif(LIBPQ)
+
+find_library(LIBM m)
+if(LIBM)
+ target_link_libraries(${PROJECT_NAME} ${LIBM})
+endif(LIBM)
+
+find_library(LIBDL dl)
+if(LIBDL)
+ target_link_libraries(${PROJECT_NAME} ${LIBDL})
+endif(LIBDL)
+
+find_library(LIBINTL intl)
+if(LIBINTL)
+ target_link_libraries(${PROJECT_NAME} ${LIBINTL})
+endif(LIBINTL)
+
+find_library(LIBTERMCAP termcap)
+if(LIBTERMCAP)
+ target_link_libraries(${PROJECT_NAME} ${LIBTERMCAP})
+else(LIBTERMCAP)
+ find_library(LIBCURSES curses)
+ if(LIBCURSES)
+ target_link_libraries(${PROJECT_NAME} ${LIBCURSES})
+ else(LIBCURSES)
+ find_library(LIBNCURSES ncurses)
+ if(LIBNCURSES)
+ target_link_libraries(${PROJECT_NAME} ${LIBNCURSES})
+ endif(LIBNCURSES)
+ endif(LIBCURSES)
+endif(LIBTERMCAP)
+
+find_library(LIBKSTAT kstat)
+if(LIBKSTAT)
+ target_link_libraries(${PROJECT_NAME} ${LIBKSTAT})
+endif(LIBKSTAT)
+
+find_library(LIBELF elf)
+if(LIBELF)
+ target_link_libraries(${PROJECT_NAME} ${LIBELF})
+endif(LIBELF)
+
+find_library(LIBMACH mach)
+if(LIBMACH)
+ target_link_libraries(${PROJECT_NAME} ${LIBMACH})
+endif(LIBMACH)
+
+# FreeBSD specific libraries
+
+if(${MACHINE} STREQUAL freebsd)
+ find_library(LIBKVM kvm)
+ if(LIBKVM)
+ target_link_libraries(${PROJECT_NAME} ${LIBKVM})
+ endif(LIBKVM)
+endif(${MACHINE} STREQUAL freebsd)
+
+install(
+ PROGRAMS
+ ${PROJECT_NAME}
+ DESTINATION "${INSTALLDEST}/bin"
+)
+install(
+ FILES
+ pg_top.1
+ DESTINATION "${INSTALLDEST}/share/man/man1"
+)
diff --git a/HISTORY b/HISTORY
index 8cb58b3..8f164b4 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1,5 +1,9 @@
Release Notes
+Release 4.0.0
+
+ * Replace autoconf with cmake
+
Release 3.7.0
* Added support for monitoring databases on remote systems.
diff --git a/INSTALL b/INSTALL
index 30c18f1..a35004f 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,56 +1,46 @@
pg_top
- Version 3.6.1
+ Version 4.0.0
Mark Wong
and a cast of ... a few
INSTALLATION
-Configuration and installation of pg_top is easy. pg_top version 3.6
-comes with a configure script generated by gnu autoconf. After
-unpacking the tar file, simply run "./configure". The script will
-automatically perform a series of checks on the system and determine
-what settings are appropriate for the Makefile and certain include
-files. Once configure completes, simply type "make install" and
-pg_top will be compiled and installed. By default, the installation
-location is /usr/local/bin. You can change the destination location
-with the --prefix option to configure.
+Configuring
+-----------
-pg_config must be in your path in order to install pg_top.
+cmake [options] CMakeLists.txt
-In addition to the standard options, pg_top's configure script supports
-the following:
+options:
- --with-module=name
+ -DDESTDIR=PREFIX
- Force the use of a particular module. Modules are located
- in the subdirectory "machine". A module's name is derived
- from the file's basename without the leading "m_".
+ Install files in PREFIX.
- --with-ext=name
+ -DENABLE_COLOR=0
- Compile with the extension "name", found in the subdirectory
- "ext". At the present time, there are no extensions in the
- standard distribution.
+ Default on. Include code that allows for the use of color in the output
+ display. Use -DENABLE_COLOR=0 if you do not want this feature compiled in
+ to the code. The configure script also recognizes the spelling "colour".
- --enable-debug
- --disable-debug
+ -DENABLE_COLOR=0
- Default off. Include debugging output in the compilation,
- which can be seen with the -D switch.
+ Default on. Include code that allows for the use of color in the output
+ display. Use -DENABLE_COLOR=0 if you do not want this feature compiled in
+ to the code. The configure script also recognizes the spelling "colour".
- --enable-color
- --disable-color
+ -DENABLE_KILL=0
- Default on. Include code that allows for the use of color
- in the output display. Use --disable-color if you do not
- want this feature compiled in to the code. The configure
- script also recognizes the spelling "colour".
+ Default on. Include code that allows for renicing and sending signals to
+ processes from within pg_top (the 'kill' and 'renice' commands). Use
+ -DENABLE_KILL=0 if you do not want this feature compiled in to the code.
- --enable-kill
- --disable-kill
+Installing
+----------
- Default on. Include code that allows for renicing and sending
- signals to processes from within pg_top (the 'kill' and 'renice'
- commands). Use --disable-kill if you do not want this feature
- compiled in to the code.
+make install
+
+Uninstalling
+------------
+
+xargs rm < install_manifest.txt
diff --git a/config.h.in b/config.h.in
new file mode 100644
index 0000000..c229bfe
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,23 @@
+#cmakedefine ENABLE_COLOR 1
+#cmakedefine ENABLE_KILL 1
+#cmakedefine HAVE_GETOPT 1
+#cmakedefine HAVE_MEMCPY 1
+#cmakedefine HAVE_SETPRIORITY 1
+#cmakedefine HAVE_SIGACTION 1
+#cmakedefine HAVE_SIGHOLD 1
+#cmakedefine HAVE_SIGPROCMASK 1
+#cmakedefine HAVE_SIGRELSE 1
+#cmakedefine HAVE_SNPRINTF 1
+#cmakedefine HAVE_STRCHR 1
+#cmakedefine HAVE_STRERROR 1
+#cmakedefine HAVE_STRING_H 1
+#cmakedefine HAVE_STRINGS_H 1
+#cmakedefine HAVE_SYS_TIME_H 1
+#cmakedefine HAVE_SYS_RESOURCE_H 1
+#cmakedefine HAVE_UNISTD_H 1
+#cmakedefine OSMAJOR @OSMAJOR@
+#cmakedefine OSREV @OSREV@
+#cmakedefine STDC_HEADERS 1
+#cmakedefine TIME_WITH_SYS_TIME 1
+#cmakedefine RETSIGTYPE @RETSIGTYPE@
+#cmakedefine time_t @time_t@