您可以检测它
directly in the Makefile,或者在配置源文件(可能是configure.ac)中定义条件,因为您使用的是autoreconf:
# AC_CANONICAL_HOST is needed to access the 'host_os' variable
AC_CANONICAL_HOST
build_linux=no
build_windows=no
build_mac=no
# Detect the target system
case "${host_os}" in
linux*)
build_linux=yes
;;
cygwin*|mingw*)
build_windows=yes
;;
darwin*)
build_mac=yes
;;
*)
AC_MSG_ERROR(["OS $host_os is not supported"])
;;
esac
# Pass the conditionals to automake
AM_CONDITIONAL([LINUX],[test "$build_linux" = "yes"])
AM_CONDITIONAL([WINDOWS],[test "$build_windows" = "yes"])
AM_CONDITIONAL([OSX],[test "$build_mac" = "yes"])
Note: host_os refers to the target system,so if you are cross-compiling it sets the OS conditional of the system you are compiling to.