xref: /freebsd/share/mk/host-target.mk (revision 22cf89c938886d14f5796fc49f9f020c23ea8eaf)
1# RCSid:
2#	$Id: host-target.mk,v 1.11 2015/10/25 00:07:20 sjg Exp $
3
4# Host platform information; may be overridden
5.if !defined(_HOST_OSNAME)
6_HOST_OSNAME !=	uname -s
7.export _HOST_OSNAME
8.endif
9.if !defined(_HOST_OSREL)
10_HOST_OSREL  !=	uname -r
11.export _HOST_OSREL
12.endif
13.if !defined(_HOST_MACHINE)
14_HOST_MACHINE != uname -m
15.export _HOST_MACHINE
16.endif
17.if !defined(_HOST_ARCH)
18# for NetBSD prefer $MACHINE (amd64 rather than x86_64)
19.if ${_HOST_OSNAME:NNetBSD} == ""
20_HOST_ARCH := ${_HOST_MACHINE}
21.else
22_HOST_ARCH != uname -p 2> /dev/null || uname -m
23# uname -p may produce garbage on linux
24.if ${_HOST_ARCH:[\#]} > 1 || ${_HOST_ARCH:Nunknown} == ""
25_HOST_ARCH := ${_HOST_MACHINE}
26.endif
27.endif
28.export _HOST_ARCH
29.endif
30.if !defined(HOST_MACHINE)
31HOST_MACHINE := ${_HOST_MACHINE}
32.export HOST_MACHINE
33.endif
34
35HOST_OSMAJOR := ${_HOST_OSREL:C/[^0-9].*//}
36HOST_OSTYPE  :=	${_HOST_OSNAME:S,/,,g}-${_HOST_OSREL:C/\([^\)]*\)//}-${_HOST_ARCH}
37HOST_OS      :=	${_HOST_OSNAME}
38host_os      :=	${_HOST_OSNAME:tl}
39HOST_TARGET  := ${host_os:S,/,,g}${HOST_OSMAJOR}-${_HOST_ARCH}
40
41# tr is insanely non-portable, accommodate the lowest common denominator
42TR ?= tr
43toLower = ${TR} 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'
44toUpper = ${TR} 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
45