configure.ac 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. # DT PS Tree
  2. #
  3. # Douglas Thrift
  4. #
  5. # configure.ac
  6. # Copyright 2010 Douglas Thrift
  7. #
  8. # Licensed under the Apache License, Version 2.0 (the "License");
  9. # you may not use this file except in compliance with the License.
  10. # You may obtain a copy of the License at
  11. #
  12. # http://www.apache.org/licenses/LICENSE-2.0
  13. #
  14. # Unless required by applicable law or agreed to in writing, software
  15. # distributed under the License is distributed on an "AS IS" BASIS,
  16. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. # See the License for the specific language governing permissions and
  18. # limitations under the License.
  19. AC_PREREQ([2.62])
  20. AC_INIT([DT PS Tree], [1.1.0], [douglas@douglasthrift.net], [dtpstree], [http://code.douglasthrift.net/trac/dtpstree])
  21. AC_CONFIG_SRCDIR([dtpstree.cpp])
  22. AC_CONFIG_AUX_DIR([build-aux])
  23. AX_CHECK_GNU_MAKE
  24. AC_SUBST([GNUMAKE], [$_cv_gnu_make_command])
  25. AS_IF([test "x$GNUMAKE" = x], [AC_MSG_ERROR([You need GNU make])])
  26. AC_PROG_INSTALL
  27. AC_PATH_PROG([HELP2MAN], [help2man], [:])
  28. AC_MSG_CHECKING([for realpath])
  29. AC_PATH_PROGS_FEATURE_CHECK([REALPATH], [realpath readlink greadlink gnureadlink],
  30. [AS_CASE([$ac_path_REALPATH], [*realpath],
  31. [ac_cv_path_REALPATH=$ac_path_REALPATH
  32. ac_path_REALPATH_found=:],
  33. [AS_IF([$ac_path_REALPATH -f . >/dev/null 2>&1],
  34. [ac_cv_path_REALPATH="$ac_path_REALPATH -f"
  35. ac_path_REALPATH_found=:]
  36. )]
  37. )]
  38. )
  39. AS_IF([test "x$ac_cv_path_REALPATH" != x],
  40. [AC_SUBST([REALPATH], [$ac_cv_path_REALPATH])
  41. AC_MSG_RESULT([$REALPATH])],
  42. [AC_SUBST([REALPATH], [:])
  43. AC_MSG_RESULT([no])]
  44. )
  45. AC_MSG_CHECKING([for BSD tar with xz support])
  46. AC_PATH_PROGS_FEATURE_CHECK([BSDTAR], [tar bsdtar],
  47. [AS_IF([test "x`$ac_path_BSDTAR --version 2>/dev/null | grep '^bsdtar '`" != x],
  48. [AS_IF([$ac_path_BSDTAR -cJf - /dev/null >/dev/null 2>&1],
  49. [ac_cv_path_BSDTAR=$ac_path_BSDTAR
  50. ac_path_BSDTAR_found=:]
  51. )]
  52. )]
  53. )
  54. AS_IF([test "x$ac_cv_path_BSDTAR" != x],
  55. [AC_SUBST([BSDTAR], [$ac_cv_path_BSDTAR])
  56. AC_MSG_RESULT([$BSDTAR])],
  57. [AC_SUBST([BSDTAR], [:])
  58. AC_MSG_RESULT([no])]
  59. )
  60. AC_LANG([C++])
  61. AC_DEFUN([DT_MSG_TERMCAP], [AC_MSG_ERROR([You need terminfo or termcap])])
  62. AC_DEFUN([DT_CHECK_TERMCAP], [AC_CHECK_HEADERS([termcap.h ncurses/termcap.h])
  63. AS_CASE([$ac_cv_header_termcap_h$ac_cv_header_ncurses_termcap_h], [*yes*],
  64. [AC_SEARCH_LIBS([tgetent],
  65. [termcap termlib terminfo tinfo ncurses pdcurses curses], [],
  66. [DT_MSG_TERMCAP]
  67. )], [DT_MSG_TERMCAP]
  68. )]
  69. )
  70. AC_DEFUN([DT_CHECK_TERMINFO],
  71. [AC_CHECK_HEADERS([curses.h ncurses/ncurses.h],
  72. [break])
  73. AS_CASE([$ac_cv_header_curses_h$ac_cv_header_ncurses_ncurses_h], [*yes*],
  74. [AC_CHECK_HEADERS([term.h ncurses/term.h], [break])
  75. AS_CASE([$ac_cv_header_term_h$ac_cv_header_ncurses_term_h], [*yes*],
  76. [AC_SEARCH_LIBS([setupterm],
  77. [terminfo tinfo ncurses pdcurses curses], [], [DT_CHECK_TERMCAP]
  78. )], [DT_CHECK_TERMCAP]
  79. )], [DT_CHECK_TERMCAP]
  80. )]
  81. )
  82. AC_ARG_ENABLE([terminfo],
  83. [AS_HELP_STRING([--disable-terminfo],
  84. [do not try to use the terminfo interface]
  85. )], [AS_CASE([$enableval], [no], [DT_CHECK_TERMCAP], [DT_CHECK_TERMINFO])],
  86. [DT_CHECK_TERMINFO]
  87. )
  88. AC_DEFUN([DT_MSG_BSD], [AC_MSG_ERROR([You need libbsd])])
  89. AC_CHECK_HEADER([vis.h], [], [DT_MSG_BSD])
  90. AC_SEARCH_LIBS([strvis], [bsd], [], [DT_MSG_BSD])
  91. AC_DEFUN([DT_MSG_KVM], [AC_MSG_ERROR([You need libkvm])])
  92. AC_CHECK_HEADER([kvm.h], [], [DT_MSG_KVM])
  93. AC_CHECK_HEADERS_ONCE([kinfo.h])
  94. AC_SEARCH_LIBS([kvm_openfiles], [kvm], [], [DT_MSG_KVM])
  95. AC_DEFUN([DT_INCLUDES_KVM], [#ifdef HAVE_KINFO_H
  96. #include <kinfo.h>
  97. #endif
  98. #include <kvm.h>
  99. #include <sys/param.h>
  100. #include <sys/sysctl.h>
  101. #include <sys/user.h>
  102. AC_INCLUDES_DEFAULT])
  103. AC_DEFUN([DT_CHECK_MEMBERS_KVM],
  104. [m4_foreach_w([dt_member_suffix], [pid ppid ruid comm],
  105. [AC_CHECK_MEMBER([struct ]$1[.]$2[_]dt_member_suffix,
  106. [AC_DEFINE([HAVE_STRUCT_KINFO_PROCX_]m4_toupper($2)[_]m4_toupper(dt_member_suffix))],
  107. [AC_CHECK_MEMBER([struct ]$1[.]$3[_]dt_member_suffix,
  108. [AC_DEFINE([HAVE_STRUCT_KINFO_PROCX_]m4_toupper($3)[_]m4_toupper(dt_member_suffix))],
  109. [AC_CHECK_MEMBER([struct ]$1[.]$4[_]dt_member_suffix,
  110. [AC_DEFINE([HAVE_STRUCT_KINFO_PROCX_]m4_toupper($4)[_]m4_toupper(dt_member_suffix))],
  111. [DT_MSG_KVM], [DT_INCLUDES_KVM]
  112. )], [DT_INCLUDES_KVM]
  113. )], [DT_INCLUDES_KVM]
  114. )]
  115. )]
  116. )
  117. AC_CHECK_TYPE([struct kinfo_proc2],
  118. [AC_DEFINE([HAVE_STRUCT_KINFO_PROC2])
  119. AC_CHECK_FUNC([kvm_getargv2], [], [DT_MSG_KVM])
  120. AC_CHECK_FUNC([kvm_getproc2], [], [DT_MSG_KVM])
  121. DT_CHECK_MEMBERS_KVM([kinfo_proc2], [p], [ki], [kp])],
  122. [AC_CHECK_TYPE([struct kinfo_proc],
  123. [AC_DEFINE([HAVE_STRUCT_KINFO_PROC])
  124. AC_CHECK_FUNC([kvm_getargv], [], [DT_MSG_KVM])
  125. AC_CHECK_FUNC([kvm_getprocs],
  126. [AC_TRY_COMPILE(DT_INCLUDES_KVM,
  127. [kvm_getprocs(NULL, 0, 0, 0, NULL);],
  128. [AC_DEFINE([HAVE_KINFO_NEWABI])]
  129. )], [DT_MSG_KVM])
  130. DT_CHECK_MEMBERS_KVM([kinfo_proc], [ki], [kp], [p])],
  131. [DT_MSG_KVM], [DT_INCLUDES_KVM]
  132. )], [DT_INCLUDES_KVM]
  133. )
  134. AC_CHECK_DECLS([KERN_PROC_PROC, KERN_PROC_KTHREAD, KERN_PROC_ALL], [], [],
  135. [DT_INCLUDES_KVM]
  136. )
  137. AS_CASE([$ac_cv_have_decl_KERN_PROC_PROC$ac_cv_have_decl_KERN_PROC_KTHREAD$ac_cv_have_decl_KERN_PROC_ALL],
  138. [*yes*], [], [DT_MSG_KVM]
  139. )
  140. AS_CASE([$GNUMAKE], [make], [], [AC_CONFIG_FILES([makefile])])
  141. AC_CONFIG_FILES([GNUmakefile])
  142. AC_OUTPUT