xref: /freebsd/contrib/bmake/mk/host-target.mk (revision 50696a6e8cbfdbf4a0d00f2f85f1951aa0d8e23d)
1# RCSid:
2#	$Id: host-target.mk,v 1.13 2020/08/05 23:32:08 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:NDarwin: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# sometimes we want HOST_TARGET32
41MACHINE32.amd64 = i386
42MACHINE32.x86_64 = i386
43_HOST_ARCH32 := ${MACHINE32.${_HOST_ARCH}:U${_HOST_ARCH:S,64$,,}}
44HOST_TARGET32 := ${host_os:S,/,,g}${HOST_OSMAJOR}-${_HOST_ARCH32}
45
46# tr is insanely non-portable, accommodate the lowest common denominator
47TR ?= tr
48toLower = ${TR} 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'
49toUpper = ${TR} 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
50