1#
2# Check for library functions and the like that we need.
3#
4# In some cases, we may decide to enable workarounds of various sorts
5# here too; in others, we just bomb out.  Technically, doing that is
6# unnecessary, since the build will just fail later, but this may be
7# friendlier in telling the user _why_ than letting them try to interpret
8# compiler or linker errors.
9#
10# This is distinct from the checking in build_options.cmake; that's about
11# stuff we have build options to enable/disable, whereas this is more
12# stuff we depend on unconditionally.
13#
14
15
16# getopt_long(3) is in getopt.h everywhere I can find it.  Until we find
17# a system where it's somewhere else, or systems it's nowhere and we have
18# to provide it, we'll either find it there or error out and blow up.  If
19# we don't find problems that require additional workaround in the next
20# couple releases, we should retire the check to avoid wasting time/space
21# checking things we know will work.
22check_include_files(getopt.h HAS_GETOPT_H)
23check_function_exists(getopt_long HAS_GETOPT_LONG)
24if(NOT HAS_GETOPT_H)
25	message(FATAL_ERROR "Can't find getopt.h (needed for getopt_long()).")
26endif(NOT HAS_GETOPT_H)
27if(NOT HAS_GETOPT_LONG)
28	message(FATAL_ERROR "You don't seem to have getopt_long().")
29endif(NOT HAS_GETOPT_LONG)
30
31
32
33# asprintf(3) has been in glibc since at least the early 90's, the BSD's
34# since the mid 90's, and [Open]Solaris since 11.  It's not in Sol10, at
35# least some versions of AIX, etc.  There's a version in openssh-portable
36# that I believe is pretty portable if we find a system we care about
37# lacking it and need to pull in a local version, but I don't expect to.
38#
39# n.b.; this slightly overlaps with earlier run code that sometimes needs
40# to crank on extra -D's to show this up in headers, but it differs a
41# little, so I won't bother collapsing them...
42check_function_exists(asprintf HAS_ASPRINTF)
43if(NOT HAS_ASPRINTF)
44	message(FATAL_ERROR "You don't seem to have asprintf(3).")
45endif(NOT HAS_ASPRINTF)
46