1 dnl ######################################################################
2 dnl AC_HOST_MACROS: define HOST_CPU, HOST_VENDOR, and HOST_OS
3 AC_DEFUN([AMU_HOST_MACROS],
5 # these are defined already by the macro 'CANONICAL_HOST'
6 AC_MSG_CHECKING([host cpu])
7 AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu")
8 AC_MSG_RESULT($host_cpu)
10 AC_MSG_CHECKING([vendor])
11 AC_DEFINE_UNQUOTED(HOST_VENDOR, "$host_vendor")
12 AC_MSG_RESULT($host_vendor)
14 # if vendor is apple, then check values in /usr/bin/sw_vers
15 if test "${host_vendor}" = "apple"
17 pn=`sw_vers -productName 2>/dev/null`
18 pv=`sw_vers -productVersion 2>/dev/null`
19 if test -n "${pn}" && test -n "${pv}"
21 host_os_name=`echo ${pn} | tr -d ' ' | tr '[A-Z]' '[a-z]'`
22 host_os_version="${pv}"
23 host_os="${host_os_name}-${host_os_version}"
27 AC_MSG_CHECKING([host full OS name and version])
28 # normalize some host OS names
30 # linux is linux is linux, regardless of RMS.
31 linux-gnu* | lignux* ) host_os=linux ;;
32 # NetBSD systems today are elf, so no need to distinguish
33 netbsdelf* ) host_os=`echo ${host_os} | sed 's/^netbsdelf/netbsd/'`;;
35 AC_DEFINE_UNQUOTED(HOST_OS, "$host_os")
36 AC_MSG_RESULT($host_os)
38 # break host_os into host_os_name and host_os_version
39 AC_MSG_CHECKING([host OS name])
40 host_os_name=`echo $host_os | sed 's/\..*//g'`
41 # normalize some OS names
42 case ${host_os_name} in
43 # linux is linux is linux, regardless of RMS.
44 linux-gnu* | lignux* ) host_os_name=linux ;;
45 # all NetBSD systems today should just show up as "netbsd"
46 netbsd* ) host_os_name=netbsd;;
48 AC_DEFINE_UNQUOTED(HOST_OS_NAME, "$host_os_name")
49 AC_MSG_RESULT($host_os_name)
51 # parse out the OS version of the host
52 AC_MSG_CHECKING([host OS version])
53 host_os_version=`echo $host_os | sed 's/^[[^0-9]]*//g'`
54 if test -z "$host_os_version"
56 host_os_version=`(uname -r) 2>/dev/null` || host_os_version=unknown
58 case ${host_os_version} in
59 # fixes for some OS versions (solaris used to be here)
60 * ) # do nothing for now
63 AC_DEFINE_UNQUOTED(HOST_OS_VERSION, "$host_os_version")
64 AC_MSG_RESULT($host_os_version)
66 # figure out host architecture (different than CPU)
67 AC_MSG_CHECKING([host OS architecture])
68 host_arch=`(uname -m) 2>/dev/null` || host_arch=unknown
69 # normalize some names
71 sun4* ) host_arch=sun4 ;;
72 sun3x ) host_arch=sun3 ;;
73 sun ) host_arch=`(arch) 2>/dev/null` || host_arch=unknown ;;
74 i?86 ) host_arch=i386 ;; # all x86 should show up as i386
75 Power*Macintosh ) host_arch=powerpc ;;
77 AC_DEFINE_UNQUOTED(HOST_ARCH, "$host_arch")
78 AC_MSG_RESULT($host_arch)
80 # figure out (linux) distribution, if any
81 AC_MSG_CHECKING([OS system distribution])
82 ac_config_distro=`$SHELL $ac_aux_dir/config.guess.long | cut -d'-' -f4-`
83 if test -z "$ac_config_distro"
85 ac_config_distro="none"
87 AC_DEFINE_UNQUOTED(DISTRO_NAME, "$ac_config_distro")
88 AC_MSG_RESULT($ac_config_distro)
90 # figure out host name
91 AC_MSG_CHECKING([host name])
92 host_name=`(hostname || uname -n) 2>/dev/null` || host_name=unknown
93 AC_DEFINE_UNQUOTED(HOST_NAME, "$host_name")
94 AC_MSG_RESULT($host_name)
96 # figure out user name
97 AC_MSG_CHECKING([user name])
102 if test -n "$LOGNAME"
106 user_name=`(whoami) 2>/dev/null` || user_name=unknown
109 AC_DEFINE_UNQUOTED(USER_NAME, "$user_name")
110 AC_MSG_RESULT($user_name)
112 # figure out configuration date
113 AC_MSG_CHECKING([configuration date])
114 config_date=`(date) 2>/dev/null` || config_date=unknown_date
115 AC_DEFINE_UNQUOTED(CONFIG_DATE, "$config_date")
116 AC_MSG_RESULT($config_date)
119 dnl ======================================================================