Browse Source

factor out CHECK_OS_OPTIONS

OPENBSD_5_9
Brent Cook 8 years ago
parent
commit
a9ef3ae3e9
3 changed files with 48 additions and 63 deletions
  1. +1
    -1
      .gitignore
  2. +2
    -62
      configure.ac
  3. +45
    -0
      m4/check-os-options.m4

+ 1
- 1
.gitignore View File

@ -26,7 +26,7 @@ depcomp
install-sh install-sh
libtool libtool
ltmain.sh ltmain.sh
m4/
m4/l*.m4
missing missing
ylwrap ylwrap
Makefile Makefile


+ 2
- 62
configure.ac View File

@ -29,74 +29,14 @@ AC_PROG_CC
AC_PROG_CC_STDC AC_PROG_CC_STDC
AM_PROG_CC_C_O AM_PROG_CC_C_O
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
LT_INIT
AC_PROG_YACC AC_PROG_YACC
CFLAGS="$CFLAGS -Wall -std=gnu99 -fno-strict-aliasing"
case $host_os in
*darwin*)
HOST_OS=darwin
AC_DEFINE(SETEUID_BREAKS_SETUID,[],[setuid after seteuid does not work])
AC_DEFINE(BROKEN_SETREUID,[], [Broken setreuid])
AC_DEFINE(BROKEN_SETREGID,[], [Broken setregid])
AC_DEFINE(YYSTYPE_IS_DECLARED,[], [Broken bison])
AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
;;
*freebsd*)
HOST_OS=freebsd
AC_SUBST([PROG_LDADD], ['-lthr'])
;;
*linux*)
HOST_OS=linux
CFLAGS="$CFLAGS -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE"
AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
;;
*netbsd*)
HOST_OS=netbsd
;;
*openbsd*)
HOST_OS=openbsd
AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD has __bounded__])
AC_DEFINE([HAVE_ATTRIBUTE__DEAD], [1], [OpenBSD has __dead])
;;
*solaris*)
HOST_OS=solaris
CFLAGS="$CFLAGS -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 -DBSD_COMP"
AC_SUBST([PLATFORM_LDADD], ['-lnsl -lsocket'])
;;
*) ;;
esac
AM_CONDITIONAL([HOST_DARWIN], [test x$HOST_OS = xdarwin])
AM_CONDITIONAL([HOST_FREEBSD], [test x$HOST_OS = xfreebsd])
AM_CONDITIONAL([HOST_LINUX], [test x$HOST_OS = xlinux])
AM_CONDITIONAL([HOST_NETBSD], [test x$HOST_OS = xnetbsd])
AM_CONDITIONAL([HOST_OPENBSD], [test x$HOST_OS = xopenbsd])
AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris])
CHECK_OS_OPTIONS
AC_CHECK_FUNC([dl_iterate_phdr],, AC_CHECK_FUNC([dl_iterate_phdr],,
[AC_SEARCH_LIBS([dl_iterate_phdr],[dl])]) [AC_SEARCH_LIBS([dl_iterate_phdr],[dl])])
save_cflags="$CFLAGS"
CFLAGS=-Wno-pointer-sign
AC_MSG_CHECKING([whether CC supports -Wno-pointer-sign])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[AM_CFLAGS=-Wno-pointer-sign],
[AC_MSG_RESULT([no])]
)
CFLAGS="$save_cflags $AM_CFLAGS"
AC_MSG_CHECKING([if compiling with clang])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
#ifndef __clang__
not clang
#endif
]])],
[AC_MSG_RESULT([yes])]
[CLANG_FLAGS=-Qunused-arguments],
[AC_MSG_RESULT([no])]
)
CFLAGS="$CFLAGS $CLANG_CFLAGS" CFLAGS="$CFLAGS $CLANG_CFLAGS"
LDFLAGS="$LDFLAGS $CLANG_FLAGS" LDFLAGS="$LDFLAGS $CLANG_FLAGS"


+ 45
- 0
m4/check-os-options.m4 View File

@ -0,0 +1,45 @@
AC_DEFUN([CHECK_OS_OPTIONS], [
CFLAGS="$CFLAGS -Wall -std=gnu99 -fno-strict-aliasing"
case $host_os in
*darwin*)
HOST_OS=darwin
AC_DEFINE(SETEUID_BREAKS_SETUID,[],[setuid after seteuid does not work])
AC_DEFINE(BROKEN_SETREUID,[], [Broken setreuid])
AC_DEFINE(BROKEN_SETREGID,[], [Broken setregid])
AC_DEFINE(YYSTYPE_IS_DECLARED,[], [Broken bison])
AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
;;
*freebsd*)
HOST_OS=freebsd
AC_SUBST([PROG_LDADD], ['-lthr'])
;;
*linux*)
HOST_OS=linux
CFLAGS="$CFLAGS -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE"
AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
;;
*netbsd*)
HOST_OS=netbsd
;;
*openbsd*)
HOST_OS=openbsd
AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD has __bounded__])
AC_DEFINE([HAVE_ATTRIBUTE__DEAD], [1], [OpenBSD has __dead])
;;
*solaris*)
HOST_OS=solaris
CFLAGS="$CFLAGS -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 -DBSD_COMP"
AC_SUBST([PLATFORM_LDADD], ['-lnsl -lsocket'])
;;
*) ;;
esac
AM_CONDITIONAL([HOST_DARWIN], [test x$HOST_OS = xdarwin])
AM_CONDITIONAL([HOST_FREEBSD], [test x$HOST_OS = xfreebsd])
AM_CONDITIONAL([HOST_LINUX], [test x$HOST_OS = xlinux])
AM_CONDITIONAL([HOST_NETBSD], [test x$HOST_OS = xnetbsd])
AM_CONDITIONAL([HOST_OPENBSD], [test x$HOST_OS = xopenbsd])
AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris])
])

Loading…
Cancel
Save