Portable build framework for OpenNTPD
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.8 KiB

  1. AC_DEFUN([CHECK_OS_OPTIONS], [
  2. CFLAGS="$CFLAGS -Wall -std=gnu99 -fno-strict-aliasing"
  3. case $host_os in
  4. *aix*)
  5. HOST_OS=aix
  6. if test "`echo $CC | cut -d ' ' -f 1`" != "gcc" ; then
  7. CFLAGS="-qnoansialias $USER_CFLAGS"
  8. fi
  9. AC_SUBST([PLATFORM_LDADD], ['-lperfstat -lpthread'])
  10. ;;
  11. *cygwin*)
  12. HOST_OS=cygwin
  13. ;;
  14. *darwin*)
  15. HOST_OS=darwin
  16. HOST_ABI=macosx
  17. # weak seed on failure to open /dev/random, based on latest
  18. # public source:
  19. # http://www.opensource.apple.com/source/Libc/Libc-997.90.3/gen/FreeBSD/arc4random.c
  20. USE_BUILTIN_ARC4RANDOM=yes
  21. AC_DEFINE(SETEUID_BREAKS_SETUID,[],[setuid after seteuid does not work])
  22. AC_DEFINE(BROKEN_SETREUID,[], [Broken setreuid])
  23. AC_DEFINE(BROKEN_SETREGID,[], [Broken setregid])
  24. AC_DEFINE(YYSTYPE_IS_DECLARED,[], [Broken bison])
  25. AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
  26. ;;
  27. *freebsd*)
  28. HOST_OS=freebsd
  29. HOST_ABI=elf
  30. # fork detection missing, weak seed on failure
  31. # https://svnweb.freebsd.org/base/head/lib/libc/gen/arc4random.c?revision=268642&view=markup
  32. USE_BUILTIN_ARC4RANDOM=yes
  33. AC_SUBST([PROG_LDADD], ['-lthr'])
  34. ;;
  35. *hpux*)
  36. HOST_OS=hpux;
  37. if test "`echo $CC | cut -d ' ' -f 1`" = "gcc" ; then
  38. CFLAGS="$CFLAGS -mlp64"
  39. else
  40. CFLAGS="-g -O2 +DD64 +Otype_safety=off $USER_CFLAGS"
  41. fi
  42. CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600 -D__STRICT_ALIGNMENT"
  43. AC_SUBST([PLATFORM_LDADD], ['-lpthread'])
  44. ;;
  45. *linux*)
  46. HOST_OS=linux
  47. HOST_ABI=elf
  48. CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_SOURCE -D_GNU_SOURCE"
  49. AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
  50. ;;
  51. *netbsd*)
  52. HOST_OS=netbsd
  53. HOST_ABI=elf
  54. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  55. #include <sys/param.h>
  56. #if __NetBSD_Version__ < 700000001
  57. undefined
  58. #endif
  59. ]], [[]])],
  60. [ USE_BUILTIN_ARC4RANDOM=no ],
  61. [ USE_BUILTIN_ARC4RANDOM=yes ]
  62. )
  63. CPPFLAGS="$CPPFLAGS -D_OPENBSD_SOURCE"
  64. ;;
  65. *openbsd* | *bitrig*)
  66. HOST_OS=openbsd
  67. HOST_ABI=elf
  68. AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD gcc has bounded])
  69. AC_DEFINE([HAVE_ATTRIBUTE__DEAD], [1], [OpenBSD gcc has __dead])
  70. AC_DEFINE([HAVE_ATTRIBUTE__PACKED], [1], [OpenBSD gcc has __packed])
  71. ;;
  72. *solaris*)
  73. HOST_OS=solaris
  74. HOST_ABI=elf
  75. CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 -DBSD_COMP"
  76. AC_SUBST([PLATFORM_LDADD], ['-lnsl -lsocket'])
  77. ;;
  78. *) ;;
  79. esac
  80. AM_CONDITIONAL([HOST_AIX], [test x$HOST_OS = xaix])
  81. AM_CONDITIONAL([HOST_CYGWIN], [test x$HOST_OS = xcygwin])
  82. AM_CONDITIONAL([HOST_DARWIN], [test x$HOST_OS = xdarwin])
  83. AM_CONDITIONAL([HOST_FREEBSD], [test x$HOST_OS = xfreebsd])
  84. AM_CONDITIONAL([HOST_HPUX], [test x$HOST_OS = xhpux])
  85. AM_CONDITIONAL([HOST_LINUX], [test x$HOST_OS = xlinux])
  86. AM_CONDITIONAL([HOST_NETBSD], [test x$HOST_OS = xnetbsd])
  87. AM_CONDITIONAL([HOST_OPENBSD], [test x$HOST_OS = xopenbsd])
  88. AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris])
  89. ])